Source for file calendar.php

Documentation is available at calendar.php

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

Documentation generated on 2020年1月13日 04:24:15 +0100 by phpDocumentor 1.4.3

AltStyle によって変換されたページ (->オリジナル) /