private function loadAncestorPages($page_id)
 {
     if ($this->ancestor_pages === null) {
         $pages = new Pages();
         $path = $pages->getPath($page_id);
         for ($i = count($path) - 1; $i >= 0; $i--) {
             $data = $pages->getData($path[$i], true, true);
             $properties = $pages->getProperties($path[$i]);
             $this->ancestor_pages[] = json_decode($data, true);
             $this->ancestor_page_file_url[] = $pages->getPageFilesPublishedUrl($path[$i]);
             $this->ancestor_page_data_structure[] = $this->getPageStructure($properties['template-id']);
         }
     }
 }
 public function getPage($page_id, $language_id, $preview = false)
 {
     // Smarty initialisieren
     $smarty = new Template();
     // Seiten-Infos laden
     $pages = new Pages();
     $page_properties = $pages->getProperties($page_id);
     if ($page_properties === false) {
         Helpers::fatalError('A page with the ID "' . $page_id . '" does not exist!');
     }
     // Wenn die Vorschau-Version der Seite angefordert wurde,
     // überprüfen, ob überhaupt eine editierte Version der Seite existiert,
     // wenn nicht, Vorschau-Modus ignorieren
     if ($preview) {
         if ($page_properties['status'] == Pages::STATUS_PUBLISHED) {
             $preview = false;
         }
     }
     // Seiteneigenes Verzeichnis abhängig von $preview auslesen
     if ($preview) {
         $page_files = $pages->getPageFilesEditFolder($page_id, $page_properties);
         $page_files_url = $pages->getPageFilesEditUrl($page_id, $page_properties);
     } else {
         $page_files = $pages->getPageFilesPublishedFolder($page_id, $page_properties);
         $page_files_url = $pages->getPageFilesPublishedUrl($page_id, $page_properties);
     }
     $page_url = $pages->getPageUrl($page_id, $language_id, $page_properties);
     // Grundlegende Variablen zuweisen, die zwar mit dem Inhalt nichts zu tun haben, aber wichtig sind :-)
     $smarty->assign('baseUrl', Config::get()->baseUrl);
     $smarty->assign('publicUrl', Config::get()->baseUrl . 'system/custom/frontend/public/');
     $smarty->assign('pageUrl', $page_url);
     $smarty->assign('pageId', $page_id);
     $smarty->assign('languageId', $language_id);
     $smarty->assign('templateId', $page_properties['template-id']);
     $smarty->assign('uniqueId', $page_properties['unique-id']);
     $smarty->assign('pageFiles', $page_files);
     $smarty->assign('pageFilesUrl', $page_files_url);
     $languages = Config::get()->languages->list->getArrayCopy();
     foreach ($languages as $key => $value) {
         $languages[$key]['id'] = $key;
     }
     $smarty->assign('languages', $languages);
     // Seiten-Struktur laden
     $pages_structure = DataStructure::pagesArray();
     if (!isset($pages_structure[$page_properties['template-id']]['structure'])) {
         Helpers::fatalError('A page template with the ID "' . $page_properties['template-id'] . '" does not exist!');
     }
     $page_structure = $pages_structure[$page_properties['template-id']]['structure'];
     // Die folgenden Parameter werden an die Modifikatoren und Plugins übergeben
     $parameters = array('preview' => $preview, 'pageId' => $page_id, 'languageId' => $language_id, 'templateId' => $page_properties['template-id'], 'uniqueId' => $page_properties['unique-id'], 'pageUrl' => $page_url, 'pageFiles' => $page_files, 'pageFilesUrl' => $page_files_url, 'smarty' => $smarty);
     // Seiten-Inhalt laden
     $content_object = new PageContent();
     if (!$content_object->load($page_id, !$preview)) {
         Helpers::fatalError('The content of the page with the ID "' . $page_id . '" could not be loaded!');
     }
     $page_content = $content_object->getArray($language_id, $smarty, $parameters);
     // Globale Elemente laden
     $this->loadGlobalElementsPage($smarty, $language_id);
     $this->assignGlobalElementsToSmarty($smarty, $language_id);
     // Inhalte zuweisen
     foreach ($page_structure as $block_id => $block) {
         if ($block['type'] == 'datablock') {
             $block_data = null;
             if (isset($page_content[$block_id])) {
                 $block_data = $page_content[$block_id];
             }
             $smarty->assign($block_id, $block_data);
         } elseif ($block['type'] == 'container') {
             $container_content = '';
             if (isset($page_content[$block_id])) {
                 if (is_array($page_content[$block_id])) {
                     foreach ($page_content[$block_id] as $container_element_key => $container_element) {
                         $container_content = $container_content . $this->getElement($page_id, $language_id, $container_element['elementId'], $container_element['content'], $preview);
                     }
                 }
             }
             $smarty->assign($block_id, $container_content);
         }
     }
     // registrierte Plugins aufrufen, vielleicht hat ja noch jemand etwas hinzuzufügen :-)
     Plugins::call(Plugins::ASSIGN_PAGE_DATA, $parameters);
     // Smarty-Template für die Template-ID der aktuellen Seite zurückgeben
     $page_template = $pages_structure[$page_properties['template-id']];
     return $smarty->fetch('file:[pages]' . $page_template['template']);
 }