r73215 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73214‎ | r73215 | r73216 >
Date:16:15, 17 September 2010
Author:thomasv
Status:ok
Tags:
Comment:
simplification
Modified paths:
  • /trunk/extensions/ProofreadPage/ProofreadPage_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/ProofreadPage_body.php
@@ -672,6 +672,7 @@
673673 /*
674674 * Parser hook that includes a list of pages.
675675 * parameters : index, from, to, header
 676+ * todo : check if pages are q0, with a single request
676677 */
677678 function renderPages( $input, $args, &$parser ) {
678679
@@ -729,26 +730,22 @@
730731 if( $to - $from > 1000 ) {
731732 return '<strong class="error">' . wfMsgForContent( 'proofreadpage_interval_too_large' ) . '</strong>';
732733 }
733 -
 734+ $pages = array();
 735+
734736 for( $i=$from; $i<=$to;$i++ ) {
735 - $text = "$page_namespace:$index/" . $i;
736 - list($pagenum, $links, $mode) = $this->pageNumber($i,$params);
737 - $out.= "<span>{{:MediaWiki:Proofreadpage_pagenum_template|page=".$text."|num=$pagenum}}</span>";
738 - if( $args["$i"] != null){
739 - $out.= "{{#lst:".$text."|".$args["$i"]."}}";
740 - } else if($i == $from && $args["fromsection"]){
741 - $out.= "{{#lst:".$text."|".$args["fromsection"]."}}";
742 - } else if($i == $to && $args["tosection"]){
743 - $out.= "{{#lst:".$text."|".$args["tosection"]."}}";
744 - } else {
745 - $out.= "{{:".$text."}}";
 737+ list($pagenum, $links, $mode) = $this->pageNumber( $i, $params );
 738+ $page = str_replace( ' ' , '_', "$index/" . $i );
 739+ if( $i == $from ) {
 740+ $from_page = $page;
 741+ $from_pagenum = $pagenum;
746742 }
747 - $out.= "\n";
748 - if( $i == $from ) $from_pagenum = $pagenum;
749 - if( $i == $to ) $to_pagenum = $pagenum;
 743+ if( $i == $to ) {
 744+ $to_page = $page;
 745+ $to_pagenum = $pagenum;
 746+ }
 747+ $pages[] = array( $page, $pagenum );
750748 }
751 - }
752 - else {
 749+ } else {
753750 if($from) {
754751 $adding = false;
755752 } else {
@@ -760,21 +757,15 @@
761758 $pagenum = $links[3][$i];
762759 if($text == $from ) {
763760 $adding = true;
 761+ $from_page = $from;
764762 $from_pagenum = $pagenum;
765763 }
766 - if($adding){
767 - $out.= "<span>{{:MediaWiki:Proofreadpage_pagenum_template|page="
768 - .$page_namespace.":".$text."|num=$pagenum}}</span>";
769 - if($text == $from && $args["fromsection"]){
770 - $out.= "{{#lst:".$page_namespace.":".$text."|".$args["fromsection"]."}}";
771 - } else if($text == $to && $args["tosection"]){
772 - $out.= "{{#lst:".$page_namespace.":".$text."|".$args["tosection"]."}}";
773 - } else {
774 - $out.= "{{:".$page_namespace.":".$text."}}";
775 - }
 764+ if($adding) {
 765+ $pages[] = array( $text, $pagenum );
776766 }
777767 if($text == $to ) {
778768 $adding = false;
 769+ $to_page = $to;
779770 $to_pagenum = $pagenum;
780771 }
781772 }
@@ -782,6 +773,23 @@
783774 $to_pagenum = $links[3][ count( $links[1] ) - 1 ];
784775 }
785776 }
 777+
 778+ //write the output
 779+ foreach( $pages as $item ) {
 780+ list( $page, $pagenum ) = $item;
 781+ $text = "$page_namespace:$page";
 782+ $out.= "<span>{{:MediaWiki:Proofreadpage_pagenum_template|page=".$text."|num=$pagenum}}</span>";
 783+ if( $args["$i"] != null){
 784+ $out.= "{{#lst:".$text."|".$args["$i"]."}}";
 785+ } else if($page == $from && $args["fromsection"]){
 786+ $out.= "{{#lst:".$text."|".$args["fromsection"]."}}";
 787+ } else if($page == $to && $args["tosection"]){
 788+ $out.= "{{#lst:".$text."|".$args["tosection"]."}}";
 789+ } else {
 790+ $out.= "{{:".$text."}}";
 791+ }
 792+ $out.= "\n";
 793+ }
786794 }
787795
788796 if( $header ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r73220Merging with trunk r73215 except phpunitpeter1717:16, 17 September 2010

Status & tagging log