本文整理汇总了PHP中searchHelper::checkNoHtml方法的典型用法代码示例。如果您正苦于以下问题:PHP searchHelper::checkNoHtml方法的具体用法?PHP searchHelper::checkNoHtml怎么用?PHP searchHelper::checkNoHtml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类searchHelper
的用法示例。
在下文中一共展示了searchHelper::checkNoHtml方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onContentSearch
//.........这里部分代码省略.........
$app = JFactory::getApplication();
$groups = implode(',', $user->getAuthorisedViewLevels());
$searchText = $text;
if (is_array($areas)) {
if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
return array();
}
}
$sContent = $this->params->get('search_content', 1);
$sArchived = $this->params->get('search_archived', 1);
$limit = $this->params->def('search_limit', 50);
$state = array();
if ($sContent) {
$state[] = 1;
}
if ($sArchived) {
$state[] = 2;
}
if (empty($state)) {
return array();
}
$text = trim($text);
if ($text == '') {
return array();
}
/* TODO: The $where variable does not seem to be used at all
switch ($phrase)
{
case 'exact':
$text = $db->quote('%' . $db->escape($text, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'a.title LIKE ' . $text;
$wheres2[] = 'a.description LIKE ' . $text;
$where = '(' . implode(') OR (', $wheres2) . ')';
break;
case 'any':
case 'all';
default:
$words = explode(' ', $text);
$wheres = array();
foreach ($words as $word)
{
$word = $db->quote('%' . $db->escape($word, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'a.title LIKE ' . $word;
$wheres2[] = 'a.description LIKE ' . $word;
$wheres[] = implode(' OR ', $wheres2);
}
$where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
break;
}
*/
switch ($ordering) {
case 'alpha':
$order = 'a.title ASC';
break;
case 'category':
case 'popular':
case 'newest':
case 'oldest':
default:
$order = 'a.title DESC';
}
$text = $db->quote('%' . $db->escape($text, true) . '%', false);
$query = $db->getQuery(true);
// 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.title, a.description AS text, \'\' AS created, \'2\' AS browsernav, a.id AS catid, ' . $case_when)->from('#__categories AS a')->where('(a.title LIKE ' . $text . ' OR a.description LIKE ' . $text . ') AND a.published IN (' . implode(',', $state) . ') AND a.extension = ' . $db->quote('com_content') . 'AND a.access IN (' . $groups . ')')->group('a.id, a.title, a.description, a.alias')->order($order);
if ($app->isSite() && JLanguageMultilang::isEnabled()) {
$query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
}
$db->setQuery($query, 0, $limit);
try {
$rows = $db->loadObjectList();
} catch (RuntimeException $e) {
$rows = array();
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
}
$return = array();
if ($rows) {
$count = count($rows);
for ($i = 0; $i < $count; $i++) {
$rows[$i]->href = ContentHelperRoute::getCategoryRoute($rows[$i]->slug);
$rows[$i]->section = JText::_('JCATEGORY');
}
foreach ($rows as $category) {
if (searchHelper::checkNoHtml($category, $searchText, array('name', 'title', 'text'))) {
$return[] = $category;
}
}
}
return $return;
}