Adding support for domains in SpecialPasswordReset.php.
[lhc/web/wiklou.git] / includes / specials / SpecialListgrouprights.php
index 411e315..07e08e7 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 /**
+ * Implements Special:Listgrouprights
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -15,6 +16,9 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup SpecialPage
  */
 
 /**
  */
 class SpecialListGroupRights extends SpecialPage {
 
-       var $skin;
-
        /**
         * Constructor
         */
        function __construct() {
-               global $wgUser;
                parent::__construct( 'Listgrouprights' );
-               $this->skin = $wgUser->getSkin();
        }
 
        /**
         * Show the special page
         */
        public function execute( $par ) {
-               global $wgOut, $wgImplicitGroups;
+               global $wgImplicitGroups;
                global $wgGroupPermissions, $wgRevokePermissions, $wgAddGroups, $wgRemoveGroups;
                global $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
+               $out = $this->getOutput();
 
                $this->setHeaders();
                $this->outputHeader();
+               $out->addModuleStyles( 'mediawiki.special' );
 
-               $wgOut->addHTML(
+               $out->addHTML(
                        Xml::openElement( 'table', array( 'class' => 'wikitable mw-listgrouprights-table' ) ) .
                                '<tr>' .
                                        Xml::element( 'th', null, wfMsg( 'listgrouprights-group' ) ) .
@@ -56,28 +58,37 @@ class SpecialListGroupRights extends SpecialPage {
                                '</tr>'
                );
 
-               foreach( $wgGroupPermissions as $group => $permissions ) {
-                       $groupname = ( $group == '*' ) ? 'all' : $group; // Replace * with a more descriptive groupname
+               $allGroups = array_unique( array_merge(
+                       array_keys( $wgGroupPermissions ),
+                       array_keys( $wgRevokePermissions ),
+                       array_keys( $wgAddGroups ),
+                       array_keys( $wgRemoveGroups ),
+                       array_keys( $wgGroupsAddToSelf ),
+                       array_keys( $wgGroupsRemoveFromSelf )
+               ) );
+               asort( $allGroups );
 
-                       $msg = wfMsg( 'group-' . $groupname );
-                       if ( wfEmptyMsg( 'group-' . $groupname, $msg ) || $msg == '' ) {
-                               $groupnameLocalized = $groupname;
-                       } else {
-                               $groupnameLocalized = $msg;
-                       }
+               foreach ( $allGroups as $group ) {
+                       $permissions = isset( $wgGroupPermissions[$group] )
+                               ? $wgGroupPermissions[$group]
+                               : array();
+                       $groupname = ( $group == '*' ) // Replace * with a more descriptive groupname
+                               ? 'all'
+                               : $group;
 
-                       $msg = wfMsgForContent( 'grouppage-' . $groupname );
-                       if ( wfEmptyMsg( 'grouppage-' . $groupname, $msg ) || $msg == '' ) {
-                               $grouppageLocalized = MWNamespace::getCanonicalName( NS_PROJECT ) . ':' . $groupname;
-                       } else {
-                               $grouppageLocalized = $msg;
-                       }
+                       $msg = wfMessage( 'group-' . $groupname );
+                       $groupnameLocalized = !$msg->isBlank() ? $msg->text() : $groupname;
+
+                       $msg = wfMessage( 'grouppage-' . $groupname )->inContentLanguage();
+                       $grouppageLocalized = !$msg->isBlank() ?
+                               $msg->text() :
+                               MWNamespace::getCanonicalName( NS_PROJECT ) . ':' . $groupname;
 
                        if( $group == '*' ) {
                                // Do not make a link for the generic * group
                                $grouppage = htmlspecialchars( $groupnameLocalized );
                        } else {
-                               $grouppage = $this->skin->link(
+                               $grouppage = Linker::link(
                                        Title::newFromText( $grouppageLocalized ),
                                        htmlspecialchars( $groupnameLocalized )
                                );
@@ -85,7 +96,7 @@ class SpecialListGroupRights extends SpecialPage {
 
                        if ( $group === 'user' ) {
                                // Link to Special:listusers for implicit group 'user'
-                               $grouplink = '<br />' . $this->skin->link(
+                               $grouplink = '<br />' . Linker::link(
                                        SpecialPage::getTitleFor( 'Listusers' ),
                                        wfMsgHtml( 'listgrouprights-members' ),
                                        array(),
@@ -93,7 +104,7 @@ class SpecialListGroupRights extends SpecialPage {
                                        array( 'known', 'noclasses' )
                                );
                        } elseif ( !in_array( $group, $wgImplicitGroups ) ) {
-                               $grouplink = '<br />' . $this->skin->link(
+                               $grouplink = '<br />' . Linker::link(
                                        SpecialPage::getTitleFor( 'Listusers' ),
                                        wfMsgHtml( 'listgrouprights-members' ),
                                        array(),
@@ -112,7 +123,7 @@ class SpecialListGroupRights extends SpecialPage {
                        $removegroupsSelf = isset( $wgGroupsRemoveFromSelf[$group] ) ? $wgGroupsRemoveFromSelf[$group] : array();
 
                        $id = $group == '*' ? false : Sanitizer::escapeId( $group );
-                       $wgOut->addHTML( Html::rawElement( 'tr', array( 'id' => $id ),
+                       $out->addHTML( Html::rawElement( 'tr', array( 'id' => $id ),
                                "
                                <td>$grouppage$grouplink</td>
                                        <td>" .
@@ -121,10 +132,10 @@ class SpecialListGroupRights extends SpecialPage {
                                '
                        ) );
                }
-               $wgOut->addHTML(
+               $out->addHTML(
                        Xml::closeElement( 'table' ) . "\n<br /><hr />\n"
                );
-               $wgOut->wrapWikiMsg( "<div class=\"mw-listgrouprights-key\">\n$1\n</div>", 'listgrouprights-key' );
+               $out->wrapWikiMsg( "<div class=\"mw-listgrouprights-key\">\n$1\n</div>", 'listgrouprights-key' );
        }
 
        /**
@@ -139,7 +150,7 @@ class SpecialListGroupRights extends SpecialPage {
         * @return string List of all granted permissions, separated by comma separator
         */
         private static function formatPermissions( $permissions, $revoke, $add, $remove, $addSelf, $removeSelf ) {
-               global $wgLang;
+               global $wgLang;
 
                $r = array();
                foreach( $permissions as $permission => $granted ) {
@@ -164,25 +175,25 @@ class SpecialListGroupRights extends SpecialPage {
                sort( $r );
                if( $add === true ){
                        $r[] = wfMsgExt( 'listgrouprights-addgroup-all', array( 'escape' ) );
-               } else if( is_array( $add ) && count( $add ) ) {
+               } elseif( is_array( $add ) && count( $add ) ) {
                        $add = array_values( array_unique( $add ) );
                        $r[] = wfMsgExt( 'listgrouprights-addgroup', array( 'parseinline' ), $wgLang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $add ) ), count( $add ) );
                }
                if( $remove === true ){
                        $r[] = wfMsgExt( 'listgrouprights-removegroup-all', array( 'escape' ) );
-               } else if( is_array( $remove ) && count( $remove ) ) {
+               } elseif( is_array( $remove ) && count( $remove ) ) {
                        $remove = array_values( array_unique( $remove ) );
                        $r[] = wfMsgExt( 'listgrouprights-removegroup', array( 'parseinline' ), $wgLang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $remove ) ), count( $remove ) );
                }
                if( $addSelf === true ){
                        $r[] = wfMsgExt( 'listgrouprights-addgroup-self-all', array( 'escape' ) );
-               } else if( is_array( $addSelf ) && count( $addSelf ) ) {
+               } elseif( is_array( $addSelf ) && count( $addSelf ) ) {
                        $addSelf = array_values( array_unique( $addSelf ) );
                        $r[] = wfMsgExt( 'listgrouprights-addgroup-self', array( 'parseinline' ), $wgLang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $addSelf ) ), count( $addSelf ) );
                }
                if( $removeSelf === true ){
                        $r[] = wfMsgExt( 'listgrouprights-removegroup-self-all', array( 'escape' ) );
-               } else if( is_array( $removeSelf ) && count( $removeSelf ) ) {
+               } elseif( is_array( $removeSelf ) && count( $removeSelf ) ) {
                        $removeSelf = array_values( array_unique( $removeSelf ) );
                        $r[] = wfMsgExt( 'listgrouprights-removegroup-self', array( 'parseinline' ), $wgLang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $removeSelf ) ), count( $removeSelf ) );
                }