1<?php
2
3/**
4  * SquirrelMail Shared Calendar Plugin
5  * Copyright (C) 2004-2005 Paul Lesneiwski <pdontthink@angrynerds.com>
6  * This program is licensed under GPL. See COPYING for details
7  *
8  */
9
10
11/**
12  * Displays page header for helper month view calendar
13  *
14  * @param int $yesr The year of the month to be shown
15  * @param int $month The month to be shown
16  * @param object $calendar The calendar for which the helper is
17  *                         being used
18  *
19  */
20function showHelperClockHeader($hour, $minute)
21{
22
23   global $color, $calendar_theme;
24   if (!isset($color[12])) $color[12] = '';
25
26
27   bindtextdomain ('calendar', SM_PATH . 'locale');
28   textdomain ('calendar');
29
30
31   displayHtmlHeader(_("Time Helper"), '', FALSE);
32   echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">";
33
34
35   bindtextdomain ('squirrelmail', SM_PATH . 'locale');
36   textdomain ('squirrelmail');
37
38
39//LEFT OFF HERE -- this whole file is just a copy of the helper calendar and needs to be rewritten!
40//LEFT OFF HERE -- this whole file is just a copy of the helper calendar and needs to be rewritten!
41//LEFT OFF HERE -- this whole file is just a copy of the helper calendar and needs to be rewritten!
42//LEFT OFF HERE -- this whole file is just a copy of the helper calendar and needs to be rewritten!
43exit;
44   $prev_date = mktime(0, 0, 0, $month - 1, 1, $year);
45   $act_date  = mktime(0, 0, 0, $month, 1, $year);
46   $next_date = mktime(0, 0, 0, $month + 1, 1, $year);
47   $prev_month = date('n', $prev_date );
48   $next_month = date('n', $next_date);
49   $prev_year = date('Y', $prev_date);
50   $next_year = date('Y', $next_date );
51
52
53   $self = 'helper_month.php';
54
55   echo html_tag('table', '', '', $calendar_theme['month_view_title_background'], 'width="100%" border="0" cellpadding="2" cellspacing="1"')
56      . html_tag('tr', "\n"
57      . html_tag('th', "<small><a href=\"$self?calID=" . urlencode($calendar->getID())
58      . "&year=" . ($year - 1) . "&month=$month\">&lt;&lt;&nbsp;" . ($year - 1) . "</a></small>") . "\n"
59      . html_tag('th', "<small><a href=\"$self?calID=" . urlencode($calendar->getID())
60      . "&year=$prev_year&month=$prev_month\">&lt;&nbsp;"
61      . date_intl('M', $prev_date) . "</a></small>") . "\n"
62      . html_tag('th', '<small>' . date_intl( 'F Y', $act_date ) . '</small>',
63        '', $calendar_theme['month_view_title_background'], '')
64      . html_tag('th', "<small><a href=\"$self?calID=" . urlencode($calendar->getID())
65      . "&year=$next_year&month=$next_month\">"
66      . date_intl('M', $next_date) . "&nbsp;&gt;</a></small>") . "\n"
67      . html_tag( 'th', "<small><a href=\"$self?calID=" . urlencode($calendar->getID()) . "&year="
68      . ($year + 1) . "&month=$month\">" . ($year + 1) . "&nbsp;&gt;&gt;</a></small>")) . "\n"
69      . '</table>';
70
71
72}
73
74
75/**
76  * Displays one month view for the small (popup) helper calendar
77  *
78  * @param int $yesr The year of the month to be shown
79  * @param int $month The month to be shown
80  *
81  */
82function showHelperClock($hour, $minute)
83{
84
85   global $color, $calendar_theme, $show_week_numbers_in_month_view_override;
86   if (!isset($color[12])) $color[12] = '';
87   $show_week_numbers_in_month_view = $show_week_numbers_in_month_view_override;
88
89
90   showHelperClockHeader($hour, $minute);
91
92
93   bindtextdomain ('calendar', SM_PATH . 'locale');
94   textdomain ('calendar');
95
96
97   $tuitachi = mktime(0, 0, 0, $month, 1, $year);
98   $aDay = 1 - date('w', $tuitachi);
99   $daysInMonth = date('t', $tuitachi);
100   $today = getdate(time());
101   $today = mktime(0, 0, 0, $today['mon'], $today['mday'], $today['year']);
102
103
104   echo html_tag('table', '', '', $calendar_theme['month_view_title_background'],
105                 'width="100%" border="0" cellpadding="2" cellspacing="1"')
106      . html_tag( 'tr', ($show_week_numbers_in_month_view
107      ? html_tag( 'th', '&nbsp;', '', $calendar_theme['month_view_title_background'], '')
108      : '')
109      . html_tag( 'th', '<small>' . _("Sun") . '</small>',
110        '', $calendar_theme['month_view_day_header'], 'width="14%"' ) . "\n"
111      . html_tag( 'th', '<small>' . _("Mon") . '</small>',
112        '', $calendar_theme['month_view_day_header'], 'width="14%"' ) . "\n"
113      . html_tag( 'th', '<small>' . _("Tue") . '</small>',
114        '', $calendar_theme['month_view_day_header'], 'width="14%"' ) . "\n"
115      . html_tag( 'th', '<small>' . _("Wed") . '</small>',
116        '', $calendar_theme['month_view_day_header'], 'width="14%"' ) . "\n"
117      . html_tag( 'th', '<small>' . _("Thu") . '</small>',
118        '', $calendar_theme['month_view_day_header'], 'width="14%"' ) . "\n"
119      . html_tag( 'th', '<small>' . _("Fri") . '</small>',
120        '', $calendar_theme['month_view_day_header'], 'width="14%"' ) . "\n"
121      . html_tag( 'th', '<small>' . _("Sat") . '</small>',
122        '', $calendar_theme['month_view_day_header'], 'width="14%"' ) . "\n");
123
124
125   while ($aDay <= $daysInMonth)
126   {
127
128      $theDay = mktime(0, 0, 0, $month, $aDay, $year);
129
130      // switch back to SM domain for date_intl
131      //
132      bindtextdomain ('squirrelmail', SM_PATH . 'locale');
133      textdomain ('squirrelmail');
134
135      echo html_tag('tr')
136         . ($show_week_numbers_in_month_view
137         ? html_tag('td', '<small>W' . date_intl('W', $theDay) . '</small>', '', $calendar_theme['month_view_day_background'], '')
138         : '');
139
140      bindtextdomain ('calendar', SM_PATH . 'locale');
141      textdomain ('calendar');
142
143
144      // iterate on a weekly basis
145      //
146      for ($dayOfWeek = 1; $dayOfWeek <= 7; $dayOfWeek++)
147      {
148
149         $theDay = mktime(0, 0, 0, $month, $aDay, $year);
150
151
152         // is this a day that is in this month?
153         //
154         if ($aDay <= $daysInMonth && $aDay > 0)
155         {
156
157            $holiday = $calendar->getHolidayForDay($year, $month, $aDay);
158            if (!empty($holiday))
159               $dayColor = $calendar_theme['month_view_holiday_background'];
160            else if ($dayOfWeek == 1 || $dayOfWeek == 7)
161               $dayColor = $calendar_theme['month_view_weekend_background'];
162            else if ($theDay == $today)
163               $dayColor = $calendar_theme['helper_month_view_today_background'];
164            else
165               $dayColor = $calendar_theme['month_view_day_background'];
166
167
168            echo html_tag('td', '', 'right', $dayColor, 'height="5" valign="top"');
169
170
171            $title = '';
172
173
174            if ($theDay == $today)
175               $title = _("TODAY");
176
177
178            if (!empty($holiday))
179               if ($theDay == $today)
180                  $title .= ', ' . cal_encode_output($holiday->getName(), FALSE);
181               else
182                  $title = cal_encode_output($holiday->getName(), FALSE);
183
184
185            echo "<a href=\"#\" " . (!empty($title) ? "title=\"$title\"" : '')
186               . "style=\"text-decoration:none;\"><small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$aDay</small></a>";
187
188         }
189
190
191
192         // days that are not in this month (before/after first/last day of month)
193         //
194         else
195         {
196
197            // show events before/after this month
198            //
199            $holiday = $calendar->getHolidayForDay($year, $month, $aDay);
200            if (!empty($holiday))
201               $dayColor = $calendar_theme['month_view_non_month_holiday_background'];
202            else if ($dayOfWeek == 1 || $dayOfWeek == 7)
203               $dayColor = $calendar_theme['month_view_non_month_weekend_background'];
204            else if ($theDay == $today)
205               $dayColor = $calendar_theme['helper_month_view_today_background'];
206            else
207               $dayColor = $calendar_theme['month_view_non_month_day_background'];
208
209
210            $otherMonthDayInfo = getdate($theDay);
211            echo html_tag( 'td', '', 'left', $color[4], 'height="5" valign="top"')
212               . html_tag('table', '', '', $dayColor, 'height="100%" width="100%" border="0" cellpadding="1" cellspacing="1"')
213               . html_tag('tr') . "\n"
214               . html_tag('td', '', 'right', '', 'valign="top"');
215
216
217            $title = '';
218
219
220            if ($theDay == $today)
221               $title = _("TODAY");
222
223
224            if (!empty($holiday))
225               if ($theDay == $today)
226                  $title .= ', ' . cal_encode_output($holiday->getName(), FALSE);
227               else
228                  $title = cal_encode_output($holiday->getName(), FALSE);
229
230
231            echo "<a href=\"#\" " . (!empty($title) ? "title=\"$title\"" : '')
232               . "style=\"text-decoration:none;\"><small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
233               . $otherMonthDayInfo['mday'] . '</small></a>';
234
235         }
236
237
238         // close extra table when showing events before/after this month
239         //
240         if (!($aDay <= $daysInMonth && $aDay > 0))
241            echo "</td></tr></table>";
242
243
244         echo "\n</td>\n";
245         $aDay++;
246
247      }
248
249      echo '</tr>';
250
251   }
252
253   echo '</table>';
254
255
256   bindtextdomain ('squirrelmail', SM_PATH . 'locale');
257   textdomain ('squirrelmail');
258
259
260   showHelperClockFooter($hour, $minute);
261
262}
263
264
265
266/**
267  * Displays page footer for helper month view calendar
268  *
269  * @param int $yesr The year of the month to be shown
270  * @param int $month The month to be shown
271  *
272  */
273function showHelperClockFooter($hour, $minute)
274{
275
276   echo '</body></html>';
277
278}
279
280
281
282?>
283