Merge "resourceloader: Switch params for private addLink() function"
[lhc/web/wiklou.git] / includes / specials / SpecialListgrouprights.php
index a299933..1d10791 100644 (file)
@@ -21,6 +21,8 @@
  * @ingroup SpecialPage
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * This special page lists all defined user groups and the associated rights.
  * See also @ref $wgGroupPermissions.
@@ -29,7 +31,7 @@
  * @author Petr Kadlec <mormegil@centrum.cz>
  */
 class SpecialListGroupRights extends SpecialPage {
-       function __construct() {
+       public function __construct() {
                parent::__construct( 'Listgrouprights' );
        }
 
@@ -74,21 +76,15 @@ class SpecialListGroupRights extends SpecialPage {
                $linkRenderer = $this->getLinkRenderer();
 
                foreach ( $allGroups as $group ) {
-                       $permissions = isset( $groupPermissions[$group] )
-                               ? $groupPermissions[$group]
-                               : [];
+                       $permissions = $groupPermissions[$group] ?? [];
                        $groupname = ( $group == '*' ) // Replace * with a more descriptive groupname
                                ? 'all'
                                : $group;
 
-                       $msg = $this->msg( 'group-' . $groupname );
-                       $groupnameLocalized = !$msg->isBlank() ? $msg->text() : $groupname;
+                       $groupnameLocalized = UserGroupMembership::getGroupName( $groupname );
 
-                       $msg = $this->msg( 'grouppage-' . $groupname )->inContentLanguage();
-                       $grouppageLocalized = !$msg->isBlank() ?
-                               $msg->text() :
-                               MWNamespace::getCanonicalName( NS_PROJECT ) . ':' . $groupname;
-                       $grouppageLocalizedTitle = Title::newFromText( $grouppageLocalized );
+                       $grouppageLocalizedTitle = UserGroupMembership::getGroupPage( $groupname )
+                               ?: Title::newFromText( MWNamespace::getCanonicalName( NS_PROJECT ) . ':' . $groupname );
 
                        if ( $group == '*' || !$grouppageLocalizedTitle ) {
                                // Do not make a link for the generic * group or group with invalid group page
@@ -118,13 +114,11 @@ class SpecialListGroupRights extends SpecialPage {
                                $grouplink = '';
                        }
 
-                       $revoke = isset( $revokePermissions[$group] ) ? $revokePermissions[$group] : [];
-                       $addgroups = isset( $addGroups[$group] ) ? $addGroups[$group] : [];
-                       $removegroups = isset( $removeGroups[$group] ) ? $removeGroups[$group] : [];
-                       $addgroupsSelf = isset( $groupsAddToSelf[$group] ) ? $groupsAddToSelf[$group] : [];
-                       $removegroupsSelf = isset( $groupsRemoveFromSelf[$group] )
-                               ? $groupsRemoveFromSelf[$group]
-                               : [];
+                       $revoke = $revokePermissions[$group] ?? [];
+                       $addgroups = $addGroups[$group] ?? [];
+                       $removegroups = $removeGroups[$group] ?? [];
+                       $addgroupsSelf = $groupsAddToSelf[$group] ?? [];
+                       $removegroupsSelf = $groupsRemoveFromSelf[$group] ?? [];
 
                        $id = $group == '*' ? false : Sanitizer::escapeIdForAttribute( $group );
                        $out->addHTML( Html::rawElement( 'tr', [ 'id' => $id ], "
@@ -141,7 +135,6 @@ class SpecialListGroupRights extends SpecialPage {
        }
 
        private function outputNamespaceProtectionInfo() {
-               global $wgContLang;
                $out = $this->getOutput();
                $namespaceProtection = $this->getConfig()->get( 'NamespaceProtection' );
 
@@ -169,15 +162,17 @@ class SpecialListGroupRights extends SpecialPage {
                );
                $linkRenderer = $this->getLinkRenderer();
                ksort( $namespaceProtection );
+               $validNamespaces = MWNamespace::getValidNamespaces();
+               $contLang = MediaWikiServices::getInstance()->getContentLanguage();
                foreach ( $namespaceProtection as $namespace => $rights ) {
-                       if ( !in_array( $namespace, MWNamespace::getValidNamespaces() ) ) {
+                       if ( !in_array( $namespace, $validNamespaces ) ) {
                                continue;
                        }
 
                        if ( $namespace == NS_MAIN ) {
                                $namespaceText = $this->msg( 'blanknamespace' )->text();
                        } else {
-                               $namespaceText = $wgContLang->convertNamespace( $namespace );
+                               $namespaceText = $contLang->convertNamespace( $namespace );
                        }
 
                        $out->addHTML(
@@ -231,7 +226,7 @@ class SpecialListGroupRights extends SpecialPage {
         * @param array $remove Array of groups this group is allowed to remove or true
         * @param array $addSelf Array of groups this group is allowed to add to self or true
         * @param array $removeSelf Array of group this group is allowed to remove from self or true
-        * @return string List of all granted permissions, separated by comma separator
+        * @return string HTML list of all granted permissions
         */
        private function formatPermissions( $permissions, $revoke, $add, $remove, $addSelf, $removeSelf ) {
                $r = [];