function month($tpl = null) { $fcp = new FrontCalendarPage(); $model =& $this->getModel(); $this->assignRef('highlights', $model->getAnnouncement()); $list = $fcp->formatEntries($model->getList()); $selected = $model->getSelected(); $this->assignRef('selected', $selected); $options = $model->getOptions(); $this->assignRef('options', $options); $selectedTime = CalendarForm::getMonthStart($selected); $mondayStart = true; $grid = $fcp->setMonthGrid($selectedTime, $list, $mondayStart); $this->assignRef('grid', $grid); $this->assignRef('weekday', date("w")); $this->assignRef('events', $list); $curview = date("F Y", $selectedTime); $curmonth = $selected->getMonth(); $curyear = $selected->getYear(); $prevmonth = intval($selected->getMonth()) - 1 > 0 ? intval($selected->getMonth()) - 1 : 12; $prevyear = $prevmonth == 12 ? intval($selected->getYear()) - 1 : $selected->getYear(); $nextmonth = intval($selected->getMonth()) + 1 < 13 ? intval($selected->getMonth()) + 1 : 1; $nextyear = $nextmonth == 1 ? intval($selected->getYear()) + 1 : $selected->getYear(); $this->assignRef('cur_view', $curview); $this->assignRef('cur_month', $curmonth); $this->assignRef('cur_year', $curyear); $this->assignRef('prev_month', $prevmonth); $this->assignRef('prev_year', $prevyear); $this->assignRef('next_month', $nextmonth); $this->assignRef('next_year', $nextyear); $heading = "Calendar of Events: " . $this->cur_view; $document =& JFactory::getDocument(); $document->setTitle($heading); parent::display($tpl); }
/** * Returns the last second for the identified * month in the given CalendarForm. * @param bean CalendarForm * @return int (timestamp) last second of given month */ public function getMonthEnd($cal) { global $logger; $logger->debug(get_class($this) . "::getMonthEnd({$cal})"); $start = CalendarForm::getMonthStart($cal); $days = date('t', $start); return mktime(23, 59, 59, $cal->getMonth(), $days, $cal->getYear()); }
/** * Compiles the list of events and activities for the calendar * @param object $mainframe The Joomla specific page object * @return bean summary page model bean */ private function setSummaries($mainframe) { global $mosConfig_live_site, $logger; $logger->debug(get_class($this) . "::setSummaries()"); $ss = $this->getScheduleService(); $model = new SummaryPageModel(); $cal = $this->getBeanFromRequest(); $start = CalendarForm::getMonthStart($cal); $end = CalendarForm::getMonthEnd($cal); if (FrontCalendarAction::USE_PROMOS) { $promos = $this->getPromos(); $list = array(); for ($i = 0; $i < count($promos); $i++) { $promo = $promos[$i]; $list[] = $promo; } $model->setAnnouncement($list); } // get the list of schedules for their oids $schedules = $ss->getSchedulesForRange($start, $end); // get the events for the scheudles in the range $es = $this->getEventService(); $events = array(); $cals = array(); foreach ($schedules as $sched) { $logger->debug("Finding event by schedule id: " . $sched->getOid()); $event = $es->getEventBySchedule($sched); $logger->debug("The event has a title of: " . $event->getTitle()); // only add published events if ($event->getPubState() == 'Published') { // start time if ($sched->getStartTime() > $start) { $events[] = $event; if ($this->isFilter($event)) { $cals[] = $this->setCalendarEntry($sched, $event); } } // exhibition end time if ($event->getScope() == Event::EXHIBITION && $sched->getEndTime() < $end) { $events[] = $event; if ($this->isFilter($event)) { $cals[] = $this->setCalendarEntry($sched, $event, true); } } } } $logger->debug("Number of events: " . count($events)); $model->setSelected($cal); $model->setList($cals); $model->setOptions($this->getOptions($events)); return $model; }
/** * A shared private method used to render the common * controls. * * @access private * @param template $tmpl the template object * @param model $model the page model */ function renderControls($tmpl, $model) { global $mainframe; $options = $model->getOptions(); $selected = $model->getSelected(); $selectedTime = CalendarForm::getMonthStart($selected); // set the select lists $months = $options['month']; for ($i = 0; $i < count($months['value']); $i++) { $tmpl->addVar('month_options', 'value', $months['value'][$i]); $tmpl->addVar('month_options', 'text', $months['text'][$i]); if ($months['value'][$i] == $selected->getMonth()) { $tmpl->addVar('month_options', 'selected', 'selected'); } else { $tmpl->addVar('month_options', 'selected', ''); } $tmpl->parseTemplate('month_options', 'a'); } $years = $options['year']; for ($i = 0; $i < count($years['value']); $i++) { $tmpl->addVar('year_options', 'value', $years['value'][$i]); if ($years['value'][$i] == $selected->getYear()) { $tmpl->addVar('year_options', 'selected', 'selected'); } else { $tmpl->addVar('year_options', 'selected', ''); } $tmpl->parseTemplate('year_options', 'a'); } $categories = $options['category']; foreach ($categories as $cat) { $tmpl->addVar('category_options', 'coid', $cat['oid']); $tmpl->addVar('category_options', 'name', $cat['name']); if ($cat['oid'] == $selected->getCategory()) { $tmpl->addVar('category_options', 'selected', 'selected'); } else { $tmpl->addVar('category_options', 'selected', ''); } $tmpl->parseTemplate('category_options', 'a'); } $control['cur_view'] = date("F Y", $selectedTime); $control['cur_month'] = $selected->getMonth(); $control['cur_year'] = $selected->getYear(); $control['prev_month'] = intval($selected->getMonth()) - 1 > 0 ? intval($selected->getMonth()) - 1 : 12; $control['prev_month_year'] = $control['prev_month'] == 12 ? intval($selected->getYear()) - 1 : $selected->getYear(); $control['next_month'] = intval($selected->getMonth()) + 1 < 13 ? intval($selected->getMonth()) + 1 : 1; $control['next_month_year'] = $control['next_month'] == 1 ? intval($selected->getYear()) + 1 : $selected->getYear(); // page title $mainframe->setPageTitle("Calendar of Events | " . $control['cur_view']); // add the menu marker if (isset($_REQUEST['ccmenu'])) { $control['ccmenu'] = $_REQUEST['ccmenu']; } $cal_link = $this->cceventSefUrl('index.php?option=com_ccevents&scope=cldr&task=month&month=' . $selected->getMonth() . '&year=' . $selected->getYear()); $tmpl->addVar('calendar', 'cal_view_link', $cal_link); $tmpl->addVars('calendar', $control); }