예제 #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;
 }
예제 #2
0
 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();
 }