* @package WB */ WBClass::load('WBDatasource_Calendar_Decorator'); /** * Datasource Calendar Decorator Public Calendar * * Add mandator's calender records * * @version 0.1.2 * @package WB */ class WBDatasource_Calendar_Decorator_CalendarEvent extends WBDatasource_Calendar_Decorator { /** * Decorator Config * @var array */ protected $config = array( 'calendar' => '-1' ); /** * @var WBDatasource_Calendar_Event */ private $event; /** * @var WBDictionary_URL */ private $url; /** * 2nd Constructor */ protected function init() { /** @var WBMandator */ $man = WBClass::create('WBMandator'); $man->setId($this->config[$man->getIdentifier()]); $parameter = array( 'mandator' => $man ); $this->event = WBClass::create('WBDatasource_Calendar_Event', $parameter); $this->event->setCalendarId($this->config['calendar']); $this->url = WBClass::create('WBDictionary_URL'); } /** * Decorate Day * * @param DateTime * @param array data of complete week * @param int week day 1 to 7 */ public function decorateDay($date, &$week, $dow) { $this->event->setDay($date->format('Y-m-d')); $list = $this->event->getList(); $urlP = $this->url->getIdentifier(); foreach ($list as $l) { $i = array( 'xid' => $l['id'], 'xtype' => 'calendarevent', 'timestamp' => $l['timestampstart'], 'start' => $l['timestampstart'], 'starttime' => '', 'startday' => '', 'end' => $l['timestampend'], 'endtime' => '', 'endday' => '', 'url' => '', 'urltype' => 'http', 'shopurl' => '', 'shopurltext' => $l['shopurltext'], 'shopurltype' => 'http', 'class' => 'wb-calendar-event', 'title' => $l['title'], 'brief' => $l['brief'], 'blurb' => $l['blurb'], ); if (!empty($l[$urlP])) { $this->url->load($l[$urlP]); $i['url'] = $this->url->getWord(); $url = $this->url->get(); if ('mailto' == $url['protocol']) { $i['urltype'] = 'mailto'; } } if (!empty($l['shop' . $urlP])) { $this->url->load($l['shop' . $urlP]); $i['shopurl'] = $this->url->getWord(); $url = $this->url->get(); if ('mailto' == $url['protocol']) { $i['shopurltype'] = 'mailto'; } } $t0 = explode(' ', $l['timestampstart']); $t1 = explode(' ', $l['timestampend']); if ('00:00:00' != $t0[1]) { $i['starttime'] = $t0[1]; $i['endtime'] = $t1[1]; } $i['startday'] = $t0[0]; if ('1970-01-01' != $t1[0]) { $i['endday'] = $t1[0]; } $week['day'. $dow. '_item'][] = $i; } } /** * Decorate Week * * @param DateTime * @param array data of complete week */ public function decorateWeek($date, &$week) { } }