Beispiel #1
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($sSessionId)
 {
     parent::__construct($sSessionId);
     $oRichtext = WidgetModule::getWidget('rich_text', null, null, 'documentation');
     $oRichtext->setTemplate(PagePeer::getRootPage()->getTemplate());
     $this->setSetting('richtext_session', $oRichtext->getSessionKey());
     $this->setSetting('international_option', LanguageInputWidgetModule::isMonolingual());
 }
 public static function getPost($iJournalEntryId, $sUserName, $sPassword)
 {
     if (!self::checkLogin($sUserName, $sPassword)) {
         return self::loginError();
     }
     $oJournalEntry = JournalEntryQuery::create()->findPk($iJournalEntryId);
     if ($oJournalEntry === null) {
         return self::error("No Entry with id {$iJournalEntryId}", 2);
     }
     return $oJournalEntry->getRssAttributes(PagePeer::getRootPage()->getPageOfType('journal'), true);
 }
 public function renderFile()
 {
     $this->oXmlDocument = new DOMDocument();
     $this->oUrl = $this->oXmlDocument->createElement('urlset');
     $this->oUrl->setAttribute('xmlns', $this->sXmlNamespace);
     $this->oXmlDocument->appendChild($this->oUrl);
     $oRootPage = PagePeer::getRootPage();
     $oRootNavigationItem = PageNavigationItem::navigationItemForPage($oRootPage);
     $this->renderNavigationItem($oRootNavigationItem);
     header('Content-Type: application/xml;charset=utf-8');
     print $this->oXmlDocument->saveXML();
 }
 public function __construct($sSessionId)
 {
     parent::__construct($sSessionId);
     $iDocumentationPartCategory = 2;
     if (DocumentCategoryQuery::create()->filterById($iDocumentationPartCategory)->count() === 0) {
         throw new Exception(__METHOD__ . ': Please setup the exernally managed document category for this module');
     }
     $this->setSetting('documentation_image_category_id', $iDocumentationPartCategory);
     $oRichtext = WidgetModule::getWidget('rich_text', null, null, 'documentation_part');
     $oRichtext->setTemplate(PagePeer::getRootPage()->getTemplate());
     $this->setSetting('richtext_session', $oRichtext->getSessionKey());
 }
 public function __construct($aRequestPath, Page $oJournalPage = null, $aJournalIds = null)
 {
     if ($aRequestPath === false) {
         $this->oJournalPage = $oJournalPage;
         $this->aJournalIds = $aJournalIds;
     } else {
         parent::__construct($aRequestPath);
         Manager::usePath();
         //the “journal” bit
         $this->oJournalPage = PagePeer::getRootPage()->getPageOfType('journal');
         $sLanguageId = Manager::usePath();
         if (LanguagePeer::languageIsActive($sLanguageId)) {
             Session::getSession()->setLanguage($sLanguageId);
         }
     }
     header("Content-Type: application/rss+xml;charset=" . Settings::getSetting('encoding', 'db', 'utf-8'));
     RichtextUtil::$USE_ABSOLUTE_LINKS = LinkUtil::isSSL();
 }
 public function pages($bIncludeVirtual = false)
 {
     $aResult = array();
     $cGather = function ($aNavigationItems, $iLevel) use(&$aResult, &$cGather, $bIncludeVirtual) {
         foreach ($aNavigationItems as $oNavigationItem) {
             if (!$bIncludeVirtual && !$oNavigationItem instanceof PageNavigationItem) {
                 continue;
             }
             $oResult = new StdClass();
             $oResult->level = $iLevel;
             $oResult->page_id = $oNavigationItem->getId();
             $oResult->name = $oNavigationItem->getName();
             $aResult[] = $oResult;
             if ($oNavigationItem->hasChildren(null, false, true)) {
                 $cGather($oNavigationItem->getChildren(null, false, true), $iLevel + 1);
             }
         }
     };
     $cGather(array(PageNavigationItem::navigationItemForPage(PagePeer::getRootPage())), 0);
     return $aResult;
 }
 public function renderFile()
 {
     //Prerequisites
     Session::getSession()->setLanguage($this->sLanguageId);
     //Clear index
     SearchIndexQuery::create()->filterByLanguageId($this->sLanguageId)->delete();
     //Spider index
     $oRootPage = PagePeer::getRootPage();
     $this->oRootNavigationItem = PageNavigationItem::navigationItemForPage($oRootPage);
     $this->spider($this->oRootNavigationItem);
     //GC
     gc_enable();
     //Update index
     PreviewManager::setTemporaryManager('FrontendManager');
     foreach ($this->aIndexPaths as $aPath) {
         $bIsIndexed = $this->index($aPath);
         set_time_limit(30);
         $this->gc();
         $sMessage = $bIsIndexed ? 'Indexed' : 'Skipped';
         print "{$sMessage} <code>/" . htmlentities(implode('/', $aPath)) . "</code><br>\n";
     }
     PreviewManager::revertTemporaryManager();
 }
Beispiel #9
0
 /**
  * __construct()
  */
 public function __construct()
 {
     parent::__construct();
     $this->aPathRequestParams = array();
     $this->bIsNotFound = false;
     $this->initLanguage();
     // Find requested page
     $oRootPage = PagePeer::getRootPage();
     if ($oRootPage === null) {
         throw new Exception("No root node exists in the database. Use the admin tool to create one.");
     }
     $this->oRootNavigationItem = PageNavigationItem::navigationItemForPage($oRootPage);
     $oMatchingNavigationItem = $this->oRootNavigationItem;
     while (self::hasNextPathItem()) {
         $oNextNavigationItem = $oMatchingNavigationItem->namedChild(self::usePath(), Session::language(), false, true);
         if ($oNextNavigationItem !== null) {
             $oMatchingNavigationItem = $oNextNavigationItem;
         } else {
             self::unusePath();
             break;
         }
     }
     self::$CURRENT_NAVIGATION_ITEM = $oMatchingNavigationItem;
     $oParent = $oMatchingNavigationItem;
     while (!$oParent instanceof PageNavigationItem) {
         $oParent = $oParent->getParent();
     }
     if ($oParent !== $oMatchingNavigationItem) {
         $oParent->setCurrent(false);
     }
     self::$CURRENT_PAGE = $oParent->getMe();
     // See if the filter(s) changed anything
     FilterModule::getFilters()->handleNavigationPathFound($this->oRootNavigationItem, $oMatchingNavigationItem);
     // There may now be new, virtual navigation items. Follow them.
     while (self::hasNextPathItem()) {
         $oNextNavigationItem = $oMatchingNavigationItem->namedChild(self::usePath(), Session::language(), false, true);
         if ($oNextNavigationItem !== null) {
             $oMatchingNavigationItem = $oNextNavigationItem;
         } else {
             self::unusePath();
             break;
         }
     }
     // See if anything has changed
     if (self::$CURRENT_NAVIGATION_ITEM !== $oMatchingNavigationItem && self::$CURRENT_NAVIGATION_ITEM instanceof PageNavigationItem) {
         self::$CURRENT_NAVIGATION_ITEM->setCurrent(false);
         //It is, however, still active
     }
     self::$CURRENT_NAVIGATION_ITEM = $oMatchingNavigationItem;
     $iTimesUsed = 0;
     while (self::hasNextPathItem()) {
         $sKey = self::usePath();
         $iTimesUsed++;
         $sValue = null;
         if (self::hasNextPathItem()) {
             $sValue = self::usePath();
             $iTimesUsed++;
         }
         $this->aPathRequestParams[] = $sKey;
         if (!isset($_REQUEST[$sKey]) && $sValue !== null) {
             $_REQUEST[$sKey] = $sValue;
         }
     }
     for ($i = 1; $i <= $iTimesUsed; $i++) {
         self::unusePath();
     }
     if ($oMatchingNavigationItem->isFolder()) {
         $oFirstChild = $oMatchingNavigationItem->getFirstChild(Session::language(), false, true);
         if ($oFirstChild !== null) {
             $aAdditionalPathItems = array();
             $aRequestParams = LinkUtil::getRequestedParameters();
             foreach (self::getRequestPath() as $iKey => $sPathItem) {
                 if ($iKey % 2 === 0 && isset($aRequestParams[$sPathItem])) {
                     unset($aRequestParams[$sPathItem]);
                 }
                 $aAdditionalPathItems[] = $sPathItem;
             }
             LinkUtil::redirectToManager(array_merge($oFirstChild->getLink(), $aAdditionalPathItems), null, $aRequestParams);
         } else {
             $this->bIsNotFound = true;
         }
     }
     if ($oMatchingNavigationItem->isProtected()) {
         if (!$oMatchingNavigationItem->isAccessible()) {
             $oLoginPage = self::$CURRENT_PAGE->getLoginPage();
             if ($oLoginPage !== self::$CURRENT_PAGE) {
                 Session::getSession()->setAttribute('login_referrer_page', self::$CURRENT_PAGE);
                 Session::getSession()->setAttribute('login_referrer', LinkUtil::link($oMatchingNavigationItem->getLink(), "FrontendManager"));
             }
             if ($oLoginPage === null) {
                 LinkUtil::redirect(LinkUtil::link('', "LoginManager"));
             }
             self::$CURRENT_PAGE = $oLoginPage;
         }
     }
     FilterModule::getFilters()->handlePageHasBeenSet(self::$CURRENT_PAGE, $this->bIsNotFound, self::$CURRENT_NAVIGATION_ITEM);
 }
 public function createPage($iParentId, $sPageName)
 {
     $oParentPage = PageQuery::create()->findPk($iParentId);
     if ($oParentPage == null) {
         $oParentPage = PagePeer::getRootPage();
     }
     $sPageTitle = $sPageName;
     $sPageName = StringUtil::normalizeToASCII($sPageName);
     if (!$sPageName) {
         // If all we have are special chars, leave the page name as is and only normalize minimally
         $sPageName = $sPageTitle;
     }
     $sPageName = StringUtil::normalizePath($sPageName);
     if (PagePeer::pageIsNotUnique($sPageName, $oParentPage)) {
         $oFlash = Flash::getFlash();
         $oFlash->addMessage('page.name_unique_required');
         $oFlash->finishReporting();
         throw new ValidationException($oFlash);
     }
     $oPage = new Page();
     $oPage->setName($sPageName);
     $oPageString = new PageString();
     $oPageString->setLanguageId(AdminManager::getContentLanguage());
     $oPageString->setIsInactive(false);
     $oPageString->setLinkText(null);
     $oPageString->setPageTitle($sPageTitle);
     $oPage->addPageString($oPageString);
     $oPage->setPageType('default');
     $oPage->setTemplateName($oParentPage->getTemplateName());
     $oPage->setIsInactive(true);
     $oPage->insertAsLastChildOf($oParentPage);
     return $oPage->save();
 }