X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fnoticesearchrss.php;h=14c280f62cfd3f973f5c64703ce0734b16949c6c;hb=220b51d8be61e9bd316567f3ad03fffdbc4b7526;hp=f5834c4c1c8a892ba50ef9210a05472f5c9d7be8;hpb=63d34061a2edf233a43b0f5b0f8f7f9fdd7177e8;p=quix0rs-gnu-social.git diff --git a/actions/noticesearchrss.php b/actions/noticesearchrss.php index f5834c4c1c..14c280f62c 100644 --- a/actions/noticesearchrss.php +++ b/actions/noticesearchrss.php @@ -1,7 +1,18 @@ + * @author Robin Millette + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://status.net/ + * + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 2009, StatusNet, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,56 +28,86 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/rssaction.php'; + +/** + * RSS feed for notice search action class. + * + * Formatting of RSS handled by Rss10Action + * + * @category Action + * @package StatusNet + * @author Evan Prodromou + * @author Robin Millette + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://status.net/ + */ +class NoticesearchrssAction extends Rss10Action +{ + function init() + { + return true; + } + + function prepare($args) + { + parent::prepare($args); + $this->notices = $this->getNotices(); + return true; + } + + function getNotices($limit=0) + { + $q = $this->trimmed('q'); + $notices = array(); -require_once(INSTALLDIR.'/lib/rssaction.php'); + $notice = new Notice(); -// Formatting of RSS handled by Rss10Action + $search_engine = $notice->getSearchEngine('notice'); + $search_engine->set_sort_mode('chron'); -class NoticesearchrssAction extends Rss10Action { + if (!$limit) $limit = 20; + $search_engine->limit(0, $limit, true); + if (false === $search_engine->query($q)) { + $cnt = 0; + } else { + $cnt = $notice->find(); + } - function init() { - return true; - } - - function get_notices($limit=0) { + if ($cnt > 0) { + while ($notice->fetch()) { + $notices[] = clone($notice); + } + } - $q = $this->trimmed('q'); - $notices = array(); - - $notice = new Notice(); + return $notices; + } - # lcase it for comparison - $q = strtolower($q); - - $notice->whereAdd('MATCH(content) against (\''.addslashes($q).'\')'); + function getChannel() + { + $q = $this->trimmed('q'); + $c = array('url' => common_local_url('noticesearchrss', array('q' => $q)), + // TRANS: RSS notice search feed title. %s is the query. + 'title' => sprintf(_('Updates with "%s"'), $q), + 'link' => common_local_url('noticesearch', array('q' => $q)), + // TRANS: RSS notice search feed description. + // TRANS: %1$s is the query, %2$s is the StatusNet site name. + 'description' => sprintf(_('Updates matching search term "%1$s" on %2$s.'), + $q, common_config('site', 'name'))); + return $c; + } - # Ask for an extra to see if there's more. - - if ($limit != 0) { - $notice->limit(0, $limit); - } + function getImage() + { + return null; + } - $notice->find(); - - while ($notice->fetch()) { - $notices[] = clone($notice); - } - - return $notices; - } - - function get_channel() { - global $config; - $q = $this->trimmed('q'); - $c = array('url' => common_local_url('noticesearchrss', array('q' => $q)), - 'title' => $config['site']['name'] . _t(' Search Stream for "' . $q . '"'), - 'link' => common_local_url('noticesearch', array('q' => $q)), - 'description' => _t('All updates matching search term "') . $q . '"'); - return $c; - } - - function get_image() { - return NULL; - } -} \ No newline at end of file + function isReadOnly($args) + { + return true; + } +}