/** * Returns the single instance * * @access static * @return PMF_Helper_Search */ public static function getInstance() { if (null == self::$instance) { $className = __CLASS__; self::$instance = new $className(); } return self::$instance; }
if (PMF_Configuration::getInstance()->get('main.enableRewriteRules')) { header('Location: ' . PMF_Link::getSystemUri('/index.php') . '/solution_id_' . $inputSearchTerm . '.html'); } else { header('Location: ' . PMF_Link::getSystemUri('/index.php') . '/index.php?solution_id=' . $inputSearchTerm); } exit; } $category->buildTree(); $mostPopularSearchData = $faqSearch->getMostPopularSearches($faqconfig->get('search.numberSearchTerms')); // Set base URL scheme if (PMF_Configuration::getInstance()->get('main.enableRewriteRules')) { $baseUrl = sprintf("%ssearch.html?search=%s&seite=%d%s&searchcategory=%d", PMF_Link::getSystemRelativeUri('index.php'), urlencode($inputSearchTerm), $page, $languages, $inputCategory); } else { $baseUrl = sprintf('%s?%saction=search&search=%s&seite=%d%s&searchcategory=%d', PMF_Link::getSystemRelativeUri(), empty($sids) ? '' : '$sids&', urlencode($inputSearchTerm), $page, $languages, $inputCategory); } // Pagination options $options = array('baseUrl' => $baseUrl, 'total' => $faqSearchResult->getNumberOfResults(), 'perPage' => PMF_Configuration::getInstance()->get('records.numberOfRecordsPerPage'), 'pageParamName' => 'seite', 'nextPageLinkTpl' => '<a href="{LINK_URL}">' . $PMF_LANG['msgNext'] . '</a>', 'prevPageLinkTpl' => '<a href="{LINK_URL}">' . $PMF_LANG['msgPrevious'] . '</a>', 'layoutTpl' => '<p align="center"><strong>{LAYOUT_CONTENT}</strong></p>'); $faqPagination = new PMF_Pagination($options); $faqCategoryHelper = PMF_Helper_Category::getInstance(); $faqCategoryHelper->setCategory($category); $faqSearchHelper = PMF_Helper_Search::getInstance(); $faqSearchHelper->setSearchterm($inputSearchTerm); $faqSearchHelper->setCategory($category); $faqSearchHelper->setPagination($faqPagination); $faqSearchHelper->setPlurals($plr); $faqSearchHelper->setSessionId($sids); if ('' == $searchResult && !is_null($inputSearchTerm)) { $searchResult = $faqSearchHelper->renderSearchResult($faqSearchResult, $page); } $tpl->processTemplate('writeContent', array('msgAdvancedSearch' => $tagSearch ? $PMF_LANG['msgTagSearch'] : $PMF_LANG['msgAdvancedSearch'], 'msgSearch' => $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' => $faqCategoryHelper->renderCategoryOptions($inputCategory), 'writeSendAdress' => '?' . $sids . 'action=search', 'msgSearchWord' => $PMF_LANG['msgSearchWord'], 'printResult' => $searchResult, 'openSearchLink' => $faqSearchHelper->renderOpenSearchLink(), 'msgMostPopularSearches' => $PMF_LANG['msgMostPopularSearches'], 'printMostPopularSearches' => $faqSearchHelper->renderMostPopularSearches($mostPopularSearchData))); $tpl->includeTemplate('writeContent', 'index');
if ($faqConfig->get('main.enableRewriteRules')) { header('Location: ' . $faqConfig->get('main.referenceURL') . '/solution_id_' . $inputSearchTerm . '.html'); } else { header('Location: ' . $faqConfig->get('main.referenceURL') . '/index.php?solution_id=' . $inputSearchTerm); } exit; } $category->buildTree(); $mostPopularSearchData = $faqSearch->getMostPopularSearches($faqConfig->get('search.numberSearchTerms')); // Set base URL scheme if ($faqConfig->get('main.enableRewriteRules')) { $baseUrl = sprintf("%ssearch.html?search=%s&seite=%d%s&searchcategory=%d", PMF_Link::getSystemRelativeUri('index.php'), urlencode($inputSearchTerm), $page, $languages, $inputCategory); } else { $baseUrl = sprintf('%s?%saction=search&search=%s&seite=%d%s&searchcategory=%d', PMF_Link::getSystemRelativeUri(), empty($sids) ? '' : 'sids=' . $sids . '&', urlencode($inputSearchTerm), $page, $languages, $inputCategory); } // Pagination options $options = array('baseUrl' => $baseUrl, 'total' => $faqSearchResult->getNumberOfResults(), 'perPage' => $faqConfig->get('records.numberOfRecordsPerPage'), 'pageParamName' => 'seite', 'layoutTpl' => '<div class="pagination text-center"><ul>{LAYOUT_CONTENT}</ul></div>'); $faqPagination = new PMF_Pagination($faqConfig, $options); $categoryHelper = new PMF_Helper_Category(); $categoryHelper->setCategory($category); $searchHelper = new PMF_Helper_Search($faqConfig); $searchHelper->setSearchterm($inputSearchTerm); $searchHelper->setCategory($category); $searchHelper->setPagination($faqPagination); $searchHelper->setPlurals($plr); $searchHelper->setSessionId($sids); if ('' == $searchResult && !is_null($inputSearchTerm)) { $searchResult = $searchHelper->renderSearchResult($faqSearchResult, $page); } $tpl->parse('writeContent', array('msgAdvancedSearch' => $tagSearch ? $PMF_LANG['msgTagSearch'] : $PMF_LANG['msgAdvancedSearch'], 'msgSearch' => $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' => $categoryHelper->renderOptions($inputCategory), 'writeSendAdress' => '?' . $sids . 'action=search', 'msgSearchWord' => $PMF_LANG['msgSearchWord'], 'printResult' => $searchResult, 'openSearchLink' => $searchHelper->renderOpenSearchLink(), 'msgMostPopularSearches' => $PMF_LANG['msgMostPopularSearches'], 'printMostPopularSearches' => $searchHelper->renderMostPopularSearches($mostPopularSearchData))); $tpl->merge('writeContent', 'index');
} else { $current_groups = array(-1); } if (0 == count($current_groups)) { $current_groups = array(-1); } } else { $user = new PMF_User_CurrentUser($faqConfig); $current_user = -1; $current_groups = array(-1); } $category = new PMF_Category($faqConfig); $category->setUser($current_user); $category->transform(0); $category->buildTree(); $faq = new PMF_Faq($faqConfig); $faqSearch = new PMF_Search($faqConfig); $faqSearchResult = new PMF_Search_Resultset($user, $faq, $faqConfig); // // Handle the search requests // if (!is_null($searchString)) { $faqSearch->setCategory($categoryId); $searchResult = $faqSearch->search($searchString, false); $faqSearchResult->reviewResultset($searchResult); $faqSearchHelper = new PMF_Helper_Search($faqConfig); $faqSearchHelper->setSearchterm($searchString); $faqSearchHelper->setCategory($category); $faqSearchHelper->setPlurals($plr); Response::create($faqSearchHelper->renderInstantResponseResult($faqSearchResult))->send(); }
$htmlAllCategories .= ' <div id="article_categories">'; $htmlAllCategories .= ' <p>' . $PMF_LANG['msgArticleCategories'] . '</p>'; $htmlAllCategories .= ' <ul>'; foreach ($multiCategories as $multiCat) { $path = $category->getPath($multiCat['id'], ' » ', true); if ('' === trim($path)) { continue; } $htmlAllCategories .= sprintf("<li>%s</li>\n", $path); } $htmlAllCategories .= ' </ul>'; $htmlAllCategories .= ' </div>'; } // Related FAQs $faqSearchResult->reviewResultset($faqRelation->getAllRelatedById($faq->faqRecord['id'], $faq->faqRecord['title'], $faq->faqRecord['keywords'])); $relatedFaqs = PMF_Helper_Search::getInstance()->renderRelatedFaqs($faqSearchResult, $faq->faqRecord['id']); // Show link to edit the faq? $editThisEntry = ''; if (isset($permission['editbt']) && $permission['editbt']) { $editThisEntry = sprintf('<a href="%sadmin/index.php?action=editentry&id=%d&lang=%s">%s</a>', PMF_Link::getSystemRelativeUri('index.php'), $faq->faqRecord['id'], $lang, $PMF_LANG['ad_entry_edit_1'] . ' ' . $PMF_LANG['ad_entry_edit_2']); } // Is the faq expired? $expired = date('YmdHis') > $faq->faqRecord['dateEnd']; // Does the user have the right to add a comment? if ($faq->faqRecord['active'] != 'yes' || 'n' == $faq->faqRecord['comment'] || $expired) { $commentMessage = $PMF_LANG['msgWriteNoComment']; } else { $commentMessage = sprintf("%s<a href=\"javascript:void(0);\" onclick=\"javascript:\$('#commentForm').show();\">%s</a>", $PMF_LANG['msgYouCan'], $PMF_LANG['msgWriteComment']); } $translationUrl = sprintf(str_replace('%', '%%', PMF_Link::getSystemRelativeUri('index.php')) . 'index.php?%saction=translate&cat=%s&id=%d&srclang=%s', $sids, $currentCategory, $faq->faqRecord['id'], $lang); if (!empty($switchLanguage)) {
echo $PMF_LANG['err_NotAuth']; } break; // search FAQs for suggestions // search FAQs for suggestions case 'search_records': if ($permission['editbt']) { $faq = new PMF_Faq($faqConfig); $faqSearch = new PMF_Search($faqConfig); $faqSearchResult = new PMF_Search_Resultset($user, $faq, $faqConfig); $searchResult = ''; $searchString = PMF_Filter::filterInput(INPUT_POST, 'search', FILTER_SANITIZE_STRIPPED); if (!is_null($searchString)) { $searchResult = $faqSearch->search($searchString, false); $faqSearchResult->reviewResultset($searchResult); $searchHelper = new PMF_Helper_Search($faqConfig); $searchHelper->setSearchterm($searchString); echo $searchHelper->renderAdminSuggestionResult($faqSearchResult); } } else { echo $PMF_LANG['err_NotAuth']; } break; // delete FAQs // delete FAQs case 'delete_record': if ($permission['delbt']) { $recordId = PMF_Filter::filterInput(INPUT_POST, 'record_id', FILTER_VALIDATE_INT); $recordLang = PMF_Filter::filterInput(INPUT_POST, 'record_lang', FILTER_SANITIZE_STRING); $logging = new PMF_Logging($faqConfig); $logging->logAdmin($user, 'Deleted FAQ ID ' . $recordId);
} // List all categories for this faq $htmlAllCategories = ''; $multiCategories = $category->getCategoriesFromArticle($recordId); if (count($multiCategories) > 1) { foreach ($multiCategories as $multiCat) { $path = $category->getPath($multiCat['id'], ' » ', true, 'breadcrumb-related-categories'); if ('' === trim($path)) { continue; } $htmlAllCategories .= $path; } } // Related FAQs $faqSearchResult->reviewResultset($faqRelation->getAllRelatedById($recordId, $faq->faqRecord['title'], $faq->faqRecord['keywords'])); $searchHelper = new PMF_Helper_Search($faqConfig); $relatedFaqs = $searchHelper->renderRelatedFaqs($faqSearchResult, $recordId); // Show link to edit the faq? $editThisEntry = ''; if ($user->perm->checkRight($user->getUserId(), 'editbt')) { $editThisEntry = sprintf('<a href="%sadmin/index.php?action=editentry&id=%d&lang=%s">%s</a>', PMF_Link::getSystemRelativeUri('index.php'), $recordId, $lang, $PMF_LANG['ad_entry_edit_1'] . ' ' . $PMF_LANG['ad_entry_edit_2']); } // Is the faq expired? $expired = date('YmdHis') > $faq->faqRecord['dateEnd']; // Does the user have the right to add a comment? if (-1 === $user->getUserId() && !$faqConfig->get('records.allowCommentsForGuests') || $faq->faqRecord['active'] === 'no' || 'n' == $faq->faqRecord['comment'] || $expired) { $commentMessage = $PMF_LANG['msgWriteNoComment']; } else { $commentMessage = sprintf("%s<a href=\"javascript:void(0);\" onclick=\"javascript:\$('#commentForm').show();\">%s</a>", $PMF_LANG['msgYouCan'], $PMF_LANG['msgWriteComment']); } $translationUrl = sprintf(str_replace('%', '%%', PMF_Link::getSystemRelativeUri('index.php')) . 'index.php?%saction=translate&cat=%s&id=%d&srclang=%s', $sids, $currentCategory, $recordId, $lang);
$response->setContent($PMF_LANG['err_NotAuth']); } break; // search FAQs for suggestions // search FAQs for suggestions case 'search_records': if ($user->perm->checkRight($user->getUserId(), 'editbt')) { $faq = new PMF_Faq($faqConfig); $faqSearch = new PMF_Search($faqConfig); $faqSearchResult = new PMF_Search_Resultset($user, $faq, $faqConfig); $searchResult = ''; $searchString = PMF_Filter::filterInput(INPUT_POST, 'search', FILTER_SANITIZE_STRIPPED); if (!is_null($searchString)) { $searchResult = $faqSearch->search($searchString, false); $faqSearchResult->reviewResultset($searchResult); $searchHelper = new PMF_Helper_Search($faqConfig); $searchHelper->setSearchterm($searchString); $response->setContent($searchHelper->renderAdminSuggestionResult($faqSearchResult)); } } else { $response->setContent($PMF_LANG['err_NotAuth']); } break; // delete FAQs // delete FAQs case 'delete_record': if ($user->perm->checkRight($user->getUserId(), 'delbt')) { $recordId = PMF_Filter::filterInput(INPUT_POST, 'record_id', FILTER_VALIDATE_INT); $recordLang = PMF_Filter::filterInput(INPUT_POST, 'record_lang', FILTER_SANITIZE_STRING); $logging = new PMF_Logging($faqConfig); $logging->logAdmin($user, 'Deleted FAQ ID ' . $recordId);