r73813 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73812‎ | r73813 | r73814 >
Date:15:37, 27 September 2010
Author:ashley
Status:ok
Tags:
Comment:
ProofreadPage: coding style tweaks to PHP files, removed some unused globals, added documentation, etc.
Modified paths:
  • /trunk/extensions/ProofreadPage/ProofreadPage.php (modified) (history)
  • /trunk/extensions/ProofreadPage/ProofreadPage_body.php (modified) (history)
  • /trunk/extensions/ProofreadPage/SpecialPagesWithoutScans.php (modified) (history)
  • /trunk/extensions/ProofreadPage/SpecialProofreadPages.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/ProofreadPage_body.php
@@ -15,13 +15,11 @@
1616 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1717 # http://www.gnu.org/copyleft/gpl.html
1818
19 -
2019 /*
21 - todo :
 20+ todo :
2221 - check unicity of the index page : when index is saved too
2322 */
2423
25 -
2624 class ProofreadPage {
2725
2826 /* Page and Index namespaces */
@@ -36,9 +34,9 @@
3735 */
3836 function ProofreadPage() {
3937 global $wgParser, $wgHooks;
40 - $wgParser->setHook( "pagelist", array( &$this, "renderPageList" ) );
41 - $wgParser->setHook( "pages", array( &$this, "renderPages" ) );
42 - $wgParser->setHook( "pagequality", array( &$this, "pageQuality" ) );
 38+ $wgParser->setHook( 'pagelist', array( &$this, 'renderPageList' ) );
 39+ $wgParser->setHook( 'pages', array( &$this, 'renderPages' ) );
 40+ $wgParser->setHook( 'pagequality', array( &$this, 'pageQuality' ) );
4341 $wgHooks['BeforePageDisplay'][] = array( &$this, 'beforePageDisplay' );
4442 $wgHooks['GetLinkColours'][] = array( &$this, 'getLinkColoursHook' );
4543 $wgHooks['ImageOpenShowImageInlineBefore'][] = array( &$this, 'imageMessage' );
@@ -57,70 +55,79 @@
5856 $this->index_namespace = preg_quote( wfMsgForContent( 'proofreadpage_index_namespace' ), '/' );
5957 }
6058
61 -
6259 public static function resourceLoaderRegisterModules() {
 60+ ResourceLoader::register(
 61+ 'proofreadpage.page',
 62+ new ResourceLoaderFileModule(
 63+ array(
 64+ 'scripts' => 'extensions/ProofreadPage/proofread.js',
 65+ 'messages' => array(
 66+ 'proofreadpage_index',
 67+ 'proofreadpage_nextpage',
 68+ 'proofreadpage_prevpage',
 69+ 'proofreadpage_image',
 70+ 'proofreadpage_header',
 71+ 'proofreadpage_body',
 72+ 'proofreadpage_footer',
 73+ 'proofreadpage_toggleheaders',
 74+ 'proofreadpage_page_status',
 75+ 'proofreadpage_quality0_category',
 76+ 'proofreadpage_quality1_category',
 77+ 'proofreadpage_quality2_category',
 78+ 'proofreadpage_quality3_category',
 79+ 'proofreadpage_quality4_category',
 80+ )
 81+ )
 82+ )
 83+ );
6384
64 - ResourceLoader::register( 'proofreadpage.page',
65 - new ResourceLoaderFileModule(
66 - array( 'scripts' => 'extensions/ProofreadPage/proofread.js',
67 - 'messages' => array( 'proofreadpage_index',
68 - 'proofreadpage_nextpage',
69 - 'proofreadpage_prevpage',
70 - 'proofreadpage_image',
71 - 'proofreadpage_header',
72 - 'proofreadpage_body',
73 - 'proofreadpage_footer',
74 - 'proofreadpage_toggleheaders',
75 - 'proofreadpage_page_status',
76 - 'proofreadpage_quality0_category',
77 - 'proofreadpage_quality1_category',
78 - 'proofreadpage_quality2_category',
79 - 'proofreadpage_quality3_category',
80 - 'proofreadpage_quality4_category',
81 - )
82 - ) ) );
 85+ ResourceLoader::register(
 86+ 'proofreadpage.article',
 87+ new ResourceLoaderFileModule(
 88+ array(
 89+ 'scripts' => 'extensions/ProofreadPage/proofread_article.js',
 90+ 'messages'=> array(
 91+ 'proofreadpage_source',
 92+ 'proofreadpage_source_message'
 93+ )
 94+ )
 95+ )
 96+ );
8397
84 - ResourceLoader::register( 'proofreadpage.article',
85 - new ResourceLoaderFileModule(
86 - array( 'scripts' => 'extensions/ProofreadPage/proofread_article.js',
87 - 'messages'=> array( 'proofreadpage_source', 'proofreadpage_source_message' )
88 - ) ) );
 98+ ResourceLoader::register(
 99+ 'proofreadpage.index',
 100+ new ResourceLoaderFileModule( array( 'scripts' => 'extensions/ProofreadPage/proofread_index.js' ) )
 101+ );
89102
90 - ResourceLoader::register( 'proofreadpage.index',
91 - new ResourceLoaderFileModule( array( 'scripts' => 'extensions/ProofreadPage/proofread_index.js' ) ) );
92 -
93103 return true;
94104 }
95105
96 -
97 -
98106 function schema_update() {
99107 global $wgExtNewTables;
100 - $base = dirname(__FILE__);
101 - $wgExtNewTables[] = array( 'pr_index', "$base/ProofreadPage.sql" );
 108+ $base = dirname( __FILE__ );
 109+ $wgExtNewTables[] = array( 'pr_index', "$base/ProofreadPage.sql" );
102110 return true;
103111 }
104112
105 -
106113 /**
107 - * Query the database to find if the current page is referred in an Index page.
 114+ * Query the database to find if the current page is referred in an Index page.
108115 */
109116 function load_index( $title ) {
110 -
111117 $page_namespace = $this->page_namespace;
112118 $index_namespace = $this->index_namespace;
113119
114120 $title->pr_index_title = null;
115121 $dbr = wfGetDB( DB_SLAVE );
116122 $result = $dbr->select(
117 - array( 'page', 'pagelinks' ),
118 - array( 'page_namespace', 'page_title' ),
119 - array(
120 - 'pl_namespace' => $title->getNamespace(),
121 - 'pl_title' => $title->getDBkey(),
122 - 'pl_from=page_id'
123 - ),
124 - __METHOD__ );
 123+ array( 'page', 'pagelinks' ),
 124+ array( 'page_namespace', 'page_title' ),
 125+ array(
 126+ 'pl_namespace' => $title->getNamespace(),
 127+ 'pl_title' => $title->getDBkey(),
 128+ 'pl_from=page_id'
 129+ ),
 130+ __METHOD__
 131+ );
125132
126133 while ( $x = $dbr->fetchObject( $result ) ) {
127134 $ref_title = Title::makeTitle( $x->page_namespace, $x->page_title );
@@ -130,20 +137,23 @@
131138 }
132139 }
133140 $dbr->freeResult( $result ) ;
134 -
135 - if ( $title->pr_index_title ) return;
136 -
137 - /*check if we are a page of a multipage file*/
 141+
 142+ if ( $title->pr_index_title ) {
 143+ return;
 144+ }
 145+
 146+ /* check if we are a page of a multipage file */
138147 if ( preg_match( "/^$page_namespace:(.*?)(\/([0-9]*)|)$/", $title->getPrefixedText(), $m ) ) {
139148 $imageTitle = Title::makeTitleSafe( NS_IMAGE, $m[1] );
140149 }
141 - if ( !$imageTitle ) return;
 150+ if ( !$imageTitle ) {
 151+ return;
 152+ }
142153
143154 $image = wfFindFile( $imageTitle );
144155
145156 // if it is multipage, we use the page order of the file
146157 if ( $image && $image->exists() && $image->isMultiPage() ) {
147 -
148158 $name = $image->getTitle()->getText();
149159 $index_name = "$index_namespace:$name";
150160
@@ -154,12 +164,10 @@
155165 }
156166 }
157167
158 -
159168 /**
160169 * return the URLs of the index, previous and next pages.
161170 */
162171 function navigation( $title ) {
163 -
164172 $page_namespace = $this->page_namespace;
165173 $default_header = wfMsgGetKey( 'proofreadpage_default_header', true, true, false );
166174 $default_footer = wfMsgGetKey( 'proofreadpage_default_footer', true, true, false );
@@ -188,83 +196,90 @@
189197 $next_name = "$page_namespace:$name/" . ( $pagenr + 1 );
190198 $prev_url = ( $pagenr == 1 ) ? '' : Title::newFromText( $prev_name )->getFullURL();
191199 $next_url = ( $pagenr == $count ) ? '' : Title::newFromText( $next_name )->getFullURL();
192 -
 200+
193201 } else {
194202 $prev_url = '';
195203 $next_url = '';
196204 }
197 -
 205+
198206 $index_url = $index_title->getFullURL();
199 -
 207+
200208 if ( !$index_title->exists() ) {
201209 return array( $index_url, $prev_url, $next_url, $default_header, $default_footer );
202210 }
203211
204 - //if the index page exists, find current page number, previous and next pages
 212+ // if the index page exists, find current page number, previous and next pages
205213 list( $links, $params, $attributes ) = $this->parse_index( $index_title );
206 -
207 - if( $links==null ) {
208 - list($pagenum, $links, $mode) = $this->pageNumber($pagenr,$params);
209 - $attributes["pagenum"] = $pagenum;
 214+
 215+ if( $links == null ) {
 216+ list( $pagenum, $links, $mode ) = $this->pageNumber( $pagenr, $params );
 217+ $attributes['pagenum'] = $pagenum;
210218 } else {
211 - for( $i=0; $i<count( $links[1] ); $i++) {
212 - $a_title = Title::newFromText( $page_namespace.":".$links[1][$i] );
213 - if(!$a_title) continue;
 219+ for( $i = 0; $i < count( $links[1] ); $i++ ) {
 220+ $a_title = Title::newFromText( $page_namespace . ':' . $links[1][$i] );
 221+ if( !$a_title ) {
 222+ continue;
 223+ }
214224 if( $a_title->getPrefixedText() == $title->getPrefixedText() ) {
215 - $attributes["pagenum"] = $links[3][$i];
 225+ $attributes['pagenum'] = $links[3][$i];
216226 break;
217227 }
218228 }
219 - if( ($i>0) && ($i<count($links[1])) ){
220 - $prev_title = Title::newFromText( $page_namespace.":".$links[1][$i-1] );
 229+ if( ( $i > 0 ) && ( $i < count( $links[1] ) ) ) {
 230+ $prev_title = Title::newFromText( $page_namespace . ':' . $links[1][$i - 1] );
221231 }
222 - if( ($i>=0) && ($i+1<count($links[1])) ){
223 - $next_title = Title::newFromText( $page_namespace.":".$links[1][$i+1] );
 232+ if( ( $i >= 0 ) && ( $i + 1 < count( $links[1] ) ) ) {
 233+ $next_title = Title::newFromText( $page_namespace . ':' . $links[1][$i + 1] );
224234 }
225 - if($prev_title) $prev_url = $prev_title->getFullURL();
226 - if($next_title) $next_url = $next_title->getFullURL();
 235+ if( $prev_title ) {
 236+ $prev_url = $prev_title->getFullURL();
 237+ }
 238+ if( $next_title ) {
 239+ $next_url = $next_title->getFullURL();
 240+ }
227241 }
228242
229 - // Header and Footer
 243+ // Header and Footer
230244 // use a js dictionary for style, width, header footer
231 - $header = $attributes['header'] ? $attributes['header'] : $default_header;
232 - $footer = $attributes['footer'] ? $attributes['footer'] : $default_footer;
 245+ $header = $attributes['header'] ? $attributes['header'] : $default_header;
 246+ $footer = $attributes['footer'] ? $attributes['footer'] : $default_footer;
233247 foreach ( $attributes as $key => $val ) {
234248 $header = str_replace( "{{{{$key}}}}", $val, $header );
235249 $footer = str_replace( "{{{{$key}}}}", $val, $footer );
236250 }
237 - $css = $attributes['css'] ? $attributes['css'] : "";
238 - $edit_width = $attributes['width'] ? $attributes['width'] : "";
239 -
 251+ $css = $attributes['css'] ? $attributes['css'] : '';
 252+ $edit_width = $attributes['width'] ? $attributes['width'] : '';
 253+
240254 return array( $index_url, $prev_url, $next_url, $header, $footer, $css, $edit_width );
241 -
242255 }
243256
244 -
245 - /*
 257+ /**
246258 * Read metadata from an index page.
247 - * Depending on whether the index uses pagelist,
248 - * it will return either a list of links or a list
 259+ * Depending on whether the index uses pagelist,
 260+ * it will return either a list of links or a list
249261 * of parameters to pagelist, and a list of attributes.
250262 */
251263 function parse_index( $index_title ) {
252264 $err = array( false, false, array() );
253 - if ( !$index_title ) return $err;
254 - if ( !$index_title->exists() ) return $err;
255 -
 265+ if ( !$index_title ) {
 266+ return $err;
 267+ }
 268+ if ( !$index_title->exists() ) {
 269+ return $err;
 270+ }
 271+
256272 $rev = Revision::newFromTitle( $index_title );
257273 $text = $rev->getText();
258274 return $this->parse_index_text( $text );
259275 }
260276
261 - function parse_index_text( $text ){
262 -
 277+ function parse_index_text( $text ) {
263278 $page_namespace = $this->page_namespace;
264279 //check if it is using pagelist
265280 preg_match_all( "/<pagelist([^<]*?)\/>/is", $text, $m, PREG_PATTERN_ORDER );
266281 if( $m[1] ) {
267 - $params_s = "";
268 - for( $k = 0; $k < count( $m[1] ); $k++) {
 282+ $params_s = '';
 283+ for( $k = 0; $k < count( $m[1] ); $k++ ) {
269284 $params_s = $params_s . $m[1][$k];
270285 }
271286 $params = Sanitizer::decodeTagAttributes( $params_s );
@@ -275,16 +290,15 @@
276291 preg_match_all( $tag_pattern, $text, $links, PREG_PATTERN_ORDER );
277292 }
278293
279 -
280 - //read attributes
 294+ // read attributes
281295 $attributes = array();
282 - $var_names = explode(" ", wfMsgForContent('proofreadpage_js_attributes') );
283 - for( $i = 0; $i < count($var_names); $i++ ) {
 296+ $var_names = explode( ' ', wfMsgForContent( 'proofreadpage_js_attributes' ) );
 297+ for( $i = 0; $i < count( $var_names ); $i++ ) {
284298 $tag_pattern = "/\n\|" . $var_names[$i] . "=(.*?)\n(\||\}\})/is";
285 - //$var = 'proofreadPage'.$var_names[$i];
 299+ //$var = 'proofreadPage' . $var_names[$i];
286300 $var = strtolower( $var_names[$i] );
287301 if( preg_match( $tag_pattern, $text, $matches ) ) {
288 - $attributes[$var] = $matches[1];
 302+ $attributes[$var] = $matches[1];
289303 } else {
290304 $attributes[$var] = '';
291305 }
@@ -296,10 +310,9 @@
297311 /**
298312 * Return the ordered list of links to ns-0 from an index page
299313 */
300 - function parse_index_links( $index_title ){
301 -
 314+ function parse_index_links( $index_title ) {
302315 // Instanciate a new parser object to avoid side effects of $parser->replaceVariables
303 - if( is_null($this->index_parser) ) {
 316+ if( is_null( $this->index_parser ) ) {
304317 $this->index_parser = new Parser;
305318 }
306319 $rev = Revision::newFromTitle( $index_title );
@@ -316,31 +329,31 @@
317330 */
318331 function beforePageDisplay( &$out ) {
319332 global $wgTitle, $wgJsMimeType, $wgScriptPath, $wgRequest, $wgProofreadPageVersion;
320 -
 333+
321334 $action = $wgRequest->getVal( 'action' );
322335 $isEdit = ( $action == 'submit' || $action == 'edit' ) ? 1 : 0;
323336 if ( !isset( $wgTitle ) || ( !$out->isArticle() && !$isEdit ) || isset( $out->proofreadPageDone ) ) {
324337 return true;
325338 }
326339 $out->proofreadPageDone = true;
327 -
 340+
328341 $page_namespace = $this->page_namespace;
329342 if ( preg_match( "/^$page_namespace:(.*?)(\/([0-9]*)|)$/", $wgTitle->getPrefixedText(), $m ) ) {
330343 $this->preparePage( $out, $m, $isEdit );
331344 return true;
332345 }
333 -
 346+
334347 $index_namespace = $this->index_namespace;
335348 if ( $isEdit && ( preg_match( "/^$index_namespace:(.*?)(\/([0-9]*)|)$/", $wgTitle->getPrefixedText(), $m ) ) ) {
336349 $this->prepareIndex( $out );
337350 return true;
338351 }
339 -
 352+
340353 if( $wgTitle->getNamespace() == NS_MAIN ) {
341354 $this->prepareArticle( $out );
342355 return true;
343356 }
344 -
 357+
345358 return true;
346359 }
347360
@@ -363,7 +376,7 @@
364377 if ( !isset( $wgTitle->pr_index_title ) ) {
365378 $this->load_index( $wgTitle );
366379 }
367 -
 380+
368381 $imageTitle = Title::makeTitleSafe( NS_IMAGE, $m[1] );
369382 if ( !$imageTitle ) {
370383 return true;
@@ -387,22 +400,22 @@
388401 }
389402
390403 list( $index_url, $prev_url, $next_url, $header, $footer, $css, $edit_width ) = $this->navigation( $wgTitle );
391 -
 404+
392405 $jsVars = array(
393 - 'proofreadPageWidth' => intval( $width ),
394 - 'proofreadPageHeight' => intval( $height ),
395 - 'proofreadPageEditWidth' => $edit_width,
396 - 'proofreadPageThumbURL' => $thumbURL,
397 - 'proofreadPageIsEdit' => intval( $isEdit ),
398 - 'proofreadPageIndexURL' => $index_url,
399 - 'proofreadPagePrevURL' => $prev_url,
400 - 'proofreadPageNextURL' => $next_url,
401 - 'proofreadPageHeader' => $header,
402 - 'proofreadPageFooter' => $footer,
403 - 'proofreadPageAddButtons' => $wgUser->isAllowed('pagequality'),
404 - 'proofreadPageUserName' => $wgUser->getName(),
405 - 'proofreadPageCss' => $css,
406 - );
 406+ 'proofreadPageWidth' => intval( $width ),
 407+ 'proofreadPageHeight' => intval( $height ),
 408+ 'proofreadPageEditWidth' => $edit_width,
 409+ 'proofreadPageThumbURL' => $thumbURL,
 410+ 'proofreadPageIsEdit' => intval( $isEdit ),
 411+ 'proofreadPageIndexURL' => $index_url,
 412+ 'proofreadPagePrevURL' => $prev_url,
 413+ 'proofreadPageNextURL' => $next_url,
 414+ 'proofreadPageHeader' => $header,
 415+ 'proofreadPageFooter' => $footer,
 416+ 'proofreadPageAddButtons' => $wgUser->isAllowed( 'pagequality' ),
 417+ 'proofreadPageUserName' => $wgUser->getName(),
 418+ 'proofreadPageCss' => $css,
 419+ );
407420 $out->addInlineScript( ResourceLoader::makeConfigSetScript( $jsVars ) );
408421
409422 $out->addModules( 'proofreadpage.page' );
@@ -410,9 +423,8 @@
411424 return true;
412425 }
413426
414 -
415427 /**
416 - * Hook function
 428+ * Hook function
417429 */
418430 function getLinkColoursHook( $page_ids, &$colours ) {
419431 global $wgTitle;
@@ -427,10 +439,9 @@
428440 $this->getLinkColours( $page_ids, $colours );
429441 return true;
430442 }
431 -
432443
433444 /**
434 - * Return the quality colour codes to pages linked from an index page
 445+ * Return the quality colour codes to pages linked from an index page
435446 */
436447 function getLinkColours( $page_ids, &$colours ) {
437448 $page_namespace = $this->page_namespace;
@@ -441,7 +452,7 @@
442453 if ( preg_match( "/^$page_namespace:(.*?)$/", $pdbk ) ) {
443454 $colours[$pdbk] = 'quality1';
444455 if ( !isset( $query ) ) {
445 - $query = "SELECT cl_from, cl_to FROM $catlinks WHERE cl_from IN(";
 456+ $query = "SELECT cl_from, cl_to FROM $catlinks WHERE cl_from IN(";
446457 } else {
447458 $query .= ', ';
448459 }
@@ -476,7 +487,7 @@
477488 }
478489 }
479490
480 - function imageMessage( &$imgpage , &$wgOut ) {
 491+ function imageMessage( &$imgpage, &$out ) {
481492 global $wgUser;
482493 $index_namespace = $this->index_namespace;
483494 $image = $imgpage->img;
@@ -486,48 +497,93 @@
487498 $sk = $wgUser->getSkin();
488499 $name = $image->getTitle()->getText();
489500 $link = $sk->makeKnownLink( "$index_namespace:$name", wfMsg( 'proofreadpage_image_message' ) );
490 - $wgOut->addHTML( "{$link}" );
 501+ $out->addHTML( "{$link}" );
491502 return true;
492503 }
493504
494 -
495505 // credit : http://www.mediawiki.org/wiki/Extension:RomanNumbers
496506 function toRoman( $num ) {
497507 if ( $num < 0 || $num > 9999 ) {
498508 return - 1;
499509 }
500 - $romanOnes = array( 1 => "I", 2 => "II", 3 => "III", 4 => "IV", 5 => "V", 6 => "VI", 7 => "VII", 8 => "VIII", 9 => "IX" );
501 - $romanTens = array( 1 => "X", 2 => "XX", 3 => "XXX", 4 => "XL", 5 => "L", 6 => "LX", 7 => "LXX", 8 => "LXXX", 9 => "XC" );
502 - $romanHund = array( 1 => "C", 2 => "CC", 3 => "CCC", 4 => "CD", 5 => "D", 6 => "DC", 7 => "DCC", 8 => "DCCC", 9 => "CM" );
503 - $romanThou = array( 1 => "M", 2 => "MM", 3 => "MMM", 4 => "MMMM", 5 => "MMMMM", 6 => "MMMMMM", 7 => "MMMMMMM", 8 => "MMMMMMMM", 9 => "MMMMMMMMM" );
504 -
 510+ $romanOnes = array(
 511+ 1 => 'I',
 512+ 2 => 'II',
 513+ 3 => 'III',
 514+ 4 => 'IV',
 515+ 5 => 'V',
 516+ 6 => 'VI',
 517+ 7 => 'VII',
 518+ 8 => 'VIII',
 519+ 9 => 'IX'
 520+ );
 521+ $romanTens = array(
 522+ 1 => 'X',
 523+ 2 => 'XX',
 524+ 3 => 'XXX',
 525+ 4 => 'XL',
 526+ 5 => 'L',
 527+ 6 => 'LX',
 528+ 7 => 'LXX',
 529+ 8 => 'LXXX',
 530+ 9 => 'XC'
 531+ );
 532+ $romanHund = array(
 533+ 1 => 'C',
 534+ 2 => 'CC',
 535+ 3 => 'CCC',
 536+ 4 => 'CD',
 537+ 5 => 'D',
 538+ 6 => 'DC',
 539+ 7 => 'DCC',
 540+ 8 => 'DCCC',
 541+ 9 => 'CM'
 542+ );
 543+ $romanThou = array(
 544+ 1 => 'M',
 545+ 2 => 'MM',
 546+ 3 => 'MMM',
 547+ 4 => 'MMMM',
 548+ 5 => 'MMMMM',
 549+ 6 => 'MMMMMM',
 550+ 7 => 'MMMMMMM',
 551+ 8 => 'MMMMMMMM',
 552+ 9 => 'MMMMMMMMM'
 553+ );
 554+
505555 $ones = $num % 10;
506556 $tens = ( $num - $ones ) % 100;
507557 $hund = ( $num - $tens - $ones ) % 1000;
508558 $thou = ( $num - $hund - $tens - $ones ) % 10000;
509 -
 559+
510560 $tens = $tens / 10;
511561 $hund = $hund / 100;
512562 $thou = $thou / 1000;
513 -
514 - if ( $thou ) $romanNum .= $romanThou[$thou];
515 - if ( $hund ) $romanNum .= $romanHund[$hund];
516 - if ( $tens ) $romanNum .= $romanTens[$tens];
517 - if ( $ones ) $romanNum .= $romanOnes[$ones];
518 -
 563+
 564+ if ( $thou ) {
 565+ $romanNum .= $romanThou[$thou];
 566+ }
 567+ if ( $hund ) {
 568+ $romanNum .= $romanHund[$hund];
 569+ }
 570+ if ( $tens ) {
 571+ $romanNum .= $romanTens[$tens];
 572+ }
 573+ if ( $ones ) {
 574+ $romanNum .= $romanOnes[$ones];
 575+ }
 576+
519577 return $romanNum;
520578 }
521579
522 -
523580 function pageNumber( $i, $args ) {
524 -
525581 $mode = 'normal'; // default
526582 $offset = 0;
527583 $links = true;
528584 foreach ( $args as $num => $param ) {
529585 if ( ( preg_match( "/^([0-9]*)to([0-9]*)$/", $num, $m ) && ( $i >= $m[1] && $i <= $m[2] ) )
530586 || ( is_numeric( $num ) && ( $i == $num ) ) ) {
531 - $params = explode( ";", $param );
 587+ $params = explode( ';', $param );
532588 foreach ( $params as $iparam ) {
533589 switch( $iparam ) {
534590 case 'roman':
@@ -540,61 +596,68 @@
541597 $links = false;
542598 break;
543599 default:
544 - if ( !is_numeric( $iparam ) )
 600+ if ( !is_numeric( $iparam ) ) {
545601 $mode = $iparam;
 602+ }
546603 }
547604 }
548605 }
549 -
 606+
550607 if ( is_numeric( $num ) && ( $i >= $num ) ) {
551 - $params = explode( ";", $param );
552 - foreach ( $params as $iparam )
553 - if ( is_numeric( $iparam ) )
 608+ $params = explode( ';', $param );
 609+ foreach ( $params as $iparam ) {
 610+ if ( is_numeric( $iparam ) ) {
554611 $offset = $num - $iparam;
 612+ }
 613+ }
555614 }
556 -
 615+
557616 }
558617 $view = ( $i - $offset );
559618 switch( $mode ) {
560619 case 'highroman':
561 - $view = toRoman( $view ); break;
 620+ $view = toRoman( $view );
 621+ break;
562622 case 'roman':
563 - $view = strtolower( toRoman( $view ) ); break;
 623+ $view = strtolower( toRoman( $view ) );
 624+ break;
564625 case 'normal':
565 - $view = '' . $view; break;
 626+ $view = '' . $view;
 627+ break;
566628 case 'empty':
567 - $view = '' . $view; break;
 629+ $view = '' . $view;
 630+ break;
568631 default:
569632 $view = $mode;
570633 }
571634 return array( $view, $links, $mode );
572635 }
573636
574 -
575 - /*
576 - * add the pagequality category.
577 - * todo : display whether page has been proofread by the user or by someone else
 637+ /**
 638+ * Add the pagequality category.
 639+ * @todo FIXME: display whether page has been proofread by the user or by someone else
578640 */
579641 function pageQuality( $input, $args, &$parser ) {
580642 global $wgUser;
581 -
 643+
582644 $page_namespace = $this->page_namespace;
583645 if ( !preg_match( "/^$page_namespace:(.*?)(\/([0-9]*)|)$/", $parser->Title()->getPrefixedText() ) ) {
584 - return "";
 646+ return '';
585647 }
586 -
 648+
587649 $q = $args['level'];
588 - if( ! in_array( $q, array('0','1','2','3','4') ) ) {
589 - return "";
 650+ if( !in_array( $q, array( '0', '1', '2', '3', '4' ) ) ) {
 651+ return '';
590652 }
591 - $message = "<div id=\"pagequality\" width=100% class=quality$q>".wfMsgForContent( "proofreadpage_quality{$q}_message" )."</div>";
592 - $out = "__NOEDITSECTION__[[Category:".wfMsgForContent( "proofreadpage_quality{$q}_category" )."]]";
593 - return $parser->recursiveTagParse( $out . $message);
 653+ $message = "<div id=\"pagequality\" width=100% class=quality$q>" .
 654+ wfMsgForContent( "proofreadpage_quality{$q}_message" ) . '</div>';
 655+ $out = '__NOEDITSECTION__[[Category:' .
 656+ wfMsgForContent( "proofreadpage_quality{$q}_category" ) . ']]';
 657+ return $parser->recursiveTagParse( $out . $message );
594658 }
595659
596 -
597 - /*
598 - * Parser hook for index pages
 660+ /**
 661+ * Parser hook for index pages
599662 * Display a list of coloured links to pages
600663 */
601664 function renderPageList( $input, $args, $parser ) {
@@ -603,7 +666,7 @@
604667 $page_namespace = $this->page_namespace;
605668 $index_namespace = $this->index_namespace;
606669 if ( !preg_match( "/^$index_namespace:(.*?)(\/([0-9]*)|)$/", $parser->Title()->getPrefixedText(), $m ) ) {
607 - return "";
 670+ return '';
608671 }
609672
610673 $imageTitle = Title::makeTitleSafe( NS_IMAGE, $m[1] );
@@ -612,24 +675,28 @@
613676 }
614677
615678 $image = wfFindFile( $imageTitle );
616 - if ( ! ( $image && $image->isMultiPage() && $image->pageCount() ) ) {
 679+ if ( !( $image && $image->isMultiPage() && $image->pageCount() ) ) {
617680 return '<strong class="error">' . wfMsgForContent( 'proofreadpage_nosuch_file' ) . '</strong>';
618 - }
 681+ }
619682
620 - $return = "";
621 -
 683+ $return = '';
 684+
622685 $name = $imageTitle->getDBkey();
623686 $count = $image->pageCount();
624687
625688 $from = $args['from'];
626689 $to = $args['to'];
627 - if( !$from ) $from = 1;
628 - if( !$to ) $to = $count;
 690+ if( !$from ) {
 691+ $from = 1;
 692+ }
 693+ if( !$to ) {
 694+ $to = $count;
 695+ }
629696
630697 if( !is_numeric( $from ) || !is_numeric( $to ) ) {
631698 return '<strong class="error">' . wfMsgForContent( 'proofreadpage_number_expected' ) . '</strong>';
632699 }
633 - if( ($from > $to) || ($from < 1) || ($to < 1 ) || ($to > $count) ) {
 700+ if( ( $from > $to ) || ( $from < 1 ) || ( $to < 1 ) || ( $to > $count ) ) {
634701 return '<strong class="error">' . wfMsgForContent( 'proofreadpage_invalid_interval' ) . '</strong>';
635702 }
636703
@@ -637,7 +704,9 @@
638705 $pdbk = "$page_namespace:$name" . '/' . $i ;
639706 list( $view, $links, $mode ) = $this->pageNumber( $i, $args );
640707
641 - if ( $mode == 'highroman' || $mode == 'roman' ) $view = '&#160;' . $view;
 708+ if ( $mode == 'highroman' || $mode == 'roman' ) {
 709+ $view = '&#160;' . $view;
 710+ }
642711
643712 $n = strlen( $count ) - strlen( $view );
644713 if ( $n && ( $mode == 'normal' || $mode == 'empty' ) ) {
@@ -650,24 +719,20 @@
651720 $title = Title::newFromText( $pdbk );
652721
653722 if ( $links == false ) {
654 - $return .= $view . " ";
 723+ $return .= $view . ' ';
655724 } else {
656 - $return .= "[[".$title->getPrefixedText()."|$view]] ";
 725+ $return .= '[[' . $title->getPrefixedText() . "|$view]] ";
657726 }
658727 }
659 - $return = $parser->recursiveTagParse($return);
 728+ $return = $parser->recursiveTagParse( $return );
660729 return $return;
661730 }
662731
663 -
664 -
665 -
666 - /*
 732+ /**
667733 * Parser hook that includes a list of pages.
668734 * parameters : index, from, to, header
669735 */
670736 function renderPages( $input, $args, &$parser ) {
671 -
672737 $page_namespace = $this->page_namespace;
673738 $index_namespace = $this->index_namespace;
674739 $index = $args['index'];
@@ -677,41 +742,44 @@
678743
679744 // abort if the tag is on an index page
680745 if ( preg_match( "/^$index_namespace:(.*?)(\/([0-9]*)|)$/", $parser->Title()->getPrefixedText() ) ) {
681 - return "";
 746+ return '';
682747 }
683748 // abort too if the tag is in the page namespace
684749 if ( preg_match( "/^$page_namespace:(.*?)(\/([0-9]*)|)$/", $parser->Title()->getPrefixedText() ) ) {
685 - return "";
 750+ return '';
686751 }
687 - if( ! $index ) {
 752+ if( !$index ) {
688753 return '<strong class="error">' . wfMsgForContent( 'proofreadpage_index_expected' ) . '</strong>';
689754 }
690755 $index_title = Title::newFromText( "$index_namespace:$index" );
691 - if( ! $index_title || ! $index_title->exists() ) {
 756+ if( !$index_title || !$index_title->exists() ) {
692757 return '<strong class="error">' . wfMsgForContent( 'proofreadpage_nosuch_index' ) . '</strong>';
693758 }
694759
695760 $parser->getOutput()->addTemplate( $index_title, $index_title->getArticleID(), $index_title->getLatestRevID() );
696 -
 761+
697762 $out = '';
698 -
 763+
699764 list( $links, $params, $attributes ) = $this->parse_index( $index_title );
700765
701766 if( $from || $to ) {
702 -
703 - if( $links==null ) {
 767+ if( $links == null ) {
704768 $imageTitle = Title::makeTitleSafe( NS_IMAGE, $index );
705769 if ( !$imageTitle ) {
706770 return '<strong class="error">' . wfMsgForContent( 'proofreadpage_nosuch_file' ) . '</strong>';
707771 }
708772 $image = wfFindFile( $imageTitle );
709 - if ( ! ( $image && $image->isMultiPage() && $image->pageCount() ) ) {
 773+ if ( !( $image && $image->isMultiPage() && $image->pageCount() ) ) {
710774 return '<strong class="error">' . wfMsgForContent( 'proofreadpage_nosuch_file' ) . '</strong>';
711775 }
712776 $count = $image->pageCount();
713777
714 - if( !$from ) $from = 1;
715 - if( !$to ) $to = $count;
 778+ if( !$from ) {
 779+ $from = 1;
 780+ }
 781+ if( !$to ) {
 782+ $to = $count;
 783+ }
716784
717785 if( !is_numeric( $from ) || !is_numeric( $to ) ) {
718786 return '<strong class="error">' . wfMsgForContent( 'proofreadpage_number_expected' ) . '</strong>';
@@ -724,10 +792,10 @@
725793 }
726794 $pages = array();
727795
728 - for( $i=$from; $i<=$to;$i++ ) {
729 - list($pagenum, $links, $mode) = $this->pageNumber( $i, $params );
 796+ for( $i = $from; $i <= $to; $i++ ) {
 797+ list( $pagenum, $links, $mode ) = $this->pageNumber( $i, $params );
730798 $page = str_replace( ' ' , '_', "$index/" . $i );
731 - if( $i == $from ) {
 799+ if( $i == $from ) {
732800 $from_page = $page;
733801 $from_pagenum = $pagenum;
734802 }
@@ -738,31 +806,31 @@
739807 $pages[] = array( $page, $pagenum );
740808 }
741809 } else {
742 - if($from) {
 810+ if( $from ) {
743811 $adding = false;
744812 } else {
745813 $adding = true;
746814 $from_pagenum = $links[3][0];
747815 }
748 - for( $i=0; $i < count( $links[1] ); $i++) {
 816+ for( $i = 0; $i < count( $links[1] ); $i++ ) {
749817 $text = $links[1][$i];
750818 $pagenum = $links[3][$i];
751 - if($text == $from ) {
 819+ if( $text == $from ) {
752820 $adding = true;
753821 $from_page = $from;
754822 $from_pagenum = $pagenum;
755823 }
756 - if($adding) {
 824+ if( $adding ) {
757825 $pages[] = array( $text, $pagenum );
758826 }
759 - if($text == $to ) {
 827+ if( $text == $to ) {
760828 $adding = false;
761829 $to_page = $to;
762830 $to_pagenum = $pagenum;
763831 }
764832 }
765833 if( !$to ) {
766 - $to_pagenum = $links[3][ count( $links[1] ) - 1 ];
 834+ $to_pagenum = $links[3][count( $links[1] ) - 1];
767835 }
768836 }
769837
@@ -772,58 +840,69 @@
773841 list( $page, $pagenum ) = $item;
774842 $pp[] = $page;
775843 }
776 - $pagelist = "'".implode( "', '", $pp)."'";
 844+ $pagelist = "'" . implode( "', '", $pp ) . "'";
777845 $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( $page_namespace ) );
778846 $dbr = wfGetDB( DB_SLAVE );
779847 $cat = $dbr->strencode( str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality0_category' ) ) );
780 - $res = $dbr->select( array('page', 'categorylinks' ),
781 - array("page_title"),
782 - array("page_title IN ( $pagelist )", "cl_to='$cat'", "page_namespace=$page_ns_index" ),
783 - __METHOD__, null,
784 - array('categorylinks' => array ( 'LEFT JOIN','cl_from=page_id') ) );
 848+ $res = $dbr->select(
 849+ array( 'page', 'categorylinks' ),
 850+ array( 'page_title' ),
 851+ array(
 852+ "page_title IN ( $pagelist )",
 853+ "cl_to='$cat'",
 854+ "page_namespace=$page_ns_index"
 855+ ),
 856+ __METHOD__,
 857+ null,
 858+ array( 'categorylinks' => array( 'LEFT JOIN', 'cl_from=page_id' ) )
 859+ );
785860
786861 $q0_pages = array();
787 - if( $res ) {
788 - while( $o = $dbr->fetchObject( $res ) ) {
 862+ if( $res ) {
 863+ while( $o = $dbr->fetchObject( $res ) ) {
789864 array_push( $q0_pages, $o->page_title );
790865 }
791866 }
792 -
793 - //write the output
 867+
 868+ // write the output
794869 foreach( $pages as $item ) {
795870 list( $page, $pagenum ) = $item;
796 - if( in_array( $page , $q0_pages ) ) {
 871+ if( in_array( $page, $q0_pages ) ) {
797872 $is_q0 = true;
798873 } else {
799874 $is_q0 = false;
800875 }
801876 $text = "$page_namespace:$page";
802877 if( !$is_q0 ) {
803 - $out.= "<span>{{:MediaWiki:Proofreadpage_pagenum_template|page=".$text."|num=$pagenum}}</span>";
 878+ $out .= '<span>{{:MediaWiki:Proofreadpage_pagenum_template|page=' . $text . "|num=$pagenum}}</span>";
804879 }
805 - if( $args["$i"] != null){
806 - $out.= "{{#lst:".$text."|".$args["$i"]."}}";
807 - } else if($page == $from && $args["fromsection"]){
808 - $out.= "{{#lst:".$text."|".$args["fromsection"]."}}";
809 - } else if($page == $to && $args["tosection"]){
810 - $out.= "{{#lst:".$text."|".$args["tosection"]."}}";
 880+ if( $args["$i"] != null ) {
 881+ $out .= '{{#lst:' . $text . '|' . $args["$i"] . '}}';
 882+ } elseif( $page == $from && $args['fromsection'] ) {
 883+ $out .= '{{#lst:' . $text . '|' . $args['fromsection'] . '}}';
 884+ } elseif( $page == $to && $args['tosection'] ) {
 885+ $out .= '{{#lst:' . $text . '|' . $args['tosection'] . '}}';
811886 } else {
812 - $out.= "{{:".$text."}}";
 887+ $out .= '{{:' . $text . '}}';
813888 }
814889 if( !$is_q0 ) {
815 - $out.= "\n";
 890+ $out.= "\n";
816891 }
817892 }
818893 } else {
819894 /* table of Contents */
820 - $header = "toc";
821 - if( $links==null ) {
 895+ $header = 'toc';
 896+ if( $links == null ) {
822897 $firstpage = str_replace( ' ' , '_', "$index/1" );
823898 } else {
824899 $firstpage = $links[1][0];
825900 }
826901 $firstpage_title = Title::newFromText( "$page_namespace:$firstpage" );
827 - $parser->getOutput()->addTemplate( $firstpage_title, $firstpage_title->getArticleID(), $firstpage_title->getLatestRevID() );
 902+ $parser->getOutput()->addTemplate(
 903+ $firstpage_title,
 904+ $firstpage_title->getArticleID(),
 905+ $firstpage_title->getLatestRevID()
 906+ );
828907 $parser->getOutput()->is_toc = true;
829908 }
830909
@@ -831,29 +910,47 @@
832911 $text_links = $this->parse_index_links( $index_title );
833912 $h_out = '{{:MediaWiki:Proofreadpage_header_template';
834913 $h_out .= "|value=$header";
835 - //find next and previous pages in list
836 - for( $i=1; $i < count( $text_links[1] ); $i++) {
 914+ // find next and previous pages in list
 915+ for( $i = 1; $i < count( $text_links[1] ); $i++ ) {
837916 if( $text_links[1][$i] == $parser->Title()->getPrefixedText() ) {
838917 $current = $text_links[0][$i];
839918 break;
840919 }
841920 }
842921 if( ( $i > 1 ) && ( $i < count( $text_links[1] ) ) ) {
843 - $prev = $text_links[0][$i-1];
 922+ $prev = $text_links[0][$i - 1];
844923 }
845924 if( ( $i >= 1 ) && ( $i + 1 < count( $text_links[1] ) ) ) {
846 - $next = $text_links[0][$i+1];
 925+ $next = $text_links[0][$i + 1];
847926 }
848 - if( isset( $args["current"] ) ) $current = $args["current"];
849 - if( isset( $args["prev"] ) ) $prev = $args["prev"];
850 - if( isset( $args["next"] ) ) $next = $args["next"];
851 - if( $current ) $h_out .= "|current=$current";
852 - if( $prev ) $h_out .= "|prev=$prev";
853 - if( $next ) $h_out .= "|next=$next";
854 - if( $from_pagenum ) $h_out .= "|from=$from_pagenum";
855 - if( $to_pagenum ) $h_out .= "|to=$to_pagenum";
 927+ if( isset( $args['current'] ) ) {
 928+ $current = $args['current'];
 929+ }
 930+ if( isset( $args['prev'] ) ) {
 931+ $prev = $args['prev'];
 932+ }
 933+ if( isset( $args['next'] ) ) {
 934+ $next = $args['next'];
 935+ }
 936+ if( $current ) {
 937+ $h_out .= "|current=$current";
 938+ }
 939+ if( $prev ) {
 940+ $h_out .= "|prev=$prev";
 941+ }
 942+ if( $next ) {
 943+ $h_out .= "|next=$next";
 944+ }
 945+ if( $from_pagenum ) {
 946+ $h_out .= "|from=$from_pagenum";
 947+ }
 948+ if( $to_pagenum ) {
 949+ $h_out .= "|to=$to_pagenum";
 950+ }
856951 foreach ( $attributes as $key => $val ) {
857 - if( $args[$key] ) $val = $args[$key];
 952+ if( $args[$key] ) {
 953+ $val = $args[$key];
 954+ }
858955 $h_out .= "|$key=$val";
859956 }
860957 $h_out .= '}}';
@@ -862,12 +959,11 @@
863960
864961 // wrap the output in a div, to prevent the parser from inserting pararaphs
865962 $out = "<div>$out</div>";
866 - $out = $parser->recursiveTagParse($out);
 963+ $out = $parser->recursiveTagParse( $out );
867964 return $out;
868965 }
869966
870 -
871 - /*
 967+ /**
872968 * Set is_toc flag (true if page is a table of contents)
873969 */
874970 function OutputPageParserOutput( $outputPage, $parserOutput ) {
@@ -879,7 +975,7 @@
880976 return true;
881977 }
882978
883 - /*
 979+ /**
884980 * Try to parse a page.
885981 * Return quality status of the page and username of the proofreader
886982 * Return -1 if the page cannot be parsed
@@ -894,7 +990,7 @@
895991 list( $index_url, $prev_url, $next_url, $header, $footer, $css, $edit_width ) = $this->navigation( $wgTitle );
896992 $new_text = "<noinclude><pagequality level=\"1\" user=\"$username\" />"
897993 ."$header\n\n\n</noinclude>$text<noinclude>\n$footer</noinclude>";
898 - return array( -1, null, $new_text );
 994+ return array( -1, null, $new_text );
899995 }
900996
901997 $header = $m[1];
@@ -912,22 +1008,19 @@
9131009 }
9141010
9151011 $new_text = "<noinclude><pagequality level=\"1\" user=\"$username\" />"
916 - ."$header\n\n\n</noinclude>$body<noinclude>\n$footer</noinclude>";
917 - return array( -1, null, $new_text );
918 -
 1012+ . "$header\n\n\n</noinclude>$body<noinclude>\n$footer</noinclude>";
 1013+ return array( -1, null, $new_text );
9191014 }
9201015
921 -
922 -
9231016 function importFormData( $editpage, $request ) {
9241017 global $wgTitle;
9251018
9261019 $page_namespace = $this->page_namespace;
927 - //abort if we are not a page
928 - if ( ! preg_match( "/^$page_namespace:(.*)$/", $wgTitle->getPrefixedText() ) ) {
 1020+ // abort if we are not a page
 1021+ if ( !preg_match( "/^$page_namespace:(.*)$/", $wgTitle->getPrefixedText() ) ) {
9291022 return true;
9301023 }
931 - if ( ! $request->wasPosted() ) {
 1024+ if ( !$request->wasPosted() ) {
9321025 return true;
9331026 }
9341027 $editpage->quality = $request->getVal( 'quality' );
@@ -935,31 +1028,37 @@
9361029 $editpage->header = $editpage->safeUnicodeInput( $request, 'wpHeaderTextbox' );
9371030 $editpage->footer = $editpage->safeUnicodeInput( $request, 'wpFooterTextbox' );
9381031
939 - //we want to keep ordinary spaces at the end of the main textbox
940 - $text = rtrim( $request->getText( 'wpTextbox1' ), "\t\n\r\0\x0B");
 1032+ // we want to keep ordinary spaces at the end of the main textbox
 1033+ $text = rtrim( $request->getText( 'wpTextbox1' ), "\t\n\r\0\x0B" );
9411034 $editpage->textbox1 = $request->getBool( 'safemode' )
9421035 ? $editpage->unmakesafe( $text )
9431036 : $text;
9441037
945 - if( in_array( $editpage->quality , array( "0", "1", "2", "3", "4" ) ) ) {
946 - //format the page
947 - $text = "<noinclude><pagequality level=\"".$editpage->quality."\" user=\"".$editpage->username."\" />"
948 - ."<div class=\"pagetext\">".$editpage->header."\n\n\n</noinclude>"
949 - .$editpage->textbox1
950 - ."<noinclude>\n".$editpage->footer."</div></noinclude>";
 1038+ if( in_array( $editpage->quality, array( '0', '1', '2', '3', '4' ) ) ) {
 1039+ // format the page
 1040+ $text = '<noinclude><pagequality level="' . $editpage->quality . '" user="' . $editpage->username . '" />' .
 1041+ '<div class="pagetext">' . $editpage->header."\n\n\n</noinclude>" .
 1042+ $editpage->textbox1 .
 1043+ "<noinclude>\n" . $editpage->footer . '</div></noinclude>';
9511044 $editpage->textbox1 = $text;
9521045 } else {
953 - //replace deprecated template
 1046+ // replace deprecated template
9541047 $text = $editpage->textbox1;
955 - $text = preg_replace( "/\{\{PageQuality\|(0|1|2|3|4)(|\|(.*?))\}\}/is", "<pagequality level=\"\\1\" user=\"\\3\" />", $text );
 1048+ $text = preg_replace(
 1049+ "/\{\{PageQuality\|(0|1|2|3|4)(|\|(.*?))\}\}/is",
 1050+ "<pagequality level=\"\\1\" user=\"\\3\" />",
 1051+ $text
 1052+ );
9561053 $editpage->textbox1 = $text;
9571054 }
9581055 return true;
9591056 }
9601057
961 -
962 - /*
963 - * Check the format of pages in "Page" namespace.
 1058+ /**
 1059+ * Check the format of pages in "Page" namespace.
 1060+ *
 1061+ * @param $editpage Object: EditPage object
 1062+ * @return Boolean
9641063 */
9651064 function attemptSave( $editpage ) {
9661065 global $wgOut, $wgUser;
@@ -968,53 +1067,54 @@
9691068 $index_namespace = $this->index_namespace;
9701069 $title = $editpage->mTitle;
9711070
972 - //check that pages listed on an index are unique.
 1071+ // check that pages listed on an index are unique.
9731072 if ( preg_match( "/^$index_namespace:(.*)$/", $title->getPrefixedText() ) ) {
9741073 $text = $editpage->textbox1;
975 - list( $links, $params, $attributes ) = $this->parse_index_text($text);
976 - if( $links!=null && count($links[1]) != count( array_unique($links[1]))) {
 1074+ list( $links, $params, $attributes ) = $this->parse_index_text( $text );
 1075+ if( $links != null && count( $links[1] ) != count( array_unique( $links[1] ) ) ) {
9771076 $wgOut->showErrorPage( 'proofreadpage_indexdupe', 'proofreadpage_indexdupetext' );
9781077 return false;
9791078 };
9801079 return true;
9811080 }
9821081
983 - //abort if we are not a page
984 - if ( ! preg_match( "/^$page_namespace:(.*)$/", $title->getPrefixedText() ) ) {
 1082+ // abort if we are not a page
 1083+ if ( !preg_match( "/^$page_namespace:(.*)$/", $title->getPrefixedText() ) ) {
9851084 return true;
9861085 }
9871086
9881087 $text = $editpage->textbox1;
989 - //parse the page
990 - list( $q , $username, $ptext ) = $this->parse_page( $text );
 1088+ // parse the page
 1089+ list( $q, $username, $ptext ) = $this->parse_page( $text );
9911090 if( $q == -1 ) {
9921091 $editpage->textbox1 = $ptext;
9931092 $q = 1;
9941093 }
9951094
996 - //read previous revision, so that I know how much I need to add to pr_index
 1095+ // read previous revision, so that I know how much I need to add to pr_index
9971096 $rev = Revision::newFromTitle( $title );
9981097 if( $rev ) {
9991098 $old_text = $rev->getText();
1000 - list( $old_q , $old_username, $old_ptext ) = $this->parse_page( $old_text );
 1099+ list( $old_q, $old_username, $old_ptext ) = $this->parse_page( $old_text );
10011100 if( $old_q != -1 ) {
1002 - //check usernames
1003 - if( ($old_q != $q) && !$wgUser->isAllowed('pagequality') ) {
 1101+ // check usernames
 1102+ if( ( $old_q != $q ) && !$wgUser->isAllowed( 'pagequality' ) ) {
10041103 $wgOut->showErrorPage( 'proofreadpage_nologin', 'proofreadpage_nologintext' );
10051104 return false;
10061105 }
1007 - if ( ( ($old_username != $username) || ($old_q != $q) ) && ($wgUser->getName() != $username) ) {
 1106+ if ( ( ( $old_username != $username ) || ( $old_q != $q ) ) && ( $wgUser->getName() != $username ) ) {
10081107 $wgOut->showErrorPage( 'proofreadpage_notallowed', 'proofreadpage_notallowedtext' );
10091108 return false;
10101109 }
1011 - if( ( ($q == 4) && ($old_q < 3) ) || ( ($q == 4) && ($old_q == 3) && ($old_username == $username) ) ) {
 1110+ if( ( ( $q == 4 ) && ( $old_q < 3 ) ) || ( ( $q == 4 ) && ( $old_q == 3 ) && ( $old_username == $username ) ) ) {
10121111 $wgOut->showErrorPage( 'proofreadpage_notallowed', 'proofreadpage_notallowedtext' );
10131112 return false;
10141113 }
 1114+ } else {
 1115+ $old_q = 1;
10151116 }
1016 - else $old_q = 1;
10171117 } else {
1018 - if($q == 4) {
 1118+ if( $q == 4 ) {
10191119 $wgOut->showErrorPage( 'proofreadpage_notallowed', 'proofreadpage_notallowedtext' );
10201120 return false;
10211121 }
@@ -1025,16 +1125,16 @@
10261126 $editpage->mArticle->old_q = $old_q;
10271127
10281128 return true;
1029 -
10301129 }
10311130
1032 -
1033 - /*
 1131+ /**
10341132 * if I delete a page, I need to update the index table
10351133 * if I delete an index page too...
 1134+ *
 1135+ * @param $article Object: Article object
 1136+ * @return Boolean: true
10361137 */
10371138 function articleDelete( $article ) {
1038 -
10391139 $page_namespace = $this->page_namespace;
10401140 $index_namespace = $this->index_namespace;
10411141 $title = $article->mTitle;
@@ -1043,7 +1143,7 @@
10441144 $id = $article->getID();
10451145 $dbw = wfGetDB( DB_MASTER );
10461146 $pr_index = $dbw->tableName( 'pr_index' );
1047 - $dbw->query ("DELETE FROM $pr_index WHERE pr_page_id=$id");
 1147+ $dbw->query( "DELETE FROM $pr_index WHERE pr_page_id=$id", __METHOD__ );
10481148 $dbw->commit();
10491149 return true;
10501150 }
@@ -1054,30 +1154,29 @@
10551155 $index_title = Title::newFromText( $title->pr_index_title );
10561156 $index_title->invalidateCache();
10571157 $index = new Article( $index_title );
1058 - if( $index ) $this->update_pr_index( $index, $title->getDBKey() );
 1158+ if( $index ) {
 1159+ $this->update_pr_index( $index, $title->getDBKey() );
 1160+ }
10591161 }
10601162 return true;
10611163 }
10621164
10631165 return true;
1064 -
10651166 }
10661167
1067 -
10681168 function articleSaveComplete( $article ) {
1069 -
10701169 $page_namespace = $this->page_namespace;
10711170 $index_namespace = $this->index_namespace;
10721171 $title = $article->mTitle;
10731172
1074 - //if it's an index, update pr_index table
 1173+ // if it's an index, update pr_index table
10751174 if ( preg_match( "/^$index_namespace:(.*)$/", $title->getPrefixedText(), $m ) ) {
10761175 $this->update_pr_index( $article );
10771176 return true;
10781177 }
10791178
1080 - //return if it is not a page
1081 - if ( ! preg_match( "/^$page_namespace:(.*)$/", $title->getPrefixedText() ) ) {
 1179+ // return if it is not a page
 1180+ if ( !preg_match( "/^$page_namespace:(.*)$/", $title->getPrefixedText() ) ) {
10821181 return true;
10831182 }
10841183
@@ -1091,61 +1190,79 @@
10921191 return true;
10931192 }
10941193
1095 - /*
1096 - * invalidate the cache of the index page
 1194+ /**
 1195+ * invalidate the cache of the index page
10971196 */
10981197 if ( $title->pr_index_title ) {
10991198 $index_title = Title::newFromText( $title->pr_index_title );
11001199 $index_title->invalidateCache();
11011200 }
11021201
1103 - /*
 1202+ /**
11041203 * update pr_index iteratively
11051204 */
11061205 $index = new Article( $index_title );
11071206 $index_id = $index->getID();
11081207 $dbr = wfGetDB( DB_SLAVE );
11091208 $pr_index = $dbr->tableName( 'pr_index' );
1110 - $query = "SELECT * FROM $pr_index WHERE pr_page_id=".$index_id;
 1209+ $query = "SELECT * FROM $pr_index WHERE pr_page_id=" . $index_id;
11111210 $res = $dbr->query( $query, __METHOD__ );
11121211 if( $x = $dbr->fetchObject( $res ) ) {
1113 - $n = $x->pr_count ;
1114 - $n0 = $x->pr_q0 ;
1115 - $n1 = $x->pr_q1 ;
1116 - $n2 = $x->pr_q2 ;
1117 - $n3 = $x->pr_q3 ;
1118 - $n4 = $x->pr_q4 ;
 1212+ $n = $x->pr_count;
 1213+ $n0 = $x->pr_q0;
 1214+ $n1 = $x->pr_q1;
 1215+ $n2 = $x->pr_q2;
 1216+ $n3 = $x->pr_q3;
 1217+ $n4 = $x->pr_q4;
11191218
11201219 switch( $article->new_q ) {
1121 - case 0: $n0 = $n0 + 1; break;
1122 - case 1: $n1 = $n1 + 1; break;
1123 - case 2: $n2 = $n2 + 1; break;
1124 - case 3: $n3 = $n3 + 1; break;
1125 - case 4: $n4 = $n4 + 1; break;
 1220+ case 0:
 1221+ $n0 = $n0 + 1;
 1222+ break;
 1223+ case 1:
 1224+ $n1 = $n1 + 1;
 1225+ break;
 1226+ case 2:
 1227+ $n2 = $n2 + 1;
 1228+ break;
 1229+ case 3:
 1230+ $n3 = $n3 + 1;
 1231+ break;
 1232+ case 4:
 1233+ $n4 = $n4 + 1;
 1234+ break;
11261235 }
11271236
11281237 switch( $article->old_q ) {
1129 - case 0: $n0 = $n0 - 1; break;
1130 - case 1: $n1 = $n1 - 1; break;
1131 - case 2: $n2 = $n2 - 1; break;
1132 - case 3: $n3 = $n3 - 1; break;
1133 - case 4: $n4 = $n4 - 1; break;
 1238+ case 0:
 1239+ $n0 = $n0 - 1;
 1240+ break;
 1241+ case 1:
 1242+ $n1 = $n1 - 1;
 1243+ break;
 1244+ case 2:
 1245+ $n2 = $n2 - 1;
 1246+ break;
 1247+ case 3:
 1248+ $n3 = $n3 - 1;
 1249+ break;
 1250+ case 4:
 1251+ $n4 = $n4 - 1;
 1252+ break;
11341253 }
11351254
11361255 $query = "REPLACE INTO $pr_index (pr_page_id, pr_count, pr_q0, pr_q1, pr_q2, pr_q3, pr_q4) VALUES ({$index_id},$n,$n0,$n1,$n2,$n3,$n4)";
1137 - $dbw->query ( $query );
 1256+ $dbw->query( $query, __METHOD__ );
11381257 $dbw->commit();
11391258
11401259 }
11411260 $dbr->freeResult( $res );
1142 -
 1261+
11431262 return true;
11441263 }
11451264
1146 -
11471265 /* Preload text layer from multipage formats */
11481266 function preloadText( $textbox1, $mTitle ) {
1149 -
11501267 $page_namespace = $this->page_namespace;
11511268 if ( preg_match( "/^$page_namespace:(.*?)\/([0-9]*)$/", $mTitle->getPrefixedText(), $m ) ) {
11521269 $imageTitle = Title::makeTitleSafe( NS_IMAGE, $m[1] );
@@ -1155,10 +1272,10 @@
11561273
11571274 $image = wfFindFile( $imageTitle );
11581275 if ( $image && $image->exists() ) {
1159 - $text = $image->handler->getPageText($image, $m[2]);
 1276+ $text = $image->handler->getPageText( $image, $m[2] );
11601277 if ( $text ) {
11611278 $text = preg_replace( "/(\\\\n)/", "\n", $text );
1162 - $text = preg_replace( "/(\\\\\d*)/", "", $text );
 1279+ $text = preg_replace( "/(\\\\\d*)/", '', $text );
11631280 $textbox1 = $text;
11641281 }
11651282 }
@@ -1166,10 +1283,7 @@
11671284 return true;
11681285 }
11691286
1170 -
1171 -
11721287 function movePage( $form, $ot, $nt ) {
1173 -
11741288 $page_namespace = $this->page_namespace;
11751289 if ( preg_match( "/^$page_namespace:(.*)$/", $ot->getPrefixedText() ) ) {
11761290 $this->load_index( $ot );
@@ -1177,30 +1291,32 @@
11781292 $index_title = Title::newFromText( $ot->pr_index_title );
11791293 $index_title->invalidateCache();
11801294 $index = new Article( $index_title );
1181 - if( $index ) $this->update_pr_index( $index );
 1295+ if( $index ) {
 1296+ $this->update_pr_index( $index );
 1297+ }
11821298 }
11831299 return true;
11841300 }
11851301
11861302 if ( preg_match( "/^$page_namespace:(.*)$/", $nt->getPrefixedText() ) ) {
11871303 $this->load_index( $nt );
1188 - if( $nt->pr_index_title && ($nt->pr_index_title!=$ot->pr_index_title) ) {
 1304+ if( $nt->pr_index_title && ( $nt->pr_index_title != $ot->pr_index_title ) ) {
11891305 $index_title = Title::newFromText( $nt->pr_index_title );
11901306 $index_title->invalidateCache();
11911307 $index = new Article( $index_title );
1192 - if( $index ) $this->update_pr_index( $index );
 1308+ if( $index ) {
 1309+ $this->update_pr_index( $index );
 1310+ }
11931311 }
11941312 return true;
11951313 }
11961314 return true;
11971315 }
11981316
1199 -
1200 - /*
 1317+ /**
12011318 * When an index page is created or purged, recompute pr_index values
12021319 */
12031320 function articlePurge( $article ) {
1204 -
12051321 $index_namespace = $this->index_namespace;
12061322 $title = $article->mTitle;
12071323 if ( preg_match( "/^$index_namespace:(.*)$/", $title->getPrefixedText() ) ) {
@@ -1210,10 +1326,9 @@
12111327 return true;
12121328 }
12131329
1214 -
1215 - function query_count( $dbr, $query, $cat ){
 1330+ function query_count( $dbr, $query, $cat ) {
12161331 $q = $dbr->strencode( str_replace( ' ' , '_' , wfMsgForContent( $cat ) ) );
1217 - $res = $dbr->query( str_replace( '###', $q, $query) , __METHOD__ );
 1332+ $res = $dbr->query( str_replace( '###', $q, $query ), __METHOD__ );
12181333 if( $res && $dbr->numRows( $res ) > 0 ) {
12191334 $row = $dbr->fetchObject( $res );
12201335 $n = $row->count;
@@ -1223,57 +1338,61 @@
12241339 return 0;
12251340 }
12261341
1227 -
1228 - /*
1229 - * update the pr_index entry of an article
 1342+ /**
 1343+ * Update the pr_index entry of an article
12301344 */
1231 - function update_pr_index( $index, $deletedpage=null ) {
1232 -
 1345+ function update_pr_index( $index, $deletedpage = null ) {
12331346 $page_namespace = $this->page_namespace;
12341347 $index_namespace = $this->index_namespace;
12351348 $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( $page_namespace ) );
12361349 if ( $page_ns_index == null ) {
1237 - return;
 1350+ return;
12381351 }
12391352
12401353 $index_title = $index->mTitle;
12411354 $index_id = $index->getID();
12421355 $dbr = wfGetDB( DB_SLAVE );
12431356
1244 - //read the list of pages
 1357+ // read the list of pages
12451358 $pages = array();
12461359 list( $links, $params, $attributes ) = $this->parse_index( $index_title );
1247 - if( $links==null ) {
 1360+ if( $links == null ) {
12481361 $imageTitle = Title::makeTitleSafe( NS_IMAGE, $index_title->getText() );
12491362 if ( $imageTitle ) {
12501363 $image = wfFindFile( $imageTitle );
12511364 if ( $image && $image->isMultiPage() && $image->pageCount() ) {
12521365 $n = $image->pageCount();
12531366 for ( $i = 1; $i <= $n; $i++ ) {
1254 - $page = $dbr->strencode( $index_title->getDBKey().'/'.$i );
1255 - if($page != $deletedpage) array_push( $pages, $page );
 1367+ $page = $dbr->strencode( $index_title->getDBKey() . '/' . $i );
 1368+ if( $page != $deletedpage ) {
 1369+ array_push( $pages, $page );
 1370+ }
12561371 }
12571372 }
12581373 }
12591374 } else {
1260 - $n = count($links[1]);
 1375+ $n = count( $links[1] );
12611376 for ( $i = 0; $i < $n; $i++ ) {
12621377 $page = $dbr->strencode( str_replace( ' ' , '_' , $links[1][$i] ) );
1263 - if($page != $deletedpage) array_push( $pages, $page );
 1378+ if( $page != $deletedpage ) {
 1379+ array_push( $pages, $page );
 1380+ }
12641381 }
12651382 }
12661383
1267 - if( $n==0 ) {
 1384+ if( $n == 0 ) {
12681385 return;
12691386 }
12701387
12711388 $catlinks = $dbr->tableName( 'categorylinks' );
12721389 $page = $dbr->tableName( 'page' );
1273 - $pagelist = "'".implode( "', '", $pages)."'";
1274 - $res = $dbr->select( array( 'page' ),
1275 - array( 'COUNT(page_id) AS count'),
1276 - array( "page_namespace=$page_ns_index", "page_title IN ( $pagelist )"),
1277 - __METHOD__ );
 1390+ $pagelist = "'" . implode( "', '", $pages ) . "'";
 1391+ $res = $dbr->select(
 1392+ array( 'page' ),
 1393+ array( 'COUNT(page_id) AS count'),
 1394+ array( "page_namespace=$page_ns_index", "page_title IN ( $pagelist )" ),
 1395+ __METHOD__
 1396+ );
12781397 if( $res && $dbr->numRows( $res ) > 0 ) {
12791398 $row = $dbr->fetchObject( $res );
12801399 $total = $row->count;
@@ -1289,32 +1408,31 @@
12901409 $n3 = $this->query_count( $dbr, $query, 'proofreadpage_quality3_category' );
12911410 $n4 = $this->query_count( $dbr, $query, 'proofreadpage_quality4_category' );
12921411 $n1 = $total - $n0 - $n2 - $n3 - $n4;
1293 -
 1412+
12941413 $dbw = wfGetDB( DB_MASTER );
12951414 $pr_index = $dbw->tableName( 'pr_index' );
12961415 $query = "REPLACE INTO $pr_index (pr_page_id, pr_count, pr_q0, pr_q1, pr_q2, pr_q3, pr_q4) VALUES ({$index_id},$n,$n0,$n1,$n2,$n3,$n4)";
1297 - $dbw->query ( $query );
 1416+ $dbw->query( $query, __METHOD__ );
12981417 $dbw->commit();
12991418 }
13001419
1301 -
1302 -
1303 -
1304 - /*
1305 - * In ns-0, display the proofreading status of transcluded pages
 1420+ /**
 1421+ * In main namespace, display the proofreading status of transcluded pages.
 1422+ *
 1423+ * @param $out Object: OutputPage object
13061424 */
13071425 function displayProofreadingStatus( $out ) {
13081426 global $wgTitle, $wgUser;
13091427
13101428 $id = $wgTitle->mArticleID;
1311 - if($id == -1) {
 1429+ if( $id == -1 ) {
13121430 return true;
13131431 }
13141432 $page_namespace = $this->page_namespace;
13151433 $index_namespace = $this->index_namespace;
13161434 $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( $page_namespace ) );
13171435 $index_ns_index = MWNamespace::getCanonicalIndex( strtolower( $index_namespace ) );
1318 - if( $page_ns_index==null || $index_ns_index == null){
 1436+ if( $page_ns_index == null || $index_ns_index == null ) {
13191437 return true;
13201438 }
13211439
@@ -1327,19 +1445,29 @@
13281446
13291447 // find the index page
13301448 $indextitle = null;
1331 - $res = $dbr->select( array( 'templatelinks' ),
1332 - array( 'tl_title AS title' ),
1333 - array( "tl_from=$id", "tl_namespace=$page_ns_index" ),
1334 - __METHOD__, array( 'LIMIT' => 1 ) );
 1449+ $res = $dbr->select(
 1450+ array( 'templatelinks' ),
 1451+ array( 'tl_title AS title' ),
 1452+ array( "tl_from=$id", "tl_namespace=$page_ns_index" ),
 1453+ __METHOD__,
 1454+ array( 'LIMIT' => 1 )
 1455+ );
13351456 if( $res && $dbr->numRows( $res ) > 0 ) {
13361457 $row = $dbr->fetchObject( $res );
13371458 $title = $dbr->strencode( $row->title );
13381459 $dbr->freeResult( $res );
1339 - $res2 = $dbr->select( array( 'pagelinks', 'page' ),
1340 - array( 'page_title AS title' ),
1341 - array( "pl_title='$title'","pl_namespace=$page_ns_index","page_namespace=$index_ns_index"),
1342 - __METHOD__, array( 'LIMIT' => 1 ),
1343 - array( 'page' => array( 'LEFT JOIN', 'page_id=pl_from' ) ) ) ;
 1460+ $res2 = $dbr->select(
 1461+ array( 'pagelinks', 'page' ),
 1462+ array( 'page_title AS title' ),
 1463+ array(
 1464+ "pl_title='$title'",
 1465+ "pl_namespace=$page_ns_index",
 1466+ "page_namespace=$index_ns_index"
 1467+ ),
 1468+ __METHOD__,
 1469+ array( 'LIMIT' => 1 ),
 1470+ array( 'page' => array( 'LEFT JOIN', 'page_id=pl_from' ) )
 1471+ );
13441472 if( $res2 && $dbr->numRows( $res2 ) > 0 ) {
13451473 $row = $dbr->fetchObject( $res2 );
13461474 $indextitle = $row->title;
@@ -1348,12 +1476,15 @@
13491477 }
13501478
13511479 if( isset( $out->is_toc ) && $out->is_toc ) {
1352 - if ($indextitle) {
1353 - $res = $dbr->select( array( 'pr_index', 'page' ),
1354 - array( 'pr_count', 'pr_q0', 'pr_q1', 'pr_q2', 'pr_q3', 'pr_q4' ),
1355 - array( "page_title='$indextitle'", "page_namespace=$index_ns_index" ),
1356 - __METHOD__, null,
1357 - array( 'page' => array( 'LEFT JOIN', 'page_id=pr_page_id' ) ) ) ;
 1480+ if ( $indextitle ) {
 1481+ $res = $dbr->select(
 1482+ array( 'pr_index', 'page' ),
 1483+ array( 'pr_count', 'pr_q0', 'pr_q1', 'pr_q2', 'pr_q3', 'pr_q4' ),
 1484+ array( "page_title='$indextitle'", "page_namespace=$index_ns_index" ),
 1485+ __METHOD__,
 1486+ null,
 1487+ array( 'page' => array( 'LEFT JOIN', 'page_id=pr_page_id' ) )
 1488+ );
13581489 $row = $dbr->fetchObject( $res );
13591490 if( $row ) {
13601491 $n0 = $row->pr_q0;
@@ -1362,16 +1493,19 @@
13631494 $n3 = $row->pr_q3;
13641495 $n4 = $row->pr_q4;
13651496 $n = $row->pr_count;
1366 - $ne = $n - ($n0+$n1+$n2+$n3+$n4);
 1497+ $ne = $n - ( $n0 + $n1 + $n2 + $n3 + $n4 );
13671498 }
13681499 }
13691500 } else {
13701501 // count transclusions from page namespace
1371 - $res = $dbr->select( array( 'templatelinks', 'page' ),
1372 - array( 'COUNT(page_id) AS count' ),
1373 - array( "tl_from=$id", "tl_namespace=$page_ns_index" ),
1374 - __METHOD__, null,
1375 - array( 'page' => array( 'LEFT JOIN', 'page_title=tl_title AND page_namespace=tl_namespace' ) ) ) ;
 1502+ $res = $dbr->select(
 1503+ array( 'templatelinks', 'page' ),
 1504+ array( 'COUNT(page_id) AS count' ),
 1505+ array( "tl_from=$id", "tl_namespace=$page_ns_index" ),
 1506+ __METHOD__,
 1507+ null,
 1508+ array( 'page' => array( 'LEFT JOIN', 'page_title=tl_title AND page_namespace=tl_namespace' ) )
 1509+ );
13761510 if( $res && $dbr->numRows( $res ) > 0 ) {
13771511 $row = $dbr->fetchObject( $res );
13781512 $n = $row->count;
@@ -1388,23 +1522,23 @@
13891523 $ne = 0;
13901524 }
13911525
1392 - if($n == 0) {
 1526+ if( $n == 0 ) {
13931527 return true;
13941528 }
13951529
13961530 $indexlink = '';
13971531 if( $indextitle ) {
13981532 $sk = $wgUser->getSkin();
1399 - $indexlink = $sk->makeKnownLink( "$index_namespace:$indextitle", "[index]" );
 1533+ $indexlink = $sk->makeKnownLink( "$index_namespace:$indextitle", '[index]' );
14001534 }
14011535
1402 - $q0 = $n0*100/$n;
1403 - $q1 = $n1*100/$n;
1404 - $q2 = $n2*100/$n;
1405 - $q3 = $n3*100/$n;
1406 - $q4 = $n4*100/$n;
1407 - $qe = $ne*100/$n;
1408 - $void_cell = $ne ? "<td align=center style='border-style:dotted;border-width:1px;' width=\"{$qe}\"></td>" : "";
 1536+ $q0 = $n0 * 100 / $n;
 1537+ $q1 = $n1 * 100 / $n;
 1538+ $q2 = $n2 * 100 / $n;
 1539+ $q3 = $n3 * 100 / $n;
 1540+ $q4 = $n4 * 100 / $n;
 1541+ $qe = $ne * 100 / $n;
 1542+ $void_cell = $ne ? "<td align=center style='border-style:dotted;border-width:1px;' width=\"{$qe}\"></td>" : '';
14091543 $output = "<table class=\"pr_quality\" style=\"line-height:40%;\" border=0 cellpadding=0 cellspacing=0 ><tr>
14101544 <td align=center >&nbsp;</td>
14111545 <td align=center class='quality4' width=\"$q4\"></td>
Index: trunk/extensions/ProofreadPage/SpecialProofreadPages.php
@@ -4,20 +4,22 @@
55 * @ingroup SpecialPage
66 */
77
8 -if ( !defined( 'MEDIAWIKI' ) ) die( 1 );
9 -global $wgHooks, $IP;
 8+if ( !defined( 'MEDIAWIKI' ) ) {
 9+ die( 1 );
 10+}
 11+
 12+global $IP;
1013 require_once "$IP/includes/QueryPage.php";
1114
12 -
1315 class ProofreadPages extends SpecialPage {
1416
15 - function __construct() {
 17+ public function __construct() {
1618 parent::__construct( 'IndexPages' );
1719 wfLoadExtensionMessages( 'ProofreadPage' );
1820 $this->index_namespace = preg_quote( wfMsgForContent( 'proofreadpage_index_namespace' ), '/' );
1921 }
2022
21 - function execute( $parameters ) {
 23+ public function execute( $parameters ) {
2224 global $wgOut, $wgRequest, $wgDisableTextSearch;
2325
2426 $this->setHeaders();
@@ -25,7 +27,7 @@
2628 $wgOut->addWikiText( wfMsgForContentNoTrans( 'proofreadpage_specialpage_text' ) );
2729 $searchList = array();
2830 $searchTerm = $wgRequest->getText( 'key' );
29 - if( ! $wgDisableTextSearch ) {
 31+ if( !$wgDisableTextSearch ) {
3032 $wgOut->addHTML(
3133 Xml::openElement( 'form' ) .
3234 Xml::openElement( 'fieldset' ) .
@@ -75,7 +77,7 @@
7678 }
7779
7880 function linkParameters() {
79 - return array( 'key'=> $this->searchTerm );
 81+ return array( 'key' => $this->searchTerm );
8082 }
8183
8284 function getSQL() {
@@ -92,7 +94,9 @@
9395 $index_ns_index = MWNamespace::getCanonicalIndex( strtolower( $this->index_namespace ) );
9496 $querylist = '';
9597 foreach( $this->searchList as $item ) {
96 - if( $querylist ) $querylist .= ', ';
 98+ if( $querylist ) {
 99+ $querylist .= ', ';
 100+ }
97101 $querylist .= "'" . $dbr->strencode( $item ). "'";
98102 }
99103 $query .= " WHERE page_namespace=$index_ns_index AND page_title IN ($querylist)";
@@ -105,7 +109,7 @@
106110
107111 function getOrder() {
108112 return ' ORDER BY 2*pr_q4+pr_q3 ' .
109 - ($this->sortDescending() ? 'DESC' : '');
 113+ ( $this->sortDescending() ? 'DESC' : '' );
110114 }
111115
112116 function sortDescending() {
@@ -115,13 +119,13 @@
116120 function formatResult( $skin, $result ) {
117121 global $wgLang;
118122
119 - $title = Title::newFromText( $this->index_namespace.":".$result->title );
 123+ $title = Title::newFromText( $this->index_namespace . ':' . $result->title );
120124
121125 if ( !$title ) {
122 - return '<!-- Invalid title ' . htmlspecialchars( $this->index_namespace.":".$result->title ). '-->';
 126+ return '<!-- Invalid title ' . htmlspecialchars( $this->index_namespace . ':' . $result->title ) . '-->';
123127 }
124128 $plink = $this->isCached()
125 - ? $skin->link( $title , htmlspecialchars( $title->getText() ) )
 129+ ? $skin->link( $title , htmlspecialchars( $title->getText() ) )
126130 : $skin->linkKnown( $title , htmlspecialchars( $title->getText() ) );
127131
128132 if ( !$title->exists() ) {
@@ -135,7 +139,7 @@
136140 $q3 = $result->pr_q3;
137141 $q4 = $result->pr_q4;
138142 $num_void = $size-$q1-$q2-$q3-$q4-$q0;
139 - $void_cell = $num_void ? "<td align=center style='border-style:dotted;background:#ffffff;border-width:1px;' width=\"{$num_void}\"></td>" : "";
 143+ $void_cell = $num_void ? "<td align=center style='border-style:dotted;background:#ffffff;border-width:1px;' width=\"{$num_void}\"></td>" : '';
140144
141145 // FIXME: consider using $size in 'proofreadpage_pages' instead of glueing it together in $output
142146 $pages = wfMsgExt( 'proofreadpage_pages', 'parsemag', $size );
Index: trunk/extensions/ProofreadPage/SpecialPagesWithoutScans.php
@@ -1,6 +1,5 @@
22 <?php
33 /**
4 - *
54 * This program is free software; you can redistribute it and/or modify
65 * it under the terms of the GNU General Public License as published by
76 * the Free Software Foundation; either version 2 of the License, or
@@ -15,33 +14,32 @@
1615 * with this program; if not, write to the Free Software Foundation, Inc.,
1716 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1817 * http://www.gnu.org/copyleft/gpl.html
 18+ *
 19+ * @file
 20+ * @ingroup Extensions
1921 */
2022
21 - /*
22 - * Special page that lists the texts that have no transclusions
23 - * Pages in MediaWiki:Proofreadpage_notnaked_category are excluded.
24 - *
25 - */
26 -
 23+/**
 24+ * Special page that lists the texts that have no transclusions
 25+ * Pages in MediaWiki:Proofreadpage_notnaked_category are excluded.
 26+ */
2727 class PagesWithoutScans extends SpecialPage {
2828
29 - function __construct() {
 29+ public function __construct() {
3030 parent::__construct( 'PagesWithoutScans' );
3131 }
3232
33 - function execute( $parameters ) {
34 - global $wgOut, $wgRequest, $wgDisableTextSearch;
 33+ public function execute( $parameters ) {
3534 $this->setHeaders();
3635 list( $limit, $offset ) = wfCheckLimits();
37 - $cnl = new PagesWithoutScansQuery( );
 36+ $cnl = new PagesWithoutScansQuery();
3837 $cnl->doQuery( $offset, $limit );
3938 }
4039 }
4140
42 -
4341 class PagesWithoutScansQuery extends QueryPage {
4442
45 - function __construct( ) {
 43+ function __construct() {
4644 wfLoadExtensionMessages( 'ProofreadPage' );
4745 $this->page_namespace = preg_quote( wfMsgForContent( 'proofreadpage_namespace' ), '/' );
4846 $this->cat = wfMsgForContent( 'proofreadpage_notnaked_category' );
@@ -66,7 +64,7 @@
6765 $page = $dbr->tableName( 'page' );
6866 $templatelinks = $dbr->tableName( 'templatelinks' );
6967 $categorylinks = $dbr->tableName( 'categorylinks' );
70 - $forceindex = $dbr->useIndexClause("page_len");
 68+ $forceindex = $dbr->useIndexClause( 'page_len' );
7169 $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( $this->page_namespace ) );
7270 $cat = $dbr->strencode( str_replace( ' ' , '_' , $this->cat ) );
7371 $clause = "page_namespace=" . NS_MAIN . " AND page_is_redirect=0 AND page_id NOT IN ( SELECT DISTINCT tl_from FROM $templatelinks LEFT JOIN $page ON page_id=tl_from WHERE tl_namespace=$page_ns_index AND page_namespace=" . NS_MAIN . " ) AND page_id NOT IN ( SELECT DISTINCT cl_from FROM $categorylinks WHERE cl_to='$cat' )";
@@ -89,7 +87,7 @@
9088
9189 $title = Title::makeTitleSafe( $result->namespace, $result->title );
9290 if ( !$title ) {
93 - return '<!-- Invalid title ' . htmlspecialchars( "{$result->namespace}:{$result->title}" ). '-->';
 91+ return '<!-- Invalid title ' . htmlspecialchars( "{$result->namespace}:{$result->title}" ) . '-->';
9492 }
9593 $hlink = $skin->linkKnown(
9694 $title,
Index: trunk/extensions/ProofreadPage/ProofreadPage.php
@@ -14,18 +14,11 @@
1515 # with this program; if not, write to the Free Software Foundation, Inc.,
1616 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1717 # http://www.gnu.org/copyleft/gpl.html
18 -#
19 -#
20 -#
21 -#
22 -#
23 -#
2418
2519 if ( !defined( 'MEDIAWIKI' ) ) {
2620 die( "ProofreadPage extension\n" );
2721 }
2822
29 -
3023 $wgExtensionFunctions[] = 'wfProofreadPage';
3124
3225 $dir = dirname( __FILE__ ) . '/';
@@ -44,12 +37,12 @@
4538 );
4639
4740 # special page
48 -$wgAutoloadClasses['ProofreadPages'] = dirname( __FILE__ ) . '/SpecialProofreadPages.php';
 41+$wgAutoloadClasses['ProofreadPages'] = $dir . 'SpecialProofreadPages.php';
4942 $wgSpecialPages['IndexPages'] = 'ProofreadPages';
5043 $wgSpecialPageGroups['IndexPages'] = 'pages';
5144
5245 # special page
53 -$wgAutoloadClasses['PagesWithoutScans'] = dirname( __FILE__ ) . '/SpecialPagesWithoutScans.php';
 46+$wgAutoloadClasses['PagesWithoutScans'] = $dir . 'SpecialPagesWithoutScans.php';
5447 $wgSpecialPages['PagesWithoutScans'] = 'PagesWithoutScans';
5548 $wgSpecialPageGroups['PagesWithoutScans'] = 'maintenance';
5649

Status & tagging log