X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialListgrouprights.php;h=91d8ed877267842dfc1c2c1eae1e7b35d6e6aa52;hb=5bd492d51c9d3ec0c60c8c10c39b0441accd3baf;hp=12ba2dfe38002de4f287d383a633d506d743a14d;hpb=f68b7bddb4e7593cfbb2750805ccb33b2b60c163;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialListgrouprights.php b/includes/specials/SpecialListgrouprights.php index 12ba2dfe38..91d8ed8772 100644 --- a/includes/specials/SpecialListgrouprights.php +++ b/includes/specials/SpecialListgrouprights.php @@ -1,5 +1,6 @@ skin = $wgUser->getSkin(); } /** * Show the special page */ public function execute( $par ) { - global $wgOut, $wgImplicitGroups, $wgMessageCache; + global $wgImplicitGroups; global $wgGroupPermissions, $wgRevokePermissions, $wgAddGroups, $wgRemoveGroups; global $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf; - $wgMessageCache->loadAllMessages(); $this->setHeaders(); $this->outputHeader(); - $wgOut->addHTML( + $out = $this->getOutput(); + $out->addModuleStyles( 'mediawiki.special' ); + + $out->addHTML( Xml::openElement( 'table', array( 'class' => 'wikitable mw-listgrouprights-table' ) ) . '' . Xml::element( 'th', null, wfMsg( 'listgrouprights-group' ) ) . @@ -57,28 +59,37 @@ class SpecialListGroupRights extends SpecialPage { '' ); - 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 ) ); @@ -86,20 +97,16 @@ class SpecialListGroupRights extends SpecialPage { if ( $group === 'user' ) { // Link to Special:listusers for implicit group 'user' - $grouplink = '
' . $this->skin->link( + $grouplink = '
' . Linker::linkKnown( SpecialPage::getTitleFor( 'Listusers' ), - wfMsgHtml( 'listgrouprights-members' ), - array(), - array(), - array( 'known', 'noclasses' ) + wfMsgHtml( 'listgrouprights-members' ) ); } elseif ( !in_array( $group, $wgImplicitGroups ) ) { - $grouplink = '
' . $this->skin->link( + $grouplink = '
' . Linker::linkKnown( SpecialPage::getTitleFor( 'Listusers' ), wfMsgHtml( 'listgrouprights-members' ), array(), - array( 'group' => $group ), - array( 'known', 'noclasses' ) + array( 'group' => $group ) ); } else { // No link to Special:listusers for other implicit groups as they are unlistable @@ -113,19 +120,20 @@ 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 ), " $grouppage$grouplink " . - self::formatPermissions( $permissions, $revoke, $addgroups, $removegroups, $addgroupsSelf, $removegroupsSelf ) . + $this->formatPermissions( $permissions, $revoke, $addgroups, $removegroups, + $addgroupsSelf, $removegroupsSelf ) . ' ' ) ); } - $wgOut->addHTML( + $out->addHTML( Xml::closeElement( 'table' ) . "\n

\n" ); - $wgOut->wrapWikiMsg( "
\n$1\n
", 'listgrouprights-key' ); + $out->wrapWikiMsg( "
\n$1\n
", 'listgrouprights-key' ); } /** @@ -139,9 +147,7 @@ class SpecialListGroupRights extends SpecialPage { * @param $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 */ - private static function formatPermissions( $permissions, $revoke, $add, $remove, $addSelf, $removeSelf ) { - global $wgLang; - + private function formatPermissions( $permissions, $revoke, $add, $remove, $addSelf, $removeSelf ) { $r = array(); foreach( $permissions as $permission => $granted ) { //show as granted only if it isn't revoked to prevent duplicate display of permissions @@ -163,29 +169,42 @@ class SpecialListGroupRights extends SpecialPage { } } sort( $r ); + $lang = $this->getLanguage(); 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 ) ); + $r[] = wfMsgExt( 'listgrouprights-addgroup', array( 'parseinline' ), + $lang->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 ) ); + $r[] = wfMsgExt( 'listgrouprights-removegroup', array( 'parseinline' ), + $lang->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 ) ); + $r[] = wfMsgExt( 'listgrouprights-addgroup-self', array( 'parseinline' ), + $lang->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 ) ); + $r[] = wfMsgExt( 'listgrouprights-removegroup-self', array( 'parseinline' ), + $lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $removeSelf ) ), + count( $removeSelf ) + ); } if( empty( $r ) ) { return '';