diff --git a/apps/calendar/index.php b/apps/calendar/index.php index a2042afddf15fe981771d869c6dc697ec0bbb156..e8e214c0b75e52ff934d1809e8577759f09a7900 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 41faf49a51976bac9ba9bc80b8e1cb7a9f2c2062..425c93c7338eb2be0e200297ea0e6e87fcd5a681 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 13bc8bc1bb1659fab2298486b3cbc964425bf165..92c1b8a778a27ea41ef13a8b500f1c0aa0b3e1e3 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">