/**
  * Returns the pagegroup requested for history.
  */
 protected function getPageGroupForHistory()
 {
     static $oPageGroupForHistory = null, $bInitialized = false;
     // only initialize first time for performances saving
     if (!$bInitialized) {
         $nPageGroupId = (int) AnwEnv::_GET("pagegroup");
         if ($nPageGroupId > 0) {
             $oPageGroupTmp = new AnwPageGroup($nPageGroupId);
             if ($oPageGroupTmp->exists()) {
                 $oPageGroupForHistory = $oPageGroupTmp;
             }
         }
     }
     return $oPageGroupForHistory;
 }
Beispiel #2
0
 function run()
 {
     //find TO revision
     try {
         //retrieve pagegroup
         $nPageGroupId = (int) AnwEnv::_GET("pagegroup", AnwEnv::_POST("pagegroup"));
         if (!$nPageGroupId) {
             //special case: we may have passed a pageid (ie: from lastchanges, for better performances avoiding loading pagegroup info)
             $nPageId = (int) AnwEnv::_GET("page");
             if ($nPageId) {
                 $oExistingPageTmp = AnwPage::getLastPageRevision($nPageId);
                 //high queries consuming, not 100% cached...
                 if ($oExistingPageTmp->exists()) {
                     $nPageGroupId = $oExistingPageTmp->getPageGroup()->getId();
                 }
                 unset($oExistingPageTmp);
             }
             if (!$nPageGroupId) {
                 throw new AnwBadCallException();
             }
         }
         $oPageGroup = new AnwPageGroup($nPageGroupId);
         if (!$oPageGroup->exists()) {
             throw new AnwBadCallException("pagegroup not found for revert");
         }
         //get valid changeid
         $aoPageGroupChangesById = AnwStorage::getLastChanges(false, 0, null, null, null, null, $oPageGroup);
         $nRevToChangeId = (int) AnwEnv::_GET("revto", AnwEnv::_POST("revto"));
         //may be null when coming from action_revertpage
         if (!$nRevToChangeId || !array_key_exists($nRevToChangeId, $aoPageGroupChangesById)) {
             //get last changeid from this pagegroup
             $oChangeReference = reset($aoPageGroupChangesById);
             $nRevToChangeId = $oChangeReference->getChangeId();
         }
     } catch (AnwException $e) {
         throw new AnwBadCallException();
     }
     $this->setTitle($this->t_("title"));
     $aaRevertPlan = $this->generateRevertPlan($oPageGroup, $nRevToChangeId);
     if (AnwEnv::_POST("submit") && $nRevToChangeId > 0) {
         $this->doRevert($oPageGroup, $aaRevertPlan);
     } else {
         $this->showFormRevert($oPageGroup, $aaRevertPlan, $nRevToChangeId);
     }
 }
 protected static function getCategoriesPages($oContent, $oPage)
 {
     $anCategoriesPageGroupIds = $oContent->getContentFieldValues(self::FIELD_CATEGORIES);
     $aoCategoriesPage = array();
     foreach ($anCategoriesPageGroupIds as $nCategoryPageGroupId) {
         try {
             $oCategoryPageGroup = new AnwPageGroup($nCategoryPageGroupId, self::NEWS_CLASS);
             if ($oCategoryPageGroup->exists()) {
                 //get category in current lang if available
                 $oPageNews = $oCategoryPageGroup->getPreferedPage($oPage->getLang());
                 $aoCategoriesPage[] = $oPageNews;
             }
         } catch (AnwException $e) {
         }
     }
     return $aoCategoriesPage;
 }