r59783 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59782‎ | r59783 | r59784 >
Date:11:39, 7 December 2009
Author:thomasv
Status:ok
Tags:
Comment:
do not transclude pages if from and to are missing; simply moving a block inside if() test, the rest is indentation
Modified paths:
  • /trunk/extensions/ProofreadPage/ProofreadPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/ProofreadPage.php
@@ -729,81 +729,84 @@
730730 list( $links, $params, $attributes ) = pr_parse_index( $index_title );
731731 $text_links = pr_parse_index_links( $index_title, $parser );
732732
733 - if( $links==null ) {
734 - $imageTitle = Title::makeTitleSafe( NS_IMAGE, $index );
735 - if ( !$imageTitle ) {
736 - return '<strong class="error">' . wfMsgForContent( 'proofreadpage_nosuch_file' ) . '</strong>';
737 - }
738 - $image = wfFindFile( $imageTitle );
739 - if ( ! ( $image && $image->isMultiPage() && $image->pageCount() ) ) {
740 - return '<strong class="error">' . wfMsgForContent( 'proofreadpage_nosuch_file' ) . '</strong>';
741 - }
742 - $count = $image->pageCount();
 733+ if( $from || $to ) {
743734
744 - if( !$from ) $from = 1;
745 - if( !$to ) $to = $count;
 735+ if( $links==null ) {
 736+ $imageTitle = Title::makeTitleSafe( NS_IMAGE, $index );
 737+ if ( !$imageTitle ) {
 738+ return '<strong class="error">' . wfMsgForContent( 'proofreadpage_nosuch_file' ) . '</strong>';
 739+ }
 740+ $image = wfFindFile( $imageTitle );
 741+ if ( ! ( $image && $image->isMultiPage() && $image->pageCount() ) ) {
 742+ return '<strong class="error">' . wfMsgForContent( 'proofreadpage_nosuch_file' ) . '</strong>';
 743+ }
 744+ $count = $image->pageCount();
746745
747 - if( !is_numeric( $from ) || !is_numeric( $to ) ) {
748 - return '<strong class="error">' . wfMsgForContent( 'proofreadpage_number_expected' ) . '</strong>';
749 - }
750 - if( ($from > $to) || ($from < 1) || ($to < 1 ) || ($to > $count) ) {
751 - return '<strong class="error">' . wfMsgForContent( 'proofreadpage_invalid_interval' ) . '</strong>';
752 - }
753 - if( $to - $from > 1000 ) {
754 - return '<strong class="error">' . wfMsgForContent( 'proofreadpage_interval_too_large' ) . '</strong>';
755 - }
 746+ if( !$from ) $from = 1;
 747+ if( !$to ) $to = $count;
756748
757 - for( $i=$from; $i<=$to;$i++ ) {
758 - $text = "$page_namespace:$index/" . $i;
759 - list($pagenum, $links, $mode) = pr_pageNumber($i,$params);
760 - $out.= "<span>{{:MediaWiki:Proofreadpage_pagenum_template|page=".$text."|num=$pagenum}}</span>";
761 - if( $args["$i"] != null){
762 - $out.= "{{#lst:".$text."|".$args["$i"]."}}";
763 - } else if($i == $from && $args["fromsection"]){
764 - $out.= "{{#lst:".$text."|".$args["fromsection"]."}}";
765 - } else if($i == $to && $args["tosection"]){
766 - $out.= "{{#lst:".$text."|".$args["tosection"]."}}";
767 - } else {
768 - $out.= "{{:".$text."}}";
 749+ if( !is_numeric( $from ) || !is_numeric( $to ) ) {
 750+ return '<strong class="error">' . wfMsgForContent( 'proofreadpage_number_expected' ) . '</strong>';
769751 }
770 - $out.= "\n";
771 - if( $i == $from ) $from_pagenum = $pagenum;
772 - if( $i == $to ) $to_pagenum = $pagenum;
773 - }
774 - }
775 - else {
776 - if($from) {
777 - $adding = false;
778 - } else {
779 - $adding = true;
780 - $from_pagenum = $links[3][0];
781 - }
782 - for( $i=0; $i < count( $links[1] ); $i++) {
783 - $text = $links[1][$i];
784 - $pagenum = $links[3][$i];
785 - if($text == $from ) {
786 - $adding = true;
787 - $from_pagenum = $pagenum;
 752+ if( ($from > $to) || ($from < 1) || ($to < 1 ) || ($to > $count) ) {
 753+ return '<strong class="error">' . wfMsgForContent( 'proofreadpage_invalid_interval' ) . '</strong>';
788754 }
789 - if($adding){
790 - $out.= "<span>{{:MediaWiki:Proofreadpage_pagenum_template|page="
791 - .$page_namespace.":".$text."|num=$pagenum}}</span>";
792 - if($text == $from && $args["fromsection"]){
793 - $out.= "{{#lst:".$page_namespace.":".$text."|".$args["fromsection"]."}}";
794 - } else if($text == $to && $args["tosection"]){
795 - $out.= "{{#lst:".$page_namespace.":".$text."|".$args["tosection"]."}}";
 755+ if( $to - $from > 1000 ) {
 756+ return '<strong class="error">' . wfMsgForContent( 'proofreadpage_interval_too_large' ) . '</strong>';
 757+ }
 758+
 759+ for( $i=$from; $i<=$to;$i++ ) {
 760+ $text = "$page_namespace:$index/" . $i;
 761+ list($pagenum, $links, $mode) = pr_pageNumber($i,$params);
 762+ $out.= "<span>{{:MediaWiki:Proofreadpage_pagenum_template|page=".$text."|num=$pagenum}}</span>";
 763+ if( $args["$i"] != null){
 764+ $out.= "{{#lst:".$text."|".$args["$i"]."}}";
 765+ } else if($i == $from && $args["fromsection"]){
 766+ $out.= "{{#lst:".$text."|".$args["fromsection"]."}}";
 767+ } else if($i == $to && $args["tosection"]){
 768+ $out.= "{{#lst:".$text."|".$args["tosection"]."}}";
796769 } else {
797 - $out.= "{{:".$page_namespace.":".$text."}}";
 770+ $out.= "{{:".$text."}}";
798771 }
 772+ $out.= "\n";
 773+ if( $i == $from ) $from_pagenum = $pagenum;
 774+ if( $i == $to ) $to_pagenum = $pagenum;
799775 }
800 - if($text == $to ) {
 776+ }
 777+ else {
 778+ if($from) {
801779 $adding = false;
802 - $to_pagenum = $pagenum;
 780+ } else {
 781+ $adding = true;
 782+ $from_pagenum = $links[3][0];
803783 }
 784+ for( $i=0; $i < count( $links[1] ); $i++) {
 785+ $text = $links[1][$i];
 786+ $pagenum = $links[3][$i];
 787+ if($text == $from ) {
 788+ $adding = true;
 789+ $from_pagenum = $pagenum;
 790+ }
 791+ if($adding){
 792+ $out.= "<span>{{:MediaWiki:Proofreadpage_pagenum_template|page="
 793+ .$page_namespace.":".$text."|num=$pagenum}}</span>";
 794+ if($text == $from && $args["fromsection"]){
 795+ $out.= "{{#lst:".$page_namespace.":".$text."|".$args["fromsection"]."}}";
 796+ } else if($text == $to && $args["tosection"]){
 797+ $out.= "{{#lst:".$page_namespace.":".$text."|".$args["tosection"]."}}";
 798+ } else {
 799+ $out.= "{{:".$page_namespace.":".$text."}}";
 800+ }
 801+ }
 802+ if($text == $to ) {
 803+ $adding = false;
 804+ $to_pagenum = $pagenum;
 805+ }
 806+ }
 807+ if( !$to ) {
 808+ $to_pagenum = $links[3][ count( $links[1] ) - 1 ];
 809+ }
804810 }
805 - if( !$to ) {
806 - $to_pagenum = $links[3][ count( $links[1] ) - 1 ];
807 - }
808811 }
809812
810813 if( $header ) {

Status & tagging log