first implementation of the search function

This commit is contained in:
Georg Ehrke 2011-11-14 22:52:34 +01:00
parent 89b3a395df
commit 3d498002d0
2 changed files with 28 additions and 0 deletions

View 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');

View File

@ -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();