function run()
 {
     //get a page history ?
     $oPage = null;
     $oPageGroup = null;
     $oPageGroup = $this->getPageGroupForHistory();
     if (!$oPageGroup) {
         // did we requested a page history?
         $oPage = $this->getPageForHistory();
     }
     //page title
     if ($oPage) {
         $sTitle = $this->t_("history_t", array("pagename" => $oPage->getName()));
     } else {
         if ($oPageGroup) {
             $sTitle = $this->t_("history_pagegroup_t", array("pagegroupid" => $oPageGroup->getId()));
         } else {
             $sTitle = $this->t_("title");
         }
     }
     $this->setTitle($sTitle);
     //filter change types
     $amAllChangeTypes = AnwChange::getChangeTypes();
     $amDisplayChangeTypes = array();
     foreach ($amAllChangeTypes as $mChangeType) {
         if (AnwEnv::_GET("ct_" . $mChangeType)) {
             $amDisplayChangeTypes[] = $mChangeType;
         }
     }
     if (count($amDisplayChangeTypes) == 0) {
         $amDisplayChangeTypes = $amAllChangeTypes;
         if (!$oPage) {
             $amDisplayChangeTypes = AnwUtils::array_remove($amDisplayChangeTypes, AnwChange::TYPE_PAGE_EDITION_DEPLOY);
             $amDisplayChangeTypes = AnwUtils::array_remove($amDisplayChangeTypes, AnwChange::TYPE_PAGE_UPDATELINKS);
         }
     }
     //initialize filters
     list($asAllLangs, $asDisplayLangs) = $this->filterLangs(array("view"), true);
     list($asAllClasses, $asDisplayClasses) = $this->filterContentClasses();
     $nDefaultDisplayModeGrouped = 1;
     //disable filters if a page is selected
     if ($oPage || $oPageGroup) {
         $asDisplayLangs = $asAllLangs;
         $asDisplayClasses = $asAllClasses;
         $nDefaultDisplayModeGrouped = 0;
         //show in detailled mode by default
     }
     //display mode
     $bGrouped = AnwEnv::_GET("fg", $nDefaultDisplayModeGrouped);
     //limit
     $nLimit = $this->cfg(self::CFG_LIMIT);
     if ($bGrouped) {
         $nLimit *= 2;
     }
     //TODO
     $nStart = (int) AnwEnv::_GET("s", 0);
     $nStartPrev = $nStart - $nLimit;
     $nStartNext = $nStart + $nLimit;
     //get last changes
     $aoChanges = AnwStorage::getLastChanges($nLimit, $nStart, $asDisplayLangs, $asDisplayClasses, $amDisplayChangeTypes, $oPage, $oPageGroup);
     if ($bGrouped) {
         $aoChanges = AnwSimilarChanges::groupSimilarChanges($aoChanges);
     }
     //check permissions
     foreach ($aoChanges as $i => $oChange) {
         if ($oChange->getPage() && !$oChange->getPage()->isActionAllowed("view") || !AnwCurrentSession::isActionAllowed($oChange->getPageName(), "view", $oChange->getPageLang())) {
             unset($aoChanges[$i]);
         }
     }
     if (AnwEnv::_GET("feed")) {
         $this->showFeed($aoChanges);
     } else {
         $this->showHtml($aoChanges, $amAllChangeTypes, $amDisplayChangeTypes, $asAllLangs, $asDisplayLangs, $asAllClasses, $asDisplayClasses, $nStartPrev, $nStartNext, $sTitle, $bGrouped, $oPage, $oPageGroup);
     }
 }
Example #2
0
    private function showFormRevert($oPageGroup, $aaRevertPlan, $nRevToChangeId)
    {
        $aoChanges = array();
        $aoChangesUnfiltered = AnwStorage::getLastChanges(false, 0, null, null, null, null, $oPageGroup);
        foreach ($aoChangesUnfiltered as $oChange) {
            // only keep "revertable" changes
            if ($oChange->isRevertAvailable()) {
                $aoChanges[] = $oChange;
            }
        }
        $sHistoryPageGroupLink = false;
        if (AnwCurrentSession::isActionGlobalAllowed("lastchanges")) {
            $sHistoryPageGroupLink = AnwUtils::aLink("lastchanges", array("pagegroup" => $oPageGroup->getId()));
        }
        $this->out .= $this->tpl()->formRevert($this->linkMe(array("pagegroup" => $oPageGroup->getId())), $aoChanges, $nRevToChangeId, $sHistoryPageGroupLink);
        foreach ($aaRevertPlan['DELETE'] as $oPageForDelete) {
            $this->out .= $this->tpl()->simulateDelete($oPageForDelete->getLang(), $oPageForDelete->getName());
        }
        foreach ($aaRevertPlan['REVERT'] as $aoRevertPages) {
            $oPageCurrent = $aoRevertPages[0];
            $oPageForRevert = $aoRevertPages[1];
            if ($oPageCurrent->isGlobalAndViewActionAllowed('diff')) {
                $sImgDiff = AnwUtils::xQuote(AnwUtils::pathImg("diff.gif"));
                $sAltDiff = AnwUtils::xQuote(self::g_("change_diff_link"));
                $sLnkDiff = AnwUtils::xQuote(AnwUtils::link($oPageCurrent, "diff", array("page" => $oPageCurrent->getId(), "revfrom" => $oPageCurrent->getChangeId(), "revto" => $oPageForRevert->getChangeId())));
                $sLnkDiff = <<<EOF
<a href="{$sLnkDiff}" title="{$sAltDiff}" target="_blank"><img src="{$sImgDiff}" alt="{$sAltDiff}"/></a>
EOF;
            } else {
                $sLnkDiff = '';
            }
            $this->out .= $this->tpl()->simulateRevert($oPageCurrent->getLang(), $oPageCurrent->getName(), $oPageForRevert, $sLnkDiff);
        }
        foreach ($aaRevertPlan['RESTORE'] as $oPageForRestore) {
            $this->out .= $this->tpl()->simulateCreate($oPageForRestore);
        }
        foreach ($aaRevertPlan['KEEP'] as $oPageForKeep) {
            $this->out .= $this->tpl()->simulateKeep($oPageForKeep->getLang(), $oPageForKeep->getName());
        }
        $this->out .= $this->tpl()->end();
    }
Example #3
0
 function getPageRevisions($nLimit = false)
 {
     if (!$this->exists()) {
         throw new AnwUnexpectedException("Can't get page revisions for a non-existing page");
     }
     $aoChanges = AnwStorage::getLastChanges($nLimit, 0, null, null, null, $this);
     $aoPageRevisions = array();
     foreach ($aoChanges as $oChange) {
         if ($oChange->getPage() && $oChange->getPage()->exists()) {
             //$aoPageRevisions[] = new AnwPageById($this->getId(), $oChange->getTime(), $oChange);
             $aoPageRevisions[] = $oChange->getPage();
         }
     }
     return $aoPageRevisions;
 }