PageRenderTime 56ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/root/calendar.php

http://phpbb3calendar.googlecode.com/
PHP | 136 lines | 108 code | 14 blank | 14 comment | 7 complexity | 2f8526d5192cb2f5373f4473c14219d1 MD5 | raw file
  1. <?php
  2. /**
  3. *
  4. * @package phpBB3
  5. * @version $Id: calendar.php,v ALPHA 3 2007/10/02 10:00:00 Jcc264 Exp $
  6. * @copyright (c) 2007 M and J Media
  7. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  8. *
  9. */
  10. /**
  11. * @ignore
  12. */
  13. define('IN_PHPBB', true);
  14. $phpbb_root_path = './';
  15. $phpEx = substr(strrchr(__FILE__, '.'), 1);
  16. include($phpbb_root_path . 'common.'.$phpEx);
  17. include($phpbb_root_path . 'includes/functions_calendar.'.$phpEx);
  18. // Start session management
  19. $user->session_begin();
  20. $auth->acl($user->data);
  21. $user->setup('mods/calendar');
  22. $month_array = genarate_month_array(request_var('month',0));
  23. foreach ( $month_array['build'] as $week)
  24. {
  25. for($i =0 ; $i<=6; $i++)
  26. {
  27. $event_array = get_events($week[$i], $month_array['month'], $month_array['year']);
  28. $birthday_array = get_birthdays($week[$i], $month_array['month'], $month_array['year']);
  29. if( (count($event_array)>0) || (count($birthday_array)>0) )
  30. {
  31. //there is a event going on
  32. $output_text = '';
  33. if( isset($event_array[1]) )
  34. {
  35. $output_text .= '<a href="calendar_view.php?month='.$month_array['month'].'&day='.$week[$i].'&year='.$month_array['year'].'" title="'.$event_array[1]['event_name'].'">'.mb_substr($event_array[1]['event_name'], 0, 15).(mb_strlen($event_array[1]['event_name'])>15?'...':'').'</a><br>';
  36. }
  37. else
  38. {
  39. $output_text .= '&nbsp;<br>';
  40. }
  41. if( isset($event_array[2]) )
  42. {
  43. $output_text .= '<a href="calendar_view.php?month='.$month_array['month'].'&day='.$week[$i].'&year='.$month_array['year'].'" title="'.$event_array[2]['event_name'].'">'.mb_substr($event_array[2]['event_name'], 0, 15).(mb_strlen($event_array[1]['event_name'])>15?'...':'').'</a><br>';
  44. }
  45. else
  46. {
  47. $output_text .= '&nbsp;<br>';
  48. }
  49. if( count($event_array) > 3)
  50. {
  51. $output_text .= '<a href="calendar_view.php?month='.$month_array['month'].'&day='.$week[$i].'&year='.$month_array['year'].'" title="More Events...">More Events...</a><br>';
  52. }
  53. elseif( isset($event_array[3]) )
  54. {
  55. $output_text .= '<a href="calendar_view.php?month='.$month_array['month'].'&day='.$week[$i].'&year='.$month_array['year'].'" title="'.$event_array[3]['event_name'].'">'.mb_substr($event_array[3]['event_name'], 0, 15).(mb_strlen($event_array[1]['event_name'])>15?'...':'').'</a><br>';
  56. }
  57. else
  58. {
  59. $output_text .= '&nbsp;<br>';
  60. }
  61. if( count($birthday_array) > 0 )
  62. {
  63. $output_text .= '<a href="calendar_view.php?month='.$month_array['month'].'&day='.$week[$i].'&year='.$month_array['year'].'" title="Birthday" >Birthday</a><br>';
  64. }
  65. else
  66. {
  67. $output_text .= '&nbsp;<br>';
  68. }
  69. $week[$i] = array(
  70. 'day' => '<b><a href="calendar_view.php?month='.$month_array['month'].'&day='.$week[$i].'&year='.$month_array['year'].'">'.$week[$i].'</a></b>',
  71. 'event' => $output_text,
  72. );
  73. }
  74. else
  75. {
  76. //This is a eventless day
  77. $week[$i] = array(
  78. 'day' => (isset($week[$i])?$week[$i]:''),
  79. 'event' => '&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;<br>',
  80. );
  81. }
  82. }
  83. $template->assign_block_vars('calendar_week', array(
  84. 'DAY0' => $week[0]['day'],
  85. 'DAY1' => $week[1]['day'],
  86. 'DAY2' => $week[2]['day'],
  87. 'DAY3' => $week[3]['day'],
  88. 'DAY4' => $week[4]['day'],
  89. 'DAY5' => $week[5]['day'],
  90. 'DAY6' => $week[6]['day'],
  91. 'DAY0_EVENTS' => $week[0]['event'],
  92. 'DAY1_EVENTS' => $week[1]['event'],
  93. 'DAY2_EVENTS' => $week[2]['event'],
  94. 'DAY3_EVENTS' => $week[3]['event'],
  95. 'DAY4_EVENTS' => $week[4]['event'],
  96. 'DAY5_EVENTS' => $week[5]['event'],
  97. 'DAY6_EVENTS' => $week[6]['event'],
  98. ));
  99. }
  100. $template->assign_vars(array(
  101. 'L_CALENDAR' => 'Calendar',
  102. 'L_SUN' => $user->lang['calendar']['long_day'][0],
  103. 'L_MON' => $user->lang['calendar']['long_day'][1],
  104. 'L_TUE' => $user->lang['calendar']['long_day'][2],
  105. 'L_WED' => $user->lang['calendar']['long_day'][3],
  106. 'L_THU' => $user->lang['calendar']['long_day'][4],
  107. 'L_FRI' => $user->lang['calendar']['long_day'][5],
  108. 'L_SAT' => $user->lang['calendar']['long_day'][6],
  109. 'L_CALENDAR_MONTH' => $user->lang['calendar']['long_month'][$month_array['month']]." ".$month_array['year'],
  110. 'U_NEXT_MONTH' => append_sid($_SERVER["PHP_SELF"] . "?month=" . (request_var('month',0) + 1)),
  111. 'U_PREV_MONTH' => append_sid($_SERVER["PHP_SELF"] . "?month=" . (request_var('month',0) - 1)),
  112. 'IMG_LEFT_ARROW' => '&lt;&lt;',
  113. 'IMG_RIGHT_ARROW' => '&gt;&gt;',
  114. 'S_NEW_EVENT' => $auth->acl_get('u_new_event'),
  115. ));
  116. $page_title="Calendar";
  117. page_header($page_title);
  118. $template->set_filenames(array(
  119. 'body' => 'calendar_body.html')
  120. );
  121. page_footer();
  122. ?>