X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FHistoryPage.php;h=11315acfd510ecde00b1800110a5431a277c68d6;hb=0399907dbddd4c9808a91a06f64e44beb1fc2c26;hp=620f0e6b17c3953eefbddb147dc3512d428a4aed;hpb=9e9e22fb86350136d38306f39918c3149207685d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/HistoryPage.php b/includes/HistoryPage.php index 620f0e6b17..11315acfd5 100644 --- a/includes/HistoryPage.php +++ b/includes/HistoryPage.php @@ -15,40 +15,33 @@ * history. * */ -class HistoryPage { +class HistoryPage extends ContextSource { const DIR_PREV = 0; const DIR_NEXT = 1; - /** Contains the Article object. Passed on construction. */ - private $article; - /** The $article title object. Found on construction. */ - private $title; - /** Shortcut to the user Skin object. */ - private $skin; + /** Contains the Page object. Passed on construction. */ + protected $article; /** * Construct a new HistoryPage. * * @param $article Article */ - function __construct( $article ) { - global $wgUser; - $this->article = $article; - $this->title = $article->getTitle(); - $this->skin = $wgUser->getSkin(); + function __construct( Page $page, IContextSource $context ) { + $this->article = $page; + $this->context = clone $context; // don't clobber the main context + $this->context->setTitle( $page->getTitle() ); // must match $this->preCacheMessages(); } - /** Get the Article object we are working on. */ + /** + * Get the Article object we are working on. + * @return Page + */ public function getArticle() { return $this->article; } - /** Get the Title object. */ - public function getTitle() { - return $this->title; - } - /** * As we use the same small set of messages in various methods and that * they are called often, we call them once and save them in $this->message @@ -68,52 +61,61 @@ class HistoryPage { * @return nothing */ function history() { - global $wgOut, $wgRequest, $wgScript; + global $wgScript, $wgUseFileCache; + $out = $this->getOutput(); + $request = $this->getRequest(); /** * Allow client caching. */ - if ( $wgOut->checkLastModified( $this->article->getTouched() ) ) + if ( $out->checkLastModified( $this->article->getTouched() ) ) { return; // Client cache fresh and headers sent, nothing more to do. + } wfProfileIn( __METHOD__ ); + # Fill in the file cache if not set already + if ( $wgUseFileCache && HTMLFileCache::useFileCache( $this->getContext() ) ) { + $cache = HTMLFileCache::newFromTitle( $this->getTitle(), 'history' ); + if ( !$cache->isCacheGood( /* Assume up to date */ ) ) { + ob_start( array( &$cache, 'saveToFileCache' ) ); + } + } + // 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.views.history' ) ); + $out->setPageTitle( wfMsg( 'history-title', $this->getTitle()->getPrefixedText() ) ); + $out->setPageTitleActionText( wfMsg( 'history_short' ) ); + $out->setArticleFlag( false ); + $out->setArticleRelated( true ); + $out->setRobotPolicy( 'noindex,nofollow' ); + $out->setFeedAppendQuery( 'action=history' ); + $out->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( + $logLink = Linker::linkKnown( $logPage, wfMsgHtml( 'viewpagelogs' ), array(), - array( 'page' => $this->title->getPrefixedText() ), - array( 'known', 'noclasses' ) + array( 'page' => $this->getTitle()->getPrefixedText() ) ); - $wgOut->setSubtitle( $logLink ); + $out->setSubtitle( $logLink ); // Handle atom/RSS feeds. - $feedType = $wgRequest->getVal( 'feed' ); + $feedType = $request->getVal( 'feed' ); if ( $feedType ) { wfProfileOut( __METHOD__ ); return $this->feed( $feedType ); } // Fail nicely if article doesn't exist. - if ( !$this->title->exists() ) { - $wgOut->addWikiMsg( 'nohistory' ); + if ( !$this->getTitle()->exists() ) { + $out->addWikiMsg( 'nohistory' ); # show deletion/move log if there is an entry LogEventsList::showLogExtract( - $wgOut, + $out, array( 'delete', 'move' ), - $this->title->getPrefixedText(), + $this->getTitle(), '', array( 'lim' => 10, 'conds' => array( "log_action != 'revision'" ), @@ -128,32 +130,32 @@ class HistoryPage { /** * Add date selector to quickly get to a certain time */ - $year = $wgRequest->getInt( 'year' ); - $month = $wgRequest->getInt( 'month' ); - $tagFilter = $wgRequest->getVal( 'tagfilter' ); + $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 ( $wgRequest->getBool( 'deleted' ) ) { + if ( $request->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"; + 'deleted', 'mw-show-deleted-only', $request->getBool( 'deleted' ) ) . "\n"; // Add the general form $action = htmlspecialchars( $wgScript ); - $wgOut->addHTML( + $out->addHTML( "