/** * Displays all available events. * * @return string HTML Code */ public function view() { // check object type $objectType = FormUtil::getPassedValue('ot', 'event', 'GET'); $this->throwNotFoundUnless(in_array($objectType, TimeIt_Util::getObjectTypes('view')), $this->__f('Unkown object type %s.', DataUtil::formatForDisplay($objectType))); // load filter $filter = TimeIt_Filter_Container::getFilterFormGETPOST($objectType); $this->view->assign('modvars', ModUtil::getVar('TimeIt')); // vars $tpl = null; $theme = null; $domain = $this->serviceManager->getService('timeit.manager.' . $objectType); // load the data if ($objectType == 'event') { $calendarId = (int) FormUtil::getPassedValue('cid', ModUtil::getVar('TimeIt', 'defaultCalendar'), 'GETPOST'); $calendar = $this->serviceManager->getService('timeit.manager.calendar')->getObject($calendarId); $this->throwNotFoundIf(empty($calendar), $this->__f('Calendar [%s] not found.', $calendarId)); $year = (int) FormUtil::getPassedValue('year', date("Y"), 'GETPOST'); $month = (int) FormUtil::getPassedValue('month', date("n"), 'GETPOST'); $day = (int) FormUtil::getPassedValue('day', date("j"), 'GETPOST'); $tpl = FormUtil::getPassedValue('viewType', FormUtil::getPassedValue('viewtype', $calendar['config']['defaultView'], 'GETPOST'), 'GETPOST'); $firstDayOfWeek = (int) FormUtil::getPassedValue('firstDayOfWeek', -1, 'GETPOST'); $theme = FormUtil::getPassedValue('template', $calendar['config']['defaultTemplate'], 'GETPOST'); // backward compatibility if ($theme == 'default') { $theme = 'table'; } // check for a valid $tpl if ($tpl != 'year' && $tpl != 'month' && $tpl != 'week' && $tpl != 'day') { $tpl = $calendar['config']['defaultView']; } $tpl = 'month'; $theme = 'table'; $this->view->assign('template', $theme); $this->view->assign('viewed_day', $day); $this->view->assign('viewed_month', $month); $this->view->assign('viewed_year', $year); $this->view->assign('viewType', $tpl); $this->view->assign('calendar', $calendar); $this->view->assign('viewed_date', DateUtil::getDatetime(mktime(0, 0, 0, $month, $day, $year), DATEONLYFORMAT_FIXED)); $this->view->assign('date_today', DateUtil::getDatetime(null, DATEONLYFORMAT_FIXED)); $this->view->assign('month_startDate', DateUtil::getDatetime(mktime(0, 0, 0, $month, 1, $year), DATEONLYFORMAT_FIXED)); $this->view->assign('month_endDate', DateUtil::getDatetime(mktime(0, 0, 0, $month, DateUtil::getDaysInMonth($month, $year), $year), DATEONLYFORMAT_FIXED)); $this->view->assign('filter_obj_url', $filter->toURL()); $this->view->assign('firstDayOfWeek', $firstDayOfWeek); $this->view->assign('selectedCats', array()); $categories = CategoryRegistryUtil::getRegisteredModuleCategories('TimeIt', 'TimeIt_events'); foreach ($categories as $property => $cid) { $cat = CategoryUtil::getCategoryByID($cid); if (isset($cat['__ATTRIBUTES__']['calendarid']) && !empty($cat['__ATTRIBUTES__']['calendarid'])) { if ($cat['__ATTRIBUTES__']['calendarid'] != $calendar['id']) { unset($categories[$property]); } } } $this->view->assign('categories', $categories); // load event data switch ($tpl) { case 'year': $objectData = $domain->getYearEvents($year, $calendar['id'], $firstDayOfWeek); break; case 'month': $objectData = $domain->getMonthEvents($year, $month, $day, $calendar['id'], $firstDayOfWeek, $filter); break; case 'week': $objectData = $domain->getWeekEvents($year, $month, $day, $calendar['id'], $filter); break; case 'day': $objectData = $domain->getDayEvents($year, $month, $day, $calendar['id'], $filter); break; } } // assign the data $this->view->assign('objectArray', $objectData); // render the html return $this->_renderTemplate($this->view, $objectType, 'user', 'view', $theme, $tpl, 'table'); }