Index: trunk/extensions/ProofreadPage/ProofreadPage.php |
— | — | @@ -196,7 +196,7 @@ |
197 | 197 | } |
198 | 198 | |
199 | 199 | //if the index page exists, find current page number, previous and next pages |
200 | | - list( $links, $params, $attributes ) = pr_parse_index($index_title); |
| 200 | + list( $text_links, $links, $params, $attributes ) = pr_parse_index($index_title); |
201 | 201 | |
202 | 202 | if( $links==null ) { |
203 | 203 | list($pagenum, $links, $mode) = pr_pageNumber($pagenr,$params); |
— | — | @@ -269,6 +269,10 @@ |
270 | 270 | preg_match_all( $tag_pattern, $text, $links, PREG_PATTERN_ORDER ); |
271 | 271 | } |
272 | 272 | |
| 273 | + //links in ns-0 |
| 274 | + $text_links_pattern = "/\[\[([^:\|]*?)(\|(.*?)|)\]\]/i"; |
| 275 | + preg_match_all( $text_links_pattern, $text, $text_links, PREG_PATTERN_ORDER ); |
| 276 | + |
273 | 277 | //read attributes |
274 | 278 | $attributes = array(); |
275 | 279 | $var_names = explode(" ", wfMsgForContent('proofreadpage_js_attributes') ); |
— | — | @@ -282,7 +286,7 @@ |
283 | 287 | $attributes[$var] = ''; |
284 | 288 | } |
285 | 289 | } |
286 | | - return array( $links, $params, $attributes ); |
| 290 | + return array( $text_links, $links, $params, $attributes ); |
287 | 291 | |
288 | 292 | } |
289 | 293 | |
— | — | @@ -683,7 +687,7 @@ |
684 | 688 | |
685 | 689 | /* |
686 | 690 | * Parser hook that includes a list of pages. |
687 | | - * It needs 3 parameters : index, from, to |
| 691 | + * parameters : index, from, to, header |
688 | 692 | */ |
689 | 693 | function pr_renderPages( $input, $args ) { |
690 | 694 | global $wgParser, $wgTitle; |
— | — | @@ -693,6 +697,7 @@ |
694 | 698 | $index = $args['index']; |
695 | 699 | $from = $args['from']; |
696 | 700 | $to = $args['to']; |
| 701 | + $header = $args['header']; |
697 | 702 | |
698 | 703 | if( ! $index ) { |
699 | 704 | return '<strong class="error">' . wfMsgForContent( 'proofreadpage_index_expected' ) . '</strong>'; |
— | — | @@ -703,7 +708,7 @@ |
704 | 709 | } |
705 | 710 | |
706 | 711 | $out = ''; |
707 | | - list( $links, $params, $attributes ) = pr_parse_index( $index_title ); |
| 712 | + list( $text_links, $links, $params, $attributes ) = pr_parse_index( $index_title ); |
708 | 713 | |
709 | 714 | if( $links==null ) { |
710 | 715 | $imageTitle = Title::makeTitleSafe( NS_IMAGE, $index ); |
— | — | @@ -742,8 +747,9 @@ |
743 | 748 | } else { |
744 | 749 | $out.= "{{:".$text."}}"; |
745 | 750 | } |
| 751 | + if( $i == $from ) $from_pagenum = $pagenum; |
| 752 | + if( $i == $to ) $to_pagenum = $pagenum; |
746 | 753 | } |
747 | | - $out = $wgParser->recursiveTagParse($out); |
748 | 754 | } |
749 | 755 | else { |
750 | 756 | if($from) { |
— | — | @@ -754,7 +760,10 @@ |
755 | 761 | for( $i=0; $i<count( $links[1] ); $i++) { |
756 | 762 | $text = $links[1][$i]; |
757 | 763 | $pagenum = $links[3][$i]; |
758 | | - if($text == $from ) $adding = true; |
| 764 | + if($text == $from ) { |
| 765 | + $adding = true; |
| 766 | + $from_pagenum = $pagenum; |
| 767 | + } |
759 | 768 | if($adding){ |
760 | 769 | $out.= "<span>{{:MediaWiki:Proofreadpage_pagenum_template|page=" |
761 | 770 | .$page_namespace.":".$text."|num=$pagenum}}</span>"; |
— | — | @@ -766,10 +775,41 @@ |
767 | 776 | $out.= "{{:".$page_namespace.":".$text."}}"; |
768 | 777 | } |
769 | 778 | } |
770 | | - if($text == $to ) $adding = false; |
| 779 | + if($text == $to ) { |
| 780 | + $adding = false; |
| 781 | + $to_pagenum = $pagenum; |
| 782 | + } |
771 | 783 | } |
772 | | - $out = $wgParser->recursiveTagParse($out); |
773 | 784 | } |
| 785 | + |
| 786 | + if( $header ) { |
| 787 | + $h_out = '{{'.$header; |
| 788 | + //find next and previous pages in list |
| 789 | + for( $i=1; $i < count( $text_links[1] ); $i++) { |
| 790 | + if( $text_links[1][$i] == $wgTitle->getPrefixedText() ) { |
| 791 | + $current = $text_links[0][$i]; |
| 792 | + break; |
| 793 | + } |
| 794 | + } |
| 795 | + if( ( $i > 1 ) && ( $i < count( $text_links[1] ) ) ) { |
| 796 | + $prev = $text_links[0][$i-1]; |
| 797 | + } |
| 798 | + if( ( $i >= 1 ) && ( $i + 1 < count( $text_links[1] ) ) ) { |
| 799 | + $next = $text_links[0][$i+1]; |
| 800 | + } |
| 801 | + if( $current ) $h_out .= "|current=$current"; |
| 802 | + if( $prev ) $h_out .= "|prev=$prev"; |
| 803 | + if( $next ) $h_out .= "|next=$next"; |
| 804 | + if( $from_pagenum ) $h_out .= "|from=$from_pagenum"; |
| 805 | + if( $to_pagenum ) $h_out .= "|to=$to_pagenum"; |
| 806 | + foreach ( $attributes as $key => $val ) { |
| 807 | + $h_out .= "|$key=$val"; |
| 808 | + } |
| 809 | + $h_out .= '}}'; |
| 810 | + $out = $h_out . $out; |
| 811 | + } |
| 812 | + |
| 813 | + $out = $wgParser->recursiveTagParse($out); |
774 | 814 | return $out; |
775 | 815 | } |
776 | 816 | |
— | — | @@ -858,7 +898,7 @@ |
859 | 899 | //check that pages listed on an index are unique. |
860 | 900 | if ( preg_match( "/^$index_namespace:(.*)$/", $title->getPrefixedText() ) ) { |
861 | 901 | $text = $editpage->textbox1; |
862 | | - list( $links, $params, $attributes ) = pr_parse_index_text($text); |
| 902 | + list( $text_links, $links, $params, $attributes ) = pr_parse_index_text($text); |
863 | 903 | if( $links!=null && count($links[1]) != count( array_unique($links[1]))) { |
864 | 904 | $wgOut->showErrorPage( 'proofreadpage_indexdupe', 'proofreadpage_indexdupetext' ); |
865 | 905 | return false; |
— | — | @@ -1117,7 +1157,7 @@ |
1118 | 1158 | |
1119 | 1159 | //read the list of pages |
1120 | 1160 | $pages = array(); |
1121 | | - list( $links, $params, $attributes ) = pr_parse_index( $index_title ); |
| 1161 | + list( $text_links, $links, $params, $attributes ) = pr_parse_index( $index_title ); |
1122 | 1162 | if( $links==null ) { |
1123 | 1163 | $imageTitle = Title::makeTitleSafe( NS_IMAGE, $index_title->getText() ); |
1124 | 1164 | if ( $imageTitle ) { |