| 1 | <?php |
| 2 | /* |
| 3 | * day.php |
| 4 | * |
| 5 | * Copyright (c) 2001 Michal Szczotka <michal@tuxy.org> |
| 6 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
| 7 | * |
| 8 | * Displays the day page (day view). |
| 9 | * |
| 10 | * $Id$ |
| 11 | */ |
| 12 | |
| 13 | require_once('calendar_data.php'); |
| 14 | require_once('functions.php'); |
| 15 | chdir('..'); |
| 16 | require_once('../src/validate.php'); |
| 17 | require_once('../functions/strings.php'); |
| 18 | require_once('../functions/date.php'); |
| 19 | require_once('../config/config.php'); |
| 20 | require_once('../functions/page_header.php'); |
| 21 | require_once('../src/load_prefs.php'); |
| 22 | |
| 23 | //displays head of day calendar view |
| 24 | function day_header() { |
| 25 | global $color, $month, $day, $year, $prev_year, $prev_month, $prev_day, |
| 26 | $prev_date, $next_month, $next_day, $next_year, $next_date; |
| 27 | |
| 28 | echo " <TR BGCOLOR=\"$color[0]\"><TD>" . |
| 29 | " <TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">\n" . |
| 30 | " <TR><TH WIDTH=\"5%\" ALIGN=LEFT><A HREF=\"day.php?year=$prev_year&month=$prev_month&day=$prev_day\">< ". |
| 31 | date_intl('D',$prev_date)."</A></TH>\n" . |
| 32 | " <TH WIDTH=\"75%\">" . |
| 33 | date_intl( 'l, F d Y', mktime(0, 0, 0, $month, $day, $year)) . "</TH>\n" . |
| 34 | " <TH ALIGN=RIGHT><A HREF=\"day.php?year=$next_year&month=$next_month&day=$next_day\">". |
| 35 | date_intl('D',$next_date)." ></A></TH></TR>\n"; |
| 36 | } |
| 37 | |
| 38 | //events for specific day are inserted into "daily" array |
| 39 | function initialize_events() { |
| 40 | global $daily_events, $calendardata, $month, $day, $year; |
| 41 | |
| 42 | for ($i=7;$i<23;$i++){ |
| 43 | if ($i<10){ |
| 44 | $evntime = '0' . $i . '00'; |
| 45 | } else { |
| 46 | $evntime = $i . '00'; |
| 47 | } |
| 48 | $daily_events[$evntime] = 'empty'; |
| 49 | } |
| 50 | |
| 51 | $cdate = $month . $day . $year; |
| 52 | |
| 53 | if (isset($calendardata[$cdate])){ |
| 54 | while ( $calfoo = each($calendardata[$cdate])){ |
| 55 | $daily_events["$calfoo[key]"] = $calendardata[$cdate][$calfoo[key]]; |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | //main loop for displaying daily events |
| 61 | function display_events() { |
| 62 | global $daily_events, $month, $day, $year, $color; |
| 63 | |
| 64 | ksort($daily_events,SORT_STRING); |
| 65 | $eo=0; |
| 66 | while ($calfoo = each($daily_events)){ |
| 67 | if ($eo==0){ |
| 68 | $eo=4; |
| 69 | } else { |
| 70 | $eo=0; |
| 71 | } |
| 72 | |
| 73 | $ehour = substr($calfoo[key],0,2); |
| 74 | $eminute = substr($calfoo[key],2,2); |
| 75 | if (!is_array($calfoo[value])){ |
| 76 | echo " <TR BGCOLOR=\"$color[$eo]\"><TD>$ehour:$eminute</TD>\n" . |
| 77 | " <TD> </TD>\n" . |
| 78 | " <TD ALIGN=CENTER><FONT SIZE=-1><A HREF=\"event_create.php?year=$year&month=$month&day=$day&hour=".substr($calfoo[key],0,2)."\">". |
| 79 | _("ADD") . "</A></FONT></TD></TR>\n"; |
| 80 | } else { |
| 81 | $calbar=$calfoo[value]; |
| 82 | if ($calbar[length]!=0){ |
| 83 | $elength = '-'.date('H:i',mktime($ehour,$eminute+$calbar[length],0,1,1,0)); |
| 84 | } else { |
| 85 | $elength=''; |
| 86 | } |
| 87 | echo " <TR BGCOLOR=\"$color[$eo]\"><TD>$ehour:$eminute$elength</TD>\n" . |
| 88 | " <TD>["; |
| 89 | echo ($calbar[priority]==1) ? "<FONT COLOR=\"$color[1]\">$calbar[title]</FONT>" : "$calbar[title]"; |
| 90 | echo"] $calbar[message] </TD>\n" . |
| 91 | " <TD ALIGN=CENTER><FONT SIZE=-1><nobr>\n" . |
| 92 | "<A HREF=\"event_edit.php?year=$year&month=$month&day=$day&hour=".substr($calfoo[key],0,2)."&minute=".substr($calfoo[key],2,2)."\">". |
| 93 | _("EDIT") . "</A> | \n" . |
| 94 | "<A HREF=\"event_delete.php?dyear=$year&dmonth=$month&dday=$day&dhour=".substr($calfoo[key],0,2)."&dminute=".substr($calfoo[key],2,2)."&year=$year&month=$month&day=$day\">" . |
| 95 | _("DEL") . '</A>' . |
| 96 | " </nobr></FONT></TD></TR>\n"; |
| 97 | } |
| 98 | $i++; |
| 99 | } |
| 100 | |
| 101 | |
| 102 | } |
| 103 | |
| 104 | if ($month <= 0){ |
| 105 | $month = date( 'm'); |
| 106 | } |
| 107 | if ($year <= 0){ |
| 108 | $year = date( 'Y'); |
| 109 | } |
| 110 | if ($day <= 0){ |
| 111 | $day = date( 'd'); |
| 112 | } |
| 113 | |
| 114 | $prev_date = mktime(0, 0, 0, $month , $day - 1, $year); |
| 115 | $next_date = mktime(0, 0, 0, $month , $day + 1, $year); |
| 116 | $prev_day = date ('d',$prev_date); |
| 117 | $prev_month = date ('m',$prev_date); |
| 118 | $prev_year = date ('Y',$prev_date); |
| 119 | $next_day = date ('d',$next_date); |
| 120 | $next_month = date ('m',$next_date); |
| 121 | $next_year = date ('Y',$next_date); |
| 122 | |
| 123 | $calself=basename($PHP_SELF); |
| 124 | |
| 125 | $daily_events = array(); |
| 126 | |
| 127 | displayPageHeader($color, 'None'); |
| 128 | calendar_header(); |
| 129 | readcalendardata(); |
| 130 | day_header(); |
| 131 | initialize_events(); |
| 132 | display_events(); |
| 133 | ?> |
| 134 | </table></td></tr></table> |
| 135 | </body></html> |