r85593 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85592‎ | r85593 | r85594 >
Date:23:50, 6 April 2011
Author:reedy
Status:ok
Tags:
Comment:
Fix accessors, collapse duplicate cases

Fix whitespace/braces

Remove superfluous comments
Modified paths:
  • /trunk/extensions/SubPageList3/SubPageList3.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SubPageList3/SubPageList3.php
@@ -60,73 +60,56 @@
6161 class SubpageList3 {
6262
6363 /**
64 - * parser object
65 - * @var object parser object
66 - * @private
 64+ * @var Parser
6765 */
68 - var $parser;
 66+ private $parser;
6967
7068
7169 /**
72 - * title object
73 - * @var object title object
74 - * @private
 70+ * @var Title
7571 */
76 - var $title;
 72+ private $title;
7773
7874 /**
7975 * @var Title
80 - * @private
8176 */
82 - var $ptitle;
 77+ private $ptitle;
8378
8479 /**
85 - * namespace string
86 - * @var string namespace object
87 - * @private
 80+ * @var string
8881 */
89 - var $namespace = '';
 82+ private $namespace = '';
9083
9184 /**
92 - * token string
9385 * @var string token object
94 - * @private
9586 */
96 - var $token = '*';
 87+ private $token = '*';
9788
9889 /**
99 - * language object
100 - * @var object language object
101 - * @private
 90+ * @var Language
10291 */
103 - var $language;
 92+ private $language;
10493
10594 /**
106 - * error display on or off
107 - * @var mixed error display on or off
108 - * @private
 95+ * @var int error display on or off
10996 * @default 0 hide errors
11097 */
111 - var $debug = 0;
 98+ private $debug = 0;
11299
113100 /**
114101 * contain the error messages
115102 * @var array contain the errors messages
116 - * @private
117103 */
118 - var $errors = array();
 104+ private $errors = array();
119105
120 -
121106 /**
122107 * order type
123108 * Can be:
124109 * - asc
125110 * - desc
126111 * @var string order type
127 - * @private
128 - * @default asc
129112 */
130 - var $order = 'asc';
 113+ private $order = 'asc';
131114
132115 /**
133116 * column thats used as order method
@@ -135,9 +118,8 @@
136119 * - lastedit: Timestamp numeric order of the last edit of a page
137120 * @var string order method
138121 * @private
139 - * @default title
140122 */
141 - var $ordermethod = 'title';
 123+ private $ordermethod = 'title';
142124
143125 /**
144126 * mode of the output
@@ -146,10 +128,9 @@
147129 * - ordered: OL list as output
148130 * - bar: uses · as a delimiter producing a horizontal bar menu
149131 * @var string mode of output
150 - * @private
151132 * @default unordered
152133 */
153 - var $mode = 'unordered';
 134+ private $mode = 'unordered';
154135
155136 /**
156137 * parent of the listed pages
@@ -158,10 +139,9 @@
159140 * - string: title of the specific title
160141 * e.g. if you are in Mainpage/ it will list all subpages of Mainpage/
161142 * @var mixed parent of listed pages
162 - * @private
163143 * @default -1 current
164144 */
165 - var $parent = -1;
 145+ private $parent = -1;
166146
167147 /**
168148 * style of the path (title)
@@ -170,11 +150,10 @@
171151 * - notparent: the path without the $parent item, e.g. Entry/Sub
172152 * - no: no path, only the page title, e.g. Sub
173153 * @var string style of the path (title)
174 - * @private
175154 * @default normal
176155 * @see $parent
177156 */
178 - var $showpath = 'no';
 157+ private $showpath = 'no';
179158
180159 /**
181160 * whether to show next sublevel only, or all sublevels
@@ -182,11 +161,10 @@
183162 * - 0 / no / false
184163 * - 1 / yes / true
185164 * @var mixed show one sublevel only
186 - * @private
187165 * @default 0
188166 * @see $parent
189167 */
190 - var $kidsonly = 0;
 168+ private $kidsonly = 0;
191169
192170 /**
193171 * whether to show parent as the top item
@@ -194,11 +172,10 @@
195173 * - 0 / no / false
196174 * - 1 / yes / true
197175 * @var mixed show one sublevel only
198 - * @private
199176 * @default 0
200177 * @see $parent
201178 */
202 - var $showparent = 0;
 179+ private $showparent = 0;
203180
204181 /**
205182 * Constructor function of the class
@@ -209,13 +186,6 @@
210187 */
211188 function __construct( $parser ) {
212189 global $wgContLang;
213 -
214 - /**
215 - * assignment of the object to the classs vars
216 - * @see $parser
217 - * @see $title
218 - * @see $language
219 - */
220190 $this->parser = $parser;
221191 $this->title = $parser->mTitle;
222192 $this->language = $wgContLang;
@@ -319,11 +289,7 @@
320290 if( isset( $options['showpath'] ) ) {
321291 switch( strtolower( $options['showpath'] ) ) {
322292 case 'no':
323 - $this->showpath = 'no';
324 - break;
325293 case '0':
326 - $this->showpath = 'no';
327 - break;
328294 case 'false':
329295 $this->showpath = 'no';
330296 break;
@@ -331,14 +297,8 @@
332298 $this->showpath = 'notparent';
333299 break;
334300 case 'full':
335 - $this->showpath = 'full';
336 - break;
337301 case 'yes':
338 - $this->showpath = 'full';
339 - break;
340302 case '1':
341 - $this->showpath = 'full';
342 - break;
343303 case 'true':
344304 $this->showpath = 'full';
345305 break;
@@ -374,7 +334,7 @@
375335 function render() {
376336 wfProfileIn( __METHOD__ );
377337 $pages = $this->getTitles();
378 - if($pages!=null && count( $pages ) > 0 ) {
 338+ if( $pages != null && count( $pages ) > 0 ) {
379339 $list = $this->makeList( $pages );
380340 $html = $this->parse( $list );
381341 } else {
@@ -428,7 +388,7 @@
429389 }
430390
431391 // don't let list cross namespaces
432 - if (strlen($nsi)>0) {
 392+ if ( strlen( $nsi ) > 0 ) {
433393 $conditions['page_namespace'] = $nsi;
434394 }
435395 $conditions['page_is_redirect'] = 0;
@@ -489,7 +449,9 @@
490450 # add parent item
491451 if ($this->showparent) {
492452 $pn = '[[' . $this->ptitle->getPrefixedText() .'|'. $this->ptitle->getText() .']]';
493 - if( $this->mode != 'bar' ) $pn = $this->token . $pn;
 453+ if( $this->mode != 'bar' ) {
 454+ $pn = $this->token . $pn;
 455+ }
494456 $ss = trim($pn);
495457 $list[] = $ss;
496458 $c++; // flag for bar token to be added on next item
@@ -499,28 +461,33 @@
500462 $list = array();
501463 foreach( $titles as $title ) {
502464 $lv = substr_count($title, '/') - $parlv;
503 - if ($this->kidsonly!=1 || $lv<2) {
504 - if ($this->showparent) $lv++;
 465+ if ( $this->kidsonly!=1 || $lv < 2 ) {
 466+ if ($this->showparent) {
 467+ $lv++;
 468+ }
505469 $ss = "";
506470 if( $this->mode == 'bar' ) {
507471 if( $c>0) {
508472 $ss .= $this->token;
509473 }
510474 } else {
511 - for ($i=0; $i<$lv; $i++) {
 475+ for ( $i = 0; $i < $lv; $i++ ) {
512476 $ss .= $this->token;
513477 }
514478 }
515479 $ss .= $this->makeListItem( $title );
516 - $ss = trim($ss); // make sure we don't get any <pre></pre> tags
 480+ $ss = trim( $ss ); // make sure we don't get any <pre></pre> tags
517481 $list[] = $ss;
518482 }
519483 $c++;
520 - if ($c>200) break; // safety
 484+ if ( $c > 200 ) {
 485+ break;
 486+ }
521487 }
 488+ $retval = '';
522489 if( count( $list ) > 0 ) {
523490 $retval = implode( "\n", $list );
524 - if ($this->mode == 'bar') {
 491+ if ( $this->mode == 'bar' ) {
525492 $retval = implode( "", $list );
526493 }
527494 }

Status & tagging log