/** * Renders the result page for the main search page * * @param PMF_Search_Resultset $resultSet PMF_Search_Resultset object * @param integer $currentPage Current page number * * @return string */ public function renderSearchResult(PMF_Search_Resultset $resultSet, $currentPage) { $html = ''; $confPerPage = PMF_Configuration::getInstance()->get('main.numberOfRecordsPerPage'); $numOfResults = $resultSet->getNumberOfResults(); $totalPages = ceil($numOfResults / $confPerPage); $lastPage = $currentPage * $confPerPage; $firstPage = $lastPage - $confPerPage; if ($lastPage > $numOfResults) { $lastPage = $numOfResults; } if (0 < $numOfResults) { $html .= sprintf("<p>%s</p>\n", $this->plurals->GetMsg('plmsgSearchAmount', $numOfResults)); if (1 < $totalPages) { $html .= sprintf("<p><strong>%s%d %s %s</strong></p>\n", $this->translation['msgPage'], $currentPage, $this->translation['msgVoteFrom'], $this->plurals->GetMsg('plmsgPagesTotal', $totalPages)); } $html .= "<ul class=\"phpmyfaq_ul\">\n"; $counter = $displayedCounter = 0; foreach ($resultSet->getResultset() as $result) { if ($displayedCounter >= $confPerPage) { continue; } $counter++; if ($counter <= $firstPage) { continue; } $displayedCounter++; $categoryName = $this->categoryLayout->renderBreadcrumb(array($result->category_id)); $question = PMF_Utils::chopString($result->question, 15); $answerPreview = PMF_Utils::chopString(strip_tags($result->answer), 25); $searchterm = str_replace(array('^', '.', '?', '*', '+', '{', '}', '(', ')', '[', ']', '"'), '', $this->searchterm); $searchterm = preg_quote($searchterm, '/'); $searchItems = explode(' ', $searchterm); if (PMF_String::strlen($searchItems[0]) > 1) { foreach ($searchItems as $item) { if (PMF_String::strlen($item) > 2) { $question = PMF_Utils::setHighlightedString($question, $item); $answerPreview = PMF_Utils::setHighlightedString($answerPreview, $item); } } } // Build the link to the faq record $currentUrl = sprintf('%s?%saction=artikel&cat=%d&id=%d&artlang=%s&highlight=%s', PMF_Link::getSystemRelativeUri(), $this->sessionId, $result->category_id, $result->id, $result->lang, urlencode($searchterm)); $oLink = new PMF_Link($currentUrl); $oLink->text = $oLink->itemTitle = $oLink->tooltip = $result->question; $html .= "<li>"; $html .= sprintf("<strong>%s</strong>: %s<br />", $categoryName, $oLink->toHtmlAnchor()); $html .= sprintf("<div class=\"searchpreview\"><strong>%s</strong> %s...</div><br />\n", $this->translation['msgSearchContent'], $answerPreview); $html .= "</li>"; } $html .= "</ul>\n"; if (1 < $totalPages) { $html .= $this->pagination->render(); } } else { $html = $this->translation['err_noArticles']; } return $html; }
if (isset($_SESSION['parsedTemplates']) && $tpl->ajax_request) { $tpl->parsedTemplates = $_SESSION['parsedTemplates']; } else { $tpl->TemplateAjaxInit(); $_SESSION['parsedTemplates'] = $tpl->parsedTemplates; } } $usersOnLine = $faqsession->getUsersOnline(); $totUsersOnLine = $usersOnLine[0] + $usersOnLine[1]; $systemUri = PMF_Link::getSystemUri('index.php'); $categoryTree = new PMF_Category_Tree($categoryData); // If it's an ajax request , get the whole tree else get the filtered tree if ($tpl->ajax_active && $tpl->ajax_request == 'ajax_init') { $categoryLayout = new PMF_Category_Layout(new PMF_Category_Tree_Helper($categoryTree)); } else { $categoryLayout = new PMF_Category_Layout(new PMF_Category_Tree_Helper(new PMF_Category_Path($categoryTree, $categoryPath))); } $keywordsArray = array_merge(explode(',', $keywords), explode(',', $faqconfig->get('main.metaKeywords'))); $keywordsArray = array_filter($keywordsArray, 'strlen'); shuffle($keywordsArray); $keywords = implode(',', $keywordsArray); $main_template_vars = array('msgRegisterUser' => '<a href="?' . $sids . 'action=register">' . $PMF_LANG['msgRegisterUser'] . '</a>', 'msgLoginUser' => $PMF_LANG['msgLoginUser'], 'title' => $faqconfig->get('main.titleFAQ') . $title, 'baseHref' => $systemUri, 'version' => $faqconfig->get('main.currentVersion'), 'header' => str_replace('"', '', $faqconfig->get('main.titleFAQ')), 'metaTitle' => str_replace('"', '', $faqconfig->get('main.titleFAQ')), 'metaDescription' => $metaDescription, 'metaKeywords' => $keywords, 'metaPublisher' => $faqconfig->get('main.metaPublisher'), 'metaLanguage' => $PMF_LANG['metaLanguage'], 'metaCharset' => 'utf-8', 'phpmyfaqversion' => $faqconfig->get('main.currentVersion'), 'stylesheet' => $PMF_LANG['dir'] == 'rtl' ? 'style.rtl' : 'style', 'action' => $action, 'dir' => $PMF_LANG['dir'], 'msgCategory' => $PMF_LANG['msgCategory'], 'showCategories' => $categoryLayout->renderNavigation($cat), 'languageBox' => $PMF_LANG['msgLangaugeSubmit'], 'writeLangAdress' => $writeLangAdress, 'switchLanguages' => PMF_Language::selectLanguages($LANGCODE, true), 'userOnline' => $plr->getMsg('plmsgUserOnline', $totUsersOnLine) . $plr->getMsg('plmsgGuestOnline', $usersOnLine[0]) . $plr->getMsg('plmsgRegisteredOnline', $usersOnLine[1]), 'stickyRecordsHeader' => $PMF_LANG['stickyRecordsHeader'], 'copyright' => 'powered by <a href="http://www.phpmyfaq.de" target="_blank">phpMyFAQ</a> ' . $faqconfig->get('main.currentVersion')); if ('main' == $action || 'show' == $action) { if ('main' == $action && PMF_Configuration::getInstance()->get('main.useAjaxSearchOnStartpage')) { $tpl->processBlock('index', 'globalSuggestBox', array('ajaxlanguage' => $LANGCODE)); } else { $tpl->processBlock('index', 'globalSearchBox', array('writeSendAdress' => '?' . $sids . 'action=search', 'searchBox' => $PMF_LANG['msgSearch'], 'categoryId' => $cat === 0 ? '%' : (int) $cat, 'msgSearch' => '<a class="help" href="index.php?' . $sids . 'action=search">' . $PMF_LANG["msgAdvancedSearch"] . '</a>')); } } $stickyRecordsParams = $faq->getStickyRecords(); if (!isset($stickyRecordsParams['error'])) {
* @author Thorsten Rinne <*****@*****.**> * @author Minoru TODA <*****@*****.**> * @copyright 2003-2010 phpMyFAQ Team * @license http://www.mozilla.org/MPL/MPL-1.1.html Mozilla Public License Version 1.1 * @link http://www.phpmyfaq.de * @since 2003-02-23 */ if (!defined('IS_VALID_PHPMYFAQ')) { header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME'])); exit; } printf("<h2>%s</h2>\n", $PMF_LANG['ad_entry_aor']); if ($permission['editbt'] || $permission['delbt']) { $categoryRelations = new PMF_Category_Relations(); $categoryData = new PMF_Category_Tree_DataProvider_SingleQuery($LANGCODE); $categoryLayout = new PMF_Category_Layout(new PMF_Category_Tree_Helper(new PMF_Category_Tree($categoryData))); $linkverifier = new PMF_Linkverifier($user->getLogin()); $comment = new PMF_Comment(); $faq = new PMF_Faq(); if ($linkverifier->isReady()) { link_verifier_javascript(); } $cond = $numCommentsByFaq = $numActiveByCat = array(); $internalSearch = $linkState = $searchterm = ''; $searchcat = $currentcategory = 0; $orderby = 1; $sortby = null; $linkState = PMF_Filter::filterInput(INPUT_POST, 'linkstate', FILTER_SANITIZE_STRING); $searchcat = PMF_Filter::filterInput(INPUT_POST, 'searchcat', FILTER_VALIDATE_INT); $searchterm = PMF_Filter::filterInput(INPUT_POST, 'searchterm', FILTER_SANITIZE_STRIPPED); if (!is_null($linkState)) {
* @category phpMyFAQ * @package Administration * @author Thorsten Rinne <*****@*****.**> * @copyright 2003-2010 phpMyFAQ Team * @license http://www.mozilla.org/MPL/MPL-1.1.html Mozilla Public License Version 1.1 * @link http://www.phpmyfaq.de * @since 2003-02-24 */ if (!defined('IS_VALID_PHPMYFAQ_ADMIN')) { header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME'])); exit; } if ($permission['viewlog']) { // Get category data $categoryData = new PMF_Category_Tree_DataProvider_SingleQuery($LANGCODE); $categoryLayout = new PMF_Category_Layout(new PMF_Category_Tree_Helper(new PMF_Category_Tree($categoryData))); // Get rating data $ratings = new PMF_Rating(); //$ratingData = $ratings->fetchAll(); $ratingdata = $ratings->getAllRatings(); $numratings = count($ratingdata); $oldcategory = 0; // Get FAQ record data $faqRecord = new PMF_Faq_Record(); $faqRecord->setLanguage($LANGCODE); $faqData = $faqRecord->fetchAll(); ?> <h2><?php print $PMF_LANG["ad_rs"]; ?> </h2>
$(document).ready(function(){ setTimeout(function() { window.location = "index.php?action=view"; }, 5000); }); //--> </script> <?php } else { print $PMF_LANG['ad_entry_savedfail'] . $db->error(); } } elseif (isset($submit['submit'][2]) && !is_null($question) && !is_null($categories)) { // Preview $categoryDataProvider = new PMF_Category_Tree_DataProvider_SingleQuery($LANGCODE); $categoryTree = new PMF_Category_Tree($categoryDataProvider); $categoryLayout = new PMF_Category_Layout(new PMF_Category_Tree_Helper($categoryTree)); $categorylist = ''; foreach ($categories['rubrik'] as $categoryId) { $categoryPath = $categoryDataProvider->getPath($categoryId); $categorylist .= $categoryLayout->renderBreadcrumb($categoryPath) . '<br />'; } ?> <h3><strong><em><?php print $categorylist; ?> </em> <?php print $question; ?> </strong></h3> <?php
* @author Thorsten Rinne <*****@*****.**> * @copyright 2002-2010 phpMyFAQ Team * @license http://www.mozilla.org/MPL/MPL-1.1.html Mozilla Public License Version 1.1 * @link http://www.phpmyfaq.de * @since 2002-09-16 */ if (!defined('IS_VALID_PHPMYFAQ')) { header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME'])); exit; } $captcha = new PMF_Captcha($db, $Language); $captcha->setSessionId($sids); if (!is_null($showCaptcha)) { $captcha->showCaptchaImg(); exit; } $faqsession->userTracking('new_entry', 0); // Get possible user input $inputQuestion = PMF_Filter::filterInput(INPUT_GET, 'question', FILTER_VALIDATE_INT); $inputCategory = PMF_Filter::filterInput(INPUT_GET, 'cat', FILTER_VALIDATE_INT); $question = $readonly = ''; if (!is_null($inputQuestion)) { $faqQuestions = new PMF_Faq_Questions(); $question = $faqQuestions->fetch($inputQuestion); if (PMF_String::strlen($question->question)) { $readonly = ' readonly="readonly"'; } } $categoryLayout = new PMF_Category_Layout(new PMF_Category_Tree_Helper(new PMF_Category_Tree($categoryData))); $tpl->processTemplate('writeContent', array('msgNewContentHeader' => $PMF_LANG['msgNewContentHeader'], 'msgNewContentAddon' => $PMF_LANG['msgNewContentAddon'], 'writeSendAdress' => '?' . $sids . 'action=save', 'defaultContentMail' => $user instanceof PMF_User_CurrentUser ? $user->getUserData('email') : '', 'defaultContentName' => $user instanceof PMF_User_CurrentUser ? $user->getUserData('display_name') : '', 'msgNewContentName' => $PMF_LANG['msgNewContentName'], 'msgNewContentMail' => $PMF_LANG['msgNewContentMail'], 'msgNewContentCategory' => $PMF_LANG['msgNewContentCategory'], 'printCategoryOptions' => $categoryLayout->renderOptions(array($inputCategory)), 'msgNewContentTheme' => $PMF_LANG['msgNewContentTheme'], 'readonly' => $readonly, 'printQuestion' => $question instanceof PMF_Faq_Questions ? $question->question : '', 'msgNewContentArticle' => $PMF_LANG['msgNewContentArticle'], 'msgNewContentKeywords' => $PMF_LANG['msgNewContentKeywords'], 'msgNewContentLink' => $PMF_LANG['msgNewContentLink'], 'captchaFieldset' => PMF_Helper_Captcha::getInstance()->renderFieldset($PMF_LANG['msgCaptcha'], $captcha->printCaptcha('add')), 'msgNewContentSubmit' => $PMF_LANG['msgNewContentSubmit'])); $tpl->includeTemplate('writeContent', 'index');
* The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * @category phpMyFAQ * @package Frontend * @author Thorsten Rinne <*****@*****.**> * @copyright 2002-2010 phpMyFAQ Team * @license http://www.mozilla.org/MPL/MPL-1.1.html Mozilla Public License Version 1.1 * @link http://www.phpmyfaq.de * @since 2002-09-17 */ if (!defined('IS_VALID_PHPMYFAQ')) { header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME'])); exit; } $captcha = new PMF_Captcha($sids); if (!is_null($showCaptcha)) { $captcha->showCaptchaImg(); exit; } $faqsession->userTracking('ask_question', 0); $categoryLayout = new PMF_Category_Layout(new PMF_Category_Tree_Helper(new PMF_Category_Tree($categoryData))); $tpl->processTemplate('writeContent', array('msgQuestion' => $PMF_LANG['msgQuestion'], 'msgNewQuestion' => $PMF_LANG['msgNewQuestion'], 'writeSendAdress' => '?' . $sids . 'action=savequestion', 'msgNewContentName' => $PMF_LANG['msgNewContentName'], 'msgNewContentMail' => $PMF_LANG['msgNewContentMail'], 'defaultContentMail' => $user instanceof PMF_User_CurrentUser ? $user->getUserData('email') : '', 'defaultContentName' => $user instanceof PMF_User_CurrentUser ? $user->getUserData('display_name') : '', 'msgAskCategory' => $PMF_LANG['msgAskCategory'], 'printCategoryOptions' => $categoryLayout->renderOptions(), 'msgAskYourQuestion' => $PMF_LANG['msgAskYourQuestion'], 'captchaFieldset' => PMF_Helper_Captcha::getInstance()->renderFieldset($PMF_LANG['msgCaptcha'], $captcha->printCaptcha('ask')), 'msgNewContentSubmit' => $PMF_LANG['msgNewContentSubmit'])); $tpl->includeTemplate('writeContent', 'index');
$record_ids = $tagging->getRecordsByTagId($inputTag); $printResult = $faq->showAllRecordsByIds($record_ids); } // // Handle the full text search stuff // if (!is_null($inputSearchTerm) || !is_null($search)) { if (!is_null($inputSearchTerm)) { $inputSearchTerm = $db->escapeString(strip_tags($inputSearchTerm)); } if (!is_null($search)) { $inputSearchTerm = $db->escapeString(strip_tags($search)); } $printResult = searchEngine($inputSearchTerm, $inputCategory, $allLanguages); $inputSearchTerm = stripslashes($inputSearchTerm); $faqsearch->logSearchTerm($inputSearchTerm); } // Change a little bit the $searchCategory value; $inputCategory = '%' == $inputCategory ? 0 : $inputCategory; $faqsession->userTracking('fulltext_search', $inputSearchTerm); $openSearchLink = sprintf('<a class="searchplugin" href="#" onclick="window.external.AddSearchProvider(\'%s/opensearch.php\');">%s</a>', PMF_Link::getSystemUri('/index.php'), $PMF_LANG['opensearch_plugin_install']); $mostPopularSearches = ''; $mostPopularSearchData = $faqsearch->getMostPopularSearches($faqconfig->get('main.numberSearchTerms')); foreach ($mostPopularSearchData as $searchItem) { if (PMF_String::strlen($searchItem['searchterm']) > 0) { $mostPopularSearches .= sprintf('<li><a href="?search=%s&submit=Search&action=search">%s</a> (%dx)</li>', urlencode($searchItem['searchterm']), $searchItem['searchterm'], $searchItem['number']); } } $categoryLayout = new PMF_Category_Layout(new PMF_Category_Tree_Helper(new PMF_Category_Tree($categoryData))); $tpl->processTemplate('writeContent', array('msgSearch' => $tagSearch ? $PMF_LANG['msgTagSearch'] : $PMF_LANG['msgSearch'], 'searchString' => PMF_String::htmlspecialchars($inputSearchTerm, ENT_QUOTES, 'utf-8'), 'searchOnAllLanguages' => $PMF_LANG['msgSearchOnAllLanguages'], 'checkedAllLanguages' => $allLanguages ? ' checked="checked"' : '', 'selectCategories' => $PMF_LANG['msgSelectCategories'], 'allCategories' => $PMF_LANG['msgAllCategories'], 'printCategoryOptions' => $categoryLayout->renderOptions(array($inputCategory)), 'writeSendAdress' => '?' . $sids . 'action=search', 'msgSearchWord' => $PMF_LANG['msgSearchWord'], 'printResult' => $printResult, 'openSearchLink' => $openSearchLink, 'msgMostPopularSearches' => $PMF_LANG['msgMostPopularSearches'], 'printMostPopularSearches' => '<ul class="phpmyfaq_ul">' . $mostPopularSearches . '</ul>')); $tpl->includeTemplate('writeContent', 'index');
* @package Administration * @author Thorsten Rinne <*****@*****.**> * @copyright 2003-2010 phpMyFAQ Team * @license http://www.mozilla.org/MPL/MPL-1.1.html Mozilla Public License Version 1.1 * @link http://www.phpmyfaq.de * @since 2003-02-24 */ if (!defined('IS_VALID_PHPMYFAQ_ADMIN')) { header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME'])); exit; } if ($permission['delquestion']) { $questionId = PMF_Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT); $delete = PMF_Filter::filterInput(INPUT_GET, 'delete', FILTER_SANITIZE_STRING, 'no'); $categoryData = new PMF_Category_Tree_DataProvider_SingleQuery($LANGCODE); $categoryLayout = new PMF_Category_Layout(new PMF_Category_Tree_Helper(new PMF_Category_Tree($categoryData))); $faqQuestions = new PMF_Faq_Questions(); if ($delete == 'yes') { $faqQuestions->delete($questionId); print $PMF_LANG['ad_entry_delsuc']; } else { $toggleQuestion = PMF_Filter::filterInput(INPUT_GET, 'is_visible', FILTER_SANITIZE_STRING); if ($toggleQuestion == 'toggle') { $is_visible = $faqQuestions->getVisibility($questionId); if (!is_null($is_visible)) { $faqQuestions->setVisibility($questionId, $is_visible == 'N' ? 'Y' : 'N'); } } printf("<h2>%s</h2>", $PMF_LANG['msgOpenQuestions']); $openQuestions = $faqQuestions->fetchAll(); if (count($openQuestions) > 0) {
if (!defined('IS_VALID_PHPMYFAQ')) { header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME'])); exit; } require PMF_INCLUDE_DIR . '/Export.php'; ?> <h2><?php print $PMF_LANG["ad_menu_export"]; ?> </h2> <form action="?action=exportfile" method="post"> <?php if (!PMF_Db::checkOnEmptyTable('faqdata')) { if (!PMF_Db::checkOnEmptyTable('faqcategories')) { $categoryData = new PMF_Category_Tree_DataProvider_SingleQuery($LANGCODE); $categoryLayout = new PMF_Category_Layout(new PMF_Category_Tree_Helper(new PMF_Category_Tree($categoryData))); ?> <fieldset><legend><?php print $PMF_LANG['ad_export_which_cat']; ?> </legend> <label class="left" for="rubrik"><?php print $PMF_LANG["ad_entry_category"]; ?> </label> <select name="catid" id="catid" size="1"> <?php print $categoryLayout->renderOptions(); ?> </select> <br />
?> </select> </fieldset> </form> <br /> <?php } if (isset($revisionid_selected) && isset($faqData['revision_id']) && $revisionid_selected != $faqData['revision_id']) { $faq->language = $faqData['lang']; $faq->getRecord($faqData['id'], $revisionid_selected, true); $faqData = $faq->faqRecord; $tags = implode(',', $tagging->getAllTagsById($faqData['id'])); } } $categoryData = new PMF_Category_Tree_DataProvider_SingleQuery($LANGCODE); $categoryLayout = new PMF_Category_Layout(new PMF_Category_Tree_Helper(new PMF_Category_Tree($categoryData))); ?> <form id="faqEditor" style="float: left;" action="?action=<?php print $url_variables; ?> " method="post"> <input type="hidden" name="revision_id" id="revision_id" value="<?php print $faqData['revision_id']; ?> " /> <input type="hidden" name="record_id" id="record_id" value="<?php print $faqData['id']; ?> " /> <input type="hidden" name="csrf" value="<?php
* @since 2002-08-27 */ if (!defined('IS_VALID_PHPMYFAQ')) { header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME'])); exit; } $categoryId = PMF_Filter::filterInput(INPUT_GET, 'cat', FILTER_VALIDATE_INT); if (!is_null($categoryId)) { $faqsession->userTracking('show_category', $categoryId); $categoryNode = new PMF_Category_Node(); $categoryNode->setLanguage($LANGCODE); $selectedCategoryData = $categoryNode->fetch($categoryId); $records = $faq->showAllRecords($categoryId, $faqconfig->get('records.orderby'), $faqconfig->get('records.sortby')); if (!$records) { $records = $categoryLayout->renderTree(); } $backToParent = ''; if ($selectedCategoryData->parent_id != 0) { $url = sprintf('%saction=show&cat=%d', $sids, $selectedCategoryData->parent_id); $oLink = new PMF_Link(PMF_Link::getSystemRelativeUri() . '?' . $url); $oLink->text = $PMF_LANG['msgCategoryUp']; $backToParent = $oLink->toHtmlAnchor(); } $tpl->processTemplate('writeContent', array('writeCategory' => $PMF_LANG['msgEntriesIn'] . $selectedCategoryData->name, 'writeCategoryDescription' => $selectedCategoryData->description, 'writeThemes' => $records, 'writeOneThemeBack' => $backToParent)); $tpl->includeTemplate('writeContent', 'index'); } else { $categoryLayout = new PMF_Category_Layout(new PMF_Category_Tree_Helper($categoryTree)); $faqsession->userTracking('show_all_categories', 0); $tpl->processTemplate('writeContent', array('writeCategory' => $PMF_LANG['msgFullCategories'], 'writeCategoryDescription' => '', 'writeThemes' => $categoryLayout->renderTree(), 'writeOneThemeBack' => '')); $tpl->includeTemplate('writeContent', 'index'); }