improve search function
This commit is contained in:
parent
db490fbc8f
commit
f18e866a1e
3 changed files with 37 additions and 3 deletions
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
new OC_Search_Provider_Calendar();
|
||||
|
|
|
@ -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">
|
||||
|
|
Loading…
Reference in a new issue