public function renderFile()
 {
     //Send Content-Type
     $sCharset = Settings::getSetting('encoding', 'browser', 'utf-8');
     if ($this->sType === ResourceIncluder::RESOURCE_TYPE_CSS) {
         header("Content-Type: text/css;charset={$sCharset}");
     } else {
         if ($this->sType === ResourceIncluder::RESOURCE_TYPE_JS) {
             header("Content-Type: text/javascript;charset={$sCharset}");
         }
     }
     //Find consolidated resources
     $aKeys = array();
     while (Manager::hasNextPathItem()) {
         $aKeys[] = Manager::usePath();
     }
     $sKey = 'consolidated-output-' . $this->sType . '-' . implode('|', $aKeys);
     $oCachingStrategy = clone CachingStrategy::fromConfig('file');
     $oCache = new Cache($sKey, 'resource', $oCachingStrategy);
     $oItemCachingStrategy = clone $oCachingStrategy;
     $oItemCachingStrategy->init(array('key_encode' => null));
     $oCache->sendCacheControlHeaders();
     if (!$oCache->entryExists(false)) {
         foreach ($aKeys as $sItemKey) {
             $oItemCache = new Cache($sItemKey, DIRNAME_PRELOAD, $oItemCachingStrategy);
             if (!$oItemCache->entryExists(false)) {
                 throw new Exception("Consolidated resource {$sItemKey} does not exist.");
             }
             $oCache->setContents($oItemCache->getContentsAsString() . "\n", false, true);
         }
     }
     $oCache->sendCacheControlHeaders();
     $oCache->passContents(true);
 }
Esempio n. 2
0
 public static function redirectToLanguage($sLanguageId = null)
 {
     if ($sLanguageId == null) {
         $sLanguageId = Session::language();
     }
     $oLanguage = LanguageQuery::language($sLanguageId)->findOne();
     $sLanguageInPathId = null;
     if (Manager::hasNextPathItem()) {
         $oLanguageInPath = LanguageQuery::language(Manager::peekNextPathItem(), true)->findOne();
         if ($oLanguageInPath && $oLanguageInPath->getIsActive()) {
             Manager::usePath();
             $sLanguageInPathId = $oLanguageInPath->getId();
         }
     }
     $sManager = Manager::getManagerClassNormalized(null);
     if ($sManager::shouldIncludeLanguageInLink()) {
         if ($sLanguageInPathId === $sLanguageId) {
             return;
         }
     } else {
         if ($sLanguageInPathId === null) {
             //Did not include language in link and should not
             return;
         }
     }
     self::redirectToManager(Manager::getRequestPath(), $sManager, array(), $oLanguage);
 }
Esempio n. 3
0
 public function __construct()
 {
     try {
         $this->oRootPage = PagePeer::getRootPage();
     } catch (Exception $e) {
         $this->oRootPage = self::initializeRootPage();
     }
     $this->oTreeWidget = new TreeWidgetModule();
     $this->oTreeWidget->setDelegate($this);
     $this->oTreeWidget->setSetting('init_dnd', true);
     $oInitialPage = null;
     if (Manager::hasNextPathItem()) {
         $oInitialPage = PageQuery::create()->findPk(Manager::usePath());
         if ($oInitialPage !== null) {
             Session::getSession()->setAttribute('persistent_page_id', $oInitialPage->getId());
         }
     } else {
         if (Session::getSession()->hasAttribute('persistent_page_id')) {
             $oInitialPage = PageQuery::create()->findPk(Session::getSession()->getAttribute('persistent_page_id'));
         }
     }
     if ($oInitialPage === null) {
         $oInitialPage = $this->oRootPage;
     }
     $this->addResourceParameter(ResourceIncluder::RESOURCE_TYPE_JS, 'tree_session', $this->oTreeWidget->getSessionKey());
     $this->addResourceParameter(ResourceIncluder::RESOURCE_TYPE_JS, 'initial_page_id', $oInitialPage->getId());
     $this->addResourceParameter(ResourceIncluder::RESOURCE_TYPE_JS, 'initial_page_tree_left', $oInitialPage->getTreeLeft());
     $oResourceIncluder = ResourceIncluder::defaultIncluder();
     $oResourceIncluder->addResource('admin/template.css', null, null, array(), ResourceIncluder::PRIORITY_NORMAL, null, true);
 }
 public function __construct()
 {
     $this->initialize();
     if (Manager::hasNextPathItem()) {
         $this->sFilePath = Manager::peekNextPathItem();
     }
 }