function smarty_function_pageurl($params, Smarty_Internal_Template $template) { $output = ''; if (isset($params['page'])) { if (isset($params['language'])) { $language_id = $params['language']; } else { $language_id = $template->getTemplateVars('languageId'); if ($language_id === null) { $language_id = Config::get()->languages->standard; } } $mixed_id = $params['page']; $page_id = false; $pages = new Pages(); if (is_int($mixed_id)) { $page_id = $mixed_id; } else { if (is_numeric($mixed_id)) { $page_id = (int) $mixed_id; } else { if (is_string($mixed_id)) { $page_id = $pages->getPageIdByUniqueId($mixed_id); } } } if ($page_id !== false) { $output = $pages->getPageUrl($page_id, $language_id); } } return $output; }
public function getlinkAction() { // Parameter auslesen $link_to_page_id = Request::postParam('linkToPageId'); $link_to_language_id = Request::postParam('linkToLanguageId'); $link_to_anchor_name = Request::postParam('linkToAnchorName'); // Parameter überprüfen if (!is_numeric($link_to_page_id) || $link_to_language_id == '') { $this->error(self::RESULT_ERROR_BAD_REQUEST); return; } $pages = new Pages(); // Die absolute URL auslesen $absolute_url = $pages->getPageUrl($link_to_page_id, $link_to_language_id); // eine zum Stammverzeichnis des CMS relative URL daraus machen $base_url = Config::get()->baseUrl; $relative_url = UTF8String::substr($absolute_url, UTF8String::strlen($base_url), UTF8String::strlen($absolute_url)); if ($link_to_anchor_name != '') { if ($relative_url != '') { $relative_url = rtrim($relative_url, '/') . '/'; } $relative_url .= '#' . $link_to_anchor_name; } // Zurückgeben $this->success($relative_url); }
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']); }