Source for file api.calendar.php

Documentation is available at api.calendar.php

  1. <?php
  2. ////////////////////////////////////////////////////////////////////////////////
  3. // Copyright (C) ReloadCMS Development Team //
  4. // http://reloadcms.sf.net //
  5. // //
  6. // This program is distributed in the hope that it will be useful, //
  7. // but WITHOUT ANY WARRANTY, without even the implied warranty of //
  8. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
  9. // //
  10. // This product released under GNU General Public License v2 //
  11. ////////////////////////////////////////////////////////////////////////////////
  12.  
  13.  
  14.  
  15. class calendar{
  16. var $_temp = array();
  17. var $_events = array();
  18. var $_highlight = array();
  19. function calendar($month, $year){
  20. global $system;
  21. $this->_temp['first_day_stamp'] = mktime(0, 0, 0, $month, 1, $year);
  22. $this->_temp['first_day_week_pos'] = date('w', $this->_temp['first_day_stamp']);
  23. $this->_temp['number_of_days'] = date('t', $this->_temp['first_day_stamp']);
  24. }
  25. function assignEvent($day, $link){
  26. $this->_events[(int)$day] = $link;
  27. }
  28. function highlightDay($day, $style = '!'){
  29. $this->_highlight[(int)$day] = $style;
  30. }
  31. function returnCalendar(){
  32. global $system;
  33. $return = '<table width="100%" border="0" cellspacing="1" cellpadding="0">';
  34. $return .= '<tr>';
  35. $return .= '<th align="center" colspan="7">' . rcms_date_localise(date('F Y', $this->_temp['first_day_stamp'])) . '</th>';
  36. $return .= '</tr>';
  37. $return .= '<tr>';
  38. $return .= rcms_date_localise('<th align="center">Mon</th><th align="center">Tue</th><th align="center">Wed</th><th align="center">Thu</th><th align="center">Fri</th><th align="center">Sat</th><th align="center">Sun</th>');
  39. $return .= '</tr>';
  40. $days_showed = 1;
  41. $cwpos = $this->_temp['first_day_week_pos'];
  42. if($cwpos == 0) $cwpos = 7;
  43. while($days_showed <= $this->_temp['number_of_days']){
  44. $return .= '<tr>';
  45. if($cwpos > 1) {
  46. $return .= '<td colspan="' . ($cwpos-1) . '">&nbsp;</td>';
  47. }
  48. $inc = 0;
  49. for ($i = $days_showed; $i < $days_showed + 7 && $i <= $this->_temp['number_of_days'] && $cwpos <= 7; $i++){
  50. $class = '';
  51. if(!empty($this->_highlight[$i])) {
  52. $class = 'special ';
  53. }
  54. if(empty($this->_events[$i])) {
  55. $class .= 'row2';
  56. } else {
  57. $class .= 'row3';
  58. }
  59. if(empty($this->_events[$i])) {
  60. $return .= '<td align="center" class="' . $class . '">' . $i . '</td>';
  61. } else {
  62. $return .= '<td align="center" class="' . $class . '"><a href="' . $this->_events[$i] . '" class="' . $class . '">' . $i . '</a></td>';
  63. }
  64. $cwpos++;
  65. $inc++;
  66. }
  67. $days_showed = $days_showed + $inc;
  68. $cwpos = 0;
  69. $return .= '</tr>';
  70. }
  71. $return .= '</table>';
  72. return $return;
  73. }
  74. }
  75. ?>

Documentation generated on Fri, 08 Jun 2007 12:21:17 +0300 by phpDocumentor 1.3.0RC3