Source for file newsfeeds.php
Documentation is available at newsfeeds.php
* @subpackage Search.newsfeeds
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Newsfeeds Search plugin
* @subpackage Search.newsfeeds
* Load the language file on instantiation.
* @return array An array of search areas
'newsfeeds' =>
'PLG_SEARCH_NEWSFEEDS_NEWSFEEDS'
* Newsfeeds 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)
$groups =
implode(',', $user->getAuthorisedViewLevels());
$sContent =
$this->params->get('search_content', 1);
$sArchived =
$this->params->get('search_archived', 1);
$limit =
$this->params->def('search_limit', 50);
$text =
$db->quote('%' .
$db->escape($text, true) .
'%', false);
$wheres2[] =
'a.name LIKE ' .
$text;
$wheres2[] =
'a.link LIKE ' .
$text;
$where =
'(' .
implode(') OR (', $wheres2) .
')';
foreach ($words as $word)
$word =
$db->quote('%' .
$db->escape($word, true) .
'%', false);
$wheres2[] =
'a.name LIKE ' .
$word;
$wheres2[] =
'a.link LIKE ' .
$word;
$wheres[] =
implode(' OR ', $wheres2);
$where =
'(' .
implode(($phrase ==
'all' ?
') AND (' :
') OR ('), $wheres) .
')';
$order =
'c.title ASC, a.name ASC';
$searchNewsfeeds =
JText::_('PLG_SEARCH_NEWSFEEDS_NEWSFEEDS');
$query =
$db->getQuery(true);
$case_when =
' CASE WHEN ';
$case_when .=
$query->charLength('a.alias', '!=', '0');
$a_id =
$query->castAsChar('a.id');
$case_when .=
$query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .=
$a_id .
' END as slug';
$case_when1 =
' CASE WHEN ';
$case_when1 .=
$query->charLength('c.alias', '!=', '0');
$c_id =
$query->castAsChar('c.id');
$case_when1 .=
$query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .=
$c_id .
' END as catslug';
$query->select('a.name AS title, \'\' AS created, a.link AS text, ' .
$case_when .
"," .
$case_when1)
->select($query->concatenate(array($db->quote($searchNewsfeeds), 'c.title'), " / ") .
' AS section')
->select('\'1\' AS browsernav')
->from('#__newsfeeds AS a')
->join('INNER', '#__categories as c ON c.id = a.catid')
->where('(' .
$where .
') AND a.published IN (' .
implode(',', $state) .
') AND c.published = 1 AND c.access IN (' .
$groups .
')')
$query->where('a.language in (' .
$db->quote($tag) .
',' .
$db->quote('*') .
')')
->where('c.language in (' .
$db->quote($tag) .
',' .
$db->quote('*') .
')');
$db->setQuery($query, 0, $limit);
$rows =
$db->loadObjectList();
foreach ($rows as $key =>
$row)
$rows[$key]->href =
'index.php?option=com_newsfeeds&view=newsfeed&catid=' .
$row->catslug .
'&id=' .
$row->slug;
Documentation generated on Tue, 19 Nov 2013 15:09:32 +0100 by phpDocumentor 1.4.3