r98899 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98898‎ | r98899 | r98900 >
Date:20:30, 4 October 2011
Author:ialex
Status:ok
Tags:
Comment:
* Use local context instead of global variables
* Use Linker::linkKnown() where possible
* Break long lines
Modified paths:
  • /trunk/phase3/includes/specials/SpecialListgrouprights.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialListgrouprights.php
@@ -44,10 +44,11 @@
4545 global $wgImplicitGroups;
4646 global $wgGroupPermissions, $wgRevokePermissions, $wgAddGroups, $wgRemoveGroups;
4747 global $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
48 - $out = $this->getOutput();
4948
5049 $this->setHeaders();
5150 $this->outputHeader();
 51+
 52+ $out = $this->getOutput();
5253 $out->addModuleStyles( 'mediawiki.special' );
5354
5455 $out->addHTML(
@@ -96,20 +97,16 @@
9798
9899 if ( $group === 'user' ) {
99100 // Link to Special:listusers for implicit group 'user'
100 - $grouplink = '<br />' . Linker::link(
 101+ $grouplink = '<br />' . Linker::linkKnown(
101102 SpecialPage::getTitleFor( 'Listusers' ),
102 - wfMsgHtml( 'listgrouprights-members' ),
103 - array(),
104 - array(),
105 - array( 'known', 'noclasses' )
 103+ wfMsgHtml( 'listgrouprights-members' )
106104 );
107105 } elseif ( !in_array( $group, $wgImplicitGroups ) ) {
108 - $grouplink = '<br />' . Linker::link(
 106+ $grouplink = '<br />' . Linker::linkKnown(
109107 SpecialPage::getTitleFor( 'Listusers' ),
110108 wfMsgHtml( 'listgrouprights-members' ),
111109 array(),
112 - array( 'group' => $group ),
113 - array( 'known', 'noclasses' )
 110+ array( 'group' => $group )
114111 );
115112 } else {
116113 // No link to Special:listusers for other implicit groups as they are unlistable
@@ -127,7 +124,8 @@
128125 "
129126 <td>$grouppage$grouplink</td>
130127 <td>" .
131 - self::formatPermissions( $permissions, $revoke, $addgroups, $removegroups, $addgroupsSelf, $removegroupsSelf ) .
 128+ $this->formatPermissions( $permissions, $revoke, $addgroups, $removegroups,
 129+ $addgroupsSelf, $removegroupsSelf ) .
132130 '</td>
133131 '
134132 ) );
@@ -149,9 +147,7 @@
150148 * @param $removeSelf Array of group this group is allowed to remove from self or true
151149 * @return string List of all granted permissions, separated by comma separator
152150 */
153 - private static function formatPermissions( $permissions, $revoke, $add, $remove, $addSelf, $removeSelf ) {
154 - global $wgLang;
155 -
 151+ private function formatPermissions( $permissions, $revoke, $add, $remove, $addSelf, $removeSelf ) {
156152 $r = array();
157153 foreach( $permissions as $permission => $granted ) {
158154 //show as granted only if it isn't revoked to prevent duplicate display of permissions
@@ -173,29 +169,42 @@
174170 }
175171 }
176172 sort( $r );
 173+ $lang = $this->getLang();
177174 if( $add === true ){
178175 $r[] = wfMsgExt( 'listgrouprights-addgroup-all', array( 'escape' ) );
179176 } elseif( is_array( $add ) && count( $add ) ) {
180177 $add = array_values( array_unique( $add ) );
181 - $r[] = wfMsgExt( 'listgrouprights-addgroup', array( 'parseinline' ), $wgLang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $add ) ), count( $add ) );
 178+ $r[] = wfMsgExt( 'listgrouprights-addgroup', array( 'parseinline' ),
 179+ $lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $add ) ),
 180+ count( $add )
 181+ );
182182 }
183183 if( $remove === true ){
184184 $r[] = wfMsgExt( 'listgrouprights-removegroup-all', array( 'escape' ) );
185185 } elseif( is_array( $remove ) && count( $remove ) ) {
186186 $remove = array_values( array_unique( $remove ) );
187 - $r[] = wfMsgExt( 'listgrouprights-removegroup', array( 'parseinline' ), $wgLang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $remove ) ), count( $remove ) );
 187+ $r[] = wfMsgExt( 'listgrouprights-removegroup', array( 'parseinline' ),
 188+ $lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $remove ) ),
 189+ count( $remove )
 190+ );
188191 }
189192 if( $addSelf === true ){
190193 $r[] = wfMsgExt( 'listgrouprights-addgroup-self-all', array( 'escape' ) );
191194 } elseif( is_array( $addSelf ) && count( $addSelf ) ) {
192195 $addSelf = array_values( array_unique( $addSelf ) );
193 - $r[] = wfMsgExt( 'listgrouprights-addgroup-self', array( 'parseinline' ), $wgLang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $addSelf ) ), count( $addSelf ) );
 196+ $r[] = wfMsgExt( 'listgrouprights-addgroup-self', array( 'parseinline' ),
 197+ $lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $addSelf ) ),
 198+ count( $addSelf )
 199+ );
194200 }
195201 if( $removeSelf === true ){
196202 $r[] = wfMsgExt( 'listgrouprights-removegroup-self-all', array( 'escape' ) );
197203 } elseif( is_array( $removeSelf ) && count( $removeSelf ) ) {
198204 $removeSelf = array_values( array_unique( $removeSelf ) );
199 - $r[] = wfMsgExt( 'listgrouprights-removegroup-self', array( 'parseinline' ), $wgLang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $removeSelf ) ), count( $removeSelf ) );
 205+ $r[] = wfMsgExt( 'listgrouprights-removegroup-self', array( 'parseinline' ),
 206+ $lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $removeSelf ) ),
 207+ count( $removeSelf )
 208+ );
200209 }
201210 if( empty( $r ) ) {
202211 return '';

Status & tagging log