private function saveTranslations($sAddLang)
 {
     try {
         if (!Anwi18n::langExists($sAddLang)) {
             throw new AnwBadLangException();
         }
         $this->out .= $this->tpl()->startProcess();
         $bSomethingDone = false;
         $aoPageGroups = AnwStorage::getPageGroups(false, null, null);
         AnwStorage::transactionStart();
         try {
             foreach ($aoPageGroups as $oPageGroup) {
                 $aoPages = $oPageGroup->getPages();
                 $bChecked = AnwEnv::_POST($this->getChkName($oPageGroup));
                 if (!isset($aoPages[$sAddLang]) && $bChecked) {
                     $sTranslationName = AnwEnv::_POST($this->getInputName($oPageGroup));
                     //check permissions : translate
                     if (!AnwCurrentSession::isActionAllowed($sTranslationName, 'translate', $sAddLang)) {
                         throw new AnwAclException("permission translate denied");
                     }
                     //find PageRef
                     $nPageRefId = (int) AnwEnv::_POST($this->getInputRef($oPageGroup));
                     $oPageRef = new AnwPageById($nPageRefId);
                     if (isset($aoPages[$oPageRef->getLang()]) && $oPageRef->getId() == $aoPages[$oPageRef->getLang()]->getId()) {
                         //create translation
                         $oPageTranslation = $oPageRef->createNewTranslation($sTranslationName, $sAddLang);
                         $this->out .= $this->tpl()->newTranslationCreated($sAddLang, $oPageTranslation->link());
                         $bSomethingDone = true;
                     }
                 }
             }
             AnwStorage::transactionCommit();
         } catch (AnwException $e) {
             AnwStorage::transactionRollback();
             throw $e;
         }
         $sUrlContinue = $this->linkMe(array("addlang" => $sAddLang));
         if (!$bSomethingDone) {
             AnwUtils::redirect($sUrlContinue);
         }
         $this->out .= $this->tpl()->endProcess($sUrlContinue);
     } catch (AnwBadPageNameException $e) {
         $this->showForm($sAddLang, $this->g_("err_badpagename"));
     } catch (AnwBadLangException $e) {
         $this->showForm($sAddLang, $this->g_("err_badlang"));
     } catch (AnwPageAlreadyExistsException $e) {
         $this->showForm($sAddLang, $this->g_("err_pagealreadyexists"));
     } catch (AnwAclException $e) {
         $this->showForm($sAddLang, $this->g_("err_nopermission"));
     } catch (AnwLangExistsForPageGroupException $e) {
         $this->showForm($sAddLang, $this->g_("err_langexistsforpagegroup"));
     }
 }
Esempio n. 2
0
 function getActivePage()
 {
     if ($this->bActivePageExists === false) {
         return null;
     }
     if ($this->oPage) {
         return $this->oPage->getActivePage();
     }
     $oPage = new AnwPageById($this->getPageId());
     if ($oPage->exists()) {
         return $oPage;
     }
     return null;
 }
Esempio n. 3
0
 private static function getLockFromData($oData)
 {
     $oLockPage = new AnwPageById($oData->LockPage);
     $oLockPage->setSkipLoadingContent(true);
     $oLockUser = self::sqlToUser($oData->LockUser, $oData->LockUserName);
     $nLockTime = $oData->LockTime;
     $nLockTimeLast = $oData->LockTimeLast;
     $nLockType = $oData->LockType;
     $oLock = new AnwLock($oLockPage, $oLockUser, $nLockTime, $nLockTimeLast, $nLockType);
     return $oLock;
 }
Esempio n. 4
0
 static function getPageByChangeId($nPageId, $nChangeId)
 {
     //is it active page?
     $oPage = new AnwPageById($nPageId);
     if ($oPage->exists() && $oPage->getChangeId() == $nChangeId) {
         return $oPage;
     }
     //is it an archive?
     $oPage = new AnwPageById($nPageId, $nChangeId);
     if ($oPage->exists() && $oPage->getChangeId() == $nChangeId) {
         return $oPage;
     }
     throw new AnwPageNotFoundException();
 }