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


PHP SearchHelper::checkNoHTML方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: onContentSearch

 /**
  * K2 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
  * @param mixed  An array if the search it to be restricted to areas, null if search all
  */
 public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     // If K2 items are not enabled in this search operation return now
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
             return array();
         }
     }
     // Trim text. If it is empty return now
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     // Load K2 Model class
     require_once JPATH_ADMINISTRATOR . '/components/com_k2/models/model.php';
     // Add include path
     K2Model::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/models');
     // Search items
     $model = K2Model::getInstance('Items');
     $model->setState('site', true);
     $model->setState('search', $text);
     $model->setState('search.mode', $phrase);
     switch ($ordering) {
         case 'oldest':
             $model->setState('sorting', 'created');
             break;
         case 'popular':
             $model->setState('sorting', 'hits.reverse');
             break;
         case 'alpha':
             $model->setState('sorting', 'title');
             break;
         case 'category':
             $model->setState('sorting', 'category');
             break;
         case 'newest':
             $model->setState('sorting', 'created.reverse');
             break;
         default:
             $model->setState('sorting', 'id.reverse');
             break;
     }
     $limit = $this->params->def('search_limit', 50);
     $model->setState('limit', $limit);
     $rows = $model->getRows();
     $results = array();
     foreach ($rows as $item) {
         $item->browsernav = '';
         $item->section = $item->category->name;
         $item->href = $item->link;
         $item->text = $item->introtext . ' ' . $item->fulltext;
         $item->extra_fields_search = '';
         foreach ($item->extraFieldsGroups as $extraFieldGroup) {
             foreach ($extraFieldGroup->fields as $field) {
                 $item->extra_fields_search .= $field->output . ' ';
             }
         }
         $item->tags_search = '';
         foreach ($item->tags as $tag) {
             $item->tags_search .= $tag->name . ' ';
         }
         if (SearchHelper::checkNoHTML($item, $text, array('title', 'introtext', 'fulltext', 'extra_fields_search', 'tags_search'))) {
             $results[] = $item;
         }
     }
     return $results;
 }
开发者ID:Naldo100,项目名称:k2-v3-dev-build,代码行数:76,代码来源:k2.php


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