5 * PostCalendar::PostNuke Events Calendar Module
6 * Copyright (C) 2002 The PostCalendar Team
7 * http://postcalendar.tv
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * To read the license please read the docs/license.txt or visit
24 * http://www.gnu.org/copyleft/gpl.html
27 function smarty_function_pc_sort_day($params, &$smarty)
32 $smarty->trigger_error("sort_array: missing 'var' parameter");
36 if (!in_array('value', array_keys($params))) {
37 $smarty->trigger_error("sort_array: missing 'value' parameter");
41 if (!in_array('order', array_keys($params))) {
45 if (!in_array('inc', array_keys($params))) {
49 if (!in_array('start', array_keys($params))) {
53 list($sh,$sm) = explode(':', $start);
56 if (!in_array('end', array_keys($params))) {
60 list($eh,$em) = explode(':', $end);
63 if (strtolower($order) == 'asc') {
64 $function = 'sort_byTimeA';
67 if (strtolower($order) == 'desc') {
68 $function = 'sort_byTimeD';
71 foreach ($value as $events) {
72 usort($events, $function);
76 // here we want to create an intelligent array of
77 // columns and rows to build a nice day view
80 while ("$ch:$cm" <= "$eh:$em") {
81 $hours["$ch:$cm"] = array();
85 $ch = sprintf('%02d', $ch+
1);
89 $alldayevents = array();
90 foreach ($newArray as $event) {
91 list($sh,$sm,$ss) = explode(':', $event['startTime']);
92 $eh = sprintf('%02d', $sh +
$event['duration_hours']);
93 $em = sprintf('%02d', $sm +
$event['duration_minutes']);
95 if ($event['alldayevent']) {
96 // we need an entire column . save till later
97 $alldayevents[] = $event;
99 //find open time slots - avoid overlapping
103 //what times do we need?
104 while ("$ch:$cm" < "$eh:$em") {
105 $needed[] = "$ch:$cm";
109 $ch = sprintf('%02d', $ch+
1);
114 foreach ($needed as $time) {
116 $hours[$time][] = $event;
117 $key = count($hours[$time])-1;
119 $hours[$time][$key] = 'continued';
127 //pcDebugVar($hours);
128 $smarty->assign_by_ref($var, $hours);