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")); } }