day.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. /*
  3. * day.php
  4. *
  5. * Copyright (c) 2001 Michal Szczotka <michal@tuxy.org>
  6. * Licensed under the GNU GPL. For full terms see the file COPYING.
  7. *
  8. * Displays the day page (day view).
  9. *
  10. * $Id$
  11. */
  12. require_once('calendar_data.php');
  13. require_once('functions.php');
  14. chdir('..');
  15. require_once('../src/validate.php');
  16. require_once('../functions/strings.php');
  17. require_once('../functions/date.php');
  18. require_once('../config/config.php');
  19. require_once('../functions/page_header.php');
  20. require_once('../src/load_prefs.php');
  21. require_once('../functions/html.php');
  22. //displays head of day calendar view
  23. function day_header() {
  24. global $color, $month, $day, $year, $prev_year, $prev_month, $prev_day,
  25. $prev_date, $next_month, $next_day, $next_year, $next_date;
  26. echo html_tag( 'tr', '', '', $color[0] ) . "\n".
  27. html_tag( 'td', '', 'left' ) .
  28. html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n" .
  29. html_tag( 'tr',
  30. html_tag( 'th',
  31. "<a href=\"day.php?year=$prev_year&month=$prev_month&day=$prev_day\">&lt;&nbsp;".
  32. date_intl('D',$prev_date)."</a>",
  33. 'left' ) .
  34. html_tag( 'th', date_intl( 'l, F d Y', mktime(0, 0, 0, $month, $day, $year)) ,
  35. '', '', 'width="75%"' ) .
  36. html_tag( 'th',
  37. "<a href=\"day.php?year=$next_year&month=$next_month&day=$next_day\">".
  38. date_intl('D',$next_date)."&nbsp;&gt;</a>" ,
  39. 'right' )
  40. );
  41. }
  42. //events for specific day are inserted into "daily" array
  43. function initialize_events() {
  44. global $daily_events, $calendardata, $month, $day, $year;
  45. for ($i=7;$i<23;$i++){
  46. if ($i<10){
  47. $evntime = '0' . $i . '00';
  48. } else {
  49. $evntime = $i . '00';
  50. }
  51. $daily_events[$evntime] = 'empty';
  52. }
  53. $cdate = $month . $day . $year;
  54. if (isset($calendardata[$cdate])){
  55. while ( $calfoo = each($calendardata[$cdate])){
  56. $daily_events["$calfoo[key]"] = $calendardata[$cdate][$calfoo['key']];
  57. }
  58. }
  59. }
  60. //main loop for displaying daily events
  61. function display_events() {
  62. global $daily_events, $month, $day, $year, $color;
  63. ksort($daily_events,SORT_STRING);
  64. $eo=0;
  65. while ($calfoo = each($daily_events)){
  66. if ($eo==0){
  67. $eo=4;
  68. } else {
  69. $eo=0;
  70. }
  71. $ehour = substr($calfoo['key'],0,2);
  72. $eminute = substr($calfoo['key'],2,2);
  73. if (!is_array($calfoo['value'])){
  74. echo html_tag( 'tr',
  75. html_tag( 'td', $ehour . ':' . $eminute, 'left' ) .
  76. html_tag( 'td', '&nbsp;', 'left' ) .
  77. html_tag( 'td',
  78. "<font size=\"-1\"><a href=\"event_create.php?year=$year&month=$month&day=$day&hour=".substr($calfoo['key'],0,2)."\">".
  79. _("ADD") . "</a></font>" ,
  80. 'center' ) ,
  81. '', $color[$eo]);
  82. } else {
  83. $calbar=$calfoo['value'];
  84. if ($calbar['length']!=0){
  85. $elength = '-'.date('H:i',mktime($ehour,$eminute+$calbar['length'],0,1,1,0));
  86. } else {
  87. $elength='';
  88. }
  89. echo html_tag( 'tr', '', '', $color[$eo] ) .
  90. html_tag( 'td', $ehour . ':' . $eminute . $elength, 'left' ) .
  91. html_tag( 'td', '', 'left' ) . '[';
  92. echo ($calbar['priority']==1) ? "<font color=\"$color[1]\">$calbar[title]</font>" : "$calbar[title]";
  93. echo"] $calbar[message]&nbsp;" .
  94. html_tag( 'td',
  95. "<font size=\"-1\"><nobr>\n" .
  96. "<a href=\"event_edit.php?year=$year&month=$month&day=$day&hour=".substr($calfoo['key'],0,2)."&minute=".substr($calfoo['key'],2,2)."\">".
  97. _("EDIT") . "</a>&nbsp;|&nbsp;\n" .
  98. "<a href=\"event_delete.php?dyear=$year&dmonth=$month&dday=$day&dhour=".substr($calfoo['key'],0,2)."&dminute=".substr($calfoo['key'],2,2)."&year=$year&month=$month&day=$day\">" .
  99. _("DEL") . '</a>' .
  100. "</nobr></font>\n" ,
  101. 'center' );
  102. }
  103. }
  104. }
  105. if ($month <= 0){
  106. $month = date( 'm');
  107. }
  108. if ($year <= 0){
  109. $year = date( 'Y');
  110. }
  111. if ($day <= 0){
  112. $day = date( 'd');
  113. }
  114. $prev_date = mktime(0, 0, 0, $month , $day - 1, $year);
  115. $next_date = mktime(0, 0, 0, $month , $day + 1, $year);
  116. $prev_day = date ('d',$prev_date);
  117. $prev_month = date ('m',$prev_date);
  118. $prev_year = date ('Y',$prev_date);
  119. $next_day = date ('d',$next_date);
  120. $next_month = date ('m',$next_date);
  121. $next_year = date ('Y',$next_date);
  122. $calself=basename($PHP_SELF);
  123. $daily_events = array();
  124. displayPageHeader($color, 'None');
  125. calendar_header();
  126. readcalendardata();
  127. day_header();
  128. initialize_events();
  129. display_events();
  130. ?>
  131. </table></td></tr></table>
  132. </body></html>