diff --git a/apps/calendar/index.php b/apps/calendar/index.php index a2042afddf..e8e214c0b7 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 41faf49a51..425c93c733 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 13bc8bc1bb..92c1b8a778 100755 --- a/apps/calendar/templates/calendar.php +++ b/apps/calendar/templates/calendar.php @@ -18,6 +18,16 @@ var missing_field_startsbeforeends = 't('The event ends before it starts') ?>'; var missing_field_dberror = 't('There was a database fail') ?>'; var totalurl = '/calendars'; + $(document).ready(function() { + + });