Example #1
0
 /**
  * Print the history page for an article.
  * @return nothing
  */
 function history()
 {
     global $wgOut, $wgRequest, $wgScript;
     /**
      * Allow client caching.
      */
     if ($wgOut->checkLastModified($this->article->getTouched())) {
         return;
     }
     // Client cache fresh and headers sent, nothing more to do.
     wfProfileIn(__METHOD__);
     // Setup page variables.
     $wgOut->setPageTitle(wfMsg('history-title', $this->title->getPrefixedText()));
     $wgOut->setPageTitleActionText(wfMsg('history_short'));
     $wgOut->setArticleFlag(false);
     $wgOut->setArticleRelated(true);
     $wgOut->setRobotPolicy('noindex,nofollow');
     $wgOut->setSyndicated(true);
     $wgOut->setFeedAppendQuery('action=history');
     $wgOut->addModules(array('mediawiki.legacy.history', 'mediawiki.action.history'));
     // Creation of a subtitle link pointing to [[Special:Log]]
     $logPage = SpecialPage::getTitleFor('Log');
     $logLink = $this->skin->link($logPage, wfMsgHtml('viewpagelogs'), array(), array('page' => $this->title->getPrefixedText()), array('known', 'noclasses'));
     $wgOut->setSubtitle($logLink);
     // Handle atom/RSS feeds.
     $feedType = $wgRequest->getVal('feed');
     if ($feedType) {
         wfProfileOut(__METHOD__);
         return $this->feed($feedType);
     }
     // Fail nicely if article doesn't exist.
     if (!$this->title->exists()) {
         $wgOut->addWikiMsg('nohistory');
         # show deletion/move log if there is an entry
         LogEventsList::showLogExtract($wgOut, array('delete', 'move'), $this->title->getPrefixedText(), '', array('lim' => 10, 'conds' => array("log_action != 'revision'"), 'showIfEmpty' => false, 'msgKey' => array('moveddeleted-notice')));
         wfProfileOut(__METHOD__);
         return;
     }
     /**
      * Add date selector to quickly get to a certain time
      */
     $year = $wgRequest->getInt('year');
     $month = $wgRequest->getInt('month');
     $tagFilter = $wgRequest->getVal('tagfilter');
     $tagSelector = ChangeTags::buildTagFilterSelector($tagFilter);
     /**
      * Option to show only revisions that have been (partially) hidden via RevisionDelete
      */
     if ($wgRequest->getBool('deleted')) {
         $conds = array("rev_deleted != '0'");
     } else {
         $conds = array();
     }
     $checkDeleted = Xml::checkLabel(wfMsg('history-show-deleted'), 'deleted', 'mw-show-deleted-only', $wgRequest->getBool('deleted')) . "\n";
     // Add the general form
     $action = htmlspecialchars($wgScript);
     $wgOut->addHTML("<form action=\"{$action}\" method=\"get\" id=\"mw-history-searchform\">" . Xml::fieldset(wfMsg('history-fieldset-title'), false, array('id' => 'mw-history-search')) . Html::hidden('title', $this->title->getPrefixedDBKey()) . "\n" . Html::hidden('action', 'history') . "\n" . Xml::dateMenu($year, $month) . '&#160;' . ($tagSelector ? implode('&#160;', $tagSelector) . '&#160;' : '') . $checkDeleted . Xml::submitButton(wfMsg('allpagessubmit')) . "\n" . '</fieldset></form>');
     wfRunHooks('PageHistoryBeforeList', array(&$this->article));
     // Create and output the list.
     $pager = new HistoryPager($this, $year, $month, $tagFilter, $conds);
     $wgOut->addHTML($pager->getNavigationBar() . $pager->getBody() . $pager->getNavigationBar());
     $wgOut->preventClickjacking($pager->getPreventClickjacking());
     wfProfileOut(__METHOD__);
 }
 /**
  * Print the history page for an article.
  */
 function onView()
 {
     $out = $this->getOutput();
     $request = $this->getRequest();
     /**
      * Allow client caching.
      */
     if ($out->checkLastModified($this->page->getTouched())) {
         return;
         // Client cache fresh and headers sent, nothing more to do.
     }
     wfProfileIn(__METHOD__);
     $this->preCacheMessages();
     $config = $this->context->getConfig();
     # Fill in the file cache if not set already
     $useFileCache = $config->get('UseFileCache');
     if ($useFileCache && HTMLFileCache::useFileCache($this->getContext())) {
         $cache = HTMLFileCache::newFromTitle($this->getTitle(), 'history');
         if (!$cache->isCacheGood()) {
             ob_start(array(&$cache, 'saveToFileCache'));
         }
     }
     // Setup page variables.
     $out->setFeedAppendQuery('action=history');
     $out->addModules('mediawiki.action.history');
     if ($config->get('UseMediaWikiUIEverywhere')) {
         $out = $this->getOutput();
         $out->addModuleStyles(array('mediawiki.ui.input', 'mediawiki.ui.checkbox'));
     }
     // Handle atom/RSS feeds.
     $feedType = $request->getVal('feed');
     if ($feedType) {
         $this->feed($feedType);
         wfProfileOut(__METHOD__);
         return;
     }
     // Fail nicely if article doesn't exist.
     if (!$this->page->exists()) {
         $out->addWikiMsg('nohistory');
         # show deletion/move log if there is an entry
         LogEventsList::showLogExtract($out, array('delete', 'move'), $this->getTitle(), '', array('lim' => 10, 'conds' => array("log_action != 'revision'"), 'showIfEmpty' => false, 'msgKey' => array('moveddeleted-notice')));
         wfProfileOut(__METHOD__);
         return;
     }
     /**
      * Add date selector to quickly get to a certain time
      */
     $year = $request->getInt('year');
     $month = $request->getInt('month');
     $tagFilter = $request->getVal('tagfilter');
     $tagSelector = ChangeTags::buildTagFilterSelector($tagFilter);
     /**
      * Option to show only revisions that have been (partially) hidden via RevisionDelete
      */
     if ($request->getBool('deleted')) {
         $conds = array('rev_deleted != 0');
     } else {
         $conds = array();
     }
     if ($this->getUser()->isAllowed('deletedhistory')) {
         $checkDeleted = Xml::checkLabel($this->msg('history-show-deleted')->text(), 'deleted', 'mw-show-deleted-only', $request->getBool('deleted')) . "\n";
     } else {
         $checkDeleted = '';
     }
     // Add the general form
     $action = htmlspecialchars(wfScript());
     $out->addHTML("<form action=\"{$action}\" method=\"get\" id=\"mw-history-searchform\">" . Xml::fieldset($this->msg('history-fieldset-title')->text(), false, array('id' => 'mw-history-search')) . Html::hidden('title', $this->getTitle()->getPrefixedDBkey()) . "\n" . Html::hidden('action', 'history') . "\n" . Xml::dateMenu($year == null ? MWTimestamp::getLocalInstance()->format('Y') : $year, $month) . '&#160;' . ($tagSelector ? implode('&#160;', $tagSelector) . '&#160;' : '') . $checkDeleted . Xml::submitButton($this->msg('allpagessubmit')->text()) . "\n" . '</fieldset></form>');
     wfRunHooks('PageHistoryBeforeList', array(&$this->page, $this->getContext()));
     // Create and output the list.
     $pager = new HistoryPager($this, $year, $month, $tagFilter, $conds);
     $out->addHTML($pager->getNavigationBar() . $pager->getBody() . $pager->getNavigationBar());
     $out->preventClickjacking($pager->getPreventClickjacking());
     wfProfileOut(__METHOD__);
 }
 public static function addToHistLine(HistoryPager $history, $row, &$s, &$liClasses)
 {
     $fa = FlaggableWikiPage::getTitleInstance($history->getTitle());
     if (!$fa->isReviewable()) {
         return true;
         // nothing to do here
     }
     # Fetch and process cache the stable revision
     if (!isset($history->fr_stableRevId)) {
         $srev = $fa->getStableRev();
         $history->fr_stableRevId = $srev ? $srev->getRevId() : null;
         $history->fr_stableRevUTS = $srev ? wfTimestamp(TS_UNIX, $srev->getRevTimestamp()) : null;
         $history->fr_pendingRevs = false;
     }
     if (!$history->fr_stableRevId) {
         return true;
         // nothing to do here
     }
     $title = $history->getTitle();
     $revId = (int) $row->rev_id;
     // Pending revision: highlight and add diff link
     $link = $class = '';
     if (wfTimestamp(TS_UNIX, $row->rev_timestamp) > $history->fr_stableRevUTS) {
         $class = 'flaggedrevs-pending';
         $link = wfMsgExt('revreview-hist-pending-difflink', 'parseinline', $title->getPrefixedText(), $history->fr_stableRevId, $revId);
         $link = '<span class="plainlinks mw-fr-hist-difflink">' . $link . '</span>';
         $history->fr_pendingRevs = true;
         // pending rev shown above stable
         // Reviewed revision: highlight and add link
     } elseif (isset($row->fr_quality)) {
         if (!($row->rev_deleted & Revision::DELETED_TEXT)) {
             # Add link to stable version of *this* rev, if any
             list($link, $class) = self::markHistoryRow($title, $row);
             # Space out and demark the stable revision
             if ($revId == $history->fr_stableRevId && $history->fr_pendingRevs) {
                 $liClasses[] = 'fr-hist-stable-margin';
             }
         }
     }
     # Style the row as needed
     if ($class) {
         $s = "<span class='{$class}'>{$s}</span>";
     }
     # Add stable old version link
     if ($link) {
         $s .= " {$link}";
     }
     return true;
 }