当前位置: 首页>>代码示例>>PHP>>正文


PHP SearchHelper类代码示例

本文整理汇总了PHP中SearchHelper的典型用法代码示例。如果您正苦于以下问题:PHP SearchHelper类的具体用法?PHP SearchHelper怎么用?PHP SearchHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SearchHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkOpenOffice

 function checkOpenOffice()
 {
     $diagnose = SearchHelper::checkOpenOfficeAvailablity();
     if (!is_null($diagnose)) {
         $this->addIssue('Open Office Server', $diagnose);
     }
 }
开发者ID:jpbauer,项目名称:knowledgetree,代码行数:7,代码来源:cronResources.php

示例2: display

 /**
  * Method to display a view.
  *
  * @param	boolean			If true, the view output will be cached
  * @param	array			An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return	JController		This object to support chaining.
  * @since	1.5
  */
 public function display($cachable = false, $urlparams = false)
 {
     require_once JPATH_COMPONENT . '/helpers/search.php';
     // Load the submenu.
     SearchHelper::addSubmenu(JRequest::getCmd('view', 'searches'));
     parent::display();
 }
开发者ID:Simarpreet05,项目名称:joomla,代码行数:16,代码来源:controller.php

示例3: display

 /**
  * Method to display a view.
  *
  * @param   boolean  $cachable   If true, the view output will be cached
  * @param   array    $urlparams  An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return  SearchController  This object to support chaining.
  *
  * @since   1.5
  */
 public function display($cachable = false, $urlparams = false)
 {
     JLoader::register('SearchHelper', JPATH_ADMINISTRATOR . '/components/com_search/helpers/search.php');
     // Load the submenu.
     SearchHelper::addSubmenu($this->input->get('view', 'searches'));
     return parent::display();
 }
开发者ID:adjaika,项目名称:J3Base,代码行数:17,代码来源:controller.php

示例4: checkOO

 /**
  * Check that open office is running
  *
  * @return boolean
  */
 private function checkOO()
 {
     $available = SearchHelper::checkOpenOfficeAvailablity();
     if (is_null($available)) {
         return true;
     }
     return false;
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:13,代码来源:pdfConverter.php

示例5: _setToolbar

 /**
  * Setup the Toolbar.
  */
 protected function _setToolbar()
 {
     $canDo = SearchHelper::getActions();
     JToolBarHelper::title(JText::_('Search_Manager_Searches'), 'search.png');
     JToolBarHelper::custom('searches.reset', 'refresh.png', 'refresh_f2.png', 'Reset', false);
     JToolBarHelper::divider();
     if ($canDo->get('core.admin')) {
         JToolBarHelper::preferences('com_search');
     }
     JToolBarHelper::divider();
     JToolBarHelper::help('screen.stats.searches');
 }
开发者ID:joebushi,项目名称:joomla,代码行数:15,代码来源:view.html.php

示例6: render

 function render()
 {
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate("ktcore/search2/search_portlet");
     $iFolderId = KTUtil::arrayGet($_REQUEST, 'fFolderId', 1);
     $iDocumentId = KTUtil::arrayGet($_REQUEST, 'fDocumentId');
     if (!$iFolderId && !$iDocumentId) {
         return null;
     }
     $savedSearches = SearchHelper::getSavedSearches($_SESSION['userID']);
     $aTemplateData = array('context' => $this, 'folder_id' => $iFolderId, 'document_id' => $iDocumentId, 'savedSearches' => $savedSearches);
     return $oTemplate->render($aTemplateData);
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:13,代码来源:Search2Portlet.php

示例7: addToolbar

 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     $canDo = SearchHelper::getActions();
     JToolBarHelper::title(JText::_('COM_SEARCH_MANAGER_SEARCHES'), 'search.png');
     if ($canDo->get('core.edit.state')) {
         JToolBarHelper::custom('searches.reset', 'refresh.png', 'refresh_f2.png', 'JSEARCH_RESET', false);
     }
     JToolBarHelper::divider();
     if ($canDo->get('core.admin')) {
         JToolBarHelper::preferences('com_search');
     }
     JToolBarHelper::divider();
     JToolBarHelper::help('JHELP_COMPONENTS_SEARCH');
 }
开发者ID:laiello,项目名称:senluonirvana,代码行数:19,代码来源:view.html.php

示例8: searchSite

 /**
  * Remote Search method
  *
  * The sql must return the following fields that are used in a common display
  * routine: href, title, section, created, text, browsernav
  *
  * @param	string	Target search string
  * @param	string	mathcing option, exact|any|all
  * @param	string	ordering option, newest|oldest|popular|alpha|category
  * @return	array	Search Results
  * @since	1.5
  */
 function searchSite($searchword, $phrase = '', $order = '')
 {
     global $mainframe;
     // Initialize variables
     $db =& JFactory::getDBO();
     // Prepare arguments
     $searchword = $db->getEscaped(trim($searchword));
     $phrase = '';
     $ordering = '';
     // Load search plugins and fire the onSearch event
     JPluginHelper::importPlugin('search');
     $results = $mainframe->triggerEvent('onSearch', array($searchword, $phrase, $ordering));
     // Iterate through results building the return array
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_search' . DS . 'helpers' . DS . 'search.php';
     foreach ($results as $i => $rows) {
         foreach ($rows as $j => $row) {
             $results[$i][$j]->href = preg_match('#^(http|https)://#i', $row->href) ? $row->href : JURI::root() . '/' . $row->href;
             $results[$i][$j]->text = SearchHelper::prepareSearchContent($row->text, 200, $searchword);
         }
     }
     return $results;
 }
开发者ID:night-coder,项目名称:ignite,代码行数:34,代码来源:profile.php

示例9: onRestCall

 function onRestCall()
 {
     $searchword = JRequest::getVar('keyword');
     $match = JRequest::getVar('match');
     // Get the results
     $results = $this->doSearch();
     // Process them like Joomla does
     for ($i = 0; $i < count($results); $i++) {
         $row =& $results[$i]->text;
         if ($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';
         */
         $result =& $results[$i];
         if ($result->created) {
             $created = $result->created;
         } else {
             $created = '';
         }
         $result->created = $created;
         $result->count = $i + 1;
     }
     return $results;
 }
开发者ID:beingsane,项目名称:Joomla-REST-API,代码行数:39,代码来源:search.php

示例10: getPollInfo

 function getPollInfo($tIds)
 {
     $sql = 'SELECT * FROM ' . DB::table('forum_polloption') . ' WHERE tid IN (' . implode(',', $tIds) . ')';
     $result = array();
     $query = DB::query($sql);
     while ($row = DB::fetch($query)) {
         $result[$row['tid']][$row['polloptionid']] = SearchHelper::convertPoll($row);
     }
     return $result;
 }
开发者ID:pan289091315,项目名称:Discuz,代码行数:10,代码来源:Manyou.php

示例11: display

 public function display($tpl = null)
 {
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/search.php';
     $app = JFactory::getApplication();
     $pathway = $app->getPathway();
     $uri = JURI::getInstance();
     $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
     JSearchHelper::logSearch($searchword, 'com_search');
     //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);
     }
     // Sanitise searchword
     if (SearchHelper::santiseSearchWord($searchword, $state->get('match'))) {
         $error = JText::_('COM_SEARCH_ERROR_IGNOREKEYWORD');
     }
     if (!$searchword && !empty($this->input) && count($this->input->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, '#');
                 $x++;
//.........这里部分代码省略.........
开发者ID:RuDers,项目名称:JoomlaSQL,代码行数:101,代码来源:view.html.php

示例12: onContentSearch


//.........这里部分代码省略.........
     $groups = implode(',', $user->getAuthorisedViewLevels());
     $tag = JFactory::getLanguage()->getTag();
     require_once JPATH_ADMINISTRATOR . '/components/com_search/helpers/search.php';
     $searchText = $text;
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
             return array();
         }
     }
     $sContent = $this->params->get('search_products', 1);
     $limit = $this->params->def('search_limit', 50);
     $nullDate = $db->getNullDate();
     $date = JFactory::getDate();
     $now = $date->toSql();
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     switch ($phrase) {
         case 'exact':
             $text = $db->quote('%' . $db->escape($text, true) . '%', false);
             $wheres2 = array();
             $wheres2[] = 'a.name LIKE ' . $text;
             $wheres2[] = 'a.description LIKE ' . $text;
             $wheres2[] = 'a.metakey LIKE ' . $text;
             $wheres2[] = 'a.metadesc LIKE ' . $text;
             $where = '(' . implode(') OR (', $wheres2) . ')';
             break;
         case 'all':
         case 'any':
         default:
             $words = explode(' ', $text);
             $wheres = array();
             foreach ($words as $word) {
                 $word = $db->quote('%' . $db->escape($word, true) . '%', false);
                 $wheres2 = array();
                 $wheres2[] = 'a.name LIKE ' . $word;
                 $wheres2[] = 'a.description LIKE ' . $word;
                 $wheres2[] = 'a.metakey LIKE ' . $word;
                 $wheres2[] = 'a.metadesc LIKE ' . $word;
                 $wheres[] = implode(' OR ', $wheres2);
             }
             $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
             break;
     }
     switch ($ordering) {
         case 'oldest':
             $order = 'a.cdate ASC';
             break;
             /*case 'popular':
             		$order = 'a.hits DESC';
             		break;*/
         /*case 'popular':
         		$order = 'a.hits DESC';
         		break;*/
         case 'alpha':
             $order = 'a.name ASC';
             break;
         case 'category':
             $order = 'c.title ASC, a.title ASC';
             break;
         case 'newest':
         default:
             $order = 'a.cdate DESC';
             break;
     }
     $rows = array();
     $query = $db->getQuery(true);
     // Search products.
     if ($sContent && $limit > 0) {
         $query->clear();
         $query->select('a.item_id, a.name AS title, a.metadesc, a.metakey, a.cdate AS created')->select('a.description AS text')->select('c.title AS section')->from('#__kart_items AS a')->join('INNER', '#__categories AS c ON c.id=a.category')->where('(' . $where . ') AND a.state=1 AND c.published = 1')->group('a.item_id, a.name, a.metadesc, a.metakey, a.cdate, a.description, c.title, c.id')->order($order);
         $db->setQuery($query, 0, $limit);
         $list = $db->loadObjectList();
         $limit -= count($list);
         if (isset($list)) {
             $comquick2cartHelper = new comquick2cartHelper();
             $itemid = $comquick2cartHelper->getItemId('index.php?option=com_quick2cart&view=productpage&layout=default');
             foreach ($list as $key => $item) {
                 $link = 'index.php?option=com_quick2cart&view=productpage&layout=default&item_id=' . $item->item_id . '&Itemid=' . $itemid;
                 $list[$key]->href = JRoute::_($link, false);
             }
         }
         $rows[] = $list;
     }
     $results = array();
     if (count($rows)) {
         foreach ($rows as $row) {
             $new_row = array();
             foreach ($row as $article) {
                 $article->browsernav = '';
                 if (SearchHelper::checkNoHTML($article, $searchText, array('text', 'title', 'metadesc', 'metakey'))) {
                     $new_row[] = $article;
                 }
             }
             $results = array_merge($results, (array) $new_row);
         }
     }
     return $results;
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:101,代码来源:quick2cart.php

示例13: onContentSearch


//.........这里部分代码省略.........
             $order = $db->quoteName('a.created') . ' ASC';
             break;
         case 'popular':
             $order = $db->quoteName('a.hits') . ' DESC';
             break;
         case 'alpha':
             $order = $db->quoteName('a.name') . ' ASC';
             break;
         case 'newest':
             $order = $db->quoteName('a.created') . ' DESC';
             break;
         default:
             $order = $db->quoteName('a.ordering') . ' DESC';
             break;
     }
     $rows = array();
     $query = $db->getQuery(true);
     $search_section = JText::_('PLG_SEARCH_TEAMS_TEAMS');
     // search teams
     if ($sTeam and $limit > 0) {
         $query->clear();
         //sqlsrv changes
         $slug_select = ' CASE WHEN ';
         $slug_select .= $query->charLength('a.alias', '!=', '0');
         $slug_select .= ' THEN ';
         $a_id = $query->castAsChar('a.id');
         $slug_select .= $query->concatenate(array($a_id, 'a.alias'), ':');
         $slug_select .= ' ELSE ';
         $slug_select .= $a_id . ' END as slug, ';
         $query->select($db->quoteName('a.name') . ' AS title, ' . $db->quoteName('a.metadesc') . ', ' . $db->quoteName('a.metakey') . ', ' . $db->quoteName('a.created') . ' AS created, ' . $db->quoteName('a.description') . ' AS text, ' . $db->quoteName('a.language') . ' AS language, ' . $db->quote($search_section) . ' AS section, ' . $slug_select . '"2" AS browsernav');
         $query->from($db->quoteName('#__knvbapi_teams') . ' AS a');
         $query->where('(' . $where . ')' . 'AND ' . $db->quoteName('a.state') . ' = 1 ' . 'AND ' . $db->quoteName('a.access') . ' IN (' . $groups . ') ' . 'AND (' . $db->quoteName('a.publish_up') . ' = ' . $db->quote($null_date) . ' OR ' . $db->quoteName('a.publish_up') . ' <= ' . $db->quote($now) . ') ' . 'AND (' . $db->quoteName('a.publish_down') . ' = ' . $db->quote($null_date) . ' OR ' . $db->quoteName('a.publish_down') . ' >= ' . $db->quote($now) . ') ');
         // Filter by language
         if ($app->isSite() and JLanguageMultilang::isEnabled()) {
             $query->where($db->quoteName('a.language') . ' IN (' . $db->quote($tag) . ',' . $db->quote('*') . ')');
             $query->where($db->quoteName('c.language') . ' IN (' . $db->quote($tag) . ',' . $db->quote('*') . ')');
         }
         $query->group($db->quoteName('a.id') . ', ' . $db->quoteName('a.name'));
         $query->order($order);
         $db->setQuery($query, 0, $limit);
         $list = $db->loadObjectList();
         $limit -= count($list);
         if (isset($list)) {
             foreach ($list as $key => $item) {
                 $list[$key]->href = JRoute::_(KnvbapiHelperRoute::getTeamRoute($item->slug, $item->language, $this->layout, $keep_item_id));
                 //Add the selected item id to the link if there is one
                 $list[$key]->href .= $item_id_str;
             }
         }
         $rows[] = $list;
     }
     // search archived teams
     if ($sTeamArchived and $limit > 0) {
         $query->clear();
         //sqlsrv changes
         $slug_select = ' CASE WHEN ';
         $slug_select .= $query->charLength('a.alias', '!=', '0');
         $slug_select .= ' THEN ';
         $a_id = $query->castAsChar('a.id');
         $slug_select .= $query->concatenate(array($a_id, 'a.alias'), ':');
         $slug_select .= ' ELSE ';
         $slug_select .= $a_id . ' END AS slug, ';
         $query->select($db->quoteName('a.name') . ' AS title, ' . $db->quoteName('a.metadesc') . ', ' . $db->quoteName('a.metakey') . ', ' . $db->quoteName('a.created') . ' AS created, ' . $db->quoteName('a.description') . ' AS text, ' . $db->quoteName('a.language') . ' AS language, ' . $db->quote($search_section) . ' AS section, ' . $slug_select . '"2" AS browsernav');
         $query->from($db->quoteName('#__knvbapi_teams') . ' AS a');
         $query->where('(' . $where . ') ' . 'AND ' . $db->quoteName('a.state') . ' = 2 ' . 'AND ' . $db->quoteName('a.access') . ' IN (' . $groups . ') ' . 'AND (' . $db->quoteName('a.publish_up') . ' = ' . $db->quote($null_date) . ' OR ' . $db->quoteName('a.publish_up') . ' <= ' . $db->quote($now) . ') ' . 'AND (' . $db->quoteName('a.publish_down') . ' = ' . $db->quote($null_date) . ' OR ' . $db->quoteName('a.publish_down') . ' >= ' . $db->quote($now) . ') ');
         // Filter by language
         if ($app->isSite() and JLanguageMultilang::isEnabled()) {
             $query->where($db->quoteName('a.language') . ' IN (' . $db->quote($tag) . ',' . $db->quote('*') . ')');
             $query->where($db->quoteName('c.language') . ' IN (' . $db->quote($tag) . ',' . $db->quote('*') . ')');
         }
         $query->order($order);
         $db->setQuery($query, 0, $limit);
         $list3 = $db->loadObjectList();
         // find an itemid for archived to use if there isn't another one
         $item = $app->getMenu()->getItems('link', 'index.php?option=com_knvbapi&view=teamarchive', true);
         $item_id = isset($item) ? '&Itemid=' . $item->id : $item_id_str;
         if (isset($list3)) {
             foreach ($list3 as $key => $item) {
                 $date = JFactory::getDate($item->created);
                 $created_month = $date->format("n");
                 $created_year = $date->format("Y");
                 $list3[$key]->href = JRoute::_('index.php?option=com_knvbapi&view=teamarchive' . '&year=' . $created_year . '&month=' . $created_month . $item_id);
             }
         }
         $rows[] = $list3;
     }
     $results = array();
     if (count($rows)) {
         foreach ($rows as $row) {
             $new_row = array();
             foreach ($row as $team) {
                 if (SearchHelper::checkNoHTML($team, $search_text, array('title', 'description', 'metadesc', 'metakey'))) {
                     $new_row[] = $team;
                 }
             }
             $results = array_merge($results, (array) $new_row);
         }
     }
     return $results;
 }
开发者ID:esorone,项目名称:efcpw,代码行数:101,代码来源:teams.php

示例14: doSearch

 /**
  * Process search
  * @param type $query Search query
  * @return array Rerach Results 
  * 
  * This method uses portions of SearchController::search from components/com_search/controller.php
  * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
  */
 public function doSearch($query)
 {
     $wf = WFEditorPlugin::getInstance();
     $filter = JFilterInput::getInstance();
     if (!class_exists('JSite')) {
         // Load JSite class
         JLoader::register('JSite', JPATH_SITE . '/includes/application.php');
     }
     $app = JApplication::getInstance('site');
     $router = $app->getRouter('site');
     // get SearchHelper
     require_once JPATH_ADMINISTRATOR . '/components/com_search/helpers/search.php';
     // get router mode
     $sef = (int) $wf->getParam('search.link.sef_url', 0);
     // set router off so a raw url is returned by the Search plugin
     if ($router) {
         $router->setMode(0);
     }
     // slashes cause errors, <> get stripped anyway later on. # causes problems.
     $searchword = trim(str_replace(array('#', '>', '<', '\\'), '', $filter->clean($query)));
     $ordering = JRequest::getWord('ordering', null, 'post');
     $searchphrase = JRequest::getWord('searchphrase', 'all', 'post');
     $areas = JRequest::getVar('areas', null, 'post', 'array');
     // if searchword enclosed in double quotes, strip quotes and do exact match
     if (substr($searchword, 0, 1) == '"' && substr($searchword, -1) == '"') {
         $searchword = substr($searchword, 1, -1);
         $searchphrase = 'exact';
     }
     // clean areas
     if (!empty($areas)) {
         foreach ($areas as $area) {
             $areas[] = $filter->clean($area, 'cmd');
         }
     }
     $event = WF_JOOMLA15 ? 'onSearch' : 'onContentSearch';
     // trigger search on loaded plugins
     $searches = $app->triggerEvent($event, array($searchword, $searchphrase, $ordering, $areas));
     $results = array();
     $rows = array();
     foreach ($searches as $search) {
         $rows = array_merge((array) $rows, (array) $search);
     }
     for ($i = 0, $count = count($rows); $i < $count; $i++) {
         $row =& $rows[$i];
         $result = new StdClass();
         if ($searchphrase == 'exact') {
             $searchwords = array($searchword);
             $needle = $searchword;
         } else {
             $searchworda = preg_replace('#\\xE3\\x80\\x80#s', ' ', $searchword);
             $searchwords = preg_split("/\\s+/u", $searchworda);
             $needle = $searchwords[0];
         }
         // get anchors
         $anchors = self::getAnchors($row->text);
         if (!empty($anchors)) {
             $row->anchors = $anchors;
         }
         if (method_exists('SearchHelper', 'getActions')) {
             $row->text = SearchHelper::prepareSearchContent($row->text, $needle);
         } else {
             $row->text = SearchHelper::prepareSearchContent($row->text, 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->text = preg_replace($searchRegex, '<span class="highlight">\\0</span>', $row->text);
         // remove base url
         if (strpos($row->href, JURI::base(true)) !== false) {
             $row->href = substr_replace($row->href, '', 0, strlen(JURI::base(true)) + 1);
         }
         // convert to SEF
         if ($router && $sef) {
             $router->setMode(1);
             $url = str_replace('&amp;', '&', $row->href);
             $uri = $router->build($url);
             $url = $uri->toString();
             $row->href = str_replace('/administrator/', '/', $url);
         }
         $result->title = $row->title;
         $result->text = $row->text;
         $result->link = $row->href;
         $results[] = $result;
     }
     return $results;
 }
开发者ID:01J,项目名称:topm,代码行数:100,代码来源:link.php

示例15: onContentSearch


//.........这里部分代码省略.........
         case 'alpha':
             $order = 'a.title ASC';
             break;
         case 'category':
             $order = 'c.title ASC, a.title ASC';
             break;
         case 'newest':
         default:
             $order = 'a.created DESC';
             break;
     }
     $rows = array();
     $query = $db->getQuery(true);
     // Search articles.
     if ($sContent && $limit > 0) {
         $query->clear();
         // SQLSRV changes.
         $case_when = ' CASE WHEN ';
         $case_when .= $query->charLength('a.alias', '!=', '0');
         $case_when .= ' THEN ';
         $a_id = $query->castAsChar('a.id');
         $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
         $case_when .= ' ELSE ';
         $case_when .= $a_id . ' END as slug';
         $case_when1 = ' CASE WHEN ';
         $case_when1 .= $query->charLength('c.alias', '!=', '0');
         $case_when1 .= ' THEN ';
         $c_id = $query->castAsChar('c.id');
         $case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
         $case_when1 .= ' ELSE ';
         $case_when1 .= $c_id . ' END as catslug';
         $query->select('a.title AS title, a.metadesc, a.metakey, a.created AS created, a.language, a.catid')->select($query->concatenate(array('a.introtext', 'a.fulltext')) . ' AS text')->select('c.title AS section, ' . $case_when . ',' . $case_when1 . ', ' . '\'2\' AS browsernav')->from('#__content AS a')->join('INNER', '#__categories AS c ON c.id=a.catid')->where('(' . $where . ') AND a.state=1 AND c.published = 1 AND a.access IN (' . $groups . ') ' . 'AND c.access IN (' . $groups . ') ' . 'AND (a.publish_up = ' . $db->quote($nullDate) . ' OR a.publish_up <= ' . $db->quote($now) . ') ' . 'AND (a.publish_down = ' . $db->quote($nullDate) . ' OR a.publish_down >= ' . $db->quote($now) . ')')->group('a.id, a.title, a.metadesc, a.metakey, a.created, a.introtext, a.fulltext, c.title, a.alias, c.alias, c.id')->order($order);
         // Filter by language.
         if ($app->isSite() && JLanguageMultilang::isEnabled()) {
             $query->where('a.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')')->where('c.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')');
         }
         $db->setQuery($query, 0, $limit);
         $list = $db->loadObjectList();
         $limit -= count($list);
         if (isset($list)) {
             foreach ($list as $key => $item) {
                 $list[$key]->href = ContentHelperRoute::getArticleRoute($item->slug, $item->catid, $item->language);
             }
         }
         $rows[] = $list;
     }
     // Search archived content.
     if ($sArchived && $limit > 0) {
         $query->clear();
         // SQLSRV changes.
         $case_when = ' CASE WHEN ';
         $case_when .= $query->charLength('a.alias', '!=', '0');
         $case_when .= ' THEN ';
         $a_id = $query->castAsChar('a.id');
         $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
         $case_when .= ' ELSE ';
         $case_when .= $a_id . ' END as slug';
         $case_when1 = ' CASE WHEN ';
         $case_when1 .= $query->charLength('c.alias', '!=', '0');
         $case_when1 .= ' THEN ';
         $c_id = $query->castAsChar('c.id');
         $case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
         $case_when1 .= ' ELSE ';
         $case_when1 .= $c_id . ' END as catslug';
         $query->select('a.title AS title, a.metadesc, a.metakey, a.created AS created, ' . $query->concatenate(array("a.introtext", "a.fulltext")) . ' AS text,' . $case_when . ',' . $case_when1 . ', ' . 'c.title AS section, \'2\' AS browsernav');
         // .'CONCAT_WS("/", c.title) AS section, \'2\' AS browsernav' );
         $query->from('#__content AS a')->join('INNER', '#__categories AS c ON c.id=a.catid AND c.access IN (' . $groups . ')')->where('(' . $where . ') AND a.state = 2 AND c.published = 1 AND a.access IN (' . $groups . ') AND c.access IN (' . $groups . ') ' . 'AND (a.publish_up = ' . $db->quote($nullDate) . ' OR a.publish_up <= ' . $db->quote($now) . ') ' . 'AND (a.publish_down = ' . $db->quote($nullDate) . ' OR a.publish_down >= ' . $db->quote($now) . ')')->order($order);
         // Filter by language.
         if ($app->isSite() && JLanguageMultilang::isEnabled()) {
             $query->where('a.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')')->where('c.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')');
         }
         $db->setQuery($query, 0, $limit);
         $list3 = $db->loadObjectList();
         // Find an itemid for archived to use if there isn't another one.
         $item = $app->getMenu()->getItems('link', 'index.php?option=com_content&view=archive', true);
         $itemid = isset($item->id) ? '&Itemid=' . $item->id : '';
         if (isset($list3)) {
             foreach ($list3 as $key => $item) {
                 $date = JFactory::getDate($item->created);
                 $created_month = $date->format("n");
                 $created_year = $date->format("Y");
                 $list3[$key]->href = JRoute::_('index.php?option=com_content&view=archive&year=' . $created_year . '&month=' . $created_month . $itemid);
             }
         }
         $rows[] = $list3;
     }
     $results = array();
     if (count($rows)) {
         foreach ($rows as $row) {
             $new_row = array();
             foreach ($row as $article) {
                 if (SearchHelper::checkNoHTML($article, $searchText, array('text', 'title', 'metadesc', 'metakey'))) {
                     $new_row[] = $article;
                 }
             }
             $results = array_merge($results, (array) $new_row);
         }
     }
     return $results;
 }
开发者ID:educakanchay,项目名称:kanchay,代码行数:101,代码来源:content.php


注:本文中的SearchHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。