| [ Index ] |
krapohl.info |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * $Id: function.pc_sort_day.php,v 1.1 2004/02/11 17:31:22 larsneo Exp $ 4 * 5 * PostCalendar::PostNuke Events Calendar Module 6 * Copyright (C) 2002 The PostCalendar Team 7 * http://postcalendar.tv 8 * 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. 13 * 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. 18 * 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 22 * 23 * To read the license please read the docs/license.txt or visit 24 * http://www.gnu.org/copyleft/gpl.html 25 * 26 */ 27 function smarty_function_pc_sort_day($params, &$smarty) 28 { 29 extract($params); 30 31 if (empty($var)) { 32 $smarty->trigger_error("sort_array: missing 'var' parameter"); 33 return; 34 } 35 36 if (!in_array('value', array_keys($params))) { 37 $smarty->trigger_error("sort_array: missing 'value' parameter"); 38 return; 39 } 40 41 if (!in_array('order', array_keys($params))) { 42 $order = 'asc'; 43 } 44 45 if (!in_array('inc', array_keys($params))) { 46 $inc = '15'; 47 } 48 49 if (!in_array('start', array_keys($params))) { 50 $sh = '08'; 51 $sm = '00'; 52 } else { 53 list($sh,$sm) = explode(':',$start); 54 } 55 56 if (!in_array('end', array_keys($params))) { 57 $eh = '21'; 58 $em = '00'; 59 } else { 60 list($eh,$em) = explode(':',$end); 61 } 62 63 if(strtolower($order) == 'asc') $function = 'sort_byTimeA'; 64 if(strtolower($order) == 'desc') $function = 'sort_byTimeD'; 65 66 foreach($value as $events) { 67 usort($events,$function); 68 $newArray = $events; 69 } 70 71 // here we want to create an intelligent array of 72 // columns and rows to build a nice day view 73 $ch = $sh; $cm = $sm; 74 while("$ch:$cm" <= "$eh:$em") { 75 $hours["$ch:$cm"] = array(); 76 $cm += $inc; 77 if($cm >= 60) { 78 $cm = '00'; 79 $ch = sprintf('%02d',$ch+1); 80 } 81 } 82 83 $alldayevents = array(); 84 foreach($newArray as $event) { 85 list($sh,$sm,$ss) = explode(':',$event['startTime']); 86 $eh = sprintf('%02d',$sh + $event['duration_hours']); 87 $em = sprintf('%02d',$sm + $event['duration_minutes']); 88 89 if($event['alldayevent']) { 90 // we need an entire column . save till later 91 $alldayevents[] = $event; 92 } else { 93 //find open time slots - avoid overlapping 94 $needed = array(); 95 $ch = $sh; $cm = $sm; 96 //what times do we need? 97 while("$ch:$cm" < "$eh:$em") { 98 $needed[] = "$ch:$cm"; 99 $cm += $inc; 100 if($cm >= 60) { 101 $cm = '00'; 102 $ch = sprintf('%02d',$ch+1); 103 } 104 } 105 $i = 0; 106 foreach($needed as $time) { 107 if($i==0) { 108 $hours[$time][] = $event; 109 $key = count($hours[$time])-1; 110 } else { 111 $hours[$time][$key] = 'continued'; 112 } 113 $i++; 114 } 115 116 } 117 } 118 //pcDebugVar($hours); 119 $smarty->assign_by_ref($var,$hours); 120 } 121 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Feb 16 22:40:07 2005 | Cross-referenced by PHPXref 0.6 |