本文整理汇总了PHP中SearchHelper::checkNoHtml方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchHelper::checkNoHtml方法的具体用法?PHP SearchHelper::checkNoHtml怎么用?PHP SearchHelper::checkNoHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchHelper
的用法示例。
在下文中一共展示了SearchHelper::checkNoHtml方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onContentSearch
//.........这里部分代码省略.........
}
$rows = array();
$query = $db->getQuery(true);
// Search articles.
if ($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 . ') ' . $catWhere . '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);
try {
$list = $db->loadObjectList();
} catch (RuntimeException $e) {
$list = array();
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
}
$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);
try {
$list3 = $db->loadObjectList();
} catch (RuntimeException $e) {
$list3 = array();
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
}
// 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;
}
示例2: onContentSearch
//.........这里部分代码省略.........
$wheres2[] = 'a.title LIKE ' . $text;
$wheres2[] = 'a.text 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[] = 'LOWER(a.title) LIKE LOWER(' . $word . ')';
$wheres2[] = 'LOWER(a.text) LIKE LOWER(' . $word . ')';
$wheres[] = implode(' OR ', $wheres2);
}
$where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
break;
}
switch ($ordering) {
case 'oldest':
$order = 'a.created_time ASC';
break;
case 'alpha':
$order = 'a.title ASC';
break;
case 'newest':
default:
$order = 'a.created_time DESC';
break;
}
$rows = array();
$query = $db->getQuery(true);
// Search articles.
if ($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';
$query->select('a.id, a.title AS title, a.text AS text, a.og_description AS metadesc, a.og_title AS metakey, a.created_time AS created, a.language')->select($case_when . ',' . '\'2\' AS browsernav')->from('#__sppagebuilder AS a')->where('(' . $where . ') AND a.published = 1 AND a.access IN (' . $groups . ') ')->group('a.id, a.title, a.og_description, a.og_title, a.created_time, a.text, a.alias')->order($order);
// Filter by language.
if ($app->isSite() && JLanguageMultilang::isEnabled()) {
$query->where('a.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')');
}
$db->setQuery($query, 0, $limit);
try {
$list = $db->loadObjectList();
} catch (RuntimeException $e) {
echo $e->getMessage();
$list = array();
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
}
$limit -= count($list);
if (isset($list)) {
foreach ($list as $key => $item) {
// Generate nice links! Respecting menu items!
$link = 'index.php?option=com_sppagebuilder&view=page&id=' . $item->id;
$menuitem = $menu->getItems('link', $link, true);
if (isset($menuitem) && isset($menuitem->id)) {
$link .= '&Itemid=' . $menuitem->id;
}
$list[$key]->href = JRoute::_($link);
}
}
$rows[] = $list;
}
$results = array();
/*
* Postprocess result
*/
if (count($rows)) {
foreach ($rows as $row) {
$new_row = array();
foreach ($row as $article) {
// Fetch content as array
$textobj = json_decode($article->text);
// Flatten deep array
// this is some cool stuff from stackoverflow, thanks VolkerK http://stackoverflow.com/users/4833/volkerk
$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($textobj));
$text = '';
foreach ($iterator as $key => $value) {
if ($key == 'title' || $key == "text") {
$text .= $value . ' ';
}
}
$article->text = $text;
if (SearchHelper::checkNoHtml($article, $searchText, array('text', 'title', 'metadesc', 'metakey'))) {
$new_row[] = $article;
}
}
$results = array_merge($results, (array) $new_row);
}
}
return $results;
}