Index: trunk/extensions/ProofreadPage/ProofreadPage.php |
— | — | @@ -70,20 +70,41 @@ |
71 | 71 | $wgParser->setHook( "pagelist", "pr_renderPageList" ); |
72 | 72 | $wgParser->setHook( "pages", "pr_renderPages" ); |
73 | 73 | $wgParser->setHook( "pagequality", "pr_pageQuality" ); |
74 | | - wfLoadExtensionMessages( 'ProofreadPage' ); |
75 | | - $pr_page_namespace = preg_quote( wfMsgForContent( 'proofreadpage_namespace' ), '/' ); |
76 | | - $pr_index_namespace = preg_quote( wfMsgForContent( 'proofreadpage_index_namespace' ), '/' ); |
| 74 | + $pr_page_namespace = null; |
| 75 | + $pr_index_namespace = null; |
| 76 | +} |
77 | 77 | |
| 78 | + |
| 79 | +/* |
| 80 | + * accessor functions for page and index namespaces |
| 81 | + */ |
| 82 | +function pr_page_ns() { |
| 83 | + global $pr_page_namespace; |
| 84 | + if( is_null($pr_page_namespace) ) { |
| 85 | + wfLoadExtensionMessages( 'ProofreadPage' ); |
| 86 | + $pr_page_namespace = preg_quote( wfMsgForContent( 'proofreadpage_namespace' ), '/' ); |
| 87 | + } |
| 88 | + return $pr_page_namespace; |
78 | 89 | } |
79 | 90 | |
| 91 | +function pr_index_ns() { |
| 92 | + global $pr_index_namespace; |
| 93 | + if( is_null($pr_index_namespace) ) { |
| 94 | + wfLoadExtensionMessages( 'ProofreadPage' ); |
| 95 | + $pr_index_namespace = preg_quote( wfMsgForContent( 'proofreadpage_index_namespace' ), '/' ); |
| 96 | + } |
| 97 | + return $pr_index_namespace; |
| 98 | +} |
80 | 99 | |
81 | 100 | |
| 101 | + |
82 | 102 | /** |
83 | 103 | * Query the database to find if the current page is referred in an Index page. |
84 | 104 | */ |
85 | 105 | function pr_load_index( $title ) { |
86 | | - global $pr_page_namespace, $pr_index_namespace; |
87 | 106 | |
| 107 | + $page_namespace = pr_page_ns(); |
| 108 | + $index_namespace = pr_index_ns(); |
88 | 109 | $title->pr_index_title = NULL; |
89 | 110 | $dbr = wfGetDB( DB_SLAVE ); |
90 | 111 | $result = $dbr->select( |
— | — | @@ -98,7 +119,7 @@ |
99 | 120 | |
100 | 121 | while ( $x = $dbr->fetchObject( $result ) ) { |
101 | 122 | $ref_title = Title::makeTitle( $x->page_namespace, $x->page_title ); |
102 | | - if ( preg_match( "/^$pr_index_namespace:(.*)$/", $ref_title->getPrefixedText() ) ) { |
| 123 | + if ( preg_match( "/^$index_namespace:(.*)$/", $ref_title->getPrefixedText() ) ) { |
103 | 124 | $title->pr_index_title = $ref_title->getPrefixedText(); |
104 | 125 | break; |
105 | 126 | } |
— | — | @@ -108,7 +129,7 @@ |
109 | 130 | if ( $title->pr_index_title ) return; |
110 | 131 | |
111 | 132 | /*check if we are a page of a multipage file*/ |
112 | | - if ( preg_match( "/^$pr_page_namespace:(.*?)(\/([0-9]*)|)$/", $title->getPrefixedText(), $m ) ) { |
| 133 | + if ( preg_match( "/^$page_namespace:(.*?)(\/([0-9]*)|)$/", $title->getPrefixedText(), $m ) ) { |
113 | 134 | $imageTitle = Title::makeTitleSafe( NS_IMAGE, $m[1] ); |
114 | 135 | } |
115 | 136 | if ( !$imageTitle ) return; |
— | — | @@ -119,15 +140,13 @@ |
120 | 141 | if ( $image && $image->exists() && $image->isMultiPage() ) { |
121 | 142 | |
122 | 143 | $name = $image->getTitle()->getText(); |
123 | | - $index_name = "$pr_index_namespace:$name"; |
| 144 | + $index_name = "$index_namespace:$name"; |
124 | 145 | |
125 | 146 | if ( !$title->pr_index_title ) { |
126 | 147 | // there is no index, or the page is not listed in the index : use canonical index |
127 | 148 | $title->pr_index_title = $index_name; |
128 | 149 | } |
129 | 150 | } |
130 | | - |
131 | | - |
132 | 151 | } |
133 | 152 | |
134 | 153 | |
— | — | @@ -135,7 +154,8 @@ |
136 | 155 | * return the URLs of the index, previous and next pages. |
137 | 156 | */ |
138 | 157 | function pr_navigation( $title ) { |
139 | | - global $pr_page_namespace, $pr_index_namespace; |
| 158 | + |
| 159 | + $page_namespace = pr_page_ns(); |
140 | 160 | $default_header = wfMsgGetKey( 'proofreadpage_default_header', true, true, false ); |
141 | 161 | $default_footer = wfMsgGetKey( 'proofreadpage_default_footer', true, true, false ); |
142 | 162 | |
— | — | @@ -159,8 +179,8 @@ |
160 | 180 | return $err; |
161 | 181 | } |
162 | 182 | $name = $image->getTitle()->getText(); |
163 | | - $prev_name = "$pr_page_namespace:$name/" . ( $pagenr - 1 ); |
164 | | - $next_name = "$pr_page_namespace:$name/" . ( $pagenr + 1 ); |
| 183 | + $prev_name = "$page_namespace:$name/" . ( $pagenr - 1 ); |
| 184 | + $next_name = "$page_namespace:$name/" . ( $pagenr + 1 ); |
165 | 185 | $prev_url = ( $pagenr == 1 ) ? '' : Title::newFromText( $prev_name )->getFullURL(); |
166 | 186 | $next_url = ( $pagenr == $count ) ? '' : Title::newFromText( $next_name )->getFullURL(); |
167 | 187 | |
— | — | @@ -183,7 +203,7 @@ |
184 | 204 | $attributes["pagenum"] = $pagenum; |
185 | 205 | } else { |
186 | 206 | for( $i=0; $i<count( $links[1] ); $i++) { |
187 | | - $a_title = Title::newFromText( $pr_page_namespace.":".$links[1][$i] ); |
| 207 | + $a_title = Title::newFromText( $page_namespace.":".$links[1][$i] ); |
188 | 208 | if(!$a_title) continue; |
189 | 209 | if( $a_title->getPrefixedText() == $title->getPrefixedText() ) { |
190 | 210 | $attributes["pagenum"] = $links[3][$i]; |
— | — | @@ -191,10 +211,10 @@ |
192 | 212 | } |
193 | 213 | } |
194 | 214 | if( ($i>0) && ($i<count($links[1])) ){ |
195 | | - $prev_title = Title::newFromText( $pr_page_namespace.":".$links[1][$i-1] ); |
| 215 | + $prev_title = Title::newFromText( $page_namespace.":".$links[1][$i-1] ); |
196 | 216 | } |
197 | 217 | if( ($i>=0) && ($i+1<count($links[1])) ){ |
198 | | - $next_title = Title::newFromText( $pr_page_namespace.":".$links[1][$i+1] ); |
| 218 | + $next_title = Title::newFromText( $page_namespace.":".$links[1][$i+1] ); |
199 | 219 | } |
200 | 220 | if($prev_title) $prev_url = $prev_title->getFullURL(); |
201 | 221 | if($next_title) $next_url = $next_title->getFullURL(); |
— | — | @@ -232,8 +252,8 @@ |
233 | 253 | |
234 | 254 | |
235 | 255 | function pr_parse_index_text( $text ){ |
236 | | - global $pr_page_namespace, $pr_index_namespace; |
237 | 256 | |
| 257 | + $page_namespace = pr_page_ns(); |
238 | 258 | //check if it is using pagelist |
239 | 259 | preg_match_all( "/<pagelist([^<]*?)\/>/is", $text, $m, PREG_PATTERN_ORDER ); |
240 | 260 | if( $m[1] ) { |
— | — | @@ -245,7 +265,7 @@ |
246 | 266 | $links = null; |
247 | 267 | } else { |
248 | 268 | $params = null; |
249 | | - $tag_pattern = "/\[\[$pr_page_namespace:(.*?)(\|(.*?)|)\]\]/i"; |
| 269 | + $tag_pattern = "/\[\[$page_namespace:(.*?)(\|(.*?)|)\]\]/i"; |
250 | 270 | preg_match_all( $tag_pattern, $text, $links, PREG_PATTERN_ORDER ); |
251 | 271 | } |
252 | 272 | |
— | — | @@ -272,7 +292,6 @@ |
273 | 293 | */ |
274 | 294 | function pr_beforePageDisplay( &$out ) { |
275 | 295 | global $wgTitle, $wgJsMimeType, $wgScriptPath, $wgRequest, $wgProofreadPageVersion; |
276 | | - global $pr_page_namespace, $pr_index_namespace; |
277 | 296 | |
278 | 297 | $action = $wgRequest->getVal( 'action' ); |
279 | 298 | $isEdit = ( $action == 'submit' || $action == 'edit' ) ? 1 : 0; |
— | — | @@ -281,12 +300,14 @@ |
282 | 301 | } |
283 | 302 | $out->proofreadPageDone = true; |
284 | 303 | |
285 | | - if ( preg_match( "/^$pr_page_namespace:(.*?)(\/([0-9]*)|)$/", $wgTitle->getPrefixedText(), $m ) ) { |
| 304 | + $page_namespace = pr_page_ns(); |
| 305 | + if ( preg_match( "/^$page_namespace:(.*?)(\/([0-9]*)|)$/", $wgTitle->getPrefixedText(), $m ) ) { |
286 | 306 | pr_preparePage( $out, $m, $isEdit ); |
287 | 307 | return true; |
288 | 308 | } |
289 | 309 | |
290 | | - if ( $isEdit && ( preg_match( "/^$pr_index_namespace:(.*?)(\/([0-9]*)|)$/", $wgTitle->getPrefixedText(), $m ) ) ) { |
| 310 | + $index_namespace = pr_index_ns(); |
| 311 | + if ( $isEdit && ( preg_match( "/^$index_namespace:(.*?)(\/([0-9]*)|)$/", $wgTitle->getPrefixedText(), $m ) ) ) { |
291 | 312 | pr_prepareIndex( $out ); |
292 | 313 | return true; |
293 | 314 | } |
— | — | @@ -404,7 +425,6 @@ |
405 | 426 | * Hook function |
406 | 427 | */ |
407 | 428 | function pr_getLinkColoursHook( $page_ids, &$colours ) { |
408 | | - global $pr_page_namespace, $pr_index_namespace; |
409 | 429 | global $wgTitle; |
410 | 430 | |
411 | 431 | if ( !isset( $wgTitle ) ) { |
— | — | @@ -412,7 +432,8 @@ |
413 | 433 | } |
414 | 434 | |
415 | 435 | // abort if we are not an index page |
416 | | - if ( !preg_match( "/^$pr_index_namespace:(.*?)$/", $wgTitle->getPrefixedText(), $m ) ) { |
| 436 | + $index_namespace = pr_index_ns(); |
| 437 | + if ( !preg_match( "/^$index_namespace:(.*?)$/", $wgTitle->getPrefixedText(), $m ) ) { |
417 | 438 | return true; |
418 | 439 | } |
419 | 440 | pr_getLinkColours( $page_ids, $colours ); |
— | — | @@ -424,13 +445,13 @@ |
425 | 446 | * Return the quality colour codes to pages linked from an index page |
426 | 447 | */ |
427 | 448 | function pr_getLinkColours( $page_ids, &$colours ) { |
428 | | - global $pr_page_namespace, $pr_index_namespace; |
429 | 449 | |
| 450 | + $page_namespace = pr_page_ns(); |
430 | 451 | $dbr = wfGetDB( DB_SLAVE ); |
431 | 452 | $catlinks = $dbr->tableName( 'categorylinks' ); |
432 | 453 | foreach ( $page_ids as $id => $pdbk ) { |
433 | 454 | // consider only link in page namespace |
434 | | - if ( preg_match( "/^$pr_page_namespace:(.*?)$/", $pdbk ) ) { |
| 455 | + if ( preg_match( "/^$page_namespace:(.*?)$/", $pdbk ) ) { |
435 | 456 | $colours[$pdbk] = 'quality1'; |
436 | 457 | if ( !isset( $query ) ) { |
437 | 458 | $query = "SELECT cl_from, cl_to FROM $catlinks WHERE cl_from IN("; |
— | — | @@ -469,9 +490,9 @@ |
470 | 491 | } |
471 | 492 | |
472 | 493 | function pr_imageMessage( &$imgpage , &$wgOut ) { |
473 | | - global $pr_page_namespace, $pr_index_namespace; |
474 | 494 | global $wgUser; |
475 | 495 | |
| 496 | + $index_namespace = pr_index_ns(); |
476 | 497 | $image = $imgpage->img; |
477 | 498 | if ( !$image->isMultiPage() ) { |
478 | 499 | return true; |
— | — | @@ -479,7 +500,7 @@ |
480 | 501 | |
481 | 502 | $sk = $wgUser->getSkin(); |
482 | 503 | $name = $image->getTitle()->getText(); |
483 | | - $link = $sk->makeKnownLink( "$pr_index_namespace:$name", wfMsg( 'proofreadpage_image_message' ) ); |
| 504 | + $link = $sk->makeKnownLink( "$index_namespace:$name", wfMsg( 'proofreadpage_image_message' ) ); |
484 | 505 | $wgOut->addHTML( "{$link}" ); |
485 | 506 | |
486 | 507 | return true; |
— | — | @@ -488,6 +509,7 @@ |
489 | 510 | |
490 | 511 | // credit : http://www.mediawiki.org/wiki/Extension:RomanNumbers |
491 | 512 | function toRoman( $num ) { |
| 513 | + |
492 | 514 | if ( $num < 0 || $num > 9999 ) { |
493 | 515 | return - 1; |
494 | 516 | } |
— | — | @@ -519,6 +541,7 @@ |
520 | 542 | |
521 | 543 | |
522 | 544 | function pr_pageNumber( $i, $args ) { |
| 545 | + |
523 | 546 | $mode = 'normal'; // default |
524 | 547 | $offset = 0; |
525 | 548 | $links = true; |
— | — | @@ -574,10 +597,10 @@ |
575 | 598 | * todo : display whether page has been proofread by the user or by someone else |
576 | 599 | */ |
577 | 600 | function pr_pageQuality( $input, $args ) { |
578 | | - global $pr_page_namespace, $pr_index_namespace; |
579 | 601 | global $wgUser, $wgTitle, $wgParser; |
580 | 602 | |
581 | | - if ( !preg_match( "/^$pr_page_namespace:(.*?)(\/([0-9]*)|)$/", $wgTitle->getPrefixedText() ) ) { |
| 603 | + $page_namespace = pr_page_ns(); |
| 604 | + if ( !preg_match( "/^$page_namespace:(.*?)(\/([0-9]*)|)$/", $wgTitle->getPrefixedText() ) ) { |
582 | 605 | return ""; |
583 | 606 | } |
584 | 607 | $q = $args['level']; |
— | — | @@ -595,10 +618,11 @@ |
596 | 619 | * Display a list of coloured links to pages |
597 | 620 | */ |
598 | 621 | function pr_renderPageList( $input, $args ) { |
599 | | - global $pr_page_namespace, $pr_index_namespace; |
600 | 622 | global $wgUser, $wgTitle, $wgParser; |
601 | 623 | |
602 | | - if ( !preg_match( "/^$pr_index_namespace:(.*?)(\/([0-9]*)|)$/", $wgTitle->getPrefixedText(), $m ) ) { |
| 624 | + $page_namespace = pr_page_ns(); |
| 625 | + $index_namespace = pr_index_ns(); |
| 626 | + if ( !preg_match( "/^$index_namespace:(.*?)(\/([0-9]*)|)$/", $wgTitle->getPrefixedText(), $m ) ) { |
603 | 627 | return ""; |
604 | 628 | } |
605 | 629 | |
— | — | @@ -629,7 +653,7 @@ |
630 | 654 | } |
631 | 655 | |
632 | 656 | for ( $i = $from; $i < $to + 1; $i++ ) { |
633 | | - $pdbk = "$pr_page_namespace:$name" . '/' . $i ; |
| 657 | + $pdbk = "$page_namespace:$name" . '/' . $i ; |
634 | 658 | list( $view, $links, $mode ) = pr_pageNumber( $i, $args ); |
635 | 659 | |
636 | 660 | if ( $mode == 'highroman' || $mode == 'roman' ) $view = ' ' . $view; |
— | — | @@ -662,9 +686,10 @@ |
663 | 687 | * It needs 3 parameters : index, from, to |
664 | 688 | */ |
665 | 689 | function pr_renderPages( $input, $args ) { |
666 | | - global $pr_page_namespace, $pr_index_namespace; |
667 | 690 | global $wgParser, $wgTitle; |
668 | 691 | |
| 692 | + $page_namespace = pr_page_ns(); |
| 693 | + $index_namespace = pr_index_ns(); |
669 | 694 | $index = $args['index']; |
670 | 695 | $from = $args['from']; |
671 | 696 | $to = $args['to']; |
— | — | @@ -672,7 +697,7 @@ |
673 | 698 | if( ! $index ) { |
674 | 699 | return '<strong class="error">' . wfMsgForContent( 'proofreadpage_index_expected' ) . '</strong>'; |
675 | 700 | } |
676 | | - $index_title = Title::newFromText( "$pr_index_namespace:$index" ); |
| 701 | + $index_title = Title::newFromText( "$index_namespace:$index" ); |
677 | 702 | if( ! $index_title || ! $index_title->exists() ) { |
678 | 703 | return '<strong class="error">' . wfMsgForContent( 'proofreadpage_nosuch_index' ) . '</strong>'; |
679 | 704 | } |
— | — | @@ -705,7 +730,7 @@ |
706 | 731 | } |
707 | 732 | |
708 | 733 | for( $i=$from; $i<=$to;$i++ ) { |
709 | | - $text = "$pr_page_namespace:$index/" . $i; |
| 734 | + $text = "$page_namespace:$index/" . $i; |
710 | 735 | list($pagenum, $links, $mode) = pr_pageNumber($i,$params); |
711 | 736 | $out.= "<span>{{:MediaWiki:Proofreadpage_pagenum_template|page=".$text."|num=$pagenum}}</span>"; |
712 | 737 | if( $args["$i"] != null){ |
— | — | @@ -732,13 +757,13 @@ |
733 | 758 | if($text == $from ) $adding = true; |
734 | 759 | if($adding){ |
735 | 760 | $out.= "<span>{{:MediaWiki:Proofreadpage_pagenum_template|page=" |
736 | | - .$pr_page_namespace.":".$text."|num=$pagenum}}</span>"; |
| 761 | + .$page_namespace.":".$text."|num=$pagenum}}</span>"; |
737 | 762 | if($text == $from && $args["fromsection"]){ |
738 | | - $out.= "{{#lst:".$pr_page_namespace.":".$text."|".$args["fromsection"]."}}"; |
| 763 | + $out.= "{{#lst:".$page_namespace.":".$text."|".$args["fromsection"]."}}"; |
739 | 764 | } else if($text == $to && $args["tosection"]){ |
740 | | - $out.= "{{#lst:".$pr_page_namespace.":".$text."|".$args["tosection"]."}}"; |
| 765 | + $out.= "{{#lst:".$page_namespace.":".$text."|".$args["tosection"]."}}"; |
741 | 766 | } else { |
742 | | - $out.= "{{:".$pr_page_namespace.":".$text."}}"; |
| 767 | + $out.= "{{:".$page_namespace.":".$text."}}"; |
743 | 768 | } |
744 | 769 | } |
745 | 770 | if($text == $to ) $adding = false; |
— | — | @@ -755,8 +780,8 @@ |
756 | 781 | */ |
757 | 782 | function pr_parse_page( $text ) { |
758 | 783 | global $wgTitle, $wgUser; |
| 784 | + |
759 | 785 | $username = $wgUser->getName(); |
760 | | - |
761 | 786 | $page_regexp = "/^<noinclude>(.*?)<\/noinclude>(.*?)<noinclude>(.*?)<\/noinclude>$/s"; |
762 | 787 | if( !preg_match( $page_regexp, $text, $m ) ) { |
763 | 788 | pr_load_index( $wgTitle ); |
— | — | @@ -783,10 +808,10 @@ |
784 | 809 | |
785 | 810 | function pr_formData( $editpage, $request ) { |
786 | 811 | global $wgTitle; |
787 | | - global $pr_page_namespace; |
788 | 812 | |
| 813 | + $page_namespace = pr_page_ns(); |
789 | 814 | //abort if we are not a page |
790 | | - if ( ! preg_match( "/^$pr_page_namespace:(.*)$/", $wgTitle->getPrefixedText() ) ) { |
| 815 | + if ( ! preg_match( "/^$page_namespace:(.*)$/", $wgTitle->getPrefixedText() ) ) { |
791 | 816 | return true; |
792 | 817 | } |
793 | 818 | if ( ! $request->wasPosted() ) { |
— | — | @@ -824,13 +849,14 @@ |
825 | 850 | * Check the format of pages in "Page" namespace. |
826 | 851 | */ |
827 | 852 | function pr_attemptSave( $editpage ) { |
828 | | - global $pr_page_namespace, $pr_index_namespace; |
829 | 853 | global $wgOut, $wgUser; |
830 | 854 | |
| 855 | + $page_namespace = pr_page_ns(); |
| 856 | + $index_namespace = pr_index_ns(); |
831 | 857 | $title = $editpage->mTitle; |
832 | 858 | |
833 | 859 | //check that pages listed on an index are unique. |
834 | | - if ( preg_match( "/^$pr_index_namespace:(.*)$/", $title->getPrefixedText() ) ) { |
| 860 | + if ( preg_match( "/^$index_namespace:(.*)$/", $title->getPrefixedText() ) ) { |
835 | 861 | $text = $editpage->textbox1; |
836 | 862 | list( $links, $params, $attributes ) = pr_parse_index_text($text); |
837 | 863 | if( $links!=null && count($links[1]) != count( array_unique($links[1]))) { |
— | — | @@ -841,7 +867,7 @@ |
842 | 868 | } |
843 | 869 | |
844 | 870 | //abort if we are not a page |
845 | | - if ( ! preg_match( "/^$pr_page_namespace:(.*)$/", $title->getPrefixedText() ) ) { |
| 871 | + if ( ! preg_match( "/^$page_namespace:(.*)$/", $title->getPrefixedText() ) ) { |
846 | 872 | return true; |
847 | 873 | } |
848 | 874 | |
— | — | @@ -895,11 +921,12 @@ |
896 | 922 | * if I delete an index page too... |
897 | 923 | */ |
898 | 924 | function pr_articleDelete( $article ) { |
899 | | - global $pr_page_namespace, $pr_index_namespace; |
900 | 925 | |
| 926 | + $page_namespace = pr_page_ns(); |
| 927 | + $index_namespace = pr_index_ns(); |
901 | 928 | $title = $article->mTitle; |
902 | 929 | |
903 | | - if ( preg_match( "/^$pr_index_namespace:(.*)$/", $title->getPrefixedText() ) ) { |
| 930 | + if ( preg_match( "/^$index_namespace:(.*)$/", $title->getPrefixedText() ) ) { |
904 | 931 | $id = $article->getID(); |
905 | 932 | $dbw = wfGetDB( DB_MASTER ); |
906 | 933 | $pr_index = $dbw->tableName( 'pr_index' ); |
— | — | @@ -908,7 +935,7 @@ |
909 | 936 | return true; |
910 | 937 | } |
911 | 938 | |
912 | | - if ( preg_match( "/^$pr_page_namespace:(.*)$/", $title->getPrefixedText() ) ) { |
| 939 | + if ( preg_match( "/^$page_namespace:(.*)$/", $title->getPrefixedText() ) ) { |
913 | 940 | pr_load_index( $title ); |
914 | 941 | if( $title->pr_index_title ) { |
915 | 942 | $index_title = Title::newFromText( $title->pr_index_title ); |
— | — | @@ -925,18 +952,19 @@ |
926 | 953 | |
927 | 954 | |
928 | 955 | function pr_articleSaveComplete( $article ) { |
929 | | - global $pr_page_namespace, $pr_index_namespace; |
930 | 956 | |
| 957 | + $page_namespace = pr_page_ns(); |
| 958 | + $index_namespace = pr_index_ns(); |
931 | 959 | $title = $article->mTitle; |
932 | 960 | |
933 | 961 | //if it's an index, update pr_index table |
934 | | - if ( preg_match( "/^$pr_index_namespace:(.*)$/", $title->getPrefixedText(), $m ) ) { |
| 962 | + if ( preg_match( "/^$index_namespace:(.*)$/", $title->getPrefixedText(), $m ) ) { |
935 | 963 | pr_update_pr_index( $article ); |
936 | 964 | return true; |
937 | 965 | } |
938 | 966 | |
939 | 967 | //return if it is not a page |
940 | | - if ( ! preg_match( "/^$pr_page_namespace:(.*)$/", $title->getPrefixedText() ) ) { |
| 968 | + if ( ! preg_match( "/^$page_namespace:(.*)$/", $title->getPrefixedText() ) ) { |
941 | 969 | return true; |
942 | 970 | } |
943 | 971 | |
— | — | @@ -1004,10 +1032,10 @@ |
1005 | 1033 | |
1006 | 1034 | /* preload Djvu Text */ |
1007 | 1035 | function pr_preloadText( $textbox1, $mTitle ) { |
1008 | | - global $pr_page_namespace, $pr_index_namespace; |
1009 | 1036 | global $wgDjvuTxt; |
1010 | 1037 | |
1011 | | - if ( $wgDjvuTxt && preg_match( "/^$pr_page_namespace:(.*?)\/([0-9]*)$/", $mTitle->getPrefixedText(), $m ) ) { |
| 1038 | + $page_namespace = pr_page_ns(); |
| 1039 | + if ( $wgDjvuTxt && preg_match( "/^$page_namespace:(.*?)\/([0-9]*)$/", $mTitle->getPrefixedText(), $m ) ) { |
1012 | 1040 | $imageTitle = Title::makeTitleSafe( NS_IMAGE, $m[1] ); |
1013 | 1041 | if ( !$imageTitle ) { |
1014 | 1042 | return true; |
— | — | @@ -1029,9 +1057,9 @@ |
1030 | 1058 | |
1031 | 1059 | |
1032 | 1060 | function pr_movePage( $form, $ot, $nt ) { |
1033 | | - global $pr_page_namespace, $pr_index_namespace; |
1034 | 1061 | |
1035 | | - if ( preg_match( "/^$pr_page_namespace:(.*)$/", $ot->getPrefixedText() ) ) { |
| 1062 | + $page_namespace = pr_page_ns(); |
| 1063 | + if ( preg_match( "/^$page_namespace:(.*)$/", $ot->getPrefixedText() ) ) { |
1036 | 1064 | pr_load_index( $ot ); |
1037 | 1065 | if( $ot->pr_index_title ) { |
1038 | 1066 | $index_title = Title::newFromText( $ot->pr_index_title ); |
— | — | @@ -1042,7 +1070,7 @@ |
1043 | 1071 | return true; |
1044 | 1072 | } |
1045 | 1073 | |
1046 | | - if ( preg_match( "/^$pr_page_namespace:(.*)$/", $nt->getPrefixedText() ) ) { |
| 1074 | + if ( preg_match( "/^$page_namespace:(.*)$/", $nt->getPrefixedText() ) ) { |
1047 | 1075 | pr_load_index( $nt ); |
1048 | 1076 | if( $nt->pr_index_title && ($nt->pr_index_title!=$ot->pr_index_title) ) { |
1049 | 1077 | $index_title = Title::newFromText( $nt->pr_index_title ); |
— | — | @@ -1060,10 +1088,10 @@ |
1061 | 1089 | * When an index page is created or purged, recompute pr_index values |
1062 | 1090 | */ |
1063 | 1091 | function pr_articlePurge( $article ) { |
1064 | | - global $pr_page_namespace, $pr_index_namespace; |
1065 | 1092 | |
| 1093 | + $index_namespace = pr_index_ns(); |
1066 | 1094 | $title = $article->mTitle; |
1067 | | - if ( preg_match( "/^$pr_index_namespace:(.*)$/", $title->getPrefixedText() ) ) { |
| 1095 | + if ( preg_match( "/^$index_namespace:(.*)$/", $title->getPrefixedText() ) ) { |
1068 | 1096 | pr_update_pr_index( $article ); |
1069 | 1097 | return true; |
1070 | 1098 | } |
— | — | @@ -1076,9 +1104,10 @@ |
1077 | 1105 | * update the pr_index entry of an article |
1078 | 1106 | */ |
1079 | 1107 | function pr_update_pr_index( $index, $deletedpage=null ) { |
1080 | | - global $pr_page_namespace, $pr_index_namespace; |
1081 | 1108 | |
1082 | | - $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( $pr_page_namespace ) ); |
| 1109 | + $page_namespace = pr_page_ns(); |
| 1110 | + $index_namespace = pr_index_ns(); |
| 1111 | + $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( $page_namespace ) ); |
1083 | 1112 | if ( $page_ns_index == NULL ) { |
1084 | 1113 | return; |
1085 | 1114 | } |
— | — | @@ -1171,7 +1200,6 @@ |
1172 | 1201 | */ |
1173 | 1202 | function pr_OutputPageBeforeHTML( $out, $text ) { |
1174 | 1203 | global $wgTitle, $wgUser; |
1175 | | - global $pr_page_namespace, $pr_index_namespace; |
1176 | 1204 | |
1177 | 1205 | if($wgTitle->getNamespace() != NS_MAIN){ |
1178 | 1206 | return true; |
— | — | @@ -1182,8 +1210,10 @@ |
1183 | 1211 | return true; |
1184 | 1212 | } |
1185 | 1213 | |
1186 | | - $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( $pr_page_namespace ) ); |
1187 | | - $index_ns_index = MWNamespace::getCanonicalIndex( strtolower( $pr_index_namespace ) ); |
| 1214 | + $page_namespace = pr_page_ns(); |
| 1215 | + $index_namespace = pr_index_ns(); |
| 1216 | + $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( $page_namespace ) ); |
| 1217 | + $index_ns_index = MWNamespace::getCanonicalIndex( strtolower( $index_namespace ) ); |
1188 | 1218 | if( $page_ns_index==null || $index_ns_index == null){ |
1189 | 1219 | return true; |
1190 | 1220 | } |
— | — | @@ -1254,7 +1284,7 @@ |
1255 | 1285 | $dbr->freeResult( $res ); |
1256 | 1286 | } |
1257 | 1287 | $sk = $wgUser->getSkin(); |
1258 | | - $indexlink = $sk->makeKnownLink( "$pr_index_namespace:$title", "[index]" ); |
| 1288 | + $indexlink = $sk->makeKnownLink( "$index_namespace:$title", "[index]" ); |
1259 | 1289 | $output = wfMsgForContent( 'proofreadpage_quality_message', $n0, $n1, $n2, $n3, $n4, $n, $indexlink ); |
1260 | 1290 | $out->setSubtitle($output); |
1261 | 1291 | return true; |