Beispiel #1
0
 public function generateUrl($arrPages)
 {
     $arrPages = array();
     $Event = \CalendarEventsModel::findAll();
     if (empty($Event)) {
         return array();
     }
     $arrEvent = array();
     while ($Event->next()) {
         $objCalendar = \CalendarModel::findByPk($Event->pid);
         if ($objCalendar !== null && $objCalendar->jumpTo && ($objTarget = $objCalendar->getRelated('jumpTo')) !== null) {
             $arrEvent[$Event->pid][] = $this->generateEventUrl($Event, $this->generateFrontendUrl($objTarget->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/events/%s'));
         }
     }
     $InactiveArchives = \GlossarCalendarModel::findByPidsAndInactiveGlossar(array_keys($arrEvent));
     if (!empty($InactiveArchives)) {
         while ($InactiveArchives->next()) {
             unset($arrEvent[$InactiveArchives->id]);
         }
     }
     if (empty($arrEvent)) {
         return array();
     }
     $EventReader = \ModuleModel::findByType('eventreader');
     if (empty($EventReader)) {
         return array();
     }
     $arrReader = array();
     while ($EventReader->next()) {
         $arrReader[$EventReader->id] = deserialize($EventReader->cal_calendar);
     }
     $Content = \ContentModel::findBy(array("module IN ('" . implode("','", array_keys($arrReader)) . "')"), array());
     if (empty($Content)) {
         return array();
     }
     $arrContent = array();
     while ($Content->next()) {
         $arrContent[$Content->module] = $Content->pid;
     }
     $Article = \ArticleModel::findBy(array("tl_article.id IN ('" . implode("','", $arrContent) . "')"), array());
     if (empty($Article)) {
         return array();
     }
     $finishedIDs = $arrPages = array();
     while ($Article->next()) {
         // $root = $this->getRootPage($Article->pid);
         $domain = \Environment::get('base');
         $strLanguage = 'de';
         $objPages = $Article->getRelated('pid');
         $ReaderId = false;
         foreach ($arrContent as $module => $mid) {
             if ($mid == $Article->id) {
                 $ReaderId = $module;
             }
         }
         foreach ($arrReader[$ReaderId] as $event_id) {
             if (in_array($event_id, $finishedIDs)) {
                 continue;
             }
             if (!empty($arrEvent[$event_id])) {
                 foreach ($arrEvent[$event_id] as $event_domain) {
                     $event_domain = str_replace('.html', '', $event_domain);
                     $arrPages['de'][] = $domain . static::generateFrontendUrl($objPages->row(), substr($event_domain, strpos($event_domain, '/')), $strLanguage);
                 }
             }
             $finishedIDs[] = $event_id;
         }
     }
     return $arrPages;
 }
 public function getIncludeItems(\DataContainer $dc)
 {
     $arrReturn = array();
     $strTable = '';
     $strDateKey = '';
     $strTitleKeyArchive = '';
     $strTitleKeyItem = '';
     $strPatternArchiveUrl = '%s';
     $strPatternItemUrl = '%s';
     if (!$dc->activeRecord->type) {
         return $arrReturn;
     }
     switch ($dc->activeRecord->type) {
         case 'nl_news':
             $strTable = 'tl_news';
             $strDateKey = 'date';
             $strTitleKeyItem = 'headline';
             $strTitleKeyArchive = 'title';
             $strPatternArchiveUrl = 'contao/main.php?do=news&id=%s&act=edit&popup=1&nb=1&rt=%s';
             $strPatternItemUrl = 'contao/main.php?do=news&id=%s&act=edit&popup=1&nb=1&rt=%s&table=%s';
             $objItems = \NewsModel::findAll(array('order' => $strTable . '.' . $strDateKey));
             break;
         case 'nl_events':
             $strTable = 'tl_calendar_events';
             $strDateKey = 'startDate';
             $strTitleKeyItem = 'title';
             $strTitleKeyArchive = 'title';
             $strPatternArchiveUrl = 'contao/main.php?do=calendar&id=%s&act=edit&popup=1&nb=1&rt=%s';
             $strPatternItemUrl = 'contao/main.php?do=calendar&id=%s&act=edit&popup=1&nb=1&rt=%s&table=%s';
             $objItems = \CalendarEventsModel::findAll(array('order' => $strTable . '.' . $strDateKey));
             break;
         default:
             return $arrReturn;
             break;
     }
     if (!is_null($objItems)) {
         foreach ($objItems as $objItem) {
             $objArchive = $objItem->getRelated('pid');
             $strDoArchive = ampersand(sprintf($strPatternArchiveUrl, $objItem->pid, REQUEST_TOKEN));
             $strDoItem = ampersand(sprintf($strPatternItemUrl, $objItem->id, REQUEST_TOKEN, $strTable));
             $strDateField = \Date::parse(\Config::get('dateFormat') ?: 'd.m.Y', $objItem->{$strDateKey}) . ' - ';
             $time = time();
             //"($t.start='' OR $t.start<$time) AND ($t.stop='' OR $t.stop>$time) AND $t.published=1";
             $blnPublished = (!$objItem->start || $objItem->start < $time) && (!$objItem->stop || $objItem->stop > $time) && $objItem->published;
             $arrReturn[$objItem->id] = sprintf('%s<strong><a%s href="%s" title="%s" onclick="Backend.openModalIframe({\'width\':768,\'title\':\'%s\',\'url\':this.href});return false">%s</a></strong> (<a href="%s" title="%s" onclick="Backend.openModalIframe({\'width\':768,\'title\':\'%s\',\'url\':this.href});return false">%s</a>)', $strDateField, $blnPublished ? '' : ' style="color:#c33"', $strDoItem, sprintf(specialchars($GLOBALS['TL_LANG']['tl_content']['editalias'][1]), $objItem->id), sprintf(specialchars($GLOBALS['TL_LANG']['tl_content']['editalias'][1]), $objItem->id), $objItem->{$strTitleKeyItem}, $strDoArchive, sprintf(specialchars($GLOBALS['TL_LANG']['tl_content']['editalias'][1]), $objArchive->id), sprintf(specialchars($GLOBALS['TL_LANG']['tl_content']['editalias'][1]), $objArchive->id), $objArchive->{$strTitleKeyArchive});
         }
     }
     return $arrReturn;
 }
 public static function getRelatedEvents(\DataContainer $dc, array $arrRelation = array())
 {
     $arrOptionGroups = array();
     $arrOptions = array();
     // front end mode with module & relation context
     if (!empty($arrRelation)) {
         $objEvents = \CalendarEventsModel::findUpcomingByPids(deserialize($dc->objModule->cal_calendar, true), 0, array('order' => 'title'));
     } else {
         $objEvents = \CalendarEventsModel::findAll();
     }
     if ($objEvents === null) {
         return $arrOptions;
     }
     while ($objEvents->next()) {
         // return as optgroup if more than 1 $arrPids
         if (($objArchive = $objEvents->getRelated('pid')) === null) {
             continue;
         }
         $arrOptionGroups[$objArchive->title][$objEvents->id] = $objEvents->title;
         $arrOptions[$objEvents->id] = $objEvents->title;
     }
     $arrDca =& $GLOBALS['TL_DCA']['tl_submission'];
     // filter menu does not support optgroups
     if (TL_MODE == 'BE' && $dc->field != 'event') {
         return $arrOptions;
     }
     // remove optgroups if not wanted, or less than 2 optgroups
     if (count($arrOptionGroups) == 1 || $arrDca['fields'][$arrRelation['submissionField']]['eval']['optgroup'] === false) {
         return $arrOptions;
     }
     return $arrOptionGroups;
 }