Source for file calendar.php

Documentation is available at calendar.php

  1. <?php
  2.  
  3. /**
  4.  * Displays the main calendar page (month view).
  5.  *
  6.  * @copyright 2002-2018 The SquirrelMail Project Team
  7.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  8.  * @version $Id: calendar.php 14749 2018-01-16 23:36:07Z pdontthink $
  9.  * @package plugins
  10.  * @subpackage calendar
  11.  */
  12.  
  13. /** @ignore */
  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.  
  34. /**
  35.  * display upper part of month calendar view
  36.  * @return void 
  37.  * @access private
  38.  */
  39. function startcalendar({
  40.     global $year$month$color;
  41.  
  42.     $prev_date mktime(000$month 11$year);
  43.     $act_date  mktime(000$month1$year);
  44.     $next_date mktime(000$month 11$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.  
  84. /**
  85.  * main logic for month view of calendar
  86.  * @return void 
  87.  * @access private
  88.  */
  89. function drawmonthview({
  90.     global $year$month$color$calendardata$todayis;
  91.  
  92.     $aday date('w'mktime(000$month1$year));
  93.     $days_in_month date('t'mktime(000$month1$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(' ',' '),sm_encode_html_special_chars($calbar['message']));
  118.                     // FIXME: link to nowhere
  119.                     echo "<a href=\"#\" style=\"text-decoration:none; color: "
  120.                         .($calbar['priority']==$color[1$color[6])
  121.                         ."\" title=\"$title\">".sm_encode_html_special_chars($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.  
  135. /**
  136.  * end of monthly view and form to jump to any month and year
  137.  * @return void 
  138.  * @access private
  139.  */
  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');
  173. startcalendar();
  174. drawmonthview();
  175. endcalendar();
  176.  
  177. ?>
  178. </body></html>

Documentation generated on Wed, 19 Dec 2018 04:24:10 +0100 by phpDocumentor 1.4.3