Example #1
0
 private static function initializeRootPage()
 {
     $oRootPage = new Page();
     $oRootPage->makeRoot();
     $oRootPage->setName('root');
     $oRootPage->setIsInactive(false);
     $oRootPage->setPageType('default');
     $oRootPage->setTemplateName(null);
     $oFirstUser = UserQuery::create()->findOne();
     $oFirstUserId = $oFirstUser !== null ? $oFirstUser->getId() : 0;
     $oRootPage->setCreatedBy($oFirstUserId);
     $oRootPage->setUpdatedBy($oFirstUserId);
     $sPageString = new PageString();
     $sPageString->setLanguageId(Settings::getSetting("session_default", Session::SESSION_LANGUAGE_KEY, 'de'));
     $sPageString->setPageTitle('Home');
     $sPageString->setIsInactive(false);
     $oRootPage->addPageString($sPageString);
     $oRootPage->save();
     return $oRootPage;
 }
Example #2
0
 /**
  * Declares an association between this object and a Page object.
  *
  * @param                  Page $v
  * @return PageString The current object (for fluent API support)
  * @throws PropelException
  */
 public function setPage(Page $v = null)
 {
     if ($v === null) {
         $this->setPageId(NULL);
     } else {
         $this->setPageId($v->getId());
     }
     $this->aPage = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Page object, it will not be re-added.
     if ($v !== null) {
         $v->addPageString($this);
     }
     return $this;
 }
 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();
 }