squirrelmail-webmail  1.4.22
About: SquirrelMail is a standards-based webmail package with strong MIME support, address books, and folder manipulation (written in PHP4).
  Fossies Dox: squirrelmail-webmail-1.4.22.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

calendar.php
Go to the documentation of this file.
1 <?php
2 
14 define('SM_PATH','../../');
15 
16 /* SquirrelMail required files. */
17 include_once(SM_PATH . 'include/validate.php');
18 /* load date_intl() */
19 include_once(SM_PATH . 'functions/date.php');
20 
21 /* Calendar plugin required files. */
22 include_once(SM_PATH . 'plugins/calendar/calendar_data.php');
23 include_once(SM_PATH . 'plugins/calendar/functions.php');
24 
25 /* get globals */
26 if (! sqgetGlobalVar('month',$month,SQ_FORM) || ! is_numeric($month)) {
27  unset($month);
28 }
29 if (! sqgetGlobalVar('year',$year,SQ_FORM) || ! is_numeric($year)) {
30  unset($year);
31 }
32 /* got 'em */
33 
39 function startcalendar() {
40  global $year, $month, $color;
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 );
49  $self = 'calendar.php';
50 
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',
56  "<a href=\"$self?year=".($year-1)."&amp;month=$month\">&lt;&lt;&nbsp;".($year-1)."</a>"
57  ) . "\n".
58  html_tag( 'th',
59  "<a href=\"$self?year=$prev_year&amp;month=$prev_month\">&lt;&nbsp;" .
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',
64  "<a href=\"$self?year=$next_year&amp;month=$next_month\">" .
65  date_intl( 'M', $next_date) . "&nbsp;&gt;</a>"
66  ) . "\n".
67  html_tag( 'th',
68  "<a href=\"$self?year=".($year+1)."&amp;month=$month\">".($year+1)."&nbsp;&gt;&gt;</a>"
69  )
70  ) . "\n".
71  html_tag( 'tr',
72  html_tag( 'th', _("Sunday"), '', $color[5], 'width="14%"' ) ."\n" .
73  html_tag( 'th', _("Monday"), '', $color[5], 'width="14%"' ) ."\n" .
74  html_tag( 'th', _("Tuesday"), '', $color[5], 'width="14%"' ) ."\n" .
75  html_tag( 'th', _("Wednesday"), '', $color[5], 'width="14%"' ) ."\n" .
76  html_tag( 'th', _("Thursday"), '', $color[5], 'width="14%"' ) ."\n" .
77  html_tag( 'th', _("Friday"), '', $color[5], 'width="14%"' ) ."\n" .
78  html_tag( 'th', _("Saturday"), '', $color[5], 'width="14%"' ) ."\n"
79  )
80  ) ,
81  '', $color[0] ) ."\n";
82 }
83 
89 function drawmonthview() {
90  global $year, $month, $color, $calendardata, $todayis;
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) {
95  echo html_tag( 'tr' );
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){
101  echo html_tag( 'td', '', 'left', $color[4], 'height="50" valign="top"' ) ."\n".
102  html_tag( 'div', '', 'right' );
103  echo(($cdate==$todayis) ? '<font size="-1" color="'.$color[1].'">[ ' . _("TODAY") . " ] " : '<font size="-1">');
104  echo "<a href=\"day.php?year=$year&amp;month=$month&amp;day=";
105  echo(($aday<10) ? "0" : "");
106  echo "$aday\">$aday</a></font></div>";
107  } else {
108  echo html_tag( 'td', '', 'left', $color[0]) ."\n".
109  "&nbsp;";
110  }
111  if (isset($calendardata[$cdate])){
112  $i=0;
113  while ($calfoo = each($calendardata[$cdate])) {
114  $calbar = $calendardata[$cdate][$calfoo['key']];
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";
122  $i=$i+1;
123  if($i==2){
124  break;
125  }
126  }
127  }
128  echo "\n</td>\n";
129  $aday++;
130  }
131  echo '</tr>';
132  }
133 }
134 
140 function endcalendar() {
141  global $year, $month, $day, $color;
142 
143  echo html_tag( 'tr' ) ."\n" .
144  html_tag( 'td', '', 'left', '', 'colspan="7"' ) ."\n" .
145  " <form name=\"caljump\" action=\"calendar.php\" method=\"post\">\n".
146  " <select name=\"year\">\n";
147  select_option_year($year);
148  echo " </select>\n".
149  " <select name=\"month\">\n";
150  select_option_month($month);
151  echo " </select>\n".
152  ' <input type="submit" value="' . _("Go") . "\" />\n".
153  " </form>\n".
154  " </td></tr>\n".
155  "</table></td></tr></table>\n";
156 }
157 
158 
159 if( !isset( $month ) || $month <= 0){
160  $month = date( 'm' );
161 }
162 if( !isset($year) || $year <= 0){
163  $year = date( 'Y' );
164 }
165 if( !isset($day) || $day <= 0){
166  $day = date( 'd' );
167 }
168 
169 $todayis = date( 'mdY' );
170 $calself=basename($PHP_SELF);
171 
172 displayPageHeader($color, 'None');
175 startcalendar();
176 drawmonthview();
177 endcalendar();
178 
179 ?>
180 </body></html>
sqgetGlobalVar
sqgetGlobalVar($name, &$value, $search=SQ_INORDER)
Definition: global.php:344
SM_PATH
const SM_PATH
Definition: calendar.php:14
html_tag
html_tag( $tag, $val='', $align='', $bgcolor='', $xtra='')
Definition: html.php:27
$prev_date
if($month<=0) if($year<=0) if($day<=0) $prev_date
Definition: day.php:159
$prev_month
$prev_month
Definition: day.php:162
displayPageHeader
displayPageHeader($color, $mailbox, $xtra='', $session=false)
Definition: page_header.php:105
startcalendar
if(! sqgetGlobalVar('month', $month, SQ_FORM)||! is_numeric($month)) if(! sqgetGlobalVar('year', $year, SQ_FORM)||! is_numeric($year)) startcalendar()
Definition: calendar.php:39
html
Definition: html.class.php:18
date_intl
date_intl( $date_format, $stamp)
Definition: date.php:286
$calendardata
$calendardata
Definition: calendar_data.php:18
if
if(! defined( 'SM_PATH')) define( 'SM_PATH'
Definition: mime.class.php:16
drawmonthview
drawmonthview()
Definition: calendar.php:89
select_option_month
select_option_month($selected)
Definition: functions.php:160
$PHP_SELF
$PHP_SELF
Definition: strings.php:1458
$j
for($i=0; $i< $numboxes; $i++) $j
Definition: empty_trash.php:72
$next_month
$next_month
Definition: day.php:165
calendar_header
calendar_header()
Definition: functions.php:17
_
_($str)
Definition: gettext.php:160
$prev_year
$prev_year
Definition: day.php:163
$todayis
if(!isset( $month)|| $month<=0) if(!isset($year)|| $year<=0) if(!isset($day)|| $day<=0) $todayis
Definition: calendar.php:169
readcalendardata
readcalendardata()
Definition: calendar_data.php:67
select_option_year
select_option_year($selected)
Definition: functions.php:144
$calself
$calself
Definition: calendar.php:170
SQ_FORM
const SQ_FORM
Definition: global.php:21
$color
$color
Definition: load_prefs.php:28
$next_date
$next_date
Definition: day.php:160
endcalendar
endcalendar()
Definition: calendar.php:140
$next_year
$next_year
Definition: day.php:166