summaryrefslogtreecommitdiffstats
path: root/lib/search.php
diff options
context:
space:
mode:
authorAlessandro Cosentino <cosenal@gmail.com>2012-10-18 00:18:33 -0400
committerAlessandro Cosentino <cosenal@gmail.com>2012-10-18 00:18:57 -0400
commitb3baecc30eb02cc62b31ba85a95b2eca0730c620 (patch)
tree8761c641b7b348b6388aa42856724bb15a25380d /lib/search.php
parent138de85e03495a08250773541ab74b3410f6ce8f (diff)
almost-working search provider
Diffstat (limited to 'lib/search.php')
-rw-r--r--lib/search.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/search.php b/lib/search.php
new file mode 100644
index 000000000..d9d5d89f3
--- /dev/null
+++ b/lib/search.php
@@ -0,0 +1,28 @@
+<?php
+
+class OC_Search_Provider_News extends OC_Search_Provider{
+
+ function search($query) {
+ if (!OCP\App::isEnabled('news')) {
+ return array();
+ }
+
+ $feedMapper = new OCA\News\FeedMapper(OCP\USER::getUser());
+ $results=array();
+
+ if($feedMapper->feedCount() > 0) {
+ $allFeeds = $feedMapper->findAll();
+
+ $l = new OC_l10n('news');
+
+ foreach($allFeeds as $feed) {
+ if(substr_count(strtolower($feed['title']), strtolower($query)) > 0) {
+ $link = OCP\Util::linkTo('news', 'index.php').'&lastViewedFeedId='.urlencode($feed['id']);
+ $results[]=new OC_Search_Result($feed['title'], '', $link, (string)$l->t('News'));
+ }
+ }
+ }
+ return $results;
+
+ }
+}