drop obsolte .cvsignore files, these are now svn:ignore properties
[squirrelmail.git] / plugins / calendar / calendar.php
CommitLineData
d61a01d4 1<?php
7c67a5e8 2
3/**
7c67a5e8 4 * Displays the main calendar page (month view).
d61a01d4 5 *
4b5049de 6 * @copyright &copy; 2002-2007 The SquirrelMail Project Team
4b4abf93 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
8 * @version $Id$
ea5f4b8e 9 * @package plugins
10 * @subpackage calendar
d61a01d4 11 */
ea5f4b8e 12
202bcbcc 13/**
14 * Include the SquirrelMail initialization file.
15 */
16require('../../include/init.php');
d61a01d4 17
1c7143ad 18/* load date_intl() */
19include_once(SM_PATH . 'functions/date.php');
d61a01d4 20
1c7143ad 21/* Calendar plugin required files. */
22include_once(SM_PATH . 'plugins/calendar/calendar_data.php');
23include_once(SM_PATH . 'plugins/calendar/functions.php');
a6d3eff6 24
1c7143ad 25/* get globals */
26if (! sqgetGlobalVar('month',$month,SQ_FORM) || ! is_numeric($month)) {
27 unset($month);
95dcee50 28}
1c7143ad 29if (! sqgetGlobalVar('year',$year,SQ_FORM) || ! is_numeric($year)) {
30 unset($year);
95dcee50 31}
32/* got 'em */
33
1c7143ad 34/**
35 * display upper part of month calendar view
36 * @return void
37 * @access private
38 */
d61a01d4 39function startcalendar() {
ce68b76b 40 global $year, $month, $color;
d61a01d4 41
42 $prev_date = mktime(0, 0, 0, $month - 1, 1, $year);
43 $act_date = mktime(0, 0, 0, $month, 1, $year);
44 $next_date = mktime(0, 0, 0, $month + 1, 1, $year);
45 $prev_month = date( 'm', $prev_date );
46 $next_month = date( 'm', $next_date);
47 $prev_year = date( 'Y', $prev_date);
48 $next_year = date( 'Y', $next_date );
88cb1b4d 49 $self = 'calendar.php';
d61a01d4 50
b01b21d0 51 echo html_tag( 'tr', "\n".
52 html_tag( 'td', "\n".
53 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
54 html_tag( 'tr', "\n".
55 html_tag( 'th',
1ba8cd6b 56 "<a href=\"$self?year=".($year-1)."&amp;month=$month\">&lt;&lt;&nbsp;".($year-1)."</a>"
b01b21d0 57 ) . "\n".
58 html_tag( 'th',
1ba8cd6b 59 "<a href=\"$self?year=$prev_year&amp;month=$prev_month\">&lt;&nbsp;" .
b01b21d0 60 date_intl( 'M', $prev_date). "</a>"
61 ) . "\n".
62 html_tag( 'th', date_intl( 'F Y', $act_date ), '', $color[0], 'colspan="3"') .
63 html_tag( 'th',
1ba8cd6b 64 "<a href=\"$self?year=$next_year&amp;month=$next_month\">" .
b01b21d0 65 date_intl( 'M', $next_date) . "&nbsp;&gt;</a>"
66 ) . "\n".
67 html_tag( 'th',
1ba8cd6b 68 "<a href=\"$self?year=".($year+1)."&amp;month=$month\">".($year+1)."&nbsp;&gt;&gt;</a>"
b01b21d0 69 )
70 ) . "\n".
71 html_tag( 'tr',
72 html_tag( 'th', _("Sunday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
73 html_tag( 'th', _("Monday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
74 html_tag( 'th', _("Tuesday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
75 html_tag( 'th', _("Wednesday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
76 html_tag( 'th', _("Thursday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
77 html_tag( 'th', _("Friday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
78 html_tag( 'th', _("Saturday"), '', $color[5], 'width="14%" width="90"' ) ."\n"
79 )
80 ) ,
81 '', $color[0] ) ."\n";
d61a01d4 82}
83
1c7143ad 84/**
85 * main logic for month view of calendar
86 * @return void
87 * @access private
88 */
d61a01d4 89function drawmonthview() {
8d8da447 90 global $year, $month, $color, $calendardata, $todayis;
d61a01d4 91
92 $aday = 1 - date('w', mktime(0, 0, 0, $month, 1, $year));
93 $days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
94 while ($aday <= $days_in_month) {
b01b21d0 95 echo html_tag( 'tr' );
d61a01d4 96 for ($j=1; $j<=7; $j++) {
97 $cdate="$month";
98 ($aday<10)?$cdate=$cdate."0$aday":$cdate=$cdate."$aday";
99 $cdate=$cdate."$year";
100 if ( $aday <= $days_in_month && $aday > 0){
b01b21d0 101 echo html_tag( 'td', '', 'left', $color[4], 'height="50" valign="top"' ) ."\n".
102 html_tag( 'div', '', 'right' );
6fd95361 103 echo(($cdate==$todayis) ? '<font size="-1" color="'.$color[1].'">[ ' . _("TODAY") . " ] " : '<font size="-1">');
1ba8cd6b 104 echo "<a href=day.php?year=$year&amp;month=$month&amp;day=";
d61a01d4 105 echo(($aday<10) ? "0" : "");
106 echo "$aday>$aday</a></font></div>";
107 } else {
b01b21d0 108 echo html_tag( 'td', '', 'left', $color[0]) ."\n".
d61a01d4 109 "&nbsp;";
110 }
111 if (isset($calendardata[$cdate])){
112 $i=0;
113 while ($calfoo = each($calendardata[$cdate])) {
88cb1b4d 114 $calbar = $calendardata[$cdate][$calfoo['key']];
1c7143ad 115 // FIXME: how to display multiline task
116 $title = '['. $calfoo['key']. '] ' .
117 str_replace(array("\r","\n"),array(' ',' '),htmlspecialchars($calbar['message']));
118 // FIXME: link to nowhere
119 echo "<a href=\"#\" style=\"text-decoration:none; color: "
120 .($calbar['priority']==1 ? $color[1] : $color[6])
121 ."\" title=\"$title\">".htmlspecialchars($calbar['title'])."</a><br />\n";
d61a01d4 122 $i=$i+1;
123 if($i==2){
124 break;
125 }
126 }
127 }
b01b21d0 128 echo "\n</td>\n";
d61a01d4 129 $aday++;
130 }
131 echo '</tr>';
132 }
133}
134
1c7143ad 135/**
136 * end of monthly view and form to jump to any month and year
137 * @return void
1c7143ad 138 * @access private
139 */
d61a01d4 140function endcalendar() {
141 global $year, $month, $day, $color;
142
b01b21d0 143 echo html_tag( 'tr' ) ."\n" .
144 html_tag( 'td', '', 'left', '', 'colspan="7"' ) ."\n" .
6fd95361 145 " <form name=\"caljump\" action=\"calendar.php\" method=\"post\">\n".
146 " <select name=\"year\">\n";
d61a01d4 147 select_option_year($year);
6fd95361 148 echo " </select>\n".
149 " <select name=\"month\">\n";
d61a01d4 150 select_option_month($month);
6fd95361 151 echo " </select>\n".
152 ' <input type="submit" value="' . _("Go") . "\" />\n".
153 " </form>\n".
154 " </td></tr>\n".
155 "</table></td></tr></table>\n";
d61a01d4 156}
157
158
88cb1b4d 159if( !isset( $month ) || $month <= 0){
d61a01d4 160 $month = date( 'm' );
161}
88cb1b4d 162if( !isset($year) || $year <= 0){
d61a01d4 163 $year = date( 'Y' );
164}
88cb1b4d 165if( !isset($day) || $day <= 0){
d61a01d4 166 $day = date( 'd' );
167}
168
169$todayis = date( 'mdY' );
170$calself=basename($PHP_SELF);
171
172displayPageHeader($color, 'None');
173calendar_header();
174readcalendardata();
175startcalendar();
176drawmonthview();
177endcalendar();
178
179?>
91e0dccc 180</body></html>