Merge "Parser: Use 'Special:Badtitle/Parser' instead of 'NO TITLE'"
[lhc/web/wiklou.git] / includes / skins / Skin.php
index bcc257a..b0d0678 100644 (file)
@@ -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";
@@ -459,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';
                        }
                }
@@ -723,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 );
                        }
                }
 
@@ -1298,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' )