day.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?php
  2. /**
  3. * Displays the day page (day view).
  4. *
  5. * @copyright &copy; 2002-2007 The SquirrelMail Project Team
  6. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  7. * @version $Id$
  8. * @package plugins
  9. * @subpackage calendar
  10. */
  11. /**
  12. * Include the SquirrelMail initialization file.
  13. */
  14. require('../../include/init.php');
  15. /* 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('year',$year,SQ_FORM) || ! is_numeric($year)) {
  22. unset($year);
  23. }
  24. if (! sqGetGlobalVar('month',$month,SQ_FORM) || ! is_numeric($month)) {
  25. unset($month);
  26. }
  27. if (! sqGetGlobalVar('day',$day,SQ_FORM) || ! is_numeric($day)) {
  28. unset($day);
  29. }
  30. /* got 'em */
  31. /**
  32. * displays head of day calendar view
  33. * @return void
  34. * @access private
  35. */
  36. function day_header() {
  37. global $color, $month, $day, $year, $prev_year, $prev_month, $prev_day,
  38. $prev_date, $next_month, $next_day, $next_year, $next_date;
  39. echo html_tag( 'tr', '', '', $color[0] ) . "\n".
  40. html_tag( 'td', '', 'left' ) .
  41. html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n" .
  42. html_tag( 'tr',
  43. html_tag( 'th',
  44. "<a href=\"day.php?year=$prev_year&amp;month=$prev_month&amp;day=$prev_day\">&lt;&nbsp;".
  45. date_intl('D',$prev_date)."</a>",
  46. 'left' ) .
  47. html_tag( 'th', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)) ,
  48. '', '', 'width="75%"' ) .
  49. html_tag( 'th',
  50. "<a href=\"day.php?year=$next_year&amp;month=$next_month&amp;day=$next_day\">".
  51. date_intl('D',$next_date)."&nbsp;&gt;</a>" ,
  52. 'right' )
  53. );
  54. }
  55. /**
  56. * events for specific day are inserted into "daily" array
  57. * @return void
  58. * @access private
  59. */
  60. function initialize_events() {
  61. global $daily_events, $calendardata, $month, $day, $year;
  62. for ($i=7;$i<23;$i++){
  63. if ($i<10){
  64. $evntime = '0' . $i . '00';
  65. } else {
  66. $evntime = $i . '00';
  67. }
  68. $daily_events[$evntime] = 'empty';
  69. }
  70. $cdate = $month . $day . $year;
  71. if (isset($calendardata[$cdate])){
  72. while ( $calfoo = each($calendardata[$cdate])){
  73. $daily_events["$calfoo[key]"] = $calendardata[$cdate][$calfoo['key']];
  74. }
  75. }
  76. }
  77. /**
  78. * main loop for displaying daily events
  79. * @return void
  80. * @access private
  81. */
  82. function display_events() {
  83. global $daily_events, $month, $day, $year, $color;
  84. ksort($daily_events,SORT_STRING);
  85. $eo=0;
  86. while ($calfoo = each($daily_events)){
  87. if ($eo==0){
  88. $eo=4;
  89. } else {
  90. $eo=0;
  91. }
  92. $ehour = substr($calfoo['key'],0,2);
  93. $eminute = substr($calfoo['key'],2,2);
  94. if (!is_array($calfoo['value'])){
  95. echo html_tag( 'tr',
  96. html_tag( 'td', $ehour . ':' . $eminute, 'left' ) .
  97. html_tag( 'td', '&nbsp;', 'left' ) .
  98. html_tag( 'td',
  99. "<font size=\"-1\"><a href=\"event_create.php?year=$year&amp;month=$month&amp;day=$day&amp;hour="
  100. .substr($calfoo['key'],0,2)."\">".
  101. _("ADD") . "</a></font>" ,
  102. 'center' ) ,
  103. '', $color[$eo]);
  104. } else {
  105. $calbar=$calfoo['value'];
  106. if ($calbar['length']!=0){
  107. $elength = '-'.date_intl(_("H:i"),mktime($ehour,$eminute+$calbar['length'],0,1,1,0));
  108. } else {
  109. $elength='';
  110. }
  111. echo html_tag( 'tr', '', '', $color[$eo] ) .
  112. html_tag( 'td', date_intl(_("H:i"),mktime($ehour,$eminute,0,1,1,0)) . $elength, 'left' ) .
  113. html_tag( 'td', '', 'left' ) . '[';
  114. echo ($calbar['priority']==1) ?
  115. "<font color=\"$color[1]\">".htmlspecialchars($calbar['title']).'</font>' :
  116. htmlspecialchars($calbar['title']);
  117. echo'] <div style="margin-left:10px">'.nl2br(htmlspecialchars($calbar['message'])).'</div>' .
  118. html_tag( 'td',
  119. "<font size=\"-1\"><nobr>\n" .
  120. "<a href=\"event_edit.php?year=$year&amp;month=$month&amp;day=$day&amp;hour=".
  121. substr($calfoo['key'],0,2)."&amp;minute=".substr($calfoo['key'],2,2)."\">".
  122. _("EDIT") . "</a>&nbsp;|&nbsp;\n" .
  123. "<a href=\"event_delete.php?dyear=$year&amp;dmonth=$month&amp;dday=$day&amp;dhour=".
  124. substr($calfoo['key'],0,2)."&amp;dminute=".substr($calfoo['key'],2,2).
  125. "&amp;year=$year&amp;month=$month&amp;day=$day\">" .
  126. _("DEL") . '</a>' .
  127. "</nobr></font>\n" ,
  128. 'center' );
  129. }
  130. }
  131. }
  132. /* end of day functions */
  133. if ($month <= 0){
  134. $month = date( 'm');
  135. }
  136. if ($year <= 0){
  137. $year = date( 'Y');
  138. }
  139. if ($day <= 0){
  140. $day = date( 'd');
  141. }
  142. $prev_date = mktime(0, 0, 0, $month , $day - 1, $year);
  143. $next_date = mktime(0, 0, 0, $month , $day + 1, $year);
  144. $prev_day = date ('d',$prev_date);
  145. $prev_month = date ('m',$prev_date);
  146. $prev_year = date ('Y',$prev_date);
  147. $next_day = date ('d',$next_date);
  148. $next_month = date ('m',$next_date);
  149. $next_year = date ('Y',$next_date);
  150. $calself=basename($PHP_SELF);
  151. $daily_events = array();
  152. displayPageHeader($color, 'None');
  153. calendar_header();
  154. readcalendardata();
  155. day_header();
  156. initialize_events();
  157. display_events();
  158. ?>
  159. </table></td></tr></table>
  160. </body></html>