/** * @return string * @permissions view */ protected function actionRenderCalendar() { $strReturn = ""; $strContent = ""; $arrJsHighlights = array(); $strReturn .= "<content><![CDATA["; /** @var interface_calendarsource_admin[] $arrRelevantModules */ $arrRelevantModules = array(); //fetch modules relevant for processing $arrModules = class_module_system_module::getAllModules(); foreach ($arrModules as $objSingleModule) { if ($objSingleModule->getIntRecordStatus() == 1 && $objSingleModule->getAdminInstanceOfConcreteModule() instanceof interface_calendarsource_admin) { $arrRelevantModules[] = $objSingleModule->getAdminInstanceOfConcreteModule(); } } //the header row $arrWeekdays = explode(",", $this->getLang("calendar_weekday")); foreach ($arrWeekdays as $intKey => $strValue) { $arrWeekdays[$intKey] = trim(uniStrReplace("\"", "", $strValue)); } $strContent .= $this->objToolkit->getCalendarHeaderRow($arrWeekdays); //render the single rows. calculate the first day of the row $objDate = new class_date(); $objDate->setIntDay(1); //set to interval stored in session if ($this->objSession->getSession($this->strStartMonthKey) != "") { $objDate->setIntMonth($this->objSession->getSession($this->strStartMonthKey)); } if ($this->objSession->getSession($this->strStartYearKey) != "") { $objDate->setIntYear($this->objSession->getSession($this->strStartYearKey)); } $intCurMonth = $objDate->getIntMonth(); $intCurYear = $objDate->getIntYear(); $objToday = new class_date(); //start by monday while ($objDate->getIntDayOfWeek() != 1) { $objDate->setPreviousDay(); } $strEntries = ""; $intRowEntryCount = 0; while ($objDate->getIntMonth() <= $intCurMonth && $objDate->getIntYear() <= $intCurYear || $objDate->getIntMonth() == 12 && $objDate->getIntYear() < $intCurYear || $intRowEntryCount % 7 != 0) { $intRowEntryCount++; $strDate = $objDate->getIntDay(); $arrEvents = array(); if ($objDate->getIntMonth() == $intCurMonth) { //Query modules for dates $objStartDate = clone $objDate; $objStartDate->setIntHour(0)->setIntMin(0)->setIntSec(0); $objEndDate = clone $objDate; $objEndDate->setIntHour(23)->setIntMin(59)->setIntSec(59); foreach ($arrRelevantModules as $objOneModule) { $arrEvents = array_merge($objOneModule->getArrCalendarEntries($objStartDate, $objEndDate), $arrEvents); } } while (count($arrEvents) <= 3) { $objDummy = new class_calendarentry(); $objDummy->setStrClass("spacer"); $objDummy->setStrName(" "); $arrEvents[] = $objDummy; } $strEvents = ""; /** @var class_calendarentry $objOneEvent */ foreach ($arrEvents as $objOneEvent) { $strName = $objOneEvent->getStrName(); $strSecondLine = $objOneEvent->getStrSecondLine(); if ($strSecondLine != "") { $strSecondLine = "<br />" . $strSecondLine; } //register mouse-over highlight relations if ($objOneEvent->getStrHighlightId() != "" && $objOneEvent->getStrSystemid() != "") { if (!isset($arrJsHighlights[$objOneEvent->getStrHighlightId()])) { $arrJsHighlights[$objOneEvent->getStrHighlightId()] = array(); } $arrJsHighlights[$objOneEvent->getStrHighlightId()][] = $objOneEvent->getStrSystemid(); } $strEvents .= $this->objToolkit->getCalendarEvent($strName . $strSecondLine, $objOneEvent->getStrSystemid(), $objOneEvent->getStrHighlightId(), $objOneEvent->getStrClass()); } $bitBlocked = false; if ($objDate->getIntDayOfWeek() == 0 || $objDate->getIntDayOfWeek() == 6) { $bitBlocked = true; } $strToday = ""; if ($objToday->getIntYear() == $objDate->getIntYear() && $objToday->getIntMonth() == $objDate->getIntMonth() && $objToday->getIntDay() == $objDate->getIntDay()) { $strToday = " calendarDateToday"; } if ($objDate->getIntMonth() != $intCurMonth) { $strEntries .= $this->objToolkit->getCalendarEntry($strEvents, $strDate, "calendarEntryOutOfRange" . $strToday); } else { if ($bitBlocked) { $strEntries .= $this->objToolkit->getCalendarEntry($strEvents, $strDate, "calendarEntryBlocked" . $strToday); } else { $strEntries .= $this->objToolkit->getCalendarEntry($strEvents, $strDate, "calendarEntry" . $strToday); } } if ($intRowEntryCount % 7 == 0) { $strContent .= $this->objToolkit->getCalendarRow($strEntries); $strEntries = ""; } $objDate->setNextDay(); } if ($strEntries != "") { $strContent .= $this->objToolkit->getCalendarRow($strEntries); } $strReturn .= $this->objToolkit->getCalendarWrapper($strContent); //build js-arrays $strJs = "<script type=\"text/javascript\">"; foreach ($arrJsHighlights as $strCommonId => $arrEntries) { $strJs .= " var kj_cal_" . $strCommonId . " = new Array();"; foreach ($arrEntries as $strOneIdentifier) { $strJs .= "kj_cal_" . $strCommonId . ".push('" . $strOneIdentifier . "');"; } } $strJs .= "</script>"; $strReturn .= $strJs; $strReturn .= "]]></content>"; return $strReturn; }
/** * @see interface_calendarsource_admin::getArrCalendarEntries() */ public function getArrCalendarEntries(class_date $objStartDate, class_date $objEndDate) { $arrEntries = array(); if ($this->objSession->getSession(self::STR_CALENDAR_FILTER_EVENT) != "disabled") { $arrEvents = class_module_eventmanager_event::getAllEvents(null, null, $objStartDate, $objEndDate); foreach ($arrEvents as $objOneEvent) { $objEntry = new class_calendarentry(); $strAlt = $this->getLang("calendar_type_event"); $strTitle = $objOneEvent->getStrTitle(); if (uniStrlen($strTitle) > 15) { $strAlt = $strTitle . "<br />" . $strAlt; $strTitle = uniStrTrim($strTitle, 14); } $strName = getLinkAdmin($this->arrModule["modul"], "edit", "&systemid=" . $objOneEvent->getSystemid(), $strTitle, $strAlt); $objEntry->setStrName($strName); $arrEntries[] = $objEntry; } } return $arrEntries; }
/** * @see interface_calendarsource_admin::getArrCalendarEntries() */ public function getArrCalendarEntries(class_date $objStartDate, class_date $objEndDate) { $arrEntries = array(); if ($this->objSession->getSession(self::STR_CALENDAR_FILTER_NEWS) != "disabled") { $arrNews = class_module_news_news::getObjectList("", null, null, $objStartDate, $objEndDate); foreach ($arrNews as $objOneNews) { $objEntry = new class_calendarentry(); $objEntry->setStrClass("calendarEvent calendarNews"); $strAlt = $this->getLang("calendar_type_news"); $strTitle = $objOneNews->getStrTitle(); if (uniStrlen($strTitle) > 15) { $strAlt = $strTitle . "<br />" . $strAlt; $strTitle = uniStrTrim($strTitle, 14); } $strName = class_link::getLinkAdmin($this->getArrModule("modul"), "edit", "&systemid=" . $objOneNews->getSystemid(), $strTitle, $strAlt); $objEntry->setStrName($strName); $arrEntries[] = $objEntry; } } return $arrEntries; }