r85599 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85598‎ | r85599 | r85600 >
Date:00:19, 7 April 2011
Author:reedy
Status:ok
Tags:
Comment:
Style fixes and commenting
Modified paths:
  • /trunk/extensions/CloseWikis/CloseWikis.list.php (modified) (history)
  • /trunk/extensions/CloseWikis/CloseWikis.page.php (modified) (history)
  • /trunk/extensions/CloseWikis/CloseWikis.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CloseWikis/CloseWikis.php
@@ -107,8 +107,9 @@
108108
109109 /** Returns list of closed wikis in form of string array. Cached in CloseWikis::$cachedList */
110110 static function getList() {
111 - if( self::$cachedList )
 111+ if( self::$cachedList ) {
112112 return self::$cachedList;
 113+ }
113114 $list = array();
114115 $dbr = self::getMasterDB(); // Used only on writes
115116 $result = $dbr->select( 'closedwikis', 'cw_wiki', false, __METHOD__ );
@@ -131,15 +132,19 @@
132133 global $wgMemc;
133134 $memcKey = "closedwikis:{$wiki}";
134135 $cached = $wgMemc->get( $memcKey );
135 - if( is_object( $cached ) )
 136+ if( is_object( $cached ) ) {
136137 return $cached;
 138+ }
137139 $dbr = self::getSlaveDB();
138140 $result = new CloseWikisRow( $dbr->selectRow( 'closedwikis', '*', array( 'cw_wiki' => $wiki ), __METHOD__ ) );
139141 $wgMemc->set( $memcKey, $result );
140142 return $result;
141143 }
142144
143 - /** Closes a wiki */
 145+ /** Closes a wiki
 146+ *
 147+ * @param $by User
 148+ */
144149 static function close( $wiki, $dispreason, $by ) {
145150 global $wgMemc;
146151 $dbw = CloseWikis::getMasterDB();
@@ -181,15 +186,26 @@
182187 }
183188
184189 class CloseWikisHooks {
 190+ /**
 191+ * @static
 192+ * @param $title
 193+ * @param $user User
 194+ * @param $action
 195+ * @param $result
 196+ * @return bool
 197+ */
185198 static function userCan( &$title, &$user, $action, &$result ) {
186199 static $closed = null;
187200 global $wgLang;
188 - if( $action == 'read' )
 201+ if( $action == 'read' ) {
189202 return true;
190 - if( is_null( $closed ) )
 203+ }
 204+
 205+ if( is_null( $closed ) ) {
191206 $closed = CloseWikis::getClosedRow( wfWikiID() );
 207+ }
 208+
192209 if( $closed->isClosed() && !$user->isAllowed( 'editclosedwikis' ) ) {
193 -
194210 $reason = $closed->getReason();
195211 $ts = $closed->getTimestamp();
196212 $by = $closed->getBy();
Index: trunk/extensions/CloseWikis/CloseWikis.list.php
@@ -23,7 +23,6 @@
2424
2525 class SpecialListClosedWikis extends SpecialPage {
2626 public function __construct() {
27 -
2827 parent::__construct( 'ListClosedWikis' );
2928 }
3029
@@ -32,7 +31,7 @@
3332 }
3433
3534 public function execute( $par ) {
36 - global $wgUser, $wgOut, $wgLang;
 35+ global $wgOut, $wgLang;
3736
3837 $this->setHeaders();
3938 $wgOut->addWikiMsg( 'closewikis-list-intro' );
Index: trunk/extensions/CloseWikis/CloseWikis.page.php
@@ -41,16 +41,18 @@
4242 }
4343
4444 $this->closeForm();
45 - if( CloseWikis::getList() )
 45+ if( CloseWikis::getList() ) {
4646 $this->reopenForm();
 47+ }
4748 }
4849
4950 protected function buildSelect( $list, $name, $default = '' ) {
5051 sort( $list );
5152 $select = new XmlSelect( $name );
5253 $select->setDefault( $default );
53 - foreach( $list as $wiki )
 54+ foreach( $list as $wiki ) {
5455 $select->addOption( $wiki );
 56+ }
5557 return $select->getHTML();
5658 }
5759
@@ -85,8 +87,9 @@
8688 $defaultDisplayReason = $statusOK ? '' : $wgRequest->getVal( 'wpcDisplayReason' );
8789 $defaultReason = $statusOK ? '' : $wgRequest->getVal( 'wpcReason' );
8890 // For some reason Xml::textarea( 'blabla', null ) produces an unclosed tag
89 - if( !$defaultDisplayReason )
 91+ if( !$defaultDisplayReason ) {
9092 $defaultDisplayReason = '';
 93+ }
9194
9295 $wgOut->addHTML( "<fieldset><legend>{$legend}</legend>" );
9396 if( $status ) {
@@ -99,7 +102,7 @@
100103 $form['closewikis-page-close-dreason'] = Xml::textarea( 'wpcDisplayReason', $defaultDisplayReason );
101104 $form['closewikis-page-close-reason'] = Xml::input( 'wpcReason', false, $defaultReason );
102105 $wgOut->addHTML( Xml::buildForm( $form, 'closewikis-page-close-submit' ) );
103 - $wgOut->addHTML( Xml::hidden( 'wpcEdittoken', $wgUser->editToken() ) );
 106+ $wgOut->addHTML( Html::hidden( 'wpcEdittoken', $wgUser->editToken() ) );
104107 $wgOut->addHTML( "</form></fieldset>" );
105108 }
106109
@@ -142,9 +145,7 @@
143146 $form['closewikis-page-reopen-wiki'] = $this->buildSelect( CloseWikis::getList(), 'wprWiki', $defaultWiki );
144147 $form['closewikis-page-reopen-reason'] = Xml::input( 'wprReason', false, $defaultReason );
145148 $wgOut->addHTML( Xml::buildForm( $form, 'closewikis-page-reopen-submit' ) );
146 - $wgOut->addHTML( Xml::hidden( 'wprEdittoken', $wgUser->editToken() ) );
 149+ $wgOut->addHTML( Html::hidden( 'wprEdittoken', $wgUser->editToken() ) );
147150 $wgOut->addHTML( "</form></fieldset>" );
148151 }
149 -
150 -
151152 }

Status & tagging log