Overview

Packages

  • Kronolith
  • None

Classes

  • Kronolith
  • Kronolith_Ajax_Application
  • Kronolith_Ajax_Imple_ContactAutoCompleter
  • Kronolith_Ajax_Imple_Embed
  • Kronolith_Ajax_Imple_TagActions
  • Kronolith_Ajax_Imple_TagAutoCompleter
  • Kronolith_Api
  • Kronolith_Calendar
  • Kronolith_Calendar_External
  • Kronolith_Calendar_External_Tasks
  • Kronolith_Calendar_Holiday
  • Kronolith_Calendar_Internal
  • Kronolith_Calendar_Remote
  • Kronolith_Calendar_Resource
  • Kronolith_Calendars_Base
  • Kronolith_Calendars_Default
  • Kronolith_Calendars_Kolab
  • Kronolith_Day
  • Kronolith_Driver
  • Kronolith_Driver_Holidays
  • Kronolith_Driver_Horde
  • Kronolith_Driver_Ical
  • Kronolith_Driver_Kolab
  • Kronolith_Driver_Mock
  • Kronolith_Driver_Resource
  • Kronolith_Driver_Sql
  • Kronolith_Event
  • Kronolith_Event_Holidays
  • Kronolith_Event_Horde
  • Kronolith_Event_Ical
  • Kronolith_Event_Kolab
  • Kronolith_Event_Resource
  • Kronolith_Event_Sql
  • Kronolith_Exception
  • Kronolith_Factory_Calendars
  • Kronolith_Factory_Geo
  • Kronolith_Form_CreateCalendar
  • Kronolith_Form_CreateResource
  • Kronolith_Form_CreateResourceGroup
  • Kronolith_Form_DeleteCalendar
  • Kronolith_Form_DeleteResource
  • Kronolith_Form_DeleteResourceGroup
  • Kronolith_Form_EditCalendar
  • Kronolith_Form_EditRemoteCalendar
  • Kronolith_Form_EditResource
  • Kronolith_Form_EditResourceGroup
  • Kronolith_Form_SubscribeRemoteCalendar
  • Kronolith_Form_UnsubscribeRemoteCalendar
  • Kronolith_FreeBusy
  • Kronolith_FreeBusy_View
  • Kronolith_FreeBusy_View_Day
  • Kronolith_FreeBusy_View_Month
  • Kronolith_FreeBusy_View_Week
  • Kronolith_FreeBusy_View_Workweek
  • Kronolith_Geo_Base
  • Kronolith_Geo_Mysql
  • Kronolith_Geo_Sql
  • Kronolith_LoginTasks_SystemTask_Upgrade
  • Kronolith_LoginTasks_Task_PurgeEvents
  • Kronolith_Notification_Listener_AjaxStatus
  • Kronolith_Resource
  • Kronolith_Resource_Base
  • Kronolith_Resource_Group
  • Kronolith_Resource_Single
  • Kronolith_Storage
  • Kronolith_Storage_Kolab
  • Kronolith_Storage_Sql
  • Kronolith_Tagger
  • Kronolith_Test
  • Kronolith_View_Day
  • Kronolith_View_DeleteEvent
  • Kronolith_View_EditEvent
  • Kronolith_View_Event
  • Kronolith_View_ExportEvent
  • Kronolith_View_Month
  • Kronolith_View_Week
  • Kronolith_View_WorkWeek
  • Kronolith_View_Year
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * The Kronolith_View_Year:: class provides an API for viewing years.
  4:  *
  5:  * @author  Chuck Hagenbuch <chuck@horde.org>
  6:  * @author  Jan Schneider <jan@horde.org>
  7:  * @package Kronolith
  8:  */
  9: class Kronolith_View_Year
 10: {
 11:     public $year;
 12:     protected $_events = array();
 13: 
 14:     /**
 15:      *
 16:      * @param Horde_Date $date
 17:      *
 18:      * @return Kronolith_View_Year
 19:      */
 20:     public function __construct(Horde_Date $date)
 21:     {
 22:         $this->year = $date->year;
 23:         $startDate = new Horde_Date(array('year' => $this->year,
 24:                                           'month' => 1,
 25:                                           'mday' => 1));
 26:         $endDate = new Horde_Date(array('year' => $this->year,
 27:                                         'month' => 12,
 28:                                         'mday' => 31));
 29: 
 30:         try {
 31:             $this->_events = Kronolith::listEvents($startDate, $endDate, $GLOBALS['display_calendars']);
 32:         } catch (Exception $e) {
 33:             $GLOBALS['notification']->push($e, 'horde.error');
 34:             $this->_events = array();
 35:         }
 36:         if (!is_array($this->_events)) {
 37:             $this->_events = array();
 38:         }
 39:     }
 40: 
 41:     public function html()
 42:     {
 43:         global $prefs;
 44: 
 45:         require KRONOLITH_TEMPLATES . '/year/head.inc';
 46: 
 47:         $html = '<table class="nopadding" cellspacing="5" width="100%"><tr>';
 48:         for ($month = 1; $month <= 12; ++$month) {
 49:             $html .= '<td valign="top">';
 50: 
 51:             // Heading for each month.
 52:             $date = new Horde_Date(sprintf('%04d%02d01010101', $this->year, $month));
 53:             $mtitle = $date->strftime('%B');
 54:             $html .= '<h2 class="smallheader"><a class="smallheader" href="'
 55:                 . Horde::url('month.php')
 56:                 ->add('date', $date->dateString())
 57:                 . '">' . $mtitle . '</a></h2>'
 58:                 . '<table class="nopadding monthgrid" cellspacing="0" width="100%"><thead><tr class="item">';
 59:             if (!$prefs->getValue('week_start_monday')) {
 60:                 $html .= '<th>' . _("Su"). '</th>';
 61:             }
 62:             $html .= '<th>' . _("Mo") . '</th>' .
 63:                 '<th>' . _("Tu") . '</th>' .
 64:                 '<th>' . _("We") . '</th>' .
 65:                 '<th>' . _("Th") . '</th>' .
 66:                 '<th>' . _("Fr") . '</th>' .
 67:                 '<th>' . _("Sa") . '</th>';
 68:             if ($prefs->getValue('week_start_monday')) {
 69:                 $html .= '<th>' . _("Su") . '</th>';
 70:             }
 71:             $html .= '</tr></thead><tbody><tr>';
 72: 
 73:             $startday = new Horde_Date(array('mday' => 1,
 74:                                              'month' => $month,
 75:                                              'year' => $this->year));
 76:             $startday = $startday->dayOfWeek();
 77: 
 78:             $daysInView = Date_Calc::weeksInMonth($month, $this->year) * 7;
 79:             if (!$prefs->getValue('week_start_monday')) {
 80:                 $startOfView = 1 - $startday;
 81: 
 82:                 // We may need to adjust the number of days in the
 83:                 // view if we're starting weeks on Sunday.
 84:                 if ($startday == Horde_Date::DATE_SUNDAY) {
 85:                     $daysInView -= 7;
 86:                 }
 87:                 $endday = new Horde_Date(array('mday' => Horde_Date_Utils::daysInMonth($month, $this->year),
 88:                                                'month' => $month,
 89:                                                'year' => $this->year));
 90:                 $endday = $endday->dayOfWeek();
 91:                 if ($endday == Horde_Date::DATE_SUNDAY) {
 92:                     $daysInView += 7;
 93:                 }
 94:             } else {
 95:                 if ($startday == Horde_Date::DATE_SUNDAY) {
 96:                     $startOfView = -5;
 97:                 } else {
 98:                     $startOfView = 2 - $startday;
 99:                 }
100:             }
101: 
102:             $currentCalendars = array(true);
103:             foreach ($currentCalendars as $id => $cal) {
104:                 $cell = 0;
105:                 for ($day = $startOfView; $day < $startOfView + $daysInView; ++$day) {
106:                     $date = new Kronolith_Day($month, $day, $this->year);
107:                     $date->hour = $prefs->getValue('twentyFour') ? 12 : 6;
108:                     $week = $date->weekOfYear();
109: 
110:                     if ($cell % 7 == 0 && $cell != 0) {
111:                         $html .= "</tr>\n<tr>";
112:                     }
113:                     if ($date->month != $month) {
114:                         $style = 'monthgrid';
115:                     } elseif ($date->dayOfWeek() == 0 || $date->dayOfWeek() == 6) {
116:                         $style = 'weekend';
117:                     } else {
118:                         $style = 'text';
119:                     }
120: 
121:                     /* Set up the link to the day view. */
122:                     $url = Horde::url('day.php', true)
123:                         ->add('date', $date->dateString());
124: 
125:                     if ($date->month != $month) {
126:                         $cellday = '&nbsp;';
127:                     } elseif (!empty($this->_events[$date->dateString()])) {
128:                         /* There are events; create a cell with tooltip to list
129:                          * them. */
130:                         $day_events = '';
131:                         foreach ($this->_events[$date->dateString()] as $event) {
132:                             if ($event->status == Kronolith::STATUS_CONFIRMED) {
133:                                 /* Set the background color to distinguish the
134:                                  * day */
135:                                 $style = 'year-event';
136:                             }
137: 
138:                             if ($event->isAllDay()) {
139:                                 $day_events .= _("All day");
140:                             } else {
141:                                 $day_events .= $event->start->strftime($prefs->getValue('twentyFour') ? '%R' : '%I:%M%p') . '-' . $event->end->strftime($prefs->getValue('twentyFour') ? '%R' : '%I:%M%p');
142:                             }
143:                             $day_events .= ':'
144:                                 . ($event->getLocation() ? ' (' . $event->getLocation() . ')' : '')
145:                                 . ' ' . $event->getTitle() . "\n";
146:                         }
147:                         /* Bold the cell if there are events. */
148:                         $cellday = '<strong>' . Horde::linkTooltip($url, _("View Day"), '', '', '', $day_events) . $date->mday . '</a></strong>';
149:                     } else {
150:                         /* No events, plain link to the day. */
151:                         $cellday = Horde::linkTooltip($url, _("View Day")) . $date->mday . '</a>';
152:                     }
153:                     if ($date->isToday() && $date->month == $month) {
154:                         $style .= ' today';
155:                     }
156: 
157:                     $html .= '<td align="center" class="' . $style . '" height="10" width="5%" valign="top">' .
158:                         $cellday . '</td>';
159:                     ++$cell;
160:                 }
161:             }
162: 
163:             $html .= '</tr></tbody></table></td>';
164:             if ($month % 3 == 0 && $month != 12) {
165:                 $html .= '</tr><tr>';
166:             }
167:         }
168: 
169:         echo $html . '</tr></table>';
170:     }
171: 
172:     public function link($offset = 0, $full = false)
173:     {
174:         return Horde::url('year.php', $full)
175:             ->add('date', ($this->year + $offset) . '0101');
176:     }
177: 
178:     public function getName()
179:     {
180:         return 'Year';
181:     }
182: 
183: }
184: 
API documentation generated by ApiGen