diff --git a/calendar/inc/class.calendar_merge.inc.php b/calendar/inc/class.calendar_merge.inc.php index cf7b66f848..f253ea21a6 100644 --- a/calendar/inc/class.calendar_merge.inc.php +++ b/calendar/inc/class.calendar_merge.inc.php @@ -61,23 +61,24 @@ class calendar_merge extends bo_merge $prefix = ''; // List events ? - if(is_array($id) && !$id['id'] && strpos($content,'$$calendar') !== false) + if(is_array($id) && !$id['id'] && strpos($content,'$$calendar/') !== false) { $events = $this->bo->search($id + array( 'offset' => 0, 'order' => 'cal_start', )); array_unshift($events,false); unset($events[0]); // renumber the array to start with key 1, instead of 0 - $prefix = 'calendar/%d/'; + $prefix = 'calendar/%d'; } else { $events = array($id); } $replacements = array(); - foreach($events as $n => $event) + $n = 0; + foreach($events as $event) { - $values = $this->calendar_replacements($event,sprintf($prefix,$n)); + $values = $this->calendar_replacements($event,sprintf($prefix,++$n)); $replacements += $values; } return $replacements; @@ -101,7 +102,7 @@ class calendar_merge extends bo_merge foreach($this->bo->event2array($event) as $name => $data) { if (substr($name,-4) == 'date') $name = substr($name,0,-4); - $replacements['$$' . ($prefix ? $prefix . '/' : '') . $name . '$$'] = is_array($data['data']) ? implode(', ',$data['data']) : $data['data']; + $replacements['$$' . ($prefix ? $prefix . '/' : '') . 'calendar_'.$name . '$$'] = is_array($data['data']) ? implode(', ',$data['data']) : $data['data']; } foreach(array('start','end') as $what) { @@ -113,11 +114,11 @@ class calendar_merge extends bo_merge { $value = date($format,$event[$what]); if ($format == 'l') $value = lang($value); - $replacements['$$' .($prefix ? $prefix.'/':'').$what.$name.'$$'] = $value; + $replacements['$$' .($prefix ? $prefix.'/':'').'calendar_'.$what.$name.'$$'] = $value; } } $duration = ($event['end'] - $event['start'])/60; - $replacements['$$'.($prefix?$prefix.'/':'').'duration$$'] = floor($duration/60).lang('h').($duration%60 ? $duration%60 : ''); + $replacements['$$'.($prefix?$prefix.'/':'').'calendar_duration$$'] = floor($duration/60).lang('h').($duration%60 ? $duration%60 : ''); $custom = config::get_customfields('calendar'); foreach($custom as $name => $field) @@ -167,10 +168,9 @@ class calendar_merge extends bo_merge $replacements = array(); foreach($events as $day => $list) { - $i = 0; foreach($list as $key => $event) { - $days[date('Ymd',$_date)][date('l',$event['start'])][$i++] = $this->calendar_replacements($event); + $days[date('Ymd',$_date)][date('l',$event['start'])][] = $this->calendar_replacements($event); } } return $days[date('Ymd',$_date)][$plugin][0]; @@ -274,25 +274,25 @@ class calendar_merge extends bo_merge echo '