diff options
author | Georg Ehrke <ownclouddev@georgswebsite.de> | 2012-01-06 14:36:24 +0100 |
---|---|---|
committer | Georg Ehrke <ownclouddev@georgswebsite.de> | 2012-01-06 14:36:24 +0100 |
commit | f18e866a1e152a1fb13cb883d89d8efde413cea9 (patch) | |
tree | 7330e2ae18e40995fbc01525499771cf52d50ef4 /apps | |
parent | db490fbc8f6114e3aa96d3a417eb25766dc1cafb (diff) | |
download | nextcloud-server-f18e866a1e152a1fb13cb883d89d8efde413cea9.tar.gz nextcloud-server-f18e866a1e152a1fb13cb883d89d8efde413cea9.zip |
improve search function
Diffstat (limited to 'apps')
-rw-r--r-- | apps/calendar/index.php | 3 | ||||
-rw-r--r-- | apps/calendar/lib/search.php | 27 | ||||
-rwxr-xr-x | apps/calendar/templates/calendar.php | 10 |
3 files changed, 37 insertions, 3 deletions
diff --git a/apps/calendar/index.php b/apps/calendar/index.php index a2042afddf1..e8e214c0b75 100644 --- a/apps/calendar/index.php +++ b/apps/calendar/index.php @@ -42,4 +42,7 @@ OC_Util::addStyle('', 'jquery.multiselect'); OC_App::setActiveNavigationEntry('calendar_index'); $tmpl = new OC_Template('calendar', 'calendar', 'user'); $tmpl->assign('eventSources', $eventSources); +if(array_key_exists('showevent', $_GET)){ + $tmpl->assign('showevent', $_GET['showevent']); +} $tmpl->printPage(); diff --git a/apps/calendar/lib/search.php b/apps/calendar/lib/search.php index 41faf49a519..425c93c7338 100644 --- a/apps/calendar/lib/search.php +++ b/apps/calendar/lib/search.php @@ -12,15 +12,36 @@ class OC_Search_Provider_Calendar extends OC_Search_Provider{ }else{ $searchquery[] = $query; } + $user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); + $l = new OC_l10n('calendar'); 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.'); + if(substr_count(strtolower($object['summary']), strtolower($query)) > 0){ + $calendardata = OC_VObject::parse($object['calendardata']); + $vevent = $calendardata->VEVENT; + $dtstart = $vevent->DTSTART; + $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); + $start_dt = $dtstart->getDateTime(); + $start_dt->setTimezone(new DateTimeZone($user_timezone)); + $end_dt = $dtend->getDateTime(); + $end_dt->setTimezone(new DateTimeZone($user_timezone)); + if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE){ + $end_dt->modify('-1 sec'); + if($start_dt->format('d.m.Y') != $end_dt->format('d.m.Y')){ + $info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y') . ' - ' . $end_dt->format('d.m.Y'); + }else{ + $info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y'); + } + }else{ + $info = $l->t('Date') . ': ' . $start_dt->format('d.m.y H:i') . ' - ' . $end_dt->format('d.m.y H:i'); + } + $link = OC_Helper::linkTo('apps/calendar', 'index.php?showevent='.urlencode($object['id'])); + $results[]=new OC_Search_Result($object['summary'],$info, $link,$l->t('Cal.'));//$name,$text,$link,$type } } } return $results; } } -new OC_Search_Provider_Calendar();
\ No newline at end of file +new OC_Search_Provider_Calendar(); diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php index 13bc8bc1bb1..92c1b8a778a 100755 --- a/apps/calendar/templates/calendar.php +++ b/apps/calendar/templates/calendar.php @@ -18,6 +18,16 @@ var missing_field_startsbeforeends = '<?php echo $l->t('The event ends before it starts') ?>'; var missing_field_dberror = '<?php echo $l->t('There was a database fail') ?>'; var totalurl = '<?php echo OC_Helper::linkTo('apps/calendar', 'caldav.php', null, true); ?>/calendars'; + $(document).ready(function() { + <?php + if(array_key_exists('showevent', $_)){ + $data = OC_Calendar_App::getEventObject($_['showevent']); + $date = substr($data['startdate'], 0, 10); + list($year, $month, $day) = explode('-', $date); + echo '$(\'#calendar_holder\').fullCalendar(\'gotoDate\', ' . $year . ', ' . --$month . ', ' . $day . ');'; + } + ?> + }); </script> <div id="loading"><img src="<?php echo OC_Helper::imagePath('core', 'loading.gif'); ?>" /></div> <div id="controls"> |