X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fskins%2FSkin.php;h=b0d067820a0c9f8eaf2bcb39974bb37490eb8036;hb=43fe3f21d48075ebbabcf0825b1520804ca9175e;hp=e46f99d14e9381e906d3c0f544842190dd61a243;hpb=ab9436fb9a20b5a335574e36fdd476becabe2dd1;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index e46f99d14e..b0d067820a 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -61,9 +61,11 @@ abstract class Skin extends ContextSource { /** * Fetch the skinname messages for available skins. + * @deprecated since 1.34, no longer used. * @return string[] */ static function getSkinNameMessages() { + wfDeprecated( __METHOD__, '1.34' ); $messages = []; foreach ( self::getSkinNames() as $skinKey => $skinName ) { $messages[] = "skinname-$skinKey"; @@ -308,6 +310,7 @@ abstract class Skin extends ContextSource { /** * Get the current revision ID * + * @deprecated since 1.34, use OutputPage::getRevisionId instead * @return int */ public function getRevisionId() { @@ -317,11 +320,11 @@ abstract class Skin extends ContextSource { /** * Whether the revision displayed is the latest revision of the page * + * @deprecated since 1.34, use OutputPage::isRevisionCurrent instead * @return bool */ public function isRevisionCurrent() { - $revID = $this->getRevisionId(); - return $revID == 0 || $revID == $this->getTitle()->getLatestRevID(); + return $this->getOutput()->isRevisionCurrent(); } /** @@ -458,7 +461,9 @@ abstract class Skin extends ContextSource { $type = 'ns-subject'; } // T208315: add HTML class when the user can edit the page - if ( $title->quickUserCan( 'edit', $user ) ) { + if ( MediaWikiServices::getInstance()->getPermissionManager() + ->quickUserCan( 'edit', $user, $title ) + ) { $type .= ' mw-editable'; } } @@ -701,7 +706,7 @@ abstract class Skin extends ContextSource { * @return string HTML text with an URL */ function printSource() { - $oldid = $this->getRevisionId(); + $oldid = $this->getOutput()->getRevisionId(); if ( $oldid ) { $canonicalUrl = $this->getTitle()->getCanonicalURL( 'oldid=' . $oldid ); $url = htmlspecialchars( wfExpandIRI( $canonicalUrl ) ); @@ -722,24 +727,40 @@ abstract class Skin extends ContextSource { $action = $this->getRequest()->getVal( 'action', 'view' ); $title = $this->getTitle(); $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); + $permissionManager = MediaWikiServices::getInstance()->getPermissionManager(); if ( ( !$title->exists() || $action == 'history' ) && - $title->quickUserCan( 'deletedhistory', $this->getUser() ) + $permissionManager->quickUserCan( 'deletedhistory', $this->getUser(), $title ) ) { $n = $title->isDeleted(); if ( $n ) { - if ( $this->getTitle()->quickUserCan( 'undelete', $this->getUser() ) ) { + if ( $permissionManager->quickUserCan( 'undelete', + $this->getUser(), $this->getTitle() ) + ) { $msg = 'thisisdeleted'; } else { $msg = 'viewdeleted'; } - return $this->msg( $msg )->rawParams( + $subtitle = $this->msg( $msg )->rawParams( $linkRenderer->makeKnownLink( SpecialPage::getTitleFor( 'Undelete', $this->getTitle()->getPrefixedDBkey() ), $this->msg( 'restorelink' )->numParams( $n )->text() ) )->escaped(); + + // Allow extensions to add more links + $links = []; + Hooks::run( 'UndeletePageToolLinks', [ $this->getContext(), $linkRenderer, &$links ] ); + + if ( $links ) { + $subtitle .= '' + . $this->msg( 'word-separator' )->escaped() + . $this->msg( 'parentheses' ) + ->rawParams( $this->getLanguage()->pipeList( $links ) ) + ->escaped(); + } + return Html::rawElement( 'div', [ 'class' => 'mw-undelete-subtitle' ], $subtitle ); } } @@ -830,7 +851,7 @@ abstract class Skin extends ContextSource { function getCopyright( $type = 'detect' ) { $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); if ( $type == 'detect' ) { - if ( !$this->isRevisionCurrent() + if ( !$this->getOutput()->isRevisionCurrent() && !$this->msg( 'history_copyright' )->inContentLanguage()->isDisabled() ) { $type = 'history'; @@ -934,7 +955,8 @@ abstract class Skin extends ContextSource { # No cached timestamp, load it from the database if ( $timestamp === null ) { - $timestamp = Revision::getTimestampFromId( $this->getTitle(), $this->getRevisionId() ); + $timestamp = Revision::getTimestampFromId( $this->getTitle(), + $this->getOutput()->getRevisionId() ); } if ( $timestamp ) { @@ -1088,8 +1110,8 @@ abstract class Skin extends ContextSource { function editUrlOptions() { $options = [ 'action' => 'edit' ]; - if ( !$this->isRevisionCurrent() ) { - $options['oldid'] = intval( $this->getRevisionId() ); + if ( !$this->getOutput()->isRevisionCurrent() ) { + $options['oldid'] = intval( $this->getOutput()->getRevisionId() ); } return $options; @@ -1296,19 +1318,21 @@ abstract class Skin extends ContextSource { * @return array */ public function buildSidebar() { + $services = MediaWikiServices::getInstance(); $callback = function ( $old = null, &$ttl = null ) { $bar = []; $this->addToSidebar( $bar, 'sidebar' ); Hooks::run( 'SkinBuildSidebar', [ $this, &$bar ] ); - if ( MessageCache::singleton()->isDisabled() ) { + $msgCache = MediaWikiServices::getInstance()->getMessageCache(); + if ( $msgCache->isDisabled() ) { $ttl = WANObjectCache::TTL_UNCACHEABLE; // bug T133069 } return $bar; }; - $msgCache = MessageCache::singleton(); - $wanCache = MediaWikiServices::getInstance()->getMainWANObjectCache(); + $msgCache = $services->getMessageCache(); + $wanCache = $services->getMainWANObjectCache(); $config = $this->getConfig(); $sidebar = $config->get( 'EnableSidebarCache' )