r48582 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48581‎ | r48582 | r48583 >
Date:15:04, 19 March 2009
Author:thomasv
Status:ok
Tags:
Comment:
changing the pagelist syntax; handle the case of empty pages
Modified paths:
  • /trunk/extensions/ProofreadPage/ProofreadPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/ProofreadPage.php
@@ -587,41 +587,70 @@
588588 for( $i=1; $i<$count+1 ; $i++) {
589589
590590 $pdbk = "$page_namespace:$name" . '/'. $i ;
 591+ //default
 592+ $single=false;
 593+ $mode = 'normal';
 594+ $links = true;
591595
592 - $single=false;
593596 foreach ( $args as $num => $param ) {
594 - if($i == $num) {
595 - $param = explode(";",$param);
596 - if(isset($param[1])) $mode = $param[1]; else $mode='normal';
597 - if(is_numeric($param[0])) $offset = $i - $param[0];
598 - else $single=$param[0];
 597+
 598+ if( ( preg_match( "/^([0-9]*)to([0-9]*)$/", $num, $m ) && ( $i>=$m[1] && $i<=$m[2] ) )
 599+ || ( is_numeric($num) && ($i == $num) ) ) {
 600+ $params = explode(";",$param);
 601+ foreach ( $params as $iparam ) {
 602+ switch($iparam){
 603+ case 'roman':
 604+ $mode = 'roman';
 605+ break;
 606+ case 'highroman':
 607+ $mode = 'highroman';
 608+ break;
 609+ case 'empty':
 610+ $links = false;
 611+ break;
 612+ default:
 613+ if(is_numeric($iparam))
 614+ $offset = $i - $iparam[0];
 615+ else
 616+ $single = $iparam[0];
 617+
 618+ }
 619+ }
599620 }
600 - }
 621+ }
601622
602 - if( $single ) { $view = $single; $single=false; $offset=$offset+1;}
 623+ if( $single ) {
 624+ $view = $single;
 625+ $offset=$offset+1;
 626+ }
603627 else {
604 - $view = ($i - $offset);
605 - if($mode == 'highroman') $view = '&nbsp;'.toRoman($view);
606 - elseif($mode == 'roman') $view = '&nbsp;'.strtolower(toRoman($view));
607 - elseif($mode == 'normal') $view = ''.$view;
608 - else $view = $mode.$view;
 628+ $view = ($i - $offset);
 629+ if($mode == 'highroman') $view = '&nbsp;'.toRoman($view);
 630+ elseif($mode == 'roman') $view = '&nbsp;'.strtolower(toRoman($view));
 631+ elseif($mode == 'normal') $view = ''.$view;
 632+ elseif($mode == 'empty') $view = ''.$view;
 633+ else $view = $mode.$view;
609634 }
610635
611636 $n = strlen($count) - strlen($view);
612 - if( $n && ($mode == 'normal') ){
 637+ if( $n && ($mode == 'normal' || $mode == 'empty') ){
613638 $txt = '<span style="visibility:hidden;">';
614639 for( $j=0; $j<$n; $j++) $txt = $txt.'0';
615640 $view = $txt.'</span>'.$view;
616641 }
617642 $title = Title::newFromText( $pdbk );
618 - if ( !isset( $colours[$pdbk] ) ) {
619 - $link = $sk->makeBrokenLinkObj( $title, $view );
620 - } else {
621 - $link = $sk->makeColouredLinkObj( $title, $colours[$pdbk], $view );
 643+
 644+ if($links==false) $return.= $view." ";
 645+ else{
 646+ if ( !isset( $colours[$pdbk] ) ) {
 647+ $link = $sk->makeBrokenLinkObj( $title, $view );
 648+ }
 649+ else {
 650+ $link = $sk->makeColouredLinkObj( $title, $colours[$pdbk], $view );
 651+ }
 652+ $return .= "{$link} ";
622653 }
623 - $return .= "{$link} ";
624654 }
625 -
626655 }
627656 return $return;
628657 }

Status & tagging log