本文整理汇总了PHP中ServiceUtil::searchTerm方法的典型用法代码示例。如果您正苦于以下问题:PHP ServiceUtil::searchTerm方法的具体用法?PHP ServiceUtil::searchTerm怎么用?PHP ServiceUtil::searchTerm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceUtil
的用法示例。
在下文中一共展示了ServiceUtil::searchTerm方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doSearch
private function doSearch($keywords)
{
$protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
//$protocol = "http";
$domainName = $_SERVER['HTTP_HOST'];
require_once 'ServiceUtil.php';
require_once 'Config.php';
$this->load->helper('url');
$myConfig = new Config();
$myConfig->loadJsonConfig($data);
$util = new ServiceUtil();
$keywords = str_replace(" ", "%20", $keywords);
/*$sources = $this->loadSourcesConfig($data);
if($sources != null)
{
$data['ks_sources'] = $sources;
}*/
//Loading categories configurations
/*$categories = $this->loadCategoriesConfig($data);
if($categories != null)
{
$data['categories'] = $categories;
}*/
$termResult = $util->getTerm($keywords);
//var_dump($termResult);
$termSize = 0;
if (!is_null($termResult)) {
$termSize = count($termResult);
}
//echo "------Term size:".$termSize."<br/>\n";
if ($termSize == 1) {
//echo "------Curie:".$termResult[0]->curie."<br/>\n";
if (isset($termResult[0]->curie)) {
//echo "<br/><center>Redirecting to ".$termResult[0]->curie." ...</center>";
//redirect($protocol."://".$domainName."/".Config::$localContextName."/index.php/pages/view/".$termResult[0]->curie, 'refresh');
redirect($protocol . $domainName . "/" . Config::$localContextName . "/index.php/pages/view/" . $termResult[0]->curie, 'location', 301);
}
return;
}
$searchResult = $util->searchTerm($keywords);
$data['keywords'] = $keywords;
$data['termResult'] = $termResult;
if (!is_null($termResult)) {
$searchResult = array_merge($termResult, $searchResult);
$unique = array();
$uniqueArray = array();
foreach ($searchResult as $row) {
if (isset($unique[$row->curie])) {
continue;
} else {
$unique[$row->curie] = $row->curie;
array_push($uniqueArray, $row);
}
}
$searchResult = $uniqueArray;
}
$data['searchResult'] = $searchResult;
$data['page_title'] = "Search";
$data['enable_config'] = false;
$data['disableTopSearchBar'] = true;
//var_dump($termResult);
$this->load->view('templates/header2', $data);
//$this->load->view('pages/'.$page, $data);
$this->load->view('pages/search_result', $data);
$this->load->view('templates/footer2', $data);
}