Пример #1
0
 private function doRename($sNewName, $sComment, $bUpdateLinks)
 {
     $nTime = time();
     try {
         if (!AnwCurrentSession::isActionAllowed($sNewName, 'create', $this->getoPage()->getLang())) {
             throw new AnwAclException("permission create denied");
         }
         $oPageTest = new AnwPageByName($sNewName);
         $oPageTest->setSkipLoadingContent(true);
         if ($oPageTest->exists()) {
             throw new AnwPageAlreadyExistsException();
         }
         $sOldName = $this->getoPage()->getName();
         //rename page
         $this->getoPage()->rename($sNewName, $bUpdateLinks);
         //unlock
         $this->unlockPageForEdition();
         //redirect
         AnwUtils::redirect(AnwUtils::link($sNewName));
     } catch (AnwBadPageNameException $e) {
         $sError = $this->g_("err_badpagename");
         $this->renameForm($sNewName, $sComment, $sError);
     } catch (AnwBadCommentException $e) {
         $sError = $this->g_("err_badcomment");
         $this->renameForm($sNewName, $sComment, $sError);
     } catch (AnwPageAlreadyExistsException $e) {
         $sError = $this->g_("err_pagealreadyexists");
         $this->renameForm($sNewName, $sComment, $sError);
     } catch (AnwAclException $e) {
         $sError = $this->g_("err_nopermission");
         $this->renameForm($sNewName, $sComment, $sError);
     }
 }
Пример #2
0
 static function isCurrentPage($sPageName)
 {
     try {
         $sCurrentPage = AnwActionPage::getCurrentPageName();
         if ($sPageName == $sCurrentPage) {
             AnwDebug::log("isCurrentPage (" . $sPageName . ") : YES (currently " . $sCurrentPage . ")");
             return true;
         }
         //check translations if page exists
         $oPage = new AnwPageByName($sCurrentPage);
         if ($oPage->exists()) {
             $aoPages = $oPage->getPageGroup()->getPages();
             foreach ($aoPages as $oPageTranslation) {
                 if ($oPageTranslation->getName() == $sPageName) {
                     AnwDebug::log("isCurrentPage (" . $sPageName . ") : YES (currently " . $sCurrentPage . ")");
                     return true;
                 }
             }
         }
     } catch (AnwException $e) {
     }
     AnwDebug::log("isCurrentPage (" . $sPageName . ") : NO (currently " . $sCurrentPage . ")");
     return false;
 }
Пример #3
0
 static function getByNameOrSecondChance($sPageName)
 {
     //try to find page by name
     $oPageTest = new AnwPageByName($sPageName);
     if ($oPageTest->exists()) {
         return $oPageTest;
     }
     //if name not found, try second chance
     $oPageTest = $oPageTest->getSecondChance();
     if ($oPageTest) {
         return $oPageTest;
     }
     //page not found
     return false;
 }