]> source.dussan.org Git - nextcloud-server.git/commitdiff
first implementation of the search function
authorGeorg Ehrke <ownclouddev@georgswebsite.de>
Mon, 14 Nov 2011 21:52:34 +0000 (22:52 +0100)
committerGeorg Ehrke <ownclouddev@georgswebsite.de>
Mon, 14 Nov 2011 21:52:34 +0000 (22:52 +0100)
apps/calendar/appinfo/app.php
apps/calendar/lib/search.php [new file with mode: 0644]

index 2dc01eab0f64da290b3f53b33f5a34ab52b2e39c..5675e624dda9530083de5f30d6aac06ce254863c 100644 (file)
@@ -21,3 +21,5 @@ OC_App::addNavigationEntry( array(
   'name' => $l->t('Calendar')));
 
 OC_App::registerPersonal('calendar', 'settings');
+
+require_once('apps/calendar/lib/search.php');
\ No newline at end of file
diff --git a/apps/calendar/lib/search.php b/apps/calendar/lib/search.php
new file mode 100644 (file)
index 0000000..41faf49
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+class OC_Search_Provider_Calendar extends OC_Search_Provider{
+       function search($query){
+               $calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1);
+               if(count($calendars)==0 || !OC_App::isEnabled('calendar')){
+                       //return false;
+               }
+               $results=array();
+               $searchquery=array();
+               if(substr_count($query, ' ') > 0){
+                       $searchquery = explode(' ', $query);
+               }else{
+                       $searchquery[] = $query;
+               }
+               foreach($calendars as $calendar){
+                       $objects = OC_Calendar_Object::all($calendar['id']);
+                       foreach($objects as $object){
+                               if(substr_count(strtolower($object['summary']), strtolower($query)) > 0){//$name,$text,$link,$type
+                                       $results[]=new OC_Search_Result($object['summary'],'','#','Cal.');
+                               }
+                       }
+               }
+               return $results;
+       }
+}
+new OC_Search_Provider_Calendar();
\ No newline at end of file