+ var $mArticle, $mTitle, $mRequest;
+ var $mOldId, $mGen, $mCharset, $mSection;
+ var $mSmaxage, $mMaxage;
+ var $mContentType, $mExpandTemplates;
+
+ function __construct( Article $article, $request = false ) {
+ global $wgRequest, $wgInputEncoding, $wgSquidMaxage, $wgJsMimeType, $wgGroupPermissions;
+
+ $allowedCTypes = array( 'text/x-wiki', $wgJsMimeType, 'text/css', 'application/x-zope-edit' );
+ $this->mArticle = $article;
+ $this->mTitle = $article->mTitle;
+
+ if( $request === false ) {
+ $this->mRequest = $wgRequest;
+ } else {
+ $this->mRequest = $request;
+ }
+
+ $ctype = $this->mRequest->getVal( 'ctype' );
+ $smaxage = $this->mRequest->getIntOrNull( 'smaxage' );
+ $maxage = $this->mRequest->getInt( 'maxage', $wgSquidMaxage );
+
+ $this->mExpandTemplates = $this->mRequest->getVal( 'templates' ) === 'expand';
+ $this->mUseMessageCache = $this->mRequest->getBool( 'usemsgcache' );
+
+ $this->mSection = $this->mRequest->getIntOrNull( 'section' );
+
+ $oldid = $this->mRequest->getInt( 'oldid' );
+
+ switch( $wgRequest->getText( 'direction' ) ) {
+ case 'next':
+ # output next revision, or nothing if there isn't one
+ if( $oldid ) {
+ $oldid = $this->mTitle->getNextRevisionId( $oldid );
+ }
+ $oldid = $oldid ? $oldid : -1;
+ break;
+ case 'prev':
+ # output previous revision, or nothing if there isn't one
+ if( !$oldid ) {
+ # get the current revision so we can get the penultimate one
+ $this->mArticle->getTouched();
+ $oldid = $this->mArticle->mLatest;
+ }
+ $prev = $this->mTitle->getPreviousRevisionId( $oldid );
+ $oldid = $prev ? $prev : -1 ;
+ break;
+ case 'cur':
+ $oldid = 0;
+ break;
+ }
+ $this->mOldId = $oldid;