d61a01d4 |
1 | <?php |
7c67a5e8 |
2 | |
3 | /** |
4 | * day.php |
d61a01d4 |
5 | * |
7c67a5e8 |
6 | * Copyright (c) 2002 The SquirrelMail Project Team |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
d61a01d4 |
8 | * |
7c67a5e8 |
9 | * Originally contrubuted by Michal Szczotka <michal@tuxy.org> |
10 | * |
11 | * Displays the day page (day view). |
d61a01d4 |
12 | * |
2c85de8f |
13 | * $Id$ |
d61a01d4 |
14 | */ |
15 | |
16 | require_once('calendar_data.php'); |
17 | require_once('functions.php'); |
cf1efdce |
18 | |
d61a01d4 |
19 | chdir('..'); |
cf1efdce |
20 | define('SM_PATH','../'); |
21 | |
22 | /* SquirrelMail required files. */ |
23 | require_once(SM_PATH . 'include/validate.php'); |
24 | require_once(SM_PATH . 'functions/strings.php'); |
25 | require_once(SM_PATH . 'functions/date.php'); |
26 | require_once(SM_PATH . 'config/config.php'); |
27 | require_once(SM_PATH . 'functions/page_header.php'); |
aa7fb30c |
28 | require_once(SM_PATH . 'include/load_prefs.php'); |
cf1efdce |
29 | require_once(SM_PATH . 'functions/html.php'); |
d61a01d4 |
30 | |
31 | //displays head of day calendar view |
32 | function day_header() { |
33 | global $color, $month, $day, $year, $prev_year, $prev_month, $prev_day, |
34 | $prev_date, $next_month, $next_day, $next_year, $next_date; |
35 | |
b01b21d0 |
36 | echo html_tag( 'tr', '', '', $color[0] ) . "\n". |
37 | html_tag( 'td', '', 'left' ) . |
38 | html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n" . |
39 | html_tag( 'tr', |
40 | html_tag( 'th', |
41 | "<a href=\"day.php?year=$prev_year&month=$prev_month&day=$prev_day\">< ". |
42 | date_intl('D',$prev_date)."</a>", |
43 | 'left' ) . |
f3409980 |
44 | html_tag( 'th', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)) , |
45 | '', '', 'width="75%"' ) . |
b01b21d0 |
46 | html_tag( 'th', |
47 | "<a href=\"day.php?year=$next_year&month=$next_month&day=$next_day\">". |
48 | date_intl('D',$next_date)." ></a>" , |
49 | 'right' ) |
50 | ); |
d61a01d4 |
51 | } |
52 | |
53 | //events for specific day are inserted into "daily" array |
54 | function initialize_events() { |
55 | global $daily_events, $calendardata, $month, $day, $year; |
56 | |
57 | for ($i=7;$i<23;$i++){ |
58 | if ($i<10){ |
59 | $evntime = '0' . $i . '00'; |
60 | } else { |
61 | $evntime = $i . '00'; |
62 | } |
63 | $daily_events[$evntime] = 'empty'; |
64 | } |
65 | |
66 | $cdate = $month . $day . $year; |
67 | |
68 | if (isset($calendardata[$cdate])){ |
69 | while ( $calfoo = each($calendardata[$cdate])){ |
88cb1b4d |
70 | $daily_events["$calfoo[key]"] = $calendardata[$cdate][$calfoo['key']]; |
d61a01d4 |
71 | } |
72 | } |
73 | } |
74 | |
75 | //main loop for displaying daily events |
76 | function display_events() { |
77 | global $daily_events, $month, $day, $year, $color; |
78 | |
79 | ksort($daily_events,SORT_STRING); |
80 | $eo=0; |
81 | while ($calfoo = each($daily_events)){ |
82 | if ($eo==0){ |
83 | $eo=4; |
84 | } else { |
85 | $eo=0; |
86 | } |
87 | |
88cb1b4d |
88 | $ehour = substr($calfoo['key'],0,2); |
89 | $eminute = substr($calfoo['key'],2,2); |
90 | if (!is_array($calfoo['value'])){ |
b01b21d0 |
91 | echo html_tag( 'tr', |
92 | html_tag( 'td', $ehour . ':' . $eminute, 'left' ) . |
93 | html_tag( 'td', ' ', 'left' ) . |
94 | html_tag( 'td', |
95 | "<font size=\"-1\"><a href=\"event_create.php?year=$year&month=$month&day=$day&hour=".substr($calfoo['key'],0,2)."\">". |
96 | _("ADD") . "</a></font>" , |
97 | 'center' ) , |
98 | '', $color[$eo]); |
99 | |
d61a01d4 |
100 | } else { |
88cb1b4d |
101 | $calbar=$calfoo['value']; |
102 | if ($calbar['length']!=0){ |
103 | $elength = '-'.date('H:i',mktime($ehour,$eminute+$calbar['length'],0,1,1,0)); |
d61a01d4 |
104 | } else { |
105 | $elength=''; |
106 | } |
b01b21d0 |
107 | echo html_tag( 'tr', '', '', $color[$eo] ) . |
108 | html_tag( 'td', $ehour . ':' . $eminute . $elength, 'left' ) . |
109 | html_tag( 'td', '', 'left' ) . '['; |
110 | echo ($calbar['priority']==1) ? "<font color=\"$color[1]\">$calbar[title]</font>" : "$calbar[title]"; |
111 | echo"] $calbar[message] " . |
112 | html_tag( 'td', |
113 | "<font size=\"-1\"><nobr>\n" . |
114 | "<a href=\"event_edit.php?year=$year&month=$month&day=$day&hour=".substr($calfoo['key'],0,2)."&minute=".substr($calfoo['key'],2,2)."\">". |
115 | _("EDIT") . "</a> | \n" . |
116 | "<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\">" . |
117 | _("DEL") . '</a>' . |
118 | "</nobr></font>\n" , |
119 | 'center' ); |
d61a01d4 |
120 | } |
d61a01d4 |
121 | } |
122 | |
123 | |
124 | } |
125 | |
126 | if ($month <= 0){ |
127 | $month = date( 'm'); |
128 | } |
129 | if ($year <= 0){ |
130 | $year = date( 'Y'); |
131 | } |
132 | if ($day <= 0){ |
133 | $day = date( 'd'); |
134 | } |
135 | |
136 | $prev_date = mktime(0, 0, 0, $month , $day - 1, $year); |
137 | $next_date = mktime(0, 0, 0, $month , $day + 1, $year); |
138 | $prev_day = date ('d',$prev_date); |
139 | $prev_month = date ('m',$prev_date); |
140 | $prev_year = date ('Y',$prev_date); |
141 | $next_day = date ('d',$next_date); |
142 | $next_month = date ('m',$next_date); |
143 | $next_year = date ('Y',$next_date); |
144 | |
145 | $calself=basename($PHP_SELF); |
146 | |
147 | $daily_events = array(); |
148 | |
149 | displayPageHeader($color, 'None'); |
150 | calendar_header(); |
151 | readcalendardata(); |
152 | day_header(); |
153 | initialize_events(); |
154 | display_events(); |
d61a01d4 |
155 | ?> |
156 | </table></td></tr></table> |
34d86c16 |
157 | </body></html> |