本文整理汇总了PHP中SearchHelper::logSearch方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchHelper::logSearch方法的具体用法?PHP SearchHelper::logSearch怎么用?PHP SearchHelper::logSearch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchHelper
的用法示例。
在下文中一共展示了SearchHelper::logSearch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
function display($tpl = null)
{
global $mainframe;
require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'search.php';
// Initialize some variables
$pathway =& $mainframe->getPathway();
$uri =& JFactory::getURI();
$error = '';
$rows = null;
$total = 0;
// Get some data from the model
$areas =& $this->get('areas');
$state =& $this->get('state');
$searchword = $state->get('keyword');
$params =& $mainframe->getParams();
$menus =& JSite::getMenu();
$menu = $menus->getActive();
// because the application sets a default page title, we need to get it
// right from the menu item itself
if (is_object($menu)) {
$menu_params = new JParameter($menu->params);
if (!$menu_params->get('page_title')) {
$params->set('page_title', JText::_('Search'));
}
} else {
$params->set('page_title', JText::_('Search'));
}
$document =& JFactory::getDocument();
$document->setTitle($params->get('page_title'));
// Get the parameters of the active menu item
$params =& $mainframe->getParams();
// built select lists
$orders = array();
$orders[] = JHTML::_('select.option', 'newest', JText::_('Newest first'));
$orders[] = JHTML::_('select.option', 'oldest', JText::_('Oldest first'));
$orders[] = JHTML::_('select.option', 'popular', JText::_('Most popular'));
$orders[] = JHTML::_('select.option', 'alpha', JText::_('Alphabetical'));
$orders[] = JHTML::_('select.option', 'category', JText::_('Section/Category'));
$lists = array();
$lists['ordering'] = JHTML::_('select.genericlist', $orders, 'ordering', 'class="inputbox"', 'value', 'text', $state->get('ordering'));
$searchphrases = array();
$searchphrases[] = JHTML::_('select.option', 'all', JText::_('All words'));
$searchphrases[] = JHTML::_('select.option', 'any', JText::_('Any words'));
$searchphrases[] = JHTML::_('select.option', 'exact', JText::_('Exact phrase'));
$lists['searchphrase'] = JHTML::_('select.radiolist', $searchphrases, 'searchphrase', '', 'value', 'text', $state->get('match'));
// log the search
SearchHelper::logSearch($searchword);
//limit searchword
if (SearchHelper::limitSearchWord($searchword)) {
$error = JText::_('SEARCH_MESSAGE');
}
//sanatise searchword
if (SearchHelper::santiseSearchWord($searchword, $state->get('match'))) {
$error = JText::_('IGNOREKEYWORD');
}
if (!$searchword && count(JRequest::get('post'))) {
//$error = JText::_( 'Enter a search keyword' );
}
// put the filtered results back into the model
// for next release, the checks should be done in the model perhaps...
$state->set('keyword', $searchword);
if (!$error) {
$results =& $this->get('data');
$total =& $this->get('total');
$pagination =& $this->get('pagination');
require_once JPATH_SITE . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'route.php';
for ($i = 0; $i < count($results); $i++) {
$row =& $results[$i]->text;
if ($state->get('match') == 'exact') {
$searchwords = array($searchword);
$needle = $searchword;
} else {
$searchwords = preg_split("/\\s+/u", $searchword);
$needle = $searchwords[0];
}
$row = SearchHelper::prepareSearchContent($row, 200, $needle);
$searchwords = array_unique($searchwords);
$searchRegex = '#(';
$x = 0;
foreach ($searchwords as $k => $hlword) {
$searchRegex .= $x == 0 ? '' : '|';
$searchRegex .= preg_quote($hlword, '#');
$x++;
}
$searchRegex .= ')#iu';
$row = preg_replace($searchRegex, '<span class="highlight">\\0</span>', $row);
$result =& $results[$i];
if ($result->created) {
$created = JHTML::Date($result->created);
} else {
$created = '';
}
$result->created = $created;
$result->count = $i + 1;
}
}
$this->result = JText::sprintf('TOTALRESULTSFOUND', $total);
$this->assignRef('pagination', $pagination);
$this->assignRef('results', $results);
$this->assignRef('lists', $lists);
//.........这里部分代码省略.........
示例2: display
function display($tpl = null)
{
require_once JPATH_COMPONENT . '/helpers/search.php';
// Initialise some variables
$app = JFactory::getApplication();
$pathway = $app->getPathway();
$uri = JFactory::getURI();
$error = null;
$rows = null;
$results = null;
$total = 0;
// Get some data from the model
$areas = $this->get('areas');
$state = $this->get('state');
$searchword = $state->get('keyword');
$params = $app->getParams();
$menus = $app->getMenu();
$menu = $menus->getActive();
// because the application sets a default page title, we need to get it
// right from the menu item itself
if (is_object($menu)) {
$menu_params = new JRegistry();
$menu_params->loadString($menu->params);
if (!$menu_params->get('page_title')) {
$params->set('page_title', JText::_('COM_SEARCH_SEARCH'));
}
} else {
$params->set('page_title', JText::_('COM_SEARCH_SEARCH'));
}
$title = $params->get('page_title');
if ($app->getCfg('sitename_pagetitles', 0) == 1) {
$title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
} elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
$title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
}
$this->document->setTitle($title);
if ($params->get('menu-meta_description')) {
$this->document->setDescription($params->get('menu-meta_description'));
}
if ($params->get('menu-meta_keywords')) {
$this->document->setMetadata('keywords', $params->get('menu-meta_keywords'));
}
if ($params->get('robots')) {
$this->document->setMetadata('robots', $params->get('robots'));
}
// built select lists
$orders = array();
$orders[] = JHtml::_('select.option', 'newest', JText::_('COM_SEARCH_NEWEST_FIRST'));
$orders[] = JHtml::_('select.option', 'oldest', JText::_('COM_SEARCH_OLDEST_FIRST'));
$orders[] = JHtml::_('select.option', 'popular', JText::_('COM_SEARCH_MOST_POPULAR'));
$orders[] = JHtml::_('select.option', 'alpha', JText::_('COM_SEARCH_ALPHABETICAL'));
$orders[] = JHtml::_('select.option', 'category', JText::_('JCATEGORY'));
$lists = array();
$lists['ordering'] = JHtml::_('select.genericlist', $orders, 'ordering', 'class="inputbox"', 'value', 'text', $state->get('ordering'));
$searchphrases = array();
$searchphrases[] = JHtml::_('select.option', 'all', JText::_('COM_SEARCH_ALL_WORDS'));
$searchphrases[] = JHtml::_('select.option', 'any', JText::_('COM_SEARCH_ANY_WORDS'));
$searchphrases[] = JHtml::_('select.option', 'exact', JText::_('COM_SEARCH_EXACT_PHRASE'));
$lists['searchphrase'] = JHtml::_('select.radiolist', $searchphrases, 'searchphrase', '', 'value', 'text', $state->get('match'));
// log the search
SearchHelper::logSearch($searchword);
//limit searchword
$lang = JFactory::getLanguage();
$upper_limit = $lang->getUpperLimitSearchWord();
$lower_limit = $lang->getLowerLimitSearchWord();
if (SearchHelper::limitSearchWord($searchword)) {
$error = JText::sprintf('COM_SEARCH_ERROR_SEARCH_MESSAGE', $lower_limit, $upper_limit);
}
//sanatise searchword
if (SearchHelper::santiseSearchWord($searchword, $state->get('match'))) {
$error = JText::_('COM_SEARCH_ERROR_IGNOREKEYWORD');
}
if (!$searchword && count(JRequest::get('post'))) {
//$error = JText::_('COM_SEARCH_ERROR_ENTERKEYWORD');
}
// put the filtered results back into the model
// for next release, the checks should be done in the model perhaps...
$state->set('keyword', $searchword);
if ($error == null) {
$results = $this->get('data');
$total = $this->get('total');
$pagination = $this->get('pagination');
require_once JPATH_SITE . '/components/com_content/helpers/route.php';
for ($i = 0, $count = count($results); $i < $count; $i++) {
$row =& $results[$i]->text;
if ($state->get('match') == 'exact') {
$searchwords = array($searchword);
$needle = $searchword;
} else {
$searchworda = preg_replace('#\\xE3\\x80\\x80#s', ' ', $searchword);
$searchwords = preg_split("/\\s+/u", $searchworda);
$needle = $searchwords[0];
}
$row = SearchHelper::prepareSearchContent($row, $needle);
$searchwords = array_unique($searchwords);
$searchRegex = '#(';
$x = 0;
foreach ($searchwords as $k => $hlword) {
$searchRegex .= $x == 0 ? '' : '|';
$searchRegex .= preg_quote($hlword, '#');
//.........这里部分代码省略.........
示例3: search
/**
* Main method to make a search
*/
public function search()
{
$this->getSearchFields();
$word = JRequest::getString('searchword', null, 'get');
$offset = JRequest::getInt('start', 0, 'get');
$limit = JRequest::getInt('limit', 10, 'get');
if ($limit == 0) {
// no limit
$limit = 10000;
}
$this->getSearchAreas();
$elasticaQueryString = new \Elastica\Query\QueryString();
// Log search word only on the first page
if ($offset == 0) {
SearchHelper::logSearch($word);
}
// Convert accents
$word = htmlentities($word, ENT_NOQUOTES, 'utf-8');
$word = preg_replace('#\\&([A-za-z])(?:uml|circ|tilde|acute|grave|cedil|ring)\\;#', '\\1', $word);
$word = preg_replace('#\\&([A-za-z]{2})(?:lig)\\;#', '\\1', $word);
$word = preg_replace('#\\&[^;]+\\;#', '', $word);
// Check if there are quotes ( for exact search )
$exactSearch = false;
if (strlen($word) > 1 && $word[0] == '"' && $word[strlen($word) - 1] == '"') {
$exactSearch = true;
$word = substr($word, 1, strlen($word) - 2);
// Remove external "
}
$word = Elastica\Util::replaceBooleanWordsAndEscapeTerm($word);
// Escape ElasticSearch specials char
if ($exactSearch) {
$word = '"' . $word . '"';
}
if ($word == "") {
$word = "*";
}
$elasticaQueryString->setQuery($word);
//Create the actual search object with some data.
$elasticaQuery = new Elastica\Query();
$elasticaQuery->setQuery($elasticaQueryString);
if (ElasticSearchConfig::getHighLigthEnable()) {
$fields = $this->getHighlightFields();
$hlfields = array();
foreach ($fields as $field) {
foreach ($field as $highlight) {
$hlfields[] = array($highlight => array('fragment_size' => 1000, 'number_of_fragments' => 1));
}
}
$highlightFields = array('pre_tags' => array(ElasticSearchConfig::getHighLigthPre()), 'post_tags' => array(ElasticSearchConfig::getHighLigthPost()), "order" => "score", 'fields' => $hlfields);
$elasticaQuery->setHighlight($highlightFields);
}
// Set offset and limit for pagination
$elasticaQuery->setFrom($offset);
$elasticaQuery->setLimit($limit);
//Create a filter for _type
$elasticaFilterype = $this->createFilterType($this->areas);
// Add filter to the search object.
$elasticaQuery->setFilter($elasticaFilterype);
//Search on the index.
$elasticaResultSet = $this->elasticaIndex->search($elasticaQuery);
$this->results = $elasticaResultSet->getResults();
$this->totalHits = $elasticaResultSet->getTotalHits();
}
示例4: display
function display($tpl = null)
{
require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'search.php';
global $mainframe;
$params =& $mainframe->getParams();
$uri =& JFactory::getURI();
$error = '';
$rows = null;
$total = 0;
// Get some data from the model
$areas =& $this->get('areas');
$state =& $this->get('state');
$searchword = $state->get('keyword');
$menus =& JSite::getMenu();
$menu = $menus->getActive();
$document =& JFactory::getDocument();
$document->setTitle($params->get('page_title'));
$orders = array();
$lists = array();
$lists['ordering'] = JHTML::_('select.genericlist', $orders, 'ordering', 'class="inputbox"', 'value', 'text', $state->get('ordering'));
// because the application sets a default page title, we need to get it
// right from the menu item itself
if (is_object($menu)) {
$menu_params = new JParameter($menu->params);
if (!$menu_params->get('page_title')) {
$params->set('page_title', JText::_('Search'));
}
} else {
$params->set('page_title', JText::_('Search'));
}
// log the search
SearchHelper::logSearch($searchword);
//limit searchword
if (SearchHelper::limitSearchWord($searchword)) {
$error = JText::_('SEARCH_MESSAGE');
}
//sanatise searchword
if (SearchHelper::santiseSearchWord($searchword, $state->get('match'))) {
$error = JText::_('IGNOREKEYWORD');
}
if (!$searchword && count(JRequest::get('post'))) {
$error = JText::_('Enter a search keyword');
}
// put the filtered results back into the model
// for next release, the checks should be done in the model perhaps...
$state->set('keyword', $searchword);
if (!$error) {
$results =& $this->get('data');
$total =& $this->get('total');
$pagination =& $this->get('pagination');
}
$this->result = JText::sprintf('TOTALRESULTSFOUND', $total);
$this->assignRef('pagination', $pagination);
$this->assignRef('results', $results);
$this->assignRef('lists', $lists);
$this->assignRef('params', $params);
$this->assign('ordering', $state->get('ordering'));
$this->assign('searchword', $searchword);
$this->assign('searchareas', $areas);
$this->assign('total', $total);
$this->assign('error', $error);
$this->assign('action', $uri->toString());
parent::display($tpl);
}
示例5: LOWER
$db = JFactory::getDbo();
$query = 'SELECT search_term as suggestion' . ' FROM #__core_log_searches' . ' WHERE LOWER(search_term) LIKE "' . $search_term . '%"' . ' AND LENGTH(search_term) >=4' . ' AND LENGTH(search_term) >= LENGTH("' . $search_term . '")+2' . ' ORDER BY hits DESC';
$db->setQuery($query);
$hits = $db->loadObjectList();
print_r(json_encode($hits));
exit;
}
}
if ($_GET['search_exp'] != '') {
require_once dirname(__FILE__) . '/helpers/functions.php';
require_once dirname(__FILE__) . '/helpers/caching.php';
require_once JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_search/helpers/search.php';
// Nextendjimport( 'joomla.html.parameter' );
require_once JPATH_SITE . DS . 'modules' . DS . 'mod_universal_ajaxlivesearch' . DS . 'params/library/parameter.php';
if (isset($_GET['savesuggest']) && $_GET['savesuggest'] != '') {
SearchHelper::logSearch($_GET['search_exp']);
exit;
}
$areas = "";
$db = JFactory::getDBO();
$pluginlist = array();
$searchresult = array();
settype($_GET['module_id'], 'integer');
$q = sprintf("SELECT params, id FROM #__modules WHERE id = %d ", $_GET['module_id']);
$showPrice = "";
$db->setQuery($q);
$res = $db->loadResult();
$params = new SearchOfflajnJParameter("");
parseParams($params, $res);
$params->def('theme', 'elegant');
$theme = $params->get('theme', 'elegant');