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