X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FArticle.php;h=6a3e41cb3c89345118717603bc783c75724ad350;hb=a682b7335a179cd0693d838c9bbd62485fe7cbad;hp=aaef36eea273ead76b7ac7bdaa1814e377436bde;hpb=61734aed90dc18a8c31890ec3c6323f36917663e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Article.php b/includes/Article.php index aaef36eea2..6a3e41cb3c 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -150,12 +150,23 @@ class Article extends Page { /** * Get the title object of the article + * * @return Title object of this page */ public function getTitle() { return $this->mPage->getTitle(); } + /** + * Get the WikiPage object of this instance + * + * @since 1.19 + * @return WikiPage + */ + public function getPage() { + return $this->mPage; + } + /** * Clear the object */ @@ -172,16 +183,14 @@ class Article extends Page { /** * Note that getContent/loadContent do not follow redirects anymore. * If you need to fetch redirectable content easily, try - * the shortcut in Article::followRedirect() + * the shortcut in WikiPage::getRedirectTarget() * * This function has side effects! Do not use this function if you * only want the real revision text if any. * - * @return Return the text of this revision + * @return string Return the text of this revision */ public function getContent() { - global $wgUser; - wfProfileIn( __METHOD__ ); if ( $this->mPage->getID() === 0 ) { @@ -193,7 +202,7 @@ class Article extends Page { $text = ''; } } else { - $text = wfMsgExt( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon', 'parsemag' ); + $text = wfMsgExt( $this->getContext()->getUser()->isLoggedIn() ? 'noarticletext' : 'noarticletextanon', 'parsemag' ); } wfProfileOut( __METHOD__ ); @@ -224,11 +233,10 @@ class Article extends Page { * @return int The old id for the request */ public function getOldIDFromRequest() { - global $wgRequest; - $this->mRedirectUrl = false; - $oldid = $wgRequest->getIntOrNull( 'oldid' ); + $request = $this->getContext()->getRequest(); + $oldid = $request->getIntOrNull( 'oldid' ); if ( $oldid === null ) { return 0; @@ -237,27 +245,33 @@ class Article extends Page { if ( $oldid !== 0 ) { # Load the given revision and check whether the page is another one. # In that case, update this instance to reflect the change. - $this->mRevision = Revision::newFromId( $oldid ); - if ( $this->mRevision !== null ) { - // Revision title doesn't match the page title given? - if ( $this->mPage->getID() != $this->mRevision->getPage() ) { - $function = array( get_class( $this->mPage ), 'newFromID' ); - $this->mPage = call_user_func( $function, $this->mRevision->getPage() ); + if ( $oldid === $this->mPage->getLatest() ) { + $this->mRevision = $this->mPage->getRevision(); + } else { + $this->mRevision = Revision::newFromId( $oldid ); + if ( $this->mRevision !== null ) { + // Revision title doesn't match the page title given? + if ( $this->mPage->getID() != $this->mRevision->getPage() ) { + $function = array( get_class( $this->mPage ), 'newFromID' ); + $this->mPage = call_user_func( $function, $this->mRevision->getPage() ); + } } } } - if ( $wgRequest->getVal( 'direction' ) == 'next' ) { + if ( $request->getVal( 'direction' ) == 'next' ) { $nextid = $this->getTitle()->getNextRevisionID( $oldid ); if ( $nextid ) { $oldid = $nextid; + $this->mRevision = null; } else { $this->mRedirectUrl = $this->getTitle()->getFullURL( 'redirect=no' ); } - } elseif ( $wgRequest->getVal( 'direction' ) == 'prev' ) { + } elseif ( $request->getVal( 'direction' ) == 'prev' ) { $previd = $this->getTitle()->getPreviousRevisionID( $oldid ); if ( $previd ) { $oldid = $previd; + $this->mRevision = null; } } @@ -356,6 +370,19 @@ class Article extends Page { return $this->mPage->exists() && $this->mRevision && $this->mRevision->isCurrent(); } + /** + * Get the fetched Revision object depending on request parameters or null + * on failure. + * + * @since 1.19 + * @return Revision|null + */ + public function getRevisionFetched() { + $this->fetchContent(); + + return $this->mRevision; + } + /** * Use this to fetch the rev ID used on page views * @@ -374,8 +401,7 @@ class Article extends Page { * page of the given title. */ public function view() { - global $wgUser, $wgOut, $wgRequest, $wgParser; - global $wgUseFileCache, $wgUseETag, $wgDebugToolbar; + global $wgParser, $wgUseFileCache, $wgUseETag, $wgDebugToolbar; wfProfileIn( __METHOD__ ); @@ -385,17 +411,19 @@ class Article extends Page { # the first call of this method even if $oldid is used way below. $oldid = $this->getOldID(); + $user = $this->getContext()->getUser(); # Another whitelist check in case getOldID() is altering the title - $permErrors = $this->getTitle()->getUserPermissionsErrors( 'read', $wgUser ); + $permErrors = $this->getTitle()->getUserPermissionsErrors( 'read', $user ); if ( count( $permErrors ) ) { wfDebug( __METHOD__ . ": denied on secondary read check\n" ); wfProfileOut( __METHOD__ ); throw new PermissionsError( 'read', $permErrors ); } + $outputPage = $this->getContext()->getOutput(); # getOldID() may as well want us to redirect somewhere else if ( $this->mRedirectUrl ) { - $wgOut->redirect( $this->mRedirectUrl ); + $outputPage->redirect( $this->mRedirectUrl ); wfDebug( __METHOD__ . ": redirecting due to oldid\n" ); wfProfileOut( __METHOD__ ); @@ -403,7 +431,7 @@ class Article extends Page { } # If we got diff in the query, we want to see a diff page instead of the article. - if ( $wgRequest->getCheck( 'diff' ) ) { + if ( $this->getContext()->getRequest()->getCheck( 'diff' ) ) { wfDebug( __METHOD__ . ": showing diff page\n" ); $this->showDiffPage(); wfProfileOut( __METHOD__ ); @@ -412,31 +440,31 @@ class Article extends Page { } # Set page title (may be overridden by DISPLAYTITLE) - $wgOut->setPageTitle( $this->getTitle()->getPrefixedText() ); + $outputPage->setPageTitle( $this->getTitle()->getPrefixedText() ); - $wgOut->setArticleFlag( true ); + $outputPage->setArticleFlag( true ); # Allow frames by default - $wgOut->allowClickjacking(); + $outputPage->allowClickjacking(); $parserCache = ParserCache::singleton(); $parserOptions = $this->getParserOptions(); # Render printable version, use printable version cache - if ( $wgOut->isPrintable() ) { + if ( $outputPage->isPrintable() ) { $parserOptions->setIsPrintable( true ); $parserOptions->setEditSection( false ); - } elseif ( !$this->getTitle()->quickUserCan( 'edit' ) ) { + } elseif ( !$this->isCurrent() || !$this->getTitle()->quickUserCan( 'edit' ) ) { $parserOptions->setEditSection( false ); } # Try client and file cache if ( !$wgDebugToolbar && $oldid === 0 && $this->mPage->checkTouched() ) { if ( $wgUseETag ) { - $wgOut->setETag( $parserCache->getETag( $this, $parserOptions ) ); + $outputPage->setETag( $parserCache->getETag( $this, $parserOptions ) ); } # Is it client cached? - if ( $wgOut->checkLastModified( $this->mPage->getTouched() ) ) { + if ( $outputPage->checkLastModified( $this->mPage->getTouched() ) ) { wfDebug( __METHOD__ . ": done 304\n" ); wfProfileOut( __METHOD__ ); @@ -445,8 +473,8 @@ class Article extends Page { } elseif ( $wgUseFileCache && $this->tryFileCache() ) { wfDebug( __METHOD__ . ": done file cache\n" ); # tell wgOut that output is taken care of - $wgOut->disable(); - $this->mPage->doViewUpdates( $this->getContext()->getUser() ); + $outputPage->disable(); + $this->mPage->doViewUpdates( $user ); wfProfileOut( __METHOD__ ); return; @@ -456,7 +484,7 @@ class Article extends Page { # Should the parser cache be used? $useParserCache = $this->mPage->isParserCacheUsed( $parserOptions, $oldid ); wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" ); - if ( $wgUser->getStubThreshold() ) { + if ( $user->getStubThreshold() ) { wfIncrStats( 'pcache_miss_stub' ); } @@ -494,14 +522,14 @@ class Article extends Page { } else { wfDebug( __METHOD__ . ": showing parser cache contents\n" ); } - $wgOut->addParserOutput( $this->mParserOutput ); + $outputPage->addParserOutput( $this->mParserOutput ); # Ensure that UI elements requiring revision ID have # the correct version information. - $wgOut->setRevisionId( $this->mPage->getLatest() ); + $outputPage->setRevisionId( $this->mPage->getLatest() ); # Preload timestamp to avoid a DB hit $cachedTimestamp = $this->mParserOutput->getTimestamp(); if ( $cachedTimestamp !== null ) { - $wgOut->setRevisionTimestamp( $cachedTimestamp ); + $outputPage->setRevisionTimestamp( $cachedTimestamp ); $this->mPage->setTimestamp( $cachedTimestamp ); } $outputDone = true; @@ -525,16 +553,16 @@ class Article extends Page { # Ensure that UI elements requiring revision ID have # the correct version information. - $wgOut->setRevisionId( $this->getRevIdFetched() ); + $outputPage->setRevisionId( $this->getRevIdFetched() ); # Preload timestamp to avoid a DB hit - $wgOut->setRevisionTimestamp( $this->getTimestamp() ); + $outputPage->setRevisionTimestamp( $this->getTimestamp() ); # Pages containing custom CSS or JavaScript get special treatment if ( $this->getTitle()->isCssOrJsPage() || $this->getTitle()->isCssJsSubpage() ) { wfDebug( __METHOD__ . ": showing CSS/JS source\n" ); $this->showCssOrJsPage(); $outputDone = true; - } elseif( !wfRunHooks( 'ArticleViewCustom', array( $this->mContent, $this->getTitle(), $wgOut ) ) ) { + } elseif( !wfRunHooks( 'ArticleViewCustom', array( $this->mContent, $this->getTitle(), $outputPage ) ) ) { # Allow extensions do their own custom view for certain pages $outputDone = true; } else { @@ -543,10 +571,10 @@ class Article extends Page { if ( $rt ) { wfDebug( __METHOD__ . ": showing redirect=no page\n" ); # Viewing a redirect page (e.g. with parameter redirect=no) - $wgOut->addHTML( $this->viewRedirect( $rt ) ); + $outputPage->addHTML( $this->viewRedirect( $rt ) ); # Parse just to get categories, displaytitle, etc. $this->mParserOutput = $wgParser->parse( $text, $this->getTitle(), $parserOptions ); - $wgOut->addParserOutputNoText( $this->mParserOutput ); + $outputPage->addParserOutputNoText( $this->mParserOutput ); $outputDone = true; } } @@ -561,12 +589,12 @@ class Article extends Page { if ( !$poolArticleView->execute() ) { $error = $poolArticleView->getError(); if ( $error ) { - $wgOut->clearHTML(); // for release() errors - $wgOut->enableClientCache( false ); - $wgOut->setRobotPolicy( 'noindex,nofollow' ); + $outputPage->clearHTML(); // for release() errors + $outputPage->enableClientCache( false ); + $outputPage->setRobotPolicy( 'noindex,nofollow' ); $errortext = $error->getWikiText( false, 'view-pool-error' ); - $wgOut->addWikiText( '
and don't parse $m = array(); preg_match( '!\.(css|js)$!u', $this->getTitle()->getText(), $m ); - $wgOut->addHTML( "\n" ); - $wgOut->addHTML( htmlspecialchars( $this->mContent ) ); - $wgOut->addHTML( "\n\n" ); + $outputPage->addHTML( "\n" ); + $outputPage->addHTML( htmlspecialchars( $this->mContent ) ); + $outputPage->addHTML( "\n\n" ); } } @@ -696,8 +722,7 @@ class Article extends Page { * TODO: actions other than 'view' */ public function getRobotPolicy( $action, $pOutput ) { - global $wgOut, $wgArticleRobotPolicies, $wgNamespaceRobotPolicies; - global $wgDefaultRobotPolicy, $wgRequest; + global $wgArticleRobotPolicies, $wgNamespaceRobotPolicies, $wgDefaultRobotPolicy; $ns = $this->getTitle()->getNamespace(); @@ -719,13 +744,13 @@ class Article extends Page { 'index' => 'noindex', 'follow' => 'nofollow' ); - } elseif ( $wgOut->isPrintable() ) { + } elseif ( $this->getContext()->getOutput()->isPrintable() ) { # Discourage indexing of printable versions, but encourage following return array( 'index' => 'noindex', 'follow' => 'follow' ); - } elseif ( $wgRequest->getInt( 'curid' ) ) { + } elseif ( $this->getContext()->getRequest()->getInt( 'curid' ) ) { # For ?curid=x urls, disallow indexing return array( 'index' => 'noindex', @@ -794,15 +819,16 @@ class Article extends Page { /** * If this request is a redirect view, send "redirected from" subtitle to - * $wgOut. Returns true if the header was needed, false if this is not a - * redirect view. Handles both local and remote redirects. + * the output. Returns true if the header was needed, false if this is not + * a redirect view. Handles both local and remote redirects. * * @return boolean */ public function showRedirectedFromHeader() { - global $wgOut, $wgRequest, $wgRedirectSources; + global $wgRedirectSources; + $outputPage = $this->getContext()->getOutput(); - $rdfrom = $wgRequest->getVal( 'rdfrom' ); + $rdfrom = $this->getContext()->getRequest()->getVal( 'rdfrom' ); if ( isset( $this->mRedirectedFrom ) ) { // This is an internally redirected page view. @@ -815,21 +841,21 @@ class Article extends Page { array( 'redirect' => 'no' ) ); - $wgOut->addSubtitle( wfMessage( 'redirectedfrom' )->rawParams( $redir ) ); + $outputPage->addSubtitle( wfMessage( 'redirectedfrom' )->rawParams( $redir ) ); // Set the fragment if one was specified in the redirect if ( strval( $this->getTitle()->getFragment() ) != '' ) { $fragment = Xml::escapeJsString( $this->getTitle()->getFragmentForURL() ); - $wgOut->addInlineScript( "redirectToFragment(\"$fragment\");" ); + $outputPage->addInlineScript( "redirectToFragment(\"$fragment\");" ); } // Add a tag - $wgOut->addLink( array( 'rel' => 'canonical', + $outputPage->addLink( array( 'rel' => 'canonical', 'href' => $this->getTitle()->getLocalURL() ) ); - // Tell $wgOut the user arrived at this article through a redirect - $wgOut->setRedirectedFrom( $this->mRedirectedFrom ); + // Tell the output object that the user arrived at this article through a redirect + $outputPage->setRedirectedFrom( $this->mRedirectedFrom ); return true; } @@ -838,7 +864,7 @@ class Article extends Page { // If it was reported from a trusted site, supply a backlink. if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) { $redir = Linker::makeExternalLink( $rdfrom, $rdfrom ); - $wgOut->addSubtitle( wfMessage( 'redirectedfrom' )->rawParams( $redir ) ); + $outputPage->addSubtitle( wfMessage( 'redirectedfrom' )->rawParams( $redir ) ); return true; } @@ -852,11 +878,9 @@ class Article extends Page { * [[MediaWiki:Talkpagetext]]. For Article::view(). */ public function showNamespaceHeader() { - global $wgOut; - if ( $this->getTitle()->isTalkPage() ) { if ( !wfMessage( 'talkpageheader' )->isDisabled() ) { - $wgOut->wrapWikiMsg( "\n$1\n", array( 'talkpageheader' ) ); + $this->getContext()->getOutput()->wrapWikiMsg( "\n$1\n", array( 'talkpageheader' ) ); } } } @@ -865,11 +889,9 @@ class Article extends Page { * Show the footer section of an ordinary page view */ public function showViewFooter() { - global $wgOut; - # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page if ( $this->getTitle()->getNamespace() == NS_USER_TALK && IP::isValid( $this->getTitle()->getText() ) ) { - $wgOut->addWikiMsg( 'anontalkpagetext' ); + $this->getContext()->getOutput()->addWikiMsg( 'anontalkpagetext' ); } # If we have been passed an &rcid= parameter, we want to give the user a @@ -886,18 +908,19 @@ class Article extends Page { * desired, does nothing. */ public function showPatrolFooter() { - global $wgOut, $wgRequest, $wgUser; - - $rcid = $wgRequest->getVal( 'rcid' ); + $request = $this->getContext()->getRequest(); + $outputPage = $this->getContext()->getOutput(); + $user = $this->getContext()->getUser(); + $rcid = $request->getVal( 'rcid' ); if ( !$rcid || !$this->getTitle()->quickUserCan( 'patrol' ) ) { return; } - $token = $wgUser->getEditToken( $rcid ); - $wgOut->preventClickjacking(); + $token = $user->getEditToken( $rcid ); + $outputPage->preventClickjacking(); - $wgOut->addHTML( + $outputPage->addHTML( "" . wfMsgHtml( 'markaspatrolledlink', @@ -922,7 +945,8 @@ class Article extends Page { * namespace, show the default message text. To be called from Article::view(). */ public function showMissingArticle() { - global $wgOut, $wgRequest, $wgUser, $wgSend404Code; + global $wgSend404Code; + $outputPage = $this->getContext()->getOutput(); # Show info in user (talk) namespace. Does the user exist? Is he blocked? if ( $this->getTitle()->getNamespace() == NS_USER || $this->getTitle()->getNamespace() == NS_USER_TALK ) { @@ -932,11 +956,11 @@ class Article extends Page { $ip = User::isIP( $rootPart ); if ( !($user && $user->isLoggedIn()) && !$ip ) { # User does not exist - $wgOut->wrapWikiMsg( "\n\$1\n", + $outputPage->wrapWikiMsg( "\n\$1\n", array( 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ) ); } elseif ( $user->isBlocked() ) { # Show log extract if the user is currently blocked LogEventsList::showLogExtract( - $wgOut, + $outputPage, 'block', $user->getUserPage()->getPrefixedText(), '', @@ -955,13 +979,25 @@ class Article extends Page { wfRunHooks( 'ShowMissingArticle', array( $this ) ); # Show delete and move logs - LogEventsList::showLogExtract( $wgOut, array( 'delete', 'move' ), $this->getTitle()->getPrefixedText(), '', + LogEventsList::showLogExtract( $outputPage, array( 'delete', 'move' ), $this->getTitle()->getPrefixedText(), '', array( 'lim' => 10, 'conds' => array( "log_action != 'revision'" ), 'showIfEmpty' => false, 'msgKey' => array( 'moveddeleted-notice' ) ) ); + if ( !$this->mPage->hasViewableContent() && $wgSend404Code ) { + // If there's no backing content, send a 404 Not Found + // for better machine handling of broken links. + $this->getContext()->getRequest()->response()->header( "HTTP/1.1 404 Not Found" ); + } + + $hookResult = wfRunHooks( 'BeforeDisplayNoArticleText', array( $this ) ); + + if ( ! $hookResult ) { + return; + } + # Show error message $oldid = $this->getOldID(); if ( $oldid ) { @@ -972,8 +1008,8 @@ class Article extends Page { // Use the default message text $text = $this->getTitle()->getDefaultMessageText(); } else { - $createErrors = $this->getTitle()->getUserPermissionsErrors( 'create', $wgUser ); - $editErrors = $this->getTitle()->getUserPermissionsErrors( 'edit', $wgUser ); + $createErrors = $this->getTitle()->getUserPermissionsErrors( 'create', $this->getContext()->getUser() ); + $editErrors = $this->getTitle()->getUserPermissionsErrors( 'edit', $this->getContext()->getUser() ); $errors = array_merge( $createErrors, $editErrors ); if ( !count( $errors ) ) { @@ -984,43 +1020,36 @@ class Article extends Page { } $text = "\n$text\n"; - if ( !$this->mPage->hasViewableContent() && $wgSend404Code ) { - // If there's no backing content, send a 404 Not Found - // for better machine handling of broken links. - $wgRequest->response()->header( "HTTP/1.1 404 Not Found" ); - } - - $wgOut->addWikiText( $text ); + $outputPage->addWikiText( $text ); } /** * If the revision requested for view is deleted, check permissions. - * Send either an error message or a warning header to $wgOut. + * Send either an error message or a warning header to the output. * * @return boolean true if the view is allowed, false if not. */ public function showDeletedRevisionHeader() { - global $wgOut, $wgRequest; - if ( !$this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) { // Not deleted return true; } + $outputPage = $this->getContext()->getOutput(); // If the user is not allowed to see it... if ( !$this->mRevision->userCan( Revision::DELETED_TEXT ) ) { - $wgOut->wrapWikiMsg( "\n$1\n\n", + $outputPage->wrapWikiMsg( "\n$1\n\n", 'rev-deleted-text-permission' ); return false; // If the user needs to confirm that they want to see it... - } elseif ( $wgRequest->getInt( 'unhide' ) != 1 ) { + } elseif ( $this->getContext()->getRequest()->getInt( 'unhide' ) != 1 ) { # Give explanation and add a link to view the revision... $oldid = intval( $this->getOldID() ); $link = $this->getTitle()->getFullUrl( "oldid={$oldid}&unhide=1" ); $msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ? 'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide'; - $wgOut->wrapWikiMsg( "\n$1\n\n", + $outputPage->wrapWikiMsg( "\n$1\n\n", array( $msg, $link ) ); return false; @@ -1028,7 +1057,7 @@ class Article extends Page { } else { $msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ? 'rev-suppressed-text-view' : 'rev-deleted-text-view'; - $wgOut->wrapWikiMsg( "\n$1\n\n", $msg ); + $outputPage->wrapWikiMsg( "\n$1\n\n", $msg ); return true; } @@ -1040,30 +1069,34 @@ class Article extends Page { * Revision as of \; view current revision * \<- Previous version | Next Version -\> * - * @param $oldid String: revision ID of this article revision + * @param $oldid int: revision ID of this article revision */ public function setOldSubtitle( $oldid = 0 ) { - global $wgLang, $wgOut, $wgUser, $wgRequest; - if ( !wfRunHooks( 'DisplayOldSubtitle', array( &$this, &$oldid ) ) ) { return; } - $unhide = $wgRequest->getInt( 'unhide' ) == 1; + $unhide = $this->getContext()->getRequest()->getInt( 'unhide' ) == 1; # Cascade unhide param in links for easy deletion browsing $extraParams = array(); - if ( $wgRequest->getVal( 'unhide' ) ) { + if ( $unhide ) { $extraParams['unhide'] = 1; } - $revision = Revision::newFromId( $oldid ); + if ( $this->mRevision && $this->mRevision->getId() === $oldid ) { + $revision = $this->mRevision; + } else { + $revision = Revision::newFromId( $oldid ); + } + $timestamp = $revision->getTimestamp(); $current = ( $oldid == $this->mPage->getLatest() ); - $td = $wgLang->timeanddate( $timestamp, true ); - $tddate = $wgLang->date( $timestamp, true ); - $tdtime = $wgLang->time( $timestamp, true ); + $language = $this->getContext()->getLanguage(); + $td = $language->timeanddate( $timestamp, true ); + $tddate = $language->date( $timestamp, true ); + $tdtime = $language->time( $timestamp, true ); # Show user links if allowed to see them. If hidden, then show them only if requested... $userlinks = Linker::revUserTools( $revision, !$unhide ); @@ -1072,7 +1105,8 @@ class Article extends Page { ? 'revision-info-current' : 'revision-info'; - $wgOut->addSubtitle( " " . wfMessage( $infomsg, + $outputPage = $this->getContext()->getOutput(); + $outputPage->addSubtitle( "" . wfMessage( $infomsg, $td )->rawParams( $userlinks )->params( $revision->getID(), $tddate, $tdtime, $revision->getUser() )->parse() . "" ); @@ -1147,25 +1181,12 @@ class Article extends Page { array( 'known', 'noclasses' ) ); - $cdel = ''; - - // User can delete revisions or view deleted revisions... - $canHide = $wgUser->isAllowed( 'deleterevision' ); - if ( $canHide || ( $revision->getVisibility() && $wgUser->isAllowed( 'deletedhistory' ) ) ) { - if ( !$revision->userCan( Revision::DELETED_RESTRICTED ) ) { - $cdel = Linker::revDeleteLinkDisabled( $canHide ); // rev was hidden from Sysops - } else { - $query = array( - 'type' => 'revision', - 'target' => $this->getTitle()->getPrefixedDbkey(), - 'ids' => $oldid - ); - $cdel = Linker::revDeleteLink( $query, $revision->isDeleted( File::DELETED_RESTRICTED ), $canHide ); - } + $cdel = Linker::getRevDeleteLink( $this->getContext()->getUser(), $revision, $this->getTitle() ); + if ( $cdel !== '' ) { $cdel .= ' '; } - $wgOut->addSubtitle( "