Esempio n. 1
0
 function run()
 {
     // load CSS
     $this->head($this->getCssSrcComponent(self::CSS_FILENAME));
     //initialize filters
     list($asAllLangs, $asDisplayLangs) = $this->filterLangs(array("view"));
     list($asAllClasses, $asDisplayClasses) = $this->filterContentClasses();
     $this->setTitle($this->t_("title"));
     $aoPageGroups = AnwStorage::getPageGroups(true, $asDisplayLangs, $asDisplayClasses);
     $sFilters = $this->tpl()->filterStart($this->linkMe()) . $this->tpl()->filterLangs($asAllLangs, $asDisplayLangs) . $this->tpl()->filterClass($asAllClasses, $asDisplayClasses) . $this->tpl()->filterEnd();
     $this->out .= $this->tpl()->begin($sFilters);
     foreach ($aoPageGroups as $oPageGroup) {
         $tmpOut = "";
         $aoTranslations = $oPageGroup->getPages();
         foreach ($aoTranslations as $oPage) {
             if ($oPage->isActionAllowed('view')) {
                 $tmpOut .= $this->tpl()->rowTranslation($oPage, self::getPageNavEntriesAllowed($oPage));
             }
         }
         if ($tmpOut != "") {
             $this->out .= $this->tpl()->rowGroupOpen();
             $this->out .= $tmpOut;
             $this->out .= $this->tpl()->rowGroupClose();
         }
     }
     $this->out .= $this->tpl()->end();
 }
Esempio n. 2
0
 private function exportProcess($anExportPages)
 {
     //prepare an array of pages to be exported
     $aaExportPageGroups = array();
     $aoPageGroups = AnwStorage::getPageGroups();
     foreach ($aoPageGroups as $oPageGroup) {
         $bPageExported = false;
         $aoExportPages = array();
         $aoTranslations = $oPageGroup->getPages();
         foreach ($aoTranslations as $oPage) {
             $bExportDisabled = false;
             //check that page has been checked for export
             if (in_array($oPage->getId(), $anExportPages)) {
                 //check PHP permission
                 if ($oPage->hasPhpCode() && !AnwCurrentSession::getUser()->isPhpEditionAllowed()) {
                     $bExportDisabled = true;
                 }
                 //check ACL permission
                 if (!AnwCurrentSession::isActionAllowed($oPage->getName(), "export", $oPage->getLang())) {
                     $bExportDisabled = true;
                 }
                 //add page to pagegroup export array
                 if (!$bExportDisabled) {
                     $aoExportPages[] = $oPage;
                     $bPageExported = true;
                 }
             }
         }
         //add pagegroup to export array
         if ($bPageExported) {
             $aaExportPageGroups[] = array("GROUP" => $oPageGroup, "PAGES" => $aoExportPages);
         }
     }
     //export now
     $sExportData = $this->exportData($aaExportPageGroups);
     //output as a file
     $this->out = $sExportData;
     $sBackupDate = str_replace('/', '-', Anwi18n::date(time()));
     $sBackupDate .= '-' . date("H") . date("i") . date("s");
     $this->printOutputDownload("wiki-" . $sBackupDate . ".xml");
 }
 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"));
     }
 }