public function __construct($bShouldLogin = true) { parent::__construct(); SanityCheck::basicCheck(); if ($bShouldLogin && (!Session::getSession()->isAuthenticated() || !Session::getSession()->getUser()->getIsBackendLoginEnabled())) { LinkUtil::redirect(LinkUtil::link(array(), 'AdminManager', array('preview' => self::getRequestedPath()))); } $oResourceIncluder = ResourceIncluder::defaultIncluder(); $oResourceIncluder->addCustomJs('window.FILE_PREFIX = "' . MAIN_DIR_FE_PHP . Manager::getPrefixForManager('FileManager') . '";'); //Fix JSON requests when using Prototype in the frontend $oResourceIncluder->addReverseDependency('lib_prototype', false, 'preview/prototype_json_fix.js'); //Add jQuery and jQuery UI $oResourceIncluder->addJavaScriptLibrary('jquery', AdminManager::JQUERY_VERSION, null, true, null, ResourceIncluder::PRIORITY_FIRST); $oResourceIncluder->addJavaScriptLibrary('jqueryui', AdminManager::JQUERY_UI_VERSION); //Add client widget handling code $oResourceIncluder->addResource('widget/widget.js'); $oResourceIncluder->addResource('widget/widget_skeleton.js'); //Provides some basic overrides for tooltip, notifyuser and stuff //Override some site styles in specific regions $oResourceIncluder->addResource('preview/preview-reset.css'); $oResourceIncluder->addResource('preview/preview-default.css'); $oResourceIncluder->addResource('admin/theme/jquery-ui-1.10.2.custom.min.css'); //Add the css that handles styles for all widgets but namespace it so it applies only to specific areas of the page (editable areas, dialogs, the admin menu, etc.) $this->addNamespacedCss(array('widget', 'widget.css')); $oResourceIncluder->addResource('backend/additions.js', null, null, null, ResourceIncluder::PRIORITY_NORMAL, null, true); $oResourceIncluder->addResource('preview/additions.js', null, null, null, ResourceIncluder::PRIORITY_NORMAL, null, true); $oResourceIncluder->addResource('backend/additions.css', null, null, null, ResourceIncluder::PRIORITY_NORMAL, null, true); $oResourceIncluder->addResource('preview/additions.css', null, null, null, ResourceIncluder::PRIORITY_NORMAL, null, true); //preview-interface.css contains things like the edit buttons ResourceIncluder::defaultIncluder()->addResource('preview-interface.css', null, null, null, ResourceIncluder::PRIORITY_NORMAL, null, true); //Include the resources of widgets we know we’re gonna use. if ($bShouldLogin) { $oLoginWindowWidget = WidgetModule::getWidget('login_window'); LoginWindowWidgetModule::includeResources(); } $this->oAdminMenuWidget = WidgetModule::getWidget('admin_menu'); AdminMenuWidgetModule::includeResources(); $this->oPageTypeWidget = WidgetModule::getWidget('page_type'); PageTypeWidgetModule::includeResources(); }
public function writeManagerPrefix($oTemplateIdentifier) { return Manager::getPrefixForManager($oTemplateIdentifier->getValue()); }
public static function link($mPath = false, $mManager = null, $aParameters = array(), $mLanguage = null, $bIncludeLanguage = null) { if ($mPath === null) { // Respect null-links return null; } if (!$mPath) { $mPath = array(); } if (!is_array($mPath)) { $mPath = explode("/", $mPath); } $mManager = Manager::getManagerClassNormalized($mManager); $sPrefix = Manager::getPrefixForManager($mManager); if ($mLanguage === true || $mLanguage === false) { $bIncludeLanguage = $mLanguage; $mLanguage = null; } if ($bIncludeLanguage === null) { $bIncludeLanguage = $mManager::shouldIncludeLanguageInLink(); } if ($bIncludeLanguage) { if ($mLanguage === null) { $mLanguage = Session::language(true); } if ($mLanguage instanceof Language) { array_unshift($mPath, $mLanguage->getPathPrefix()); } else { if (is_string($mLanguage)) { $mLanguage = LanguageQuery::create()->findPk($mLanguage)->getPathPrefix(); array_unshift($mPath, $mLanguage); } } } foreach ($mPath as $iKey => $sValue) { if ($sValue === null || $sValue === "") { unset($mPath[$iKey]); } else { $mPath[$iKey] = rawurlencode($sValue); } } if ($sPrefix !== null && $sPrefix !== "") { $sPrefix .= "/"; } else { $sPrefix = ''; } return MAIN_DIR_FE_PHP . $sPrefix . implode('/', $mPath) . self::prepareLinkParameters($aParameters); }
public function textTagParseCallback($oHtmlTag, $sParsedChildren) { if ($oHtmlTag->getName() === 'text') { return $sParsedChildren; } if ($oHtmlTag->getName() === 'img') { if (preg_match("%display_document/(\\d+)%", $oHtmlTag->getParameter('src'), $aMatches)) { $aParameters = $oHtmlTag->getParameters(); $this->addTrackReference($aMatches[1], "Document"); return TemplateIdentifier::constructIdentifier('image', $aMatches[1], $aParameters); } } if ($oHtmlTag->getName() === 'a') { if ($sParsedChildren === '') { return ''; } $bHasMatched = preg_match("%/" . preg_quote(Manager::getPrefixForManager('FileManager'), "%") . "/([^/]+)/(\\d+)((\\D.+)?)\$%", $oHtmlTag->getParameter('href'), $aMatches) === 1; if ($bHasMatched) { $sFileMethod = $aMatches[1]; $iId = $aMatches[2]; $sAdditional = $aMatches[3]; $sIdentifier = 'file_link'; $sModel = 'Document'; if ($sFileMethod === 'external_link_proxy') { $sIdentifier = 'external_link'; $sModel = 'Link'; } else { if ($sFileMethod === 'internal_link_proxy') { $sIdentifier = 'internal_link'; $sModel = 'Page'; } } $this->addTrackReference($iId, $sModel); return TemplateIdentifier::constructIdentifier($sIdentifier, "{$iId}{$sAdditional}", array_merge($oHtmlTag->getParameters(), array('link_text' => $sParsedChildren))); } else { if (strpos($oHtmlTag->getParameter('href'), "mailto:") === 0) { return TemplateIdentifier::constructIdentifier("mailto_link", substr($oHtmlTag->getParameter('href'), strlen("mailto:")), array("link_text" => $sParsedChildren)); } } } $oTagWriter = new TagWriter($oHtmlTag->getName(), $oHtmlTag->getParameters(), $sParsedChildren); $oTagTemplate = $oTagWriter->parse(true); $oTagTemplate->bKillIdentifiersBeforeRender = false; return $oTagTemplate->render(); }