/**
  * Do something before content is loaded from DB
  * 
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page       The resolved page
  */
 public function preContentLoad(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     global $modulespath, $eventsPlaceholder, $_CONFIG, $themesPages, $page_template, $calHeadlinesObj, $calHeadlines, $_ARRAYLANG;
     switch ($this->cx->getMode()) {
         case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND:
             // Get Calendar Events
             $modulespath = ASCMS_MODULE_PATH . '/Calendar/Controller/CalendarHeadlines.class.php';
             $eventsPlaceholder = '{EVENTS_FILE}';
             if (MODULE_INDEX < 2 && $_CONFIG['calendarheadlines'] && (strpos(\Env::get('cx')->getPage()->getContent(), $eventsPlaceholder) !== false || strpos($themesPages['index'], $eventsPlaceholder) !== false || strpos($themesPages['sidebar'], $eventsPlaceholder) !== false || strpos($page_template, $eventsPlaceholder) !== false) && file_exists($modulespath)) {
                 $_ARRAYLANG = array_merge($_ARRAYLANG, \Env::get('init')->loadLanguageData('Calendar'));
                 $calHeadlinesObj = new \Cx\Modules\Calendar\Controller\CalendarHeadlines($themesPages['calendar_headlines']);
                 $calHeadlines = $calHeadlinesObj->getHeadlines();
                 \Env::get('cx')->getPage()->setContent(str_replace($eventsPlaceholder, $calHeadlines, \Env::get('cx')->getPage()->getContent()));
                 $themesPages['index'] = str_replace($eventsPlaceholder, $calHeadlines, $themesPages['index']);
                 $themesPages['sidebar'] = str_replace($eventsPlaceholder, $calHeadlines, $themesPages['sidebar']);
                 $page_template = str_replace($eventsPlaceholder, $calHeadlines, $page_template);
             }
             break;
         default:
             break;
     }
 }
 /**
  * Do something before content is loaded from DB
  *
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page       The resolved page
  */
 public function preContentLoad(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     global $modulespath, $eventsPlaceholder, $_CONFIG, $themesPages, $page_template, $calHeadlinesObj, $calHeadlines, $_ARRAYLANG;
     switch ($this->cx->getMode()) {
         case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND:
             // Get Calendar Events
             $modulespath = ASCMS_MODULE_PATH . '/Calendar/Controller/CalendarHeadlines.class.php';
             if (MODULE_INDEX < 2 && $_CONFIG['calendarheadlines'] && file_exists($modulespath)) {
                 $_ARRAYLANG = array_merge($_ARRAYLANG, \Env::get('init')->loadLanguageData('Calendar'));
                 for ($i = 0; $i <= 10; $i++) {
                     $visibleI = '';
                     if ($i > 0) {
                         $visibleI = (string) $i;
                     }
                     $eventsPlaceholder = '{EVENTS' . $visibleI . '_FILE}';
                     if (strpos(\Env::get('cx')->getPage()->getContent(), $eventsPlaceholder) !== false || strpos($themesPages['index'], $eventsPlaceholder) !== false || strpos($themesPages['sidebar'], $eventsPlaceholder) !== false || strpos($page_template, $eventsPlaceholder) !== false) {
                         $category = null;
                         $matches = array();
                         if (preg_match('/\\{CALENDAR_CATEGORY_([0-9]+)\\}/', $themesPages['calendar_headlines' . $visibleI], $matches)) {
                             $category = $matches[1];
                         }
                         $calHeadlinesObj = new \Cx\Modules\Calendar\Controller\CalendarHeadlines($themesPages['calendar_headlines' . $visibleI]);
                         $calHeadlines = $calHeadlinesObj->getHeadlines($category);
                         \Env::get('cx')->getPage()->setContent(str_replace($eventsPlaceholder, $calHeadlines, \Env::get('cx')->getPage()->getContent()));
                         $themesPages['index'] = str_replace($eventsPlaceholder, $calHeadlines, $themesPages['index']);
                         $themesPages['sidebar'] = str_replace($eventsPlaceholder, $calHeadlines, $themesPages['sidebar']);
                         $page_template = str_replace($eventsPlaceholder, $calHeadlines, $page_template);
                     }
                 }
             }
             break;
         default:
             break;
     }
 }