本文整理汇总了PHP中SearchEngine::getAdaptSearchTerms方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchEngine::getAdaptSearchTerms方法的具体用法?PHP SearchEngine::getAdaptSearchTerms怎么用?PHP SearchEngine::getAdaptSearchTerms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchEngine
的用法示例。
在下文中一共展示了SearchEngine::getAdaptSearchTerms方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: perform
function perform()
{
// get the search terms that have already been validated...
$this->_searchTerms = $this->_request->getValue("searchTerms");
// check if the search feature is disabled in this site...
$config =& Config::getConfig();
if (!$config->getValue("search_engine_enabled")) {
$this->_view = new ErrorView($this->_blogInfo, "error_search_engine_disabled");
$this->setCommonData();
return false;
}
// create the view and make sure that it hasn't been cached
$this->_view = new BlogTemplatedView($this->_blogInfo, VIEW_SEARCH_TEMPLATE, array("searchTerms" => $this->_searchTerms));
if ($this->_view->isCached()) {
return true;
}
$searchEngine = new SearchEngine();
$searchResults = $searchEngine->search($this->_blogInfo->getId(), $this->_searchTerms);
// MARKWU: I add the searchterms variable for smarty/plog template
$searchTerms = $searchEngine->getAdaptSearchTerms($this->_searchTerms);
// if no search results, return an error message
if (count($searchResults) == 0) {
$this->_view = new ErrorView($this->_blogInfo, "error_no_search_results");
$this->setCommonData();
return true;
}
// if only one search result, we can see it straight away
if (count($searchResults) == 1) {
// we have to refill the $_REQUEST array, since the next action
// is going to need some of the parameters
$request =& HttpVars::getRequest();
$searchResult = array_pop($searchResults);
$article = $searchResult->getArticle();
$request["articleId"] = $article->getId();
$request["blogId"] = $this->_blogInfo->getId();
HttpVars::setRequest($request);
// since there is only one article, we can use the ViewArticleAction action
// to display that article, instead of copy-pasting the code and doing it here.
// You just have to love MVC and OOP :)
return Controller::setForwardAction("ViewArticle");
}
// or else, show a list with all the posts that match the requested
// search terms
$this->_view->setValue("searchresults", $searchResults);
// MARKWU: Now, I can use the searchterms to get the keyword
$this->_view->setValue("searchterms", $searchTerms);
// MARKWU:
$config =& Config::getConfig();
$urlmode = $config->getValue("request_format_mode");
$this->_view->setValue("urlmode", $urlmode);
$this->setCommonData();
return true;
}