Index: branches/REL1_3/phase3/includes/Parser.php |
— | — | @@ -50,7 +50,7 @@ |
51 | 51 | { |
52 | 52 | # Persistent: |
53 | 53 | var $mTagHooks; |
54 | | - |
| 54 | + |
55 | 55 | # Cleared with clearState(): |
56 | 56 | var $mOutput, $mAutonumber, $mDTopen, $mStripState = array(); |
57 | 57 | var $mVariables, $mIncludeCount, $mArgStack, $mLastSection, $mInPre; |
— | — | @@ -102,9 +102,9 @@ |
103 | 103 | $fixtags = array( |
104 | 104 | # french spaces, last one Guillemet-left |
105 | 105 | # only if there is something before the space |
106 | | - '/(.) (\\?|:|;|!|\\302\\273)/i' => '\\1 \\2', |
| 106 | + '/(.) (\\?|:|;|!|\\302\\273)/i' => '\\1 \\2', |
107 | 107 | # french spaces, Guillemet-right |
108 | | - "/(\\302\\253) /i"=>"\\1 ", |
| 108 | + "/(\\302\\253) /i"=>"\\1 ", |
109 | 109 | '/<hr *>/i' => '<hr />', |
110 | 110 | '/<br *>/i' => '<br />', |
111 | 111 | '/<center *>/i' => '<div class="center">', |
— | — | @@ -117,10 +117,10 @@ |
118 | 118 | } else { |
119 | 119 | $fixtags = array( |
120 | 120 | # french spaces, last one Guillemet-left |
121 | | - '/ (\\?|:|!|\\302\\273)/i' => ' \\1', |
| 121 | + '/ (\\?|:|!|\\302\\273)/i' => ' \\1', |
122 | 122 | # french spaces, Guillemet-right |
123 | | - '/(\\302\\253) /i' => '\\1 ', |
124 | | - '/([^> ]+(0(1|3|9);)[^< ]*)/i' => '<span class="diacrit">\\1</span>', |
| 123 | + '/(\\302\\253) /i' => '\\1 ', |
| 124 | + '/([^> ]+(0(1|3|9);)[^< ]*)/i' => '<span class="diacrit">\\1</span>', |
125 | 125 | '/<center *>/i' => '<div class="center">', |
126 | 126 | '/<\\/center *>/i' => '</div>' |
127 | 127 | ); |
— | — | @@ -199,7 +199,7 @@ |
200 | 200 | $pre_content = array(); |
201 | 201 | $comment_content = array(); |
202 | 202 | $ext_content = array(); |
203 | | - |
| 203 | + |
204 | 204 | # Replace any instances of the placeholders |
205 | 205 | $uniq_prefix = UNIQ_PREFIX; |
206 | 206 | #$text = str_replace( $uniq_prefix, wfHtmlEscapeFirst( $uniq_prefix ), $text ); |
— | — | @@ -266,7 +266,7 @@ |
267 | 267 | $state['math'] = $state['math'] + $math_content; |
268 | 268 | $state['pre'] = $state['pre'] + $pre_content; |
269 | 269 | $state['comment'] = $state['comment'] + $comment_content; |
270 | | - |
| 270 | + |
271 | 271 | foreach( $ext_content as $tag => $array ) { |
272 | 272 | if ( array_key_exists( $tag, $state ) ) { |
273 | 273 | $state[$tag] = $state[$tag] + $array; |
— | — | @@ -297,7 +297,7 @@ |
298 | 298 | |
299 | 299 | return $text; |
300 | 300 | } |
301 | | - # always call this after unstrip() to preserve the order |
| 301 | + # always call this after unstrip() to preserve the order |
302 | 302 | function unstripNoWiki( $text, &$state ) { |
303 | 303 | # Must expand in reverse order, otherwise nested tags will be corrupted |
304 | 304 | for ( $content = end($state['nowiki']); $content !== false; $content = prev( $state['nowiki'] ) ) { |
— | — | @@ -423,8 +423,8 @@ |
424 | 424 | |
425 | 425 | # FIXME: add limits |
426 | 426 | $t = wfStrencode( $this->mTitle->getDBKey() ); |
427 | | - $sql = "SELECT DISTINCT cur_title,cur_namespace,cl_sortkey FROM |
428 | | -cur,categorylinks WHERE cl_to='$t' AND cl_from=cur_id ORDER BY |
| 427 | + $sql = "SELECT DISTINCT cur_title,cur_namespace,cl_sortkey FROM |
| 428 | +cur,categorylinks WHERE cl_to='$t' AND cl_from=cur_id ORDER BY |
429 | 429 | cl_sortkey" ; |
430 | 430 | $res = wfQuery ( $sql, DB_READ ) ; |
431 | 431 | while ( $x = wfFetchObject ( $res ) ) |
— | — | @@ -432,7 +432,7 @@ |
433 | 433 | $t = $ns = $wgLang->getNsText ( $x->cur_namespace ) ; |
434 | 434 | if ( $t != '' ) $t .= ':' ; |
435 | 435 | $t .= $x->cur_title ; |
436 | | - |
| 436 | + |
437 | 437 | if ( $x->cur_namespace == $cns ) { |
438 | 438 | $ctitle = str_replace( '_',' ',$x->cur_title ); |
439 | 439 | array_push ( $children, $sk->makeKnownLink ( $t, $ctitle ) ) ; # Subcategory |
— | — | @@ -462,22 +462,22 @@ |
463 | 463 | $r .= '<h2>' . wfMsg( 'subcategories' ) . "</h2>\n" |
464 | 464 | . wfMsg( 'subcategorycount', count( $children ) ); |
465 | 465 | if ( count ( $children ) > 6 ) { |
466 | | - |
| 466 | + |
467 | 467 | // divide list into three equal chunks |
468 | 468 | $chunk = (int) (count ( $children ) / 3); |
469 | 469 | |
470 | 470 | // get and display header |
471 | 471 | $r .= '<table width="100%"><tr valign="top">'; |
472 | | - |
| 472 | + |
473 | 473 | $startChunk = 0; |
474 | 474 | $endChunk = $chunk; |
475 | | - |
| 475 | + |
476 | 476 | // loop through the chunks |
477 | | - for($startChunk = 0, $endChunk = $chunk, $chunkIndex = 0; |
| 477 | + for($startChunk = 0, $endChunk = $chunk, $chunkIndex = 0; |
478 | 478 | $chunkIndex < 3; |
479 | 479 | $chunkIndex++, $startChunk = $endChunk, $endChunk += $chunk + 1) |
480 | 480 | { |
481 | | - |
| 481 | + |
482 | 482 | $r .= '<td><ul>'; |
483 | 483 | // output all subcategories to category |
484 | 484 | for ($index = $startChunk ; |
— | — | @@ -490,17 +490,17 @@ |
491 | 491 | { |
492 | 492 | $r .= "</ul><h3>{$children_start_char[$index]}</h3>\n<ul>"; |
493 | 493 | } |
494 | | - |
| 494 | + |
495 | 495 | $r .= "<li>{$children[$index]}</li>"; |
496 | 496 | } |
497 | 497 | $r .= '</ul></td>'; |
498 | | - |
499 | | - |
| 498 | + |
| 499 | + |
500 | 500 | } |
501 | 501 | $r .= '</tr></table>'; |
502 | 502 | } else { |
503 | 503 | // for short lists of subcategories to category. |
504 | | - |
| 504 | + |
505 | 505 | $r .= "<h3>{$children_start_char[0]}</h3>\n"; |
506 | 506 | $r .= '<ul><li>'.$children[0].'</li>'; |
507 | 507 | for ($index = 1; $index < count($children); $index++ ) |
— | — | @@ -509,7 +509,7 @@ |
510 | 510 | { |
511 | 511 | $r .= "</ul><h3>{$children_start_char[$index]}</h3>\n<ul>"; |
512 | 512 | } |
513 | | - |
| 513 | + |
514 | 514 | $r .= "<li>{$children[$index]}</li>"; |
515 | 515 | } |
516 | 516 | $r .= '</ul>'; |
— | — | @@ -522,21 +522,21 @@ |
523 | 523 | # Showing articles in this category |
524 | 524 | if ( count ( $articles ) > 6) { |
525 | 525 | $ti = $this->mTitle->getText() ; |
526 | | - |
| 526 | + |
527 | 527 | // divide list into three equal chunks |
528 | 528 | $chunk = (int) (count ( $articles ) / 3); |
529 | | - |
| 529 | + |
530 | 530 | // get and display header |
531 | 531 | $r .= '<table width="100%"><tr valign="top">'; |
532 | | - |
| 532 | + |
533 | 533 | // loop through the chunks |
534 | | - for($startChunk = 0, $endChunk = $chunk, $chunkIndex = 0; |
| 534 | + for($startChunk = 0, $endChunk = $chunk, $chunkIndex = 0; |
535 | 535 | $chunkIndex < 3; |
536 | 536 | $chunkIndex++, $startChunk = $endChunk, $endChunk += $chunk + 1) |
537 | 537 | { |
538 | | - |
| 538 | + |
539 | 539 | $r .= '<td><ul>'; |
540 | | - |
| 540 | + |
541 | 541 | // output all articles in category |
542 | 542 | for ($index = $startChunk ; |
543 | 543 | $index < $endChunk && $index < count($articles); |
— | — | @@ -548,18 +548,18 @@ |
549 | 549 | { |
550 | 550 | $r .= "</ul><h3>{$articles_start_char[$index]}</h3>\n<ul>"; |
551 | 551 | } |
552 | | - |
| 552 | + |
553 | 553 | $r .= "<li>{$articles[$index]}</li>"; |
554 | 554 | } |
555 | 555 | $r .= '</ul></td>'; |
556 | | - |
557 | | - |
| 556 | + |
| 557 | + |
558 | 558 | } |
559 | 559 | $r .= '</tr></table>'; |
560 | 560 | } elseif ( count ( $articles ) > 0) { |
561 | 561 | // for short lists of articles in categories. |
562 | 562 | $ti = $this->mTitle->getText() ; |
563 | | - |
| 563 | + |
564 | 564 | $r .= '<h3>'.$articles_start_char[0]."</h3>\n"; |
565 | 565 | $r .= '<ul><li>'.$articles[0].'</li>'; |
566 | 566 | for ($index = 1; $index < count($articles); $index++ ) |
— | — | @@ -568,7 +568,7 @@ |
569 | 569 | { |
570 | 570 | $r .= "</ul><h3>{$articles_start_char[$index]}</h3>\n<ul>"; |
571 | 571 | } |
572 | | - |
| 572 | + |
573 | 573 | $r .= "<li>{$articles[$index]}</li>"; |
574 | 574 | } |
575 | 575 | $r .= '</ul>'; |
— | — | @@ -624,7 +624,7 @@ |
625 | 625 | global $wgInputEncoding, $wgOutputEncoding; |
626 | 626 | $fname = 'Parser::tidy'; |
627 | 627 | wfProfileIn( $fname ); |
628 | | - |
| 628 | + |
629 | 629 | $cleansource = ''; |
630 | 630 | switch(strtoupper($wgOutputEncoding)) { |
631 | 631 | case 'ISO-8859-1': |
— | — | @@ -657,7 +657,7 @@ |
658 | 658 | } |
659 | 659 | |
660 | 660 | wfProfileOut( $fname ); |
661 | | - |
| 661 | + |
662 | 662 | if( $cleansource == '' && $text != '') { |
663 | 663 | wfDebug( "Tidy error detected!\n" ); |
664 | 664 | return $text . "\n<!-- Tidy found serious XHTML errors -->\n"; |
— | — | @@ -768,13 +768,13 @@ |
769 | 769 | |
770 | 770 | # Parses the text and adds the result to the strip state |
771 | 771 | # Returns the strip tag |
772 | | - function stripParse( $text, $newline, $args ) |
| 772 | + function stripParse( $text, $newline, $args ) |
773 | 773 | { |
774 | 774 | $text = $this->strip( $text, $this->mStripState ); |
775 | 775 | $text = $this->internalParse( $text, (bool)$newline, $args, false ); |
776 | 776 | return $newline.$this->insertStripItem( $text, $this->mStripState ); |
777 | 777 | } |
778 | | - |
| 778 | + |
779 | 779 | function internalParse( $text, $linestart, $args = array(), $isMain=true ) { |
780 | 780 | $fname = 'Parser::internalParse'; |
781 | 781 | wfProfileIn( $fname ); |
— | — | @@ -809,7 +809,7 @@ |
810 | 810 | wfProfileOut( $fname ); |
811 | 811 | return $text; |
812 | 812 | } |
813 | | - |
| 813 | + |
814 | 814 | # Parse ^^ tokens and return html |
815 | 815 | /* private */ function doExponent ( $text ) |
816 | 816 | { |
— | — | @@ -845,7 +845,7 @@ |
846 | 846 | wfProfileOut( $fname ); |
847 | 847 | return $outtext; |
848 | 848 | } |
849 | | - |
| 849 | + |
850 | 850 | /* private */ function &doMagicLinks( &$text ) { |
851 | 851 | $text = $this->magicISBN( $text ); |
852 | 852 | $text = $this->magicRFC( $text ); |
— | — | @@ -884,8 +884,9 @@ |
885 | 885 | } |
886 | 886 | # Count the number of occurrences of bold and italics mark-ups. |
887 | 887 | # We are not counting sequences of five apostrophes. |
888 | | - if (strlen ($arr[$i]) == 2) $numitalics++; else |
889 | | - if (strlen ($arr[$i]) == 3) $numbold++; |
| 888 | + if (strlen ($arr[$i]) == 2) $numitalics++; else |
| 889 | + if (strlen ($arr[$i]) == 3) $numbold++; else |
| 890 | + if (strlen ($arr[$i]) == 5) { $numitalics++; $numbold++; } |
890 | 891 | } |
891 | 892 | $i++; |
892 | 893 | } |
— | — | @@ -910,7 +911,7 @@ |
911 | 912 | if ($firstspace == -1) $firstspace = $i; |
912 | 913 | } else if ($x2 == " ") { |
913 | 914 | if ($firstsingleletterword == -1) $firstsingleletterword = $i; |
914 | | - } else { |
| 915 | + } else { |
915 | 916 | if ($firstmultiletterword == -1) $firstmultiletterword = $i; |
916 | 917 | } |
917 | 918 | } |
— | — | @@ -922,7 +923,7 @@ |
923 | 924 | { |
924 | 925 | $arr [ $firstsingleletterword ] = "''"; |
925 | 926 | $arr [ $firstsingleletterword-1 ] .= "'"; |
926 | | - } |
| 927 | + } |
927 | 928 | # If not, but there's a multi-letter word, use that one. |
928 | 929 | else if ($firstmultiletterword > -1) |
929 | 930 | { |
— | — | @@ -930,7 +931,9 @@ |
931 | 932 | $arr [ $firstmultiletterword-1 ] .= "'"; |
932 | 933 | } |
933 | 934 | # ... otherwise use the first one that has neither. |
934 | | - else |
| 935 | + # (notice that it is possible for all three to be -1 if, for example, |
| 936 | + # there is only one pentuple-apostrophe in the line) |
| 937 | + else if ($firstspace > -1) |
935 | 938 | { |
936 | 939 | $arr [ $firstspace ] = "''"; |
937 | 940 | $arr [ $firstspace-1 ] .= "'"; |
— | — | @@ -1160,7 +1163,7 @@ |
1161 | 1164 | } |
1162 | 1165 | } |
1163 | 1166 | wfProfileOut( $fname.'-prefixhandling' ); |
1164 | | - |
| 1167 | + |
1165 | 1168 | if ( preg_match( $e1, $line, $m ) ) { # page with normal text or alt |
1166 | 1169 | $text = $m[2]; |
1167 | 1170 | # fix up urlencoded title texts |
— | — | @@ -1428,7 +1431,7 @@ |
1429 | 1432 | $paragraphStack = false; |
1430 | 1433 | $output .= $this->closeParagraph(); |
1431 | 1434 | if($preOpenMatch and !$preCloseMatch) { |
1432 | | - $this->mInPre = true; |
| 1435 | + $this->mInPre = true; |
1433 | 1436 | } |
1434 | 1437 | if ( $closematch ) { |
1435 | 1438 | $inBlockElem = false; |
— | — | @@ -1552,12 +1555,12 @@ |
1553 | 1556 | |
1554 | 1557 | # PHP global rebinding syntax is a bit weird, need to use the GLOBALS array |
1555 | 1558 | $GLOBALS['wgCurParser'] =& $this; |
1556 | | - |
1557 | 1559 | |
| 1560 | + |
1558 | 1561 | if ( $this->mOutputType == OT_HTML ) { |
1559 | 1562 | # Variable substitution |
1560 | 1563 | $text = preg_replace_callback( "/{{([$nonBraceChars]*?)}}/", 'wfVariableSubstitution', $text ); |
1561 | | - |
| 1564 | + |
1562 | 1565 | # Argument substitution |
1563 | 1566 | $text = preg_replace_callback( "/(\\n?){{{([$titleChars]*?)}}}/", 'wfArgSubstitution', $text ); |
1564 | 1567 | } |
— | — | @@ -1612,7 +1615,7 @@ |
1613 | 1616 | $found = false; |
1614 | 1617 | $nowiki = false; |
1615 | 1618 | $noparse = false; |
1616 | | - |
| 1619 | + |
1617 | 1620 | $title = NULL; |
1618 | 1621 | |
1619 | 1622 | # $newline is an optional newline character before the braces |
— | — | @@ -1625,7 +1628,7 @@ |
1626 | 1629 | |
1627 | 1630 | $args = $this->getTemplateArgs($matches[3]); |
1628 | 1631 | $argc = count( $args ); |
1629 | | - |
| 1632 | + |
1630 | 1633 | # {{{}}} |
1631 | 1634 | if ( strpos( $matches[0], '{{{' ) !== false ) { |
1632 | 1635 | $text = $matches[0]; |
— | — | @@ -1811,7 +1814,7 @@ |
1812 | 1815 | if ( array_key_exists( $arg, $inputArgs ) ) { |
1813 | 1816 | $text = $this->stripParse( $inputArgs[$arg], $newline, array() ); |
1814 | 1817 | } |
1815 | | - |
| 1818 | + |
1816 | 1819 | return $text; |
1817 | 1820 | } |
1818 | 1821 | |
— | — | @@ -1833,7 +1836,7 @@ |
1834 | 1837 | global $wgUseTidy, $wgUserHtml; |
1835 | 1838 | $fname = 'Parser::removeHTMLtags'; |
1836 | 1839 | wfProfileIn( $fname ); |
1837 | | - |
| 1840 | + |
1838 | 1841 | if( $wgUserHtml ) { |
1839 | 1842 | $htmlpairs = array( # Tags that must be closed |
1840 | 1843 | 'b', 'del', 'i', 'ins', 'u', 'font', 'big', 'small', 'sub', 'sup', 'h1', |
— | — | @@ -1938,7 +1941,7 @@ |
1939 | 1942 | } else { |
1940 | 1943 | $text .= '<' . str_replace( '>', '>', $x); |
1941 | 1944 | } |
1942 | | - } |
| 1945 | + } |
1943 | 1946 | } |
1944 | 1947 | wfProfileOut( $fname ); |
1945 | 1948 | return $text; |
— | — | @@ -1960,7 +1963,7 @@ |
1961 | 1964 | |
1962 | 1965 | /* private */ function formatHeadings( $text, $isMain=true ) { |
1963 | 1966 | global $wgInputEncoding, $wgMaxTocLevel; |
1964 | | - |
| 1967 | + |
1965 | 1968 | $doNumberHeadings = $this->mOptions->getNumberHeadings(); |
1966 | 1969 | $doShowToc = $this->mOptions->getShowToc(); |
1967 | 1970 | $forceTocHere = false; |
— | — | @@ -2013,9 +2016,9 @@ |
2014 | 2017 | $doShowToc = 1; |
2015 | 2018 | } |
2016 | 2019 | } |
2017 | | - |
2018 | 2020 | |
2019 | 2021 | |
| 2022 | + |
2020 | 2023 | # We need this to perform operations on the HTML |
2021 | 2024 | $sk =& $this->mOptions->getSkin(); |
2022 | 2025 | |
— | — | @@ -2195,7 +2198,7 @@ |
2196 | 2199 | } |
2197 | 2200 | return $text; |
2198 | 2201 | } |
2199 | | - |
| 2202 | + |
2200 | 2203 | # Return an HTML link for the "RFC 1234" text |
2201 | 2204 | /* private */ function magicRFC( $text ) { |
2202 | 2205 | global $wgLang; |