From 63d34061a2edf233a43b0f5b0f8f7f9fdd7177e8 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 9 Jul 2008 19:42:28 -0400 Subject: add notice search rss ("tracking") darcs-hash:20080709234228-84dde-f24d277947ab49031a1b6d74184568fe2f50a685.gz --- actions/noticesearch.php | 13 ++++++++ actions/noticesearchrss.php | 72 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 actions/noticesearchrss.php (limited to 'actions') diff --git a/actions/noticesearch.php b/actions/noticesearch.php index 8b2082e8c..0a9f4c37f 100644 --- a/actions/noticesearch.php +++ b/actions/noticesearch.php @@ -69,6 +69,19 @@ class NoticesearchAction extends SearchAction { $page, 'noticesearch', array('q' => $q)); } + function show_header($arr) { + if ($arr) { + $q = $arr[0]; + } + if ($q) { + common_element('link', array('rel' => 'alternate', + 'href' => common_local_url('noticesearchrss', + array('q' => $q)), + 'type' => 'application/rss+xml', + 'title' => _t('Search Stream Feed'))); + } + } + # XXX: refactor and combine with StreamAction::show_notice() function show_notice($notice, $terms) { diff --git a/actions/noticesearchrss.php b/actions/noticesearchrss.php new file mode 100644 index 000000000..f5834c4c1 --- /dev/null +++ b/actions/noticesearchrss.php @@ -0,0 +1,72 @@ +. + */ + +if (!defined('LACONICA')) { exit(1); } + +require_once(INSTALLDIR.'/lib/rssaction.php'); + +// Formatting of RSS handled by Rss10Action + +class NoticesearchrssAction extends Rss10Action { + + function init() { + return true; + } + + function get_notices($limit=0) { + + $q = $this->trimmed('q'); + $notices = array(); + + $notice = new Notice(); + + # lcase it for comparison + $q = strtolower($q); + + $notice->whereAdd('MATCH(content) against (\''.addslashes($q).'\')'); + + # Ask for an extra to see if there's more. + + if ($limit != 0) { + $notice->limit(0, $limit); + } + + $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 -- cgit v1.2.3-54-g00ecf