/**
  * Make DCA as read only if calendar is set as churchtools calendar.
  * 
  */
 public function disableCalendarFunctions()
 {
     $id = strlen(Input::get('id')) ? Input::get('id') : CURRENT_ID;
     $calendar = \CalendarModel::findByPk($id);
     if ($calendar->churchtoolsEnableEvents) {
         unset($GLOBALS['TL_DCA']['tl_calendar_events']['list']['global_operations']['all']);
         $GLOBALS['TL_DCA']['tl_calendar_events']['config']['closed'] = true;
         unset($GLOBALS['TL_DCA']['tl_calendar_events']['list']['operations']['edit']);
         unset($GLOBALS['TL_DCA']['tl_calendar_events']['list']['operations']['editheader']);
         unset($GLOBALS['TL_DCA']['tl_calendar_events']['list']['operations']['copy']);
         unset($GLOBALS['TL_DCA']['tl_calendar_events']['list']['operations']['delete']);
         unset($GLOBALS['TL_DCA']['tl_calendar_events']['list']['operations']['toggle']);
         unset($GLOBALS['TL_DCA']['tl_calendar_events']['list']['operations']['cut']);
     }
 }
 /**
  * Load events from churchtools api based on calendar settings
  * Deletes all events in databse, so temporary changes will get lost
  *
  * @param /DataContainer $dc
  */
 public static function loadAndParseEvents($dc)
 {
     $calendar = \CalendarModel::findByPk($dc->id);
     $arrCategoryIds = deserialize($calendar->churchtoolsCalendars);
     $api = new ChurchtoolsApi();
     $events = $api->loadEvents($arrCategoryIds, $calendar->churchtoolsDaysFrom, $calendar->churchtoolsDaysTo);
     //Clear Database
     $collection = \CalendarEventsModel::findByPid($dc->id);
     if (isset($collection)) {
         while ($collection->next()) {
             $collection->delete();
         }
     }
     foreach ($events as $event) {
         $startdate = new \DateTime($event->startdate);
         $enddate = new \DateTime($event->enddate);
         $fullDayEvent = $startdate->format('His') == 00 && $enddate->format('His') == 00 ? true : false;
         $model = new \CalendarEventsModel();
         $model->pid = $dc->id;
         $model->tstamp = time();
         $model->title = $event->bezeichnung;
         //$model->alias =
         //$model->author =
         if (!$fullDayEvent) {
             $model->addTime = 1;
             $model->startTime = $startdate->getTimestamp();
             $model->endTime = $enddate->getTimestamp();
         } else {
             $model->startTime = $startdate->getTimestamp();
             $model->endTime = $enddate->getTimestamp();
         }
         $model->startDate = $startdate->getTimestamp();
         if ($startdate != $enddate) {
             $model->endDate = $enddate->getTimestamp();
         }
         //$model->location =
         //$model->teaser =
         $model->published = 1;
         $model->save();
     }
     if (\Input::get('key')) {
         \Controller::redirect(preg_replace('/(&(amp;)?|\\?)key=[^& ]*/i', '', \Environment::get('request')));
     }
 }
Beispiel #3
0
 /**
  * Replace insert tags with their values
  * 
  * @param string  $strBuffer The text with the tags to be replaced
  * @param boolean $blnCache  If true, some tags will be preserved
  * 
  * @return string The text with the replaced tags
  */
 protected function replaceInsertTags($strBuffer, $blnCache = false)
 {
     global $objPage;
     // Preserve insert tags
     if ($GLOBALS['TL_CONFIG']['disableInsertTags']) {
         return $this->restoreBasicEntities($strBuffer);
     }
     $tags = preg_split('/\\{\\{([^\\}]+)\\}\\}/', $strBuffer, -1, PREG_SPLIT_DELIM_CAPTURE);
     $strBuffer = '';
     $arrCache = array();
     for ($_rit = 0; $_rit < count($tags); $_rit = $_rit + 2) {
         $strBuffer .= $tags[$_rit];
         $strTag = $tags[$_rit + 1];
         // Skip empty tags
         if ($strTag == '') {
             continue;
         }
         // Load value from cache array
         if (isset($arrCache[$strTag])) {
             $strBuffer .= $arrCache[$strTag];
             continue;
         }
         $elements = explode('::', $strTag);
         // Skip certain elements if the output will be cached
         if ($blnCache) {
             if ($elements[0] == 'date' || $elements[0] == 'ua' || $elements[0] == 'file' || $elements[1] == 'back' || $elements[1] == 'referer' || $elements[0] == 'request_token' || strncmp($elements[0], 'cache_', 6) === 0) {
                 $strBuffer .= '{{' . $strTag . '}}';
                 continue;
             }
         }
         $arrCache[$strTag] = '';
         // Replace the tag
         switch (strtolower($elements[0])) {
             // Date
             case 'date':
                 $arrCache[$strTag] = $this->parseDate($elements[1] ?: $GLOBALS['TL_CONFIG']['dateFormat']);
                 break;
                 // Accessibility tags
             // Accessibility tags
             case 'lang':
                 if ($elements[1] == '') {
                     $arrCache[$strTag] = '</span>';
                 } elseif ($objPage->outputFormat == 'xhtml') {
                     $arrCache[$strTag] = '<span lang="' . $elements[1] . '" xml:lang="' . $elements[1] . '">';
                 } else {
                     $arrCache[$strTag] = $arrCache[$strTag] = '<span lang="' . $elements[1] . '">';
                 }
                 break;
                 // E-mail addresses
             // E-mail addresses
             case 'email':
             case 'email_open':
             case 'email_url':
                 if ($elements[1] == '') {
                     $arrCache[$strTag] = '';
                     break;
                 }
                 $strEmail = \String::encodeEmail($elements[1]);
                 // Replace the tag
                 switch (strtolower($elements[0])) {
                     case 'email':
                         $arrCache[$strTag] = '<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;' . $strEmail . '" class="email">' . preg_replace('/\\?.*$/', '', $strEmail) . '</a>';
                         break;
                     case 'email_open':
                         $arrCache[$strTag] = '<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;' . $strEmail . '" class="email">';
                         break;
                     case 'email_url':
                         $arrCache[$strTag] = $strEmail;
                         break;
                 }
                 break;
                 // Label tags
             // Label tags
             case 'label':
                 $keys = explode(':', $elements[1]);
                 if (count($keys) < 2) {
                     $arrCache[$strTag] = '';
                     break;
                 }
                 $this->loadLanguageFile($keys[0]);
                 if (count($keys) == 2) {
                     $arrCache[$strTag] = $GLOBALS['TL_LANG'][$keys[0]][$keys[1]];
                 } else {
                     $arrCache[$strTag] = $GLOBALS['TL_LANG'][$keys[0]][$keys[1]][$keys[2]];
                 }
                 break;
                 // Front end user
             // Front end user
             case 'user':
                 if (FE_USER_LOGGED_IN) {
                     $this->import('FrontendUser', 'User');
                     $value = $this->User->{$elements}[1];
                     if ($value == '') {
                         $arrCache[$strTag] = $value;
                         break;
                     }
                     $this->loadDataContainer('tl_member');
                     if ($GLOBALS['TL_DCA']['tl_member']['fields'][$elements[1]]['inputType'] == 'password') {
                         $arrCache[$strTag] = '';
                         break;
                     }
                     $value = deserialize($value);
                     $rgxp = $GLOBALS['TL_DCA']['tl_member']['fields'][$elements[1]]['eval']['rgxp'];
                     $opts = $GLOBALS['TL_DCA']['tl_member']['fields'][$elements[1]]['options'];
                     $rfrc = $GLOBALS['TL_DCA']['tl_member']['fields'][$elements[1]]['reference'];
                     if ($rgxp == 'date') {
                         $arrCache[$strTag] = $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $value);
                     } elseif ($rgxp == 'time') {
                         $arrCache[$strTag] = $this->parseDate($GLOBALS['TL_CONFIG']['timeFormat'], $value);
                     } elseif ($rgxp == 'datim') {
                         $arrCache[$strTag] = $this->parseDate($GLOBALS['TL_CONFIG']['datimFormat'], $value);
                     } elseif (is_array($value)) {
                         $arrCache[$strTag] = implode(', ', $value);
                     } elseif (is_array($opts) && array_is_assoc($opts)) {
                         $arrCache[$strTag] = isset($opts[$value]) ? $opts[$value] : $value;
                     } elseif (is_array($rfrc)) {
                         $arrCache[$strTag] = isset($rfrc[$value]) ? is_array($rfrc[$value]) ? $rfrc[$value][0] : $rfrc[$value] : $value;
                     } else {
                         $arrCache[$strTag] = $value;
                     }
                     // Convert special characters (see #1890)
                     $arrCache[$strTag] = specialchars($arrCache[$strTag]);
                 }
                 break;
                 // Link
             // Link
             case 'link':
             case 'link_open':
             case 'link_url':
             case 'link_title':
                 // Back link
                 if ($elements[1] == 'back') {
                     $strUrl = 'javascript:history.go(-1)';
                     $strTitle = $GLOBALS['TL_LANG']['MSC']['goBack'];
                     // No language files if the page is cached
                     if (!strlen($strTitle)) {
                         $strTitle = 'Go back';
                     }
                     $strName = $strTitle;
                 } elseif (strncmp($elements[1], 'http://', 7) === 0 || strncmp($elements[1], 'https://', 8) === 0) {
                     $strUrl = $elements[1];
                     $strTitle = $elements[1];
                     $strName = str_replace(array('http://', 'https://'), '', $elements[1]);
                 } else {
                     // User login page
                     if ($elements[1] == 'login') {
                         if (!FE_USER_LOGGED_IN) {
                             break;
                         }
                         $this->import('FrontendUser', 'User');
                         $elements[1] = $this->User->loginPage;
                     }
                     $objNextPage = \PageModel::findByIdOrAlias($elements[1]);
                     if ($objNextPage === null) {
                         break;
                     }
                     // Page type specific settings (thanks to Andreas Schempp)
                     switch ($objNextPage->type) {
                         case 'redirect':
                             $strUrl = $objNextPage->url;
                             if (strncasecmp($strUrl, 'mailto:', 7) === 0) {
                                 $strUrl = \String::encodeEmail($strUrl);
                             }
                             break;
                         case 'forward':
                             if (($objTarget = $objNextPage->getRelated('jumpTo')) !== null) {
                                 $strUrl = $this->generateFrontendUrl($objTarget->row());
                                 break;
                             } elseif (($objTarget = \PageModel::findFirstPublishedRegularByPid($objNextPage->id)) !== null) {
                                 if ($GLOBALS['TL_CONFIG']['addLanguageToUrl']) {
                                     $objTarget = $this->getPageDetails($objTarget);
                                     // see #3983
                                     $strUrl = $this->generateFrontendUrl($objTarget->row(), null, $objTarget->language);
                                 } else {
                                     $strUrl = $this->generateFrontendUrl($objTarget->row());
                                 }
                                 break;
                             }
                             // DO NOT ADD A break; STATEMENT
                         // DO NOT ADD A break; STATEMENT
                         default:
                             if ($GLOBALS['TL_CONFIG']['addLanguageToUrl']) {
                                 $objNextPage = $this->getPageDetails($objNextPage);
                                 // see #3983
                                 $strUrl = $this->generateFrontendUrl($objNextPage->row(), null, $objNextPage->language);
                             } else {
                                 $strUrl = $this->generateFrontendUrl($objNextPage->row());
                             }
                             break;
                     }
                     $strName = $objNextPage->title;
                     $strTarget = $objNextPage->target ? $objPage->outputFormat == 'xhtml' ? LINK_NEW_WINDOW : ' target="_blank"' : '';
                     $strTitle = $objNextPage->pageTitle ?: $objNextPage->title;
                 }
                 // Replace the tag
                 switch (strtolower($elements[0])) {
                     case 'link':
                         $arrCache[$strTag] = sprintf('<a href="%s" title="%s"%s>%s</a>', $strUrl, specialchars($strTitle), $strTarget, specialchars($strName));
                         break;
                     case 'link_open':
                         $arrCache[$strTag] = sprintf('<a href="%s" title="%s"%s>', $strUrl, specialchars($strTitle), $strTarget);
                         break;
                     case 'link_url':
                         $arrCache[$strTag] = $strUrl;
                         break;
                     case 'link_title':
                         $arrCache[$strTag] = specialchars($strTitle);
                         break;
                     case 'link_target':
                         $arrCache[$strTag] = $strTarget;
                         break;
                 }
                 break;
                 // Closing link tag
             // Closing link tag
             case 'link_close':
                 $arrCache[$strTag] = '</a>';
                 break;
                 // Insert article
             // Insert article
             case 'insert_article':
                 if (($strOutput = $this->getArticle($elements[1], false, true)) !== false) {
                     $arrCache[$strTag] = $this->replaceInsertTags(ltrim($strOutput));
                 } else {
                     $arrCache[$strTag] = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], $elements[1]) . '</p>';
                 }
                 break;
                 // Insert content element
             // Insert content element
             case 'insert_content':
                 $arrCache[$strTag] = $this->replaceInsertTags($this->getContentElement($elements[1]));
                 break;
                 // Insert module
             // Insert module
             case 'insert_module':
                 $arrCache[$strTag] = $this->replaceInsertTags($this->getFrontendModule($elements[1]));
                 break;
                 // Insert form
             // Insert form
             case 'insert_form':
                 $arrCache[$strTag] = $this->replaceInsertTags($this->getForm($elements[1]));
                 break;
                 // Article
             // Article
             case 'article':
             case 'article_open':
             case 'article_url':
             case 'article_title':
                 $objArticle = \ArticleModel::findByIdOrAlias($elements[1]);
                 if ($objArticle === null) {
                     break;
                 } else {
                     $strUrl = $this->generateFrontendUrl($objArticle->row(), '/articles/' . (!$GLOBALS['TL_CONFIG']['disableAlias'] && strlen($objArticle->alias) ? $objArticle->alias : $objArticle->id));
                 }
                 // Replace the tag
                 switch (strtolower($elements[0])) {
                     case 'article':
                         $strLink = specialchars($objArticle->title);
                         $arrCache[$strTag] = sprintf('<a href="%s" title="%s">%s</a>', $strUrl, $strLink, $strLink);
                         break;
                     case 'article_open':
                         $arrCache[$strTag] = sprintf('<a href="%s" title="%s">', $strUrl, specialchars($objArticle->title));
                         break;
                     case 'article_url':
                         $arrCache[$strTag] = $strUrl;
                         break;
                     case 'article_title':
                         $arrCache[$strTag] = specialchars($objArticle->title);
                         break;
                 }
                 break;
                 // FAQ
             // FAQ
             case 'faq':
             case 'faq_open':
             case 'faq_url':
             case 'faq_title':
                 $objFaq = \FaqModel::findByIdOrAlias($elements[1]);
                 if ($objFaq === null) {
                     break;
                 } else {
                     $strUrl = $this->generateFrontendUrl($objFaq->row(), ($GLOBALS['TL_CONFIG']['useAutoItem'] ? '/' : '/items/') . (!$GLOBALS['TL_CONFIG']['disableAlias'] && $objFaq->alias != '' ? $objFaq->alias : $objFaq->id));
                 }
                 // Replace the tag
                 switch (strtolower($elements[0])) {
                     case 'faq':
                         $strLink = specialchars($objFaq->question);
                         $arrCache[$strTag] = sprintf('<a href="%s" title="%s">%s</a>', $strUrl, $strLink, $strLink);
                         break;
                     case 'faq_open':
                         $arrCache[$strTag] = sprintf('<a href="%s" title="%s">', $strUrl, specialchars($objFaq->question));
                         break;
                     case 'faq_url':
                         $arrCache[$strTag] = $strUrl;
                         break;
                     case 'faq_title':
                         $arrCache[$strTag] = specialchars($objFaq->question);
                         break;
                 }
                 break;
                 // News
             // News
             case 'news':
             case 'news_open':
             case 'news_url':
             case 'news_title':
                 $objNews = \NewsModel::findByIdOrAlias($elements[1]);
                 if ($objNews === null) {
                     break;
                 } elseif ($objNews->source == 'internal') {
                     $strUrl = $this->generateFrontendUrl($objNews->getRelated('jumpTo')->row());
                 } elseif ($objNews->source == 'article') {
                     $objArticle = \ArticleModel::findByPk($objNews->articleId, array('eager' => true));
                     $strUrl = $this->generateFrontendUrl($objArticle->pid, '/articles/' . (!$GLOBALS['TL_CONFIG']['disableAlias'] && $objArticle->alias != '' ? $objArticle->alias : $objArticle->id));
                 } elseif ($objNews->source == 'external') {
                     $strUrl = $objNews->url;
                 } else {
                     $strUrl = $this->generateFrontendUrl($objNews->pid, ($GLOBALS['TL_CONFIG']['useAutoItem'] ? '/' : '/items/') . (!$GLOBALS['TL_CONFIG']['disableAlias'] && $objNews->alias != '' ? $objNews->alias : $objNews->id));
                 }
                 // Replace the tag
                 switch (strtolower($elements[0])) {
                     case 'news':
                         $strLink = specialchars($objNews->headline);
                         $arrCache[$strTag] = sprintf('<a href="%s" title="%s">%s</a>', $strUrl, $strLink, $strLink);
                         break;
                     case 'news_open':
                         $arrCache[$strTag] = sprintf('<a href="%s" title="%s">', $strUrl, specialchars($objNews->headline));
                         break;
                     case 'news_url':
                         $arrCache[$strTag] = $strUrl;
                         break;
                     case 'news_title':
                         $arrCache[$strTag] = specialchars($objNews->headline);
                         break;
                 }
                 break;
                 // Events
             // Events
             case 'event':
             case 'event_open':
             case 'event_url':
             case 'event_title':
                 $objEvent = \CalendarEventsModel::findByIdOrAlias($elements[1]);
                 if ($objEvent === null) {
                     break;
                 } elseif ($objEvent->source == 'internal') {
                     $strUrl = $this->generateFrontendUrl($objEvent->getRelated('jumpTo')->row());
                 } elseif ($objEvent->source == 'article') {
                     $objArticle = \ArticleModel::findByPk($objEvent->articleId, array('eager' => true));
                     $strUrl = $this->generateFrontendUrl($objArticle->pid, '/articles/' . (!$GLOBALS['TL_CONFIG']['disableAlias'] && $objArticle->alias != '' ? $objArticle->alias : $objArticle->id));
                 } elseif ($objEvent->source == 'external') {
                     $strUrl = $objEvent->url;
                 } else {
                     $strUrl = $this->generateFrontendUrl($objEvent->pid, ($GLOBALS['TL_CONFIG']['useAutoItem'] ? '/' : '/events/') . (!$GLOBALS['TL_CONFIG']['disableAlias'] && $objEvent->alias != '' ? $objEvent->alias : $objEvent->id));
                 }
                 // Replace the tag
                 switch (strtolower($elements[0])) {
                     case 'event':
                         $strLink = specialchars($objEvent->title);
                         $arrCache[$strTag] = sprintf('<a href="%s" title="%s">%s</a>', $strUrl, $strLink, $strLink);
                         break;
                     case 'event_open':
                         $arrCache[$strTag] = sprintf('<a href="%s" title="%s">', $strUrl, specialchars($objEvent->title));
                         break;
                     case 'event_url':
                         $arrCache[$strTag] = $strUrl;
                         break;
                     case 'event_title':
                         $arrCache[$strTag] = specialchars($objEvent->title);
                         break;
                 }
                 break;
                 // Article teaser
             // Article teaser
             case 'article_teaser':
                 $objTeaser = \ArticleModel::findByIdOrAlias($elements[1]);
                 if ($objTeaser !== null) {
                     if ($objPage->outputFormat == 'xhtml') {
                         $arrCache[$strTag] = \String::toXhtml($this->replaceInsertTags($objTeaser->teaser));
                     } else {
                         $arrCache[$strTag] = \String::toHtml5($this->replaceInsertTags($objTeaser->teaser));
                     }
                 }
                 break;
                 // News teaser
             // News teaser
             case 'news_teaser':
                 $objTeaser = \NewsModel::findByIdOrAlias($elements[1]);
                 if ($objTeaser !== null) {
                     if ($objPage->outputFormat == 'xhtml') {
                         $arrCache[$strTag] = \String::toXhtml($objTeaser->teaser);
                     } else {
                         $arrCache[$strTag] = \String::toHtml5($objTeaser->teaser);
                     }
                 }
                 break;
                 // Event teaser
             // Event teaser
             case 'event_teaser':
                 $objTeaser = \CalendarEventsModel::findByIdOrAlias($elements[1]);
                 if ($objTeaser !== null) {
                     if ($objPage->outputFormat == 'xhtml') {
                         $arrCache[$strTag] = \String::toXhtml($objTeaser->teaser);
                     } else {
                         $arrCache[$strTag] = \String::toHtml5($objTeaser->teaser);
                     }
                 }
                 break;
                 // News feed URL
             // News feed URL
             case 'news_feed':
                 // FIXME: feeds are now in tl_calendar_feed
                 $objFeed = \NewsArchiveModel::findByPk($elements[1]);
                 if ($objFeed !== null) {
                     $arrCache[$strTag] = $objFeed->feedBase . $objFeed->alias . '.xml';
                 }
                 break;
                 // Calendar feed URL
             // Calendar feed URL
             case 'calendar_feed':
                 // FIXME: feeds are now in tl_calendar_feed
                 $objFeed = \CalendarModel::findByPk($elements[1]);
                 if ($objFeed !== null) {
                     $arrCache[$strTag] = $objFeed->feedBase . $objFeed->alias . '.xml';
                 }
                 break;
                 // Last update
             // Last update
             case 'last_update':
                 $objUpdate = \Database::getInstance()->execute("SELECT MAX(tstamp) AS tc, (SELECT MAX(tstamp) FROM tl_news) AS tn, (SELECT MAX(tstamp) FROM tl_calendar_events) AS te FROM tl_content");
                 if ($objUpdate->numRows) {
                     $arrCache[$strTag] = $this->parseDate($elements[1] ?: $GLOBALS['TL_CONFIG']['datimFormat'], max($objUpdate->tc, $objUpdate->tn, $objUpdate->te));
                 }
                 break;
                 // Version
             // Version
             case 'version':
                 $arrCache[$strTag] = VERSION . '.' . BUILD;
                 break;
                 // Request token
             // Request token
             case 'request_token':
                 $arrCache[$strTag] = REQUEST_TOKEN;
                 break;
                 // Conditional tags
             // Conditional tags
             case 'iflng':
                 if ($elements[1] != '' && $elements[1] != $objPage->language) {
                     for ($_rit; $_rit < count($tags); $_rit += 2) {
                         if ($tags[$_rit + 1] == 'iflng') {
                             break;
                         }
                     }
                 }
                 unset($arrCache[$strTag]);
                 break;
             case 'ifnlng':
                 if ($elements[1] != '') {
                     $langs = trimsplit(',', $elements[1]);
                     if (in_array($objPage->language, $langs)) {
                         for ($_rit; $_rit < count($tags); $_rit += 2) {
                             if ($tags[$_rit + 1] == 'ifnlng') {
                                 break;
                             }
                         }
                     }
                 }
                 unset($arrCache[$strTag]);
                 break;
                 // Environment
             // Environment
             case 'env':
                 switch ($elements[1]) {
                     case 'host':
                         $arrCache[$strTag] = \Environment::get('host');
                         break;
                     case 'http_host':
                         $arrCache[$strTag] = \Environment::get('httpHost');
                         break;
                     case 'url':
                         $arrCache[$strTag] = \Environment::get('url');
                         break;
                     case 'path':
                         $arrCache[$strTag] = \Environment::get('base');
                         break;
                     case 'request':
                         $arrCache[$strTag] = $this->getIndexFreeRequest(true);
                         break;
                     case 'ip':
                         $arrCache[$strTag] = \Environment::get('ip');
                         break;
                     case 'referer':
                         $arrCache[$strTag] = $this->getReferer(true);
                         break;
                     case 'files_url':
                         $arrCache[$strTag] = TL_FILES_URL;
                         break;
                     case 'script_url':
                         $arrCache[$strTag] = TL_SCRIPT_URL;
                         break;
                     case 'plugins_url':
                         $arrCache[$strTag] = TL_PLUGINS_URL;
                         break;
                 }
                 break;
                 // Page
             // Page
             case 'page':
                 if ($elements[1] == 'pageTitle' && $objPage->pageTitle == '') {
                     $elements[1] = 'title';
                 } elseif ($elements[1] == 'parentPageTitle' && $objPage->parentPageTitle == '') {
                     $elements[1] = 'parentTitle';
                 } elseif ($elements[1] == 'mainPageTitle' && $objPage->mainPageTitle == '') {
                     $elements[1] = 'mainTitle';
                 }
                 $arrCache[$strTag] = specialchars($objPage->{$elements[1]});
                 break;
                 // User agent
             // User agent
             case 'ua':
                 $ua = \Environment::get('agent');
                 if ($elements[1] != '') {
                     $arrCache[$strTag] = $ua->{$elements[1]};
                 } else {
                     $arrCache[$strTag] = '';
                 }
                 break;
                 // Acronyms
             // Acronyms
             case 'acronym':
                 if ($objPage->outputFormat == 'xhtml') {
                     if ($elements[1] != '') {
                         $arrCache[$strTag] = '<acronym title="' . $elements[1] . '">';
                     } else {
                         $arrCache[$strTag] = '</acronym>';
                     }
                     break;
                 }
                 // NO break;
                 // Abbreviations
             // NO break;
             // Abbreviations
             case 'abbr':
                 if ($elements[1] != '') {
                     $arrCache[$strTag] = '<abbr title="' . $elements[1] . '">';
                 } else {
                     $arrCache[$strTag] = '</abbr>';
                 }
                 break;
                 // Images
             // Images
             case 'image':
                 $width = null;
                 $height = null;
                 $alt = '';
                 $class = '';
                 $rel = '';
                 $strFile = $elements[1];
                 $mode = '';
                 // Take arguments
                 if (strpos($elements[1], '?') !== false) {
                     $arrChunks = explode('?', urldecode($elements[1]), 2);
                     $strSource = \String::decodeEntities($arrChunks[1]);
                     $strSource = str_replace('[&]', '&', $strSource);
                     $arrParams = explode('&', $strSource);
                     foreach ($arrParams as $strParam) {
                         list($key, $value) = explode('=', $strParam);
                         switch ($key) {
                             case 'width':
                                 $width = $value;
                                 break;
                             case 'height':
                                 $height = $value;
                                 break;
                             case 'alt':
                                 $alt = specialchars($value);
                                 break;
                             case 'class':
                                 $class = $value;
                                 break;
                             case 'rel':
                                 $rel = $value;
                                 break;
                             case 'mode':
                                 $mode = $value;
                                 break;
                         }
                     }
                     $strFile = $arrChunks[0];
                 }
                 // Sanitize path
                 $strFile = str_replace('../', '', $strFile);
                 // Check maximum image width
                 if ($GLOBALS['TL_CONFIG']['maxImageWidth'] > 0 && $width > $GLOBALS['TL_CONFIG']['maxImageWidth']) {
                     $width = $GLOBALS['TL_CONFIG']['maxImageWidth'];
                     $height = null;
                 }
                 // Generate the thumbnail image
                 try {
                     $src = \Image::get($strFile, $width, $height, $mode);
                     $dimensions = '';
                     // Add the image dimensions
                     if (($imgSize = @getimagesize(TL_ROOT . '/' . rawurldecode($src))) !== false) {
                         $dimensions = $imgSize[3];
                     }
                     // Generate the HTML markup
                     if ($rel != '') {
                         if (strncmp($rel, 'lightbox', 8) !== 0 || $objPage->outputFormat == 'xhtml') {
                             $attribute = ' rel="' . $rel . '"';
                         } else {
                             $attribute = ' data-lightbox="' . substr($rel, 8) . '"';
                         }
                         $arrCache[$strTag] = '<a href="' . TL_FILES_URL . $strFile . '"' . ($alt != '' ? ' title="' . $alt . '"' : '') . $attribute . '><img src="' . TL_FILES_URL . $src . '" ' . $dimensions . ' alt="' . $alt . '"' . ($class != '' ? ' class="' . $class . '"' : '') . ($objPage->outputFormat == 'xhtml' ? ' />' : '>') . '</a>';
                     } else {
                         $arrCache[$strTag] = '<img src="' . TL_FILES_URL . $src . '" ' . $dimensions . ' alt="' . $alt . '"' . ($class != '' ? ' class="' . $class . '"' : '') . ($objPage->outputFormat == 'xhtml' ? ' />' : '>');
                     }
                 } catch (Exception $e) {
                     $arrCache[$strTag] = '';
                 }
                 break;
                 // Files from the templates directory
             // Files from the templates directory
             case 'file':
                 $arrGet = $_GET;
                 \Input::resetCache();
                 $strFile = $elements[1];
                 // Take arguments and add them to the $_GET array
                 if (strpos($elements[1], '?') !== false) {
                     $arrChunks = explode('?', urldecode($elements[1]));
                     $strSource = \String::decodeEntities($arrChunks[1]);
                     $strSource = str_replace('[&]', '&', $strSource);
                     $arrParams = explode('&', $strSource);
                     foreach ($arrParams as $strParam) {
                         $arrParam = explode('=', $strParam);
                         $_GET[$arrParam[0]] = $arrParam[1];
                     }
                     $strFile = $arrChunks[0];
                 }
                 // Sanitize path
                 $strFile = str_replace('../', '', $strFile);
                 // Include .php, .tpl, .xhtml and .html5 files
                 if (preg_match('/\\.(php|tpl|xhtml|html5)$/', $strFile) && file_exists(TL_ROOT . '/templates/' . $strFile)) {
                     ob_start();
                     include TL_ROOT . '/templates/' . $strFile;
                     $arrCache[$strTag] = ob_get_contents();
                     ob_end_clean();
                 }
                 $_GET = $arrGet;
                 \Input::resetCache();
                 break;
                 // HOOK: pass unknown tags to callback functions
             // HOOK: pass unknown tags to callback functions
             default:
                 if (isset($GLOBALS['TL_HOOKS']['replaceInsertTags']) && is_array($GLOBALS['TL_HOOKS']['replaceInsertTags'])) {
                     foreach ($GLOBALS['TL_HOOKS']['replaceInsertTags'] as $callback) {
                         $this->import($callback[0]);
                         $varValue = $this->{$callback}[0]->{$callback}[1]($strTag);
                         // Replace the tag and stop the loop
                         if ($varValue !== false) {
                             $arrCache[$strTag] = $varValue;
                             break;
                         }
                     }
                 }
                 break;
         }
         $strBuffer .= $arrCache[$strTag];
     }
     return $this->restoreBasicEntities($strBuffer);
 }
 protected function compile()
 {
     global $objPage;
     $this->Template->event = '';
     $this->Template->referer = 'javascript:history.go(-1)';
     $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     if ($this->objEvent === null) {
         // Do not index or cache the page
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         // Send a 404 header
         header('HTTP/1.1 404 Not Found');
         $this->Template->event = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('events')) . '</p>';
         // remove page from search index
         if ($this->cal_showInModal) {
             \HeimrichHannot\SearchPlus\Search::removePageFromIndex(\Environment::get('request'));
         }
         return;
     }
     // Overwrite the page title (see #2853 and #4955)
     if ($this->objEvent->title != '') {
         $objPage->pageTitle = strip_tags(strip_insert_tags($this->objEvent->title));
     }
     // Overwrite the page description
     if ($this->objEvent->teaser != '') {
         $objPage->description = $this->prepareMetaDescription($this->objEvent->teaser);
     }
     $strUrl = '';
     $objCalendar = \CalendarModel::findByPk($this->objEvent->pid);
     // Get the current "jumpTo" page
     if ($objCalendar !== null && $objCalendar->jumpTo && ($objTarget = $objCalendar->getRelated('jumpTo')) !== null) {
         $strUrl = $this->generateFrontendUrl($objTarget->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/events/%s');
     }
     $intStartTime = $this->objEvent->startTime;
     $intEndTime = $this->objEvent->endTime;
     $span = \Calendar::calculateSpan($intStartTime, $intEndTime);
     // Do not show dates in the past if the event is recurring (see #923)
     if ($this->objEvent->recurring) {
         $arrRange = deserialize($this->objEvent->repeatEach);
         while ($intStartTime < time() && $intEndTime < $this->objEvent->repeatEnd) {
             $intStartTime = strtotime('+' . $arrRange['value'] . ' ' . $arrRange['unit'], $intStartTime);
             $intEndTime = strtotime('+' . $arrRange['value'] . ' ' . $arrRange['unit'], $intEndTime);
         }
     }
     $objEvent = (object) $this->getEventDetails($this->objEvent, $intStartTime, $intEndTime, $strUrl, $intStartTime, $this->objEvent->pid);
     $arrSubEvents = array();
     if (!$this->cal_ungroupSubevents) {
         $objChildEvents = CalendarPlusEventsModel::findPublishedSubEvents($objEvent->id);
         if ($objChildEvents !== null) {
             while ($objChildEvents->next()) {
                 $arrSubEvents[$objChildEvents->id] = $this->addSingleEvent($objChildEvents, $intStartTime);
             }
         }
     }
     if ($objPage->outputFormat == 'xhtml') {
         $strTimeStart = '';
         $strTimeEnd = '';
         $strTimeClose = '';
     } else {
         $strTimeStart = '<time datetime="' . date('Y-m-d\\TH:i:sP', $intStartTime) . '">';
         $strTimeEnd = '<time datetime="' . date('Y-m-d\\TH:i:sP', $intEndTime) . '">';
         $strTimeClose = '</time>';
     }
     // Get date
     if ($span > 0) {
         $date = $strTimeStart . \Date::parse($objEvent->addTime ? $objPage->datimFormat : $objPage->dateFormat, $intStartTime) . $strTimeClose . ' - ' . $strTimeEnd . \Date::parse($objEvent->addTime ? $objPage->datimFormat : $objPage->dateFormat, $intEndTime) . $strTimeClose;
     } elseif ($intStartTime == $intEndTime) {
         $date = $strTimeStart . \Date::parse($objPage->dateFormat, $intStartTime) . ($objEvent->addTime ? ' (' . \Date::parse($objPage->timeFormat, $intStartTime) . ')' : '') . $strTimeClose;
     } else {
         $date = $strTimeStart . \Date::parse($objPage->dateFormat, $intStartTime) . ($objEvent->addTime ? ' (' . \Date::parse($objPage->timeFormat, $intStartTime) . $strTimeClose . ' - ' . $strTimeEnd . \Date::parse($objPage->timeFormat, $intEndTime) . ')' : '') . $strTimeClose;
     }
     $until = '';
     $recurring = '';
     // Recurring event
     if ($objEvent->recurring) {
         $arrRange = deserialize($objEvent->repeatEach);
         $strKey = 'cal_' . $arrRange['unit'];
         $recurring = sprintf($GLOBALS['TL_LANG']['MSC'][$strKey], $arrRange['value']);
         if ($objEvent->recurrences > 0) {
             $until = sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], \Date::parse($objPage->dateFormat, $objEvent->repeatEnd));
         }
     }
     // Override the default image size
     if ($this->imgSize != '') {
         $size = deserialize($this->imgSize);
         if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) {
             $objEvent->size = $this->imgSize;
         }
     }
     $imgSize = false;
     // Override the default image size
     if ($this->imgSize != '') {
         $size = deserialize($this->imgSize);
         if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) {
             $imgSize = $this->imgSize;
         }
     }
     $objTemplate = new \FrontendTemplate($this->cal_template);
     $objTemplate->setData((array) $objEvent);
     $objTemplate->nav = $this->generateArrowNavigation($objEvent, $strUrl);
     if ($this->registration !== null) {
         $objTemplate->registration = $this->registration;
         $objTemplate->module = $this;
         // falback
     }
     if (is_array($arrSubEvents) && !empty($arrSubEvents)) {
         $strSubEvents = '';
         foreach ($arrSubEvents as $subID => $arrSubEvent) {
             $objSubEventTemplate = new \FrontendTemplate($this->cal_templateSubevent);
             $objSubEventTemplate->setData($arrSubEvent);
             $this->addEventDetailsToTemplate($objSubEventTemplate, $arrSubEvent, '', '', $imgSize);
             $strSubEvents .= $objSubEventTemplate->parse() . "\n";
         }
         $objTemplate->subEvents = $strSubEvents;
     }
     if ($this->addShare && in_array('share', $this->Config->getActiveModules())) {
         $objShare = new \HeimrichHannot\Share\Share($this->objModel, $objEvent);
         $objTemplate->share = $objShare->generate();
     }
     $objTemplate->addImage = false;
     // Add an image
     if ($objEvent->addImage && $objEvent->singleSRC != '') {
         $objModel = \FilesModel::findByUuid($objEvent->singleSRC);
         if ($objModel === null) {
             if (!\Validator::isUuid($objEvent->singleSRC)) {
                 $objTemplate->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             }
         } elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
             // Do not override the field now that we have a model registry (see #6303)
             $arrEvent = $objEvent->row();
             $arrEvent['singleSRC'] = $objModel->path;
             $this->addImageToTemplate($objTemplate, $arrEvent);
         }
     }
     $objTemplate->enclosure = array();
     // Add enclosures
     if ($objEvent->addEnclosure) {
         $this->addEnclosuresToTemplate($objTemplate, $this->objEvent->row());
     }
     $this->Template->event = $objTemplate->parse();
     // HOOK: comments extension required
     if ($objEvent->noComments || !in_array('comments', \ModuleLoader::getActive())) {
         $this->Template->allowComments = false;
         return;
     }
     $this->Template->allowComments = $objCalendar->allowComments;
     // Comments are not allowed
     if (!$objCalendar->allowComments) {
         return;
     }
     // Adjust the comments headline level
     $intHl = min(intval(str_replace('h', '', $this->hl)), 5);
     $this->Template->hlc = 'h' . ($intHl + 1);
     $this->import('Comments');
     $arrNotifies = array();
     // Notify the system administrator
     if ($objCalendar->notify != 'notify_author') {
         $arrNotifies[] = $GLOBALS['TL_ADMIN_EMAIL'];
     }
     // Notify the author
     if ($objCalendar->notify != 'notify_admin') {
         if (($objAuthor = $objEvent->getRelated('author')) !== null && $objAuthor->email != '') {
             $arrNotifies[] = $objAuthor->email;
         }
     }
     $objConfig = new \stdClass();
     $objConfig->perPage = $objCalendar->perPage;
     $objConfig->order = $objCalendar->sortOrder;
     $objConfig->template = $this->com_template;
     $objConfig->requireLogin = $objCalendar->requireLogin;
     $objConfig->disableCaptcha = $objCalendar->disableCaptcha;
     $objConfig->bbcode = $objCalendar->bbcode;
     $objConfig->moderate = $objCalendar->moderate;
     $this->Comments->addCommentsToTemplate($this->Template, $objConfig, 'tl_calendar_events', $objEvent->id, $arrNotifies);
 }
Beispiel #5
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;
 }
Beispiel #6
0
 protected function getContentIds($id)
 {
     $tmpArray = array();
     $img = "";
     if ($id == "-1") {
         $result = \CalendarModel::findByPk($this->settings['calendar']);
         if ($result->thumb) {
             $img = $this->getFilePath($result->thumb);
         }
         $tmpArray[0]['title'] = $result->title;
         $tmpArray[0]['tstamp'] = $result->tstamp;
         $tmpArray[0]['thumb'] = $img;
         $tmpArray[0]['id'] = $id;
         $tmpArray[0]['type'] = "events";
     } else {
         $res = \ContentModel::findPublishedByPidAndTable($id, "tl_article");
         $tmpArray = array();
         if (count($res) > 0) {
             $article = \ArticleModel::findByPk($id);
             $page = \PageModel::findByPk($article->pid);
             if ($page->thumb) {
                 $img = $this->getFilePath($page->thumb);
             }
             while ($res->next()) {
                 $headline = unserialize($res->headline);
                 $tmpArray[] = array("id" => $res->id, "tstamp" => $res->tstamp, 'title' => $headline['value'] && $headline['value'] != "" ? $headline['value'] : null, 'thumb' => $img, "type" => "post");
             }
         }
     }
     return $tmpArray;
 }
Beispiel #7
0
 /**
  * Get all events of a certain period
  *
  * @param array   $arrCalendars
  * @param integer $intStart
  * @param integer $intEnd
  *
  * @return array
  */
 protected function getAllEvents($arrCalendars, $intStart, $intEnd)
 {
     if (!is_array($arrCalendars)) {
         return array();
     }
     $this->arrEvents = array();
     foreach ($arrCalendars as $id) {
         $strUrl = $this->strUrl;
         $objCalendar = \CalendarModel::findByPk($id);
         // Get the current "jumpTo" page
         if ($objCalendar !== null && $objCalendar->jumpTo && ($objTarget = $objCalendar->getRelated('jumpTo')) !== null) {
             $strUrl = $this->generateFrontendUrl($objTarget->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/events/%s');
         }
         // Get the events of the current period
         $objEvents = \CalendarEventsModel::findCurrentByPid($id, $intStart, $intEnd);
         if ($objEvents === null) {
             continue;
         }
         while ($objEvents->next()) {
             $this->addEvent($objEvents, $objEvents->startTime, $objEvents->endTime, $strUrl, $intStart, $intEnd, $id);
             // Recurring events
             if ($objEvents->recurring) {
                 $arrRepeat = deserialize($objEvents->repeatEach);
                 if ($arrRepeat['value'] < 1) {
                     continue;
                 }
                 $count = 0;
                 $intStartTime = $objEvents->startTime;
                 $intEndTime = $objEvents->endTime;
                 $strtotime = '+ ' . $arrRepeat['value'] . ' ' . $arrRepeat['unit'];
                 while ($intEndTime < $intEnd) {
                     if ($objEvents->recurrences > 0 && $count++ >= $objEvents->recurrences) {
                         break;
                     }
                     $intStartTime = strtotime($strtotime, $intStartTime);
                     $intEndTime = strtotime($strtotime, $intEndTime);
                     // Skip events outside the scope
                     if ($intEndTime < $intStart || $intStartTime > $intEnd) {
                         continue;
                     }
                     $this->addEvent($objEvents, $intStartTime, $intEndTime, $strUrl, $intStart, $intEnd, $id);
                 }
             }
         }
     }
     // Sort the array
     foreach (array_keys($this->arrEvents) as $key) {
         ksort($this->arrEvents[$key]);
     }
     // HOOK: modify the result set
     if (isset($GLOBALS['TL_HOOKS']['getAllEvents']) && is_array($GLOBALS['TL_HOOKS']['getAllEvents'])) {
         foreach ($GLOBALS['TL_HOOKS']['getAllEvents'] as $callback) {
             $this->import($callback[0]);
             $this->arrEvents = $this->{$callback}[0]->{$callback}[1]($this->arrEvents, $arrCalendars, $intStart, $intEnd, $this);
         }
     }
     return $this->arrEvents;
 }
 protected function getParentEventDetails($intParentEvent, $intCalendar, $strBegin)
 {
     $objParentEvent = CalendarPlusEventsModel::findPublishedByParentAndIdOrAlias($intParentEvent, array($intCalendar));
     // do not show subevent, if parent event does not exist
     if ($objParentEvent === null) {
         return null;
     }
     $strUrl = $this->strUrl;
     $objCalendar = \CalendarModel::findByPk($objParentEvent->pid);
     // Get the current "jumpTo" page
     if ($objCalendar !== null && $objCalendar->jumpTo && ($objTarget = $objCalendar->getRelated('jumpTo')) !== null) {
         $strUrl = $this->generateFrontendUrl($objTarget->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/events/%s');
     }
     return $this->getEventDetails($objParentEvent, $objParentEvent->startTime, $objParentEvent->endTime, $strUrl, $strBegin, $objParentEvent->pid);
 }
 /**
  * Get all events of a certain period
  * @param array
  * @param integer
  * @param integer
  * @return array
  */
 protected function getAllEventsExt($arrHolidays, $arrCalendars, $intStart, $intEnd, $showRecurrences = true)
 {
     if (!is_array($arrCalendars)) {
         return array();
     }
     $this->arrEvents = array();
     foreach ($arrCalendars as $id) {
         $strUrl = $this->strUrl;
         $objCalendar = \CalendarModel::findByPk($id);
         // Get the current "jumpTo" page
         if ($objCalendar !== null && $objCalendar->jumpTo && ($objTarget = $objCalendar->getRelated('jumpTo')) !== null) {
             $strUrl = $this->generateFrontendUrl($objTarget->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/events/%s');
         }
         // Get the events of the current period
         $objEvents = \CalendarEventsModelExt::findCurrentByPid($id, $intStart, $intEnd);
         if ($objEvents === null) {
             continue;
         }
         while ($objEvents->next()) {
             $eventNumber = 1;
             $eventRecurrences = (int) $objEvents->recurrences + 1;
             if ($objEvents->recurring || $objEvents->recurringExt) {
                 $objEvents->pos_idx = (int) $eventNumber;
                 if ($objEvents->recurrences == 0) {
                     $objEvents->pos_cnt = 0;
                 } else {
                     $objEvents->pos_cnt = (int) $eventRecurrences;
                 }
             }
             // Check if we have to store the event if it's on weekend
             $weekday = (int) date('N', $objEvents->startTime);
             $store = true;
             if ($objEvents->hideOnWeekend) {
                 if ($weekday == 0 || $weekday == 6 || $weekday == 7) {
                     $store = false;
                 }
             }
             if ($store === true) {
                 $eventUrl = $strUrl . "?day=" . Date("Ymd", $objEvents->startTime) . "&amp;times=" . $objEvents->startTime . "," . $objEvents->endTime;
                 $this->addEvent($objEvents, $objEvents->startTime, $objEvents->endTime, $eventUrl, $intStart, $intEnd, $id);
                 // $this->addEvent($objEvents, $objEvents->startTime, $objEvents->endTime, $strUrl, $intStart, $intEnd, $id);
             }
             /*
              * Recurring events and Ext. Recurring events
              *
              * Here we manage the recurrences. We take the repeat option and set the new values
              * if showRecurrences is false we do not need to go thru all recurring events...
              */
             if (($objEvents->recurring && $objEvents->repeatEach || $objEvents->recurringExt && $objEvents->repeatEachExt) && $showRecurrences) {
                 // list of months we need
                 $arrMonth = array(1 => 'january', 2 => 'february', 3 => 'march', 4 => 'april', 5 => 'may', 6 => 'jun', 7 => 'july', 8 => 'august', 9 => 'september', 10 => 'october', 11 => 'november', 12 => 'december');
                 $count = 0;
                 if ($objEvents->recurring) {
                     $arrRepeat = deserialize($objEvents->repeatEach);
                 } else {
                     $arrRepeat = deserialize($objEvents->repeatEachExt);
                 }
                 // start and end time of the event
                 $eventStartTime = $this->parseDate($GLOBALS['TL_CONFIG']['timeFormat'], $objEvents->startTime);
                 $eventEndTime = $this->parseDate($GLOBALS['TL_CONFIG']['timeFormat'], $objEvents->endTime);
                 // now we have to take care about the exception dates to skip
                 if ($objEvents->useExceptions) {
                     $skipInfos = deserialize($objEvents->exceptionList);
                 }
                 // time of the next event
                 $nextTime = $objEvents->endTime;
                 while ($nextTime < $intEnd) {
                     $eventNumber++;
                     $objEvents->pos_idx = (int) $eventNumber;
                     if ($objEvents->recurrences == 0) {
                         $objEvents->pos_cnt = 0;
                     } else {
                         $objEvents->pos_cnt = (int) $eventRecurrences;
                     }
                     if ($objEvents->recurrences > 0 && $count++ >= $objEvents->recurrences) {
                         break;
                     }
                     $arg = $arrRepeat['value'];
                     $unit = $arrRepeat['unit'];
                     if ($objEvents->recurring) {
                         // this is the contao default
                         $strtotime = '+ ' . $arg . ' ' . $unit;
                         $objEvents->startTime = strtotime($strtotime, $objEvents->startTime);
                         $objEvents->endTime = strtotime($strtotime, $objEvents->endTime);
                     } else {
                         // extended version.
                         $intyear = date('Y', $objEvents->startTime);
                         $intmonth = date('n', $objEvents->startTime) + 1;
                         $year = $intmonth == 13 ? $intyear + 1 : $intyear;
                         $month = $intmonth == 13 ? 1 : $intmonth;
                         $strtotime = $arg . ' ' . $unit . ' of ' . $arrMonth[$month] . ' ' . $year;
                         $objEvents->startTime = strtotime($strtotime . ' ' . $eventStartTime, $objEvents->startTime);
                         $objEvents->endTime = strtotime($strtotime . ' ' . $eventEndTime, $objEvents->endTime);
                     }
                     $nextTime = $objEvents->endTime;
                     // check if there is any exception
                     if (is_array($skipInfos)) {
                         // reset cssClass
                         $objEvents->cssClass = str_replace("exception", "", $objEvents->cssClass);
                         // date to search for
                         $searchDate = mktime(0, 0, 0, date('m', $objEvents->startTime), date("d", $objEvents->startTime), date("Y", $objEvents->startTime));
                         // store old date values for later reset
                         $oldDate = array();
                         if (is_array($skipInfos[$searchDate])) {
                             // $r = array_search($searchDate, $exception, true);
                             $r = $searchDate;
                             $action = $skipInfos[$r]['action'];
                             if ($action == "hide") {
                                 //continue the while since we don't want to show the event
                                 continue;
                             } else {
                                 if ($action == "mark") {
                                     //just add the css class to the event
                                     $objEvents->cssClass .= "exception";
                                 } else {
                                     if ($action == "move") {
                                         //just add the css class to the event
                                         $objEvents->cssClass .= "moved";
                                         // keep old date. we have to reset it later for the next recurrence
                                         $oldDate['startTime'] = $objEvents->startTime;
                                         $oldDate['endTime'] = $objEvents->endTime;
                                         // also keep the old values in the row
                                         $objEvents->oldDate = $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $objEvents->startTime);
                                         // value to add to the old date
                                         $newDate = $skipInfos[$r]['new_exception'];
                                         // store the reason for the move
                                         $objEvents->moveReason = $skipInfos[$r]['reason'];
                                         // check if we have to change the time of the event
                                         if ($skipInfos[$r]['new_start']) {
                                             $objEvents->oldStartTime = $this->parseDate($GLOBALS['TL_CONFIG']['timeFormat'], $objEvents->startTime);
                                             $objEvents->oldEndTime = $this->parseDate($GLOBALS['TL_CONFIG']['timeFormat'], $objEvents->endTime);
                                             // get the date of the event and add the new time to the new date
                                             $newStart = $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $objEvents->startTime) . ' ' . $skipInfos[$r]['new_start'];
                                             $newEnd = $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $objEvents->endTime) . ' ' . $skipInfos[$r]['new_end'];
                                             //set the new values
                                             $objEvents->startTime = strtotime($newDate, strtotime($newStart));
                                             $objEvents->endTime = strtotime($newDate, strtotime($newEnd));
                                         } else {
                                             $objEvents->startTime = strtotime($newDate, $objEvents->startTime);
                                             $objEvents->endTime = strtotime($newDate, $objEvents->endTime);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     // Skip events outside the scope
                     if ($objEvents->endTime < $intStart || $objEvents->startTime > $intEnd) {
                         // in case of a move we have to reset the original date
                         if ($oldDate) {
                             $objEvents->startTime = $oldDate['startTime'];
                             $objEvents->endTime = $oldDate['endTime'];
                         }
                         // reset this values...
                         $objEvents->moveReason = NULL;
                         $objEvents->oldDate = NULL;
                         $objEvents->oldStartTime = NULL;
                         $objEvents->oldEndTime = NULL;
                         continue;
                     }
                     $objEvents->isRecurrence = true;
                     $weekday = date('N', $objEvents->startTime);
                     $store = true;
                     if ($objEvents->hideOnWeekend) {
                         if ($weekday == 0 || $weekday == 6 || $weekday == 7) {
                             $store = false;
                         }
                     }
                     if ($store === true) {
                         $eventUrl = $strUrl . "?day=" . Date("Ymd", $objEvents->startTime) . "&amp;times=" . $objEvents->startTime . "," . $objEvents->endTime;
                         $this->addEvent($objEvents, $objEvents->startTime, $objEvents->endTime, $eventUrl, $intStart, $intEnd, $id);
                     }
                     // reset this values...
                     $objEvents->moveReason = NULL;
                     $objEvents->oldDate = NULL;
                     $objEvents->oldStartTime = NULL;
                     $objEvents->oldEndTime = NULL;
                     // in case of a move we have to reset the original date
                     if ($oldDate) {
                         $objEvents->startTime = $oldDate['startTime'];
                         $objEvents->endTime = $oldDate['endTime'];
                     }
                 }
             }
         }
     }
     // run thru all holiday calendars
     foreach ($arrHolidays as $id) {
         $strUrl = $this->strUrl;
         $objAE = $this->Database->prepare("SELECT allowEvents FROM tl_calendar WHERE id = ?")->limit(1)->execute($id);
         $allowEvents = $objAE->allowEvents == 1 ? true : false;
         $strUrl = $this->strUrl;
         $objCalendar = \CalendarModel::findByPk($id);
         // Get the current "jumpTo" page
         if ($objCalendar !== null && $objCalendar->jumpTo && ($objTarget = $objCalendar->getRelated('jumpTo')) !== null) {
             $strUrl = $this->generateFrontendUrl($objTarget->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/events/%s');
         }
         // Get the events of the current period
         $objEvents = \CalendarEventsModel::findCurrentByPid($id, $intStart, $intEnd);
         if ($objEvents === null) {
             continue;
         }
         while ($objEvents->next()) {
             // at last we add the free multi-day / holiday or what ever kind of event
             $this->addEvent($objEvents, $objEvents->startTime, $objEvents->endTime, $strUrl, $intStart, $intEnd, $id);
             /**
              * Multi-day event
              * first we have to find all free days
              */
             $span = Calendar::calculateSpan($objEvents->startTime, $objEvents->endTime);
             // unset the first day of the multi-day event
             $intDate = $objEvents->startTime;
             $key = date('Ymd', $intDate);
             // check all events if the calendar allows events on free days
             if ($this->arrEvents[$key]) {
                 foreach ($this->arrEvents[$key] as $k1 => $events) {
                     foreach ($events as $k2 => $event) {
                         // do not remove events from any holiday calendar
                         $isHolidayEvent = array_search($event['pid'], $arrHolidays);
                         // unset the event if showOnFreeDay is not set
                         if ($allowEvents === false) {
                             if ($isHolidayEvent === false) {
                                 unset($this->arrEvents[$key][$k1][$k2]);
                             }
                         } else {
                             if ($isHolidayEvent === false && !$event['showOnFreeDay'] == 1) {
                                 unset($this->arrEvents[$key][$k1][$k2]);
                             }
                         }
                     }
                 }
             }
             // unset all the other days of the multi-day event
             for ($i = 1; $i <= $span && $intDate <= $intEnd; $i++) {
                 $intDate = strtotime('+ 1 day', $intDate);
                 $key = date('Ymd', $intDate);
                 // check all events if the calendar allows events on free days
                 if ($this->arrEvents[$key]) {
                     foreach ($this->arrEvents[$key] as $k1 => $events) {
                         foreach ($events as $k2 => $event) {
                             // do not remove events from any holiday calendar
                             $isHolidayEvent = array_search($event['pid'], $arrHolidays);
                             // unset the event if showOnFreeDay is not set
                             if ($allowEvents === false) {
                                 if ($isHolidayEvent === false) {
                                     unset($this->arrEvents[$key][$k1][$k2]);
                                 }
                             } else {
                                 if ($isHolidayEvent === false && !$event['showOnFreeDay'] == 1) {
                                     unset($this->arrEvents[$key][$k1][$k2]);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // Sort the array
     foreach (array_keys($this->arrEvents) as $key) {
         ksort($this->arrEvents[$key]);
     }
     // HOOK: modify the result set
     if (isset($GLOBALS['TL_HOOKS']['getAllEvents']) && is_array($GLOBALS['TL_HOOKS']['getAllEvents'])) {
         foreach ($GLOBALS['TL_HOOKS']['getAllEvents'] as $callback) {
             $this->import($callback[0]);
             $this->arrEvents = $this->{$callback}[0]->{$callback}[1]($this->arrEvents, $arrCalendars, $intStart, $intEnd, $this);
         }
     }
     return $this->arrEvents;
 }