if (1 != $save) { $cleanQuestion = PMF_Stopwords::getInstance()->clean($question); $user = new PMF_User_CurrentUser(); $faqSearch = new PMF_Search($db, $Language); $faqSearchResult = new PMF_Search_Resultset($user, $faq); $searchResult = array(); $mergedResult = array(); foreach ($cleanQuestion as $word) { $searchResult[] = $faqSearch->search($word); } foreach ($searchResult as $resultSet) { foreach ($resultSet as $result) { $mergedResult[] = $result; } } $faqSearchResult->reviewResultset($mergedResult); if (0 < $faqSearchResult->getNumberOfResults()) { $response = sprintf('<p>%s</p>', $plr->GetMsg('plmsgSearchAmount', $faqSearchResult->getNumberOfResults())); $response .= '<ul>'; foreach ($faqSearchResult->getResultset() as $result) { $url = sprintf('/index.php?action=artikel&cat=%d&id=%d&artlang=%s', $result->category_id, $result->id, $result->lang); $oLink = new PMF_Link(PMF_Configuration::getInstance()->get('main.referenceURL') . $url); $oLink->text = PMF_Utils::chopString($result->question, 15); $oLink->itemTitle = $result->question; $response .= sprintf('<li>%s<br /><div class="searchpreview">%s...</div></li>', $oLink->toHtmlAnchor(), PMF_Utils::chopString(strip_tags($result->answer), 10)); } $response .= '</ul>'; $message = array('result' => $response); } else { $questionData = array('username' => $name, 'email' => $email, 'category_id' => $ucategory, 'question' => $question, 'is_visible' => $visibility); $faq->addQuestion($questionData);
} else { $searchResult = ''; } // // Handle the full text search stuff // if (!is_null($inputSearchTerm) || !is_null($search)) { if (!is_null($inputSearchTerm)) { $inputSearchTerm = $db->escape_string(strip_tags($inputSearchTerm)); } if (!is_null($search)) { $inputSearchTerm = $db->escape_string(strip_tags($search)); } $faqSearch->setCategory($inputCategory); $searchResults = $faqSearch->search($inputSearchTerm, $allLanguages); $faqSearchResult->reviewResultset($searchResults); $inputSearchTerm = stripslashes($inputSearchTerm); $faqSearch->logSearchTerm($inputSearchTerm); } // Change a little bit the $searchCategory value; $inputCategory = '%' == $inputCategory ? 0 : $inputCategory; $faqsession->userTracking('fulltext_search', $inputSearchTerm); if (is_numeric($inputSearchTerm) && PMF_SOLUTION_ID_START_VALUE <= $inputSearchTerm && 0 < $faqSearchResult->getNumberOfResults()) { // Before a redirection we must force the PHP session update for preventing data loss session_write_close(); 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;
if (count($multiCategories) > 1) { $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);