Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -93,7 +93,7 @@ |
94 | 94 | var $mTagHooks, $mTransparentTagHooks, $mFunctionHooks, $mFunctionSynonyms, $mVariables, |
95 | 95 | $mImageParams, $mImageParamsMagicArray, $mStripList, $mMarkerIndex, $mPreprocessor, |
96 | 96 | $mExtLinkBracketedRegex, $mUrlProtocols, $mDefaultStripList, $mVarCache, $mConf, |
97 | | - $mFunctionTagHooks; |
| 97 | + $mFunctionTagHooks, $mDoTitleConvert, $mDoContentConvert; |
98 | 98 | |
99 | 99 | |
100 | 100 | # Cleared with clearState(): |
— | — | @@ -147,6 +147,8 @@ |
148 | 148 | } |
149 | 149 | $this->mMarkerIndex = 0; |
150 | 150 | $this->mFirstCall = true; |
| 151 | + $this->mDoTitleConvert = true; |
| 152 | + $this->mDoContentConvert = true; |
151 | 153 | } |
152 | 154 | |
153 | 155 | /** |
— | — | @@ -314,7 +316,8 @@ |
315 | 317 | } |
316 | 318 | |
317 | 319 | $this->mOptions = $options; |
318 | | - $this->setTitle( $title ); |
| 320 | + $this->setTitle( $title ); // Page title has to be set for the pre-processor |
| 321 | + |
319 | 322 | $oldRevisionId = $this->mRevisionId; |
320 | 323 | $oldRevisionTimestamp = $this->mRevisionTimestamp; |
321 | 324 | if( $revid !== null ) { |
— | — | @@ -326,6 +329,11 @@ |
327 | 330 | # No more strip! |
328 | 331 | wfRunHooks( 'ParserAfterStrip', array( &$this, &$text, &$this->mStripState ) ); |
329 | 332 | $text = $this->internalParse( $text ); |
| 333 | + // internalParse took care of the notitleconvert bit, so title conversion is here. |
| 334 | + if ( $this->mDoTitleConvert && !$this->mTitle->isConversionTable()) { |
| 335 | + $this->setTitle( Title::newFromText( $wgContLang->convert( $title ) ) ); |
| 336 | + } |
| 337 | + |
330 | 338 | $text = $this->mStripState->unstripGeneral( $text ); |
331 | 339 | |
332 | 340 | # Clean up special characters, only run once, next-to-last before doBlockLevels |
— | — | @@ -343,11 +351,12 @@ |
344 | 352 | |
345 | 353 | $this->replaceLinkHolders( $text ); |
346 | 354 | |
347 | | - # the position of the parserConvert() call should not be changed. it |
| 355 | + # the position of the convert() call should not be changed. it |
348 | 356 | # assumes that the links are all replaced and the only thing left |
349 | 357 | # is the <nowiki> mark. |
350 | | - # Side-effects: this calls $this->mOutput->setTitleText() |
351 | | - $text = $wgContLang->parserConvert( $text, $this ); |
| 358 | + if ( $this->mDoContentConvert && !$this->mTitle->isConversionTable()) { |
| 359 | + $text = $wgContLang->convert( $text ); |
| 360 | + } |
352 | 361 | |
353 | 362 | $text = $this->mStripState->unstripNoWiki( $text ); |
354 | 363 | |
— | — | @@ -654,14 +663,14 @@ |
655 | 664 | $this->mStripState->general->setPair( $rnd, $text ); |
656 | 665 | return $rnd; |
657 | 666 | } |
658 | | - |
| 667 | + |
659 | 668 | /** |
660 | 669 | * Interface with html tidy |
661 | 670 | * @deprecated Use MWTidy::tidy() |
662 | 671 | */ |
663 | 672 | public static function tidy( $text ) { |
664 | 673 | wfDeprecated( __METHOD__ ); |
665 | | - return MWTidy::tidy( $text ); |
| 674 | + return MWTidy::tidy( $text ); |
666 | 675 | } |
667 | 676 | |
668 | 677 | /** |
— | — | @@ -870,7 +879,7 @@ |
871 | 880 | */ |
872 | 881 | function internalParse( $text, $isMain = true, $frame=false ) { |
873 | 882 | wfProfileIn( __METHOD__ ); |
874 | | - |
| 883 | + |
875 | 884 | $origText = $text; |
876 | 885 | |
877 | 886 | # Hook to suspend the parser in this state |
— | — | @@ -883,7 +892,7 @@ |
884 | 893 | if ($frame) { |
885 | 894 | // use frame depth to infer how include/noinclude tags should be handled |
886 | 895 | // depth=0 means this is the top-level document; otherwise it's an included document |
887 | | - if( !$frame->depth ) |
| 896 | + if( !$frame->depth ) |
888 | 897 | $flag = 0; |
889 | 898 | else |
890 | 899 | $flag = Parser::PTD_FOR_INCLUSION; |
— | — | @@ -907,6 +916,7 @@ |
908 | 917 | $text = preg_replace( '/(^|\n)-----*/', '\\1<hr />', $text ); |
909 | 918 | |
910 | 919 | $text = $this->doDoubleUnderscore( $text ); |
| 920 | + |
911 | 921 | $text = $this->doHeadings( $text ); |
912 | 922 | if( $this->mOptions->getUseDynamicDates() ) { |
913 | 923 | $df = DateFormatter::getInstance(); |
— | — | @@ -930,7 +940,7 @@ |
931 | 941 | /** |
932 | 942 | * Replace special strings like "ISBN xxx" and "RFC xxx" with |
933 | 943 | * magic external links. |
934 | | - * |
| 944 | + * |
935 | 945 | * DML |
936 | 946 | * @private |
937 | 947 | */ |
— | — | @@ -940,7 +950,7 @@ |
941 | 951 | $urlChar = self::EXT_LINK_URL_CLASS; |
942 | 952 | $text = preg_replace_callback( |
943 | 953 | '!(?: # Start cases |
944 | | - (<a.*?</a>) | # m[1]: Skip link text |
| 954 | + (<a.*?</a>) | # m[1]: Skip link text |
945 | 955 | (<.*?>) | # m[2]: Skip stuff inside HTML elements' . " |
946 | 956 | (\\b(?:$prots)$urlChar+) | # m[3]: Free external links" . ' |
947 | 957 | (?:RFC|PMID)\s+([0-9]+) | # m[4]: RFC or PMID, capture number |
— | — | @@ -1042,7 +1052,7 @@ |
1043 | 1053 | $text = $this->maybeMakeExternalImage( $url ); |
1044 | 1054 | if ( $text === false ) { |
1045 | 1055 | # Not an image, make a link |
1046 | | - $text = $sk->makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free', |
| 1056 | + $text = $sk->makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free', |
1047 | 1057 | $this->getExternalLinkAttribs( $url ) ); |
1048 | 1058 | # Register it in the output object... |
1049 | 1059 | # Replace unnecessary URL escape codes with their equivalent characters |
— | — | @@ -1482,7 +1492,7 @@ |
1483 | 1493 | wfProfileIn( __METHOD__.'-setup' ); |
1484 | 1494 | static $tc = FALSE, $e1, $e1_img; |
1485 | 1495 | # the % is needed to support urlencoded titles as well |
1486 | | - if ( !$tc ) { |
| 1496 | + if ( !$tc ) { |
1487 | 1497 | $tc = Title::legalChars() . '#%'; |
1488 | 1498 | # Match a link having the form [[namespace:link|alternate]]trail |
1489 | 1499 | $e1 = "/^([{$tc}]+)(?:\\|(.+?))?]](.*)\$/sD"; |
— | — | @@ -2016,7 +2026,7 @@ |
2017 | 2027 | } |
2018 | 2028 | } elseif( $prefixLength || $lastPrefixLength ) { |
2019 | 2029 | // We need to open or close prefixes, or both. |
2020 | | - |
| 2030 | + |
2021 | 2031 | # Either open or close a level... |
2022 | 2032 | $commonPrefixLength = $this->getCommon( $prefix, $lastPrefix ); |
2023 | 2033 | $paragraphStack = false; |
— | — | @@ -2026,12 +2036,12 @@ |
2027 | 2037 | $output .= $this->closeList( $lastPrefix[$lastPrefixLength-1] ); |
2028 | 2038 | --$lastPrefixLength; |
2029 | 2039 | } |
2030 | | - |
| 2040 | + |
2031 | 2041 | // Continue the current prefix if appropriate. |
2032 | 2042 | if ( $prefixLength <= $commonPrefixLength && $commonPrefixLength > 0 ) { |
2033 | 2043 | $output .= $this->nextItem( $prefix[$commonPrefixLength-1] ); |
2034 | 2044 | } |
2035 | | - |
| 2045 | + |
2036 | 2046 | // Open prefixes where appropriate. |
2037 | 2047 | while ( $prefixLength > $commonPrefixLength ) { |
2038 | 2048 | $char = substr( $prefix, $commonPrefixLength, 1 ); |
— | — | @@ -2048,7 +2058,7 @@ |
2049 | 2059 | } |
2050 | 2060 | $lastPrefix = $prefix2; |
2051 | 2061 | } |
2052 | | - |
| 2062 | + |
2053 | 2063 | // If we have no prefixes, go to paragraph mode. |
2054 | 2064 | if( 0 == $prefixLength ) { |
2055 | 2065 | wfProfileIn( __METHOD__."-paragraph" ); |
— | — | @@ -2592,7 +2602,7 @@ |
2593 | 2603 | return null; |
2594 | 2604 | } |
2595 | 2605 | |
2596 | | - if ( $index ) |
| 2606 | + if ( $index ) |
2597 | 2607 | $this->mVarCache[$index] = $value; |
2598 | 2608 | |
2599 | 2609 | return $value; |
— | — | @@ -2665,7 +2675,7 @@ |
2666 | 2676 | * self::OT_HTML: all templates and extension tags |
2667 | 2677 | * |
2668 | 2678 | * @param string $tex The text to transform |
2669 | | - * @param PPFrame $frame Object describing the arguments passed to the template. |
| 2679 | + * @param PPFrame $frame Object describing the arguments passed to the template. |
2670 | 2680 | * Arguments may also be provided as an associative array, as was the usual case before MW1.12. |
2671 | 2681 | * Providing arguments this way may be useful for extensions wishing to perform variable replacement explicitly. |
2672 | 2682 | * @param bool $argsOnly Only do argument (triple-brace) expansion, not double-brace expansion |
— | — | @@ -2729,7 +2739,7 @@ |
2730 | 2740 | */ |
2731 | 2741 | function limitationWarn( $limitationType, $current=null, $max=null) { |
2732 | 2742 | //does no harm if $current and $max are present but are unnecessary for the message |
2733 | | - $warning = wfMsgExt( "$limitationType-warning", array( 'parsemag', 'escape' ), $current, $max ); |
| 2743 | + $warning = wfMsgExt( "$limitationType-warning", array( 'parsemag', 'escape' ), $current, $max ); |
2734 | 2744 | $this->mOutput->addWarning( $warning ); |
2735 | 2745 | $this->addTrackingCategory( "$limitationType-category" ); |
2736 | 2746 | } |
— | — | @@ -2870,7 +2880,7 @@ |
2871 | 2881 | $found = true; |
2872 | 2882 | $noparse = true; |
2873 | 2883 | $preprocessFlags = 0; |
2874 | | - |
| 2884 | + |
2875 | 2885 | if ( is_array( $result ) ) { |
2876 | 2886 | if ( isset( $result[0] ) ) { |
2877 | 2887 | $text = $result[0]; |
— | — | @@ -3376,7 +3386,9 @@ |
3377 | 3387 | * Fills $this->mDoubleUnderscores, returns the modified text |
3378 | 3388 | */ |
3379 | 3389 | function doDoubleUnderscore( $text ) { |
| 3390 | + global $wgDisableLangConversion; |
3380 | 3391 | wfProfileIn( __METHOD__ ); |
| 3392 | + |
3381 | 3393 | // The position of __TOC__ needs to be recorded |
3382 | 3394 | $mw = MagicWord::get( 'toc' ); |
3383 | 3395 | if( $mw->match( $text ) ) { |
— | — | @@ -3416,10 +3428,23 @@ |
3417 | 3429 | $this->mOutput->setIndexPolicy( 'index' ); |
3418 | 3430 | $this->addTrackingCategory( 'index-category' ); |
3419 | 3431 | } |
| 3432 | + |
| 3433 | + if ( !$wgDisableLangConversion ) { |
| 3434 | + if( isset( $this->mDoubleUnderscores['notitleconvert'] ) ){ |
| 3435 | + $this->mDoTitleConvert = false; |
| 3436 | + } |
| 3437 | + |
| 3438 | + // Don't convert talk pages |
| 3439 | + if( isset( $this->mDoubleUnderscores['nocontentconvert'] ) |
| 3440 | + && !$this->mTitle->isTalkPage() ){ |
| 3441 | + $this->mDoContentConvert = false; |
| 3442 | + } |
| 3443 | + } |
| 3444 | + |
3420 | 3445 | wfProfileOut( __METHOD__ ); |
3421 | 3446 | return $text; |
3422 | | - } |
3423 | | - |
| 3447 | + } |
| 3448 | + |
3424 | 3449 | /** |
3425 | 3450 | * Add a tracking category, getting the title from a system message, |
3426 | 3451 | * or print a debug message if the title is invalid. |
— | — | @@ -3428,10 +3453,10 @@ |
3429 | 3454 | */ |
3430 | 3455 | protected function addTrackingCategory( $msg ){ |
3431 | 3456 | $cat = wfMsgForContent( $msg ); |
3432 | | - |
| 3457 | + |
3433 | 3458 | # Allow tracking categories to be disabled by setting them to "-" |
3434 | 3459 | if( $cat === '-' ) return false; |
3435 | | - |
| 3460 | + |
3436 | 3461 | $containerCategory = Title::makeTitleSafe( NS_CATEGORY, $cat ); |
3437 | 3462 | if ( $containerCategory ) { |
3438 | 3463 | $this->mOutput->addCategory( $containerCategory->getDBkey(), $this->getDefaultSort() ); |
— | — | @@ -3707,7 +3732,7 @@ |
3708 | 3733 | $toc .= $sk->tocLine($anchor, $tocline, |
3709 | 3734 | $numbering, $toclevel, ($isTemplate ? false : $sectionIndex)); |
3710 | 3735 | } |
3711 | | - |
| 3736 | + |
3712 | 3737 | # Add the section to the section tree |
3713 | 3738 | # Find the DOM node for this header |
3714 | 3739 | while ( $node && !$isTemplate ) { |
— | — | @@ -3716,11 +3741,11 @@ |
3717 | 3742 | if ( $bits['i'] == $sectionIndex ) |
3718 | 3743 | break; |
3719 | 3744 | } |
3720 | | - $byteOffset += mb_strlen( $this->mStripState->unstripBoth( |
| 3745 | + $byteOffset += mb_strlen( $this->mStripState->unstripBoth( |
3721 | 3746 | $frame->expand( $node, PPFrame::RECOVER_ORIG ) ) ); |
3722 | 3747 | $node = $node->getNextSibling(); |
3723 | 3748 | } |
3724 | | - $tocraw[] = array( |
| 3749 | + $tocraw[] = array( |
3725 | 3750 | 'toclevel' => $toclevel, |
3726 | 3751 | 'level' => $level, |
3727 | 3752 | 'line' => $tocline, |
— | — | @@ -3730,7 +3755,7 @@ |
3731 | 3756 | 'byteoffset' => ( $isTemplate ? null : $byteOffset ), |
3732 | 3757 | 'anchor' => $anchor, |
3733 | 3758 | ); |
3734 | | - |
| 3759 | + |
3735 | 3760 | # give headline the correct <h#> tag |
3736 | 3761 | if( $showEditLink && $sectionIndex !== false ) { |
3737 | 3762 | if( $isTemplate ) { |
— | — | @@ -3764,7 +3789,7 @@ |
3765 | 3790 | $toc = $sk->tocList( $toc ); |
3766 | 3791 | $this->mOutput->setTOCHTML( $toc ); |
3767 | 3792 | } |
3768 | | - |
| 3793 | + |
3769 | 3794 | if ( $isMain ) { |
3770 | 3795 | $this->mOutput->setSections( $tocraw ); |
3771 | 3796 | } |
— | — | @@ -3773,7 +3798,7 @@ |
3774 | 3799 | |
3775 | 3800 | $blocks = preg_split( '/<H[1-6].*?' . '>.*?<\/H[1-6]>/i', $text ); |
3776 | 3801 | $i = 0; |
3777 | | - |
| 3802 | + |
3778 | 3803 | foreach( $blocks as $block ) { |
3779 | 3804 | if( $showEditLink && $headlineCount > 0 && $i == 0 && $block !== "\n" ) { |
3780 | 3805 | # This is the [edit] link that appears for the top block of text when |
— | — | @@ -3800,7 +3825,7 @@ |
3801 | 3826 | return $full; |
3802 | 3827 | } |
3803 | 3828 | } |
3804 | | - |
| 3829 | + |
3805 | 3830 | /** |
3806 | 3831 | * Merge $tree2 into $tree1 by replacing the section with index |
3807 | 3832 | * $section in $tree1 and its descendants with the sections in $tree2. |
— | — | @@ -3823,7 +3848,7 @@ |
3824 | 3849 | $numbering = array( 0 ); |
3825 | 3850 | $titletext = $title->getPrefixedDBkey(); |
3826 | 3851 | foreach ( $tree1 as $s ) { |
3827 | | - if ( $targetLevel !== false ) { |
| 3852 | + if ( $targetLevel !== false ) { |
3828 | 3853 | if ( $s['level'] <= $targetLevel ) |
3829 | 3854 | // We've skipped enough |
3830 | 3855 | $targetLevel = false; |
— | — | @@ -3834,7 +3859,7 @@ |
3835 | 3860 | $s['fromtitle'] != $titletext ) { |
3836 | 3861 | self::incrementNumbering( $numbering, |
3837 | 3862 | $s['toclevel'], $lastLevel ); |
3838 | | - |
| 3863 | + |
3839 | 3864 | // Rewrite index, byteoffset and number |
3840 | 3865 | if ( $s['fromtitle'] == $titletext ) { |
3841 | 3866 | $s['index'] = $nextIndex++; |
— | — | @@ -3856,7 +3881,7 @@ |
3857 | 3882 | $s2['level'] += $s['level'] - 1; |
3858 | 3883 | $s2['index'] = $nextIndex++; |
3859 | 3884 | $s2['byteoffset'] += $s['byteoffset']; |
3860 | | - |
| 3885 | + |
3861 | 3886 | self::incrementNumbering( $numbering, |
3862 | 3887 | $s2['toclevel'], $lastLevel ); |
3863 | 3888 | $s2['number'] = implode( '.', array_map( |
— | — | @@ -3872,7 +3897,7 @@ |
3873 | 3898 | } |
3874 | 3899 | return $newTree; |
3875 | 3900 | } |
3876 | | - |
| 3901 | + |
3877 | 3902 | /** |
3878 | 3903 | * Increment a section number. Helper function for mergeSectionTrees() |
3879 | 3904 | * @param $number array Array representing a section number |
— | — | @@ -3890,7 +3915,7 @@ |
3891 | 3916 | } else |
3892 | 3917 | $number[$level - 1]++; |
3893 | 3918 | } |
3894 | | - |
| 3919 | + |
3895 | 3920 | /** |
3896 | 3921 | * Transform wiki markup when saving a page by doing \r\n -> \n |
3897 | 3922 | * conversion, substitting signatures, {{subst:}} templates, etc. |
— | — | @@ -4015,14 +4040,14 @@ |
4016 | 4041 | global $wgMaxSigChars; |
4017 | 4042 | |
4018 | 4043 | $username = $user->getName(); |
4019 | | - |
| 4044 | + |
4020 | 4045 | // If not given, retrieve from the user object. |
4021 | 4046 | if ( $nickname === false ) |
4022 | 4047 | $nickname = $user->getOption( 'nickname' ); |
4023 | | - |
| 4048 | + |
4024 | 4049 | if ( is_null( $fancySig ) ) |
4025 | 4050 | $fancySig = $user->getBoolOption( 'fancysig' ); |
4026 | | - |
| 4051 | + |
4027 | 4052 | $nickname = $nickname == null ? $username : $nickname; |
4028 | 4053 | |
4029 | 4054 | if( mb_strlen( $nickname ) > $wgMaxSigChars ) { |
— | — | @@ -4221,23 +4246,23 @@ |
4222 | 4247 | * @param integer $flags a combination of the following flags: |
4223 | 4248 | * SFH_NO_HASH No leading hash, i.e. {{plural:...}} instead of {{#if:...}} |
4224 | 4249 | * |
4225 | | - * SFH_OBJECT_ARGS Pass the template arguments as PPNode objects instead of text. This |
| 4250 | + * SFH_OBJECT_ARGS Pass the template arguments as PPNode objects instead of text. This |
4226 | 4251 | * allows for conditional expansion of the parse tree, allowing you to eliminate dead |
4227 | | - * branches and thus speed up parsing. It is also possible to analyse the parse tree of |
| 4252 | + * branches and thus speed up parsing. It is also possible to analyse the parse tree of |
4228 | 4253 | * the arguments, and to control the way they are expanded. |
4229 | 4254 | * |
4230 | 4255 | * The $frame parameter is a PPFrame. This can be used to produce expanded text from the |
4231 | 4256 | * arguments, for instance: |
4232 | 4257 | * $text = isset( $args[0] ) ? $frame->expand( $args[0] ) : ''; |
4233 | 4258 | * |
4234 | | - * For technical reasons, $args[0] is pre-expanded and will be a string. This may change in |
| 4259 | + * For technical reasons, $args[0] is pre-expanded and will be a string. This may change in |
4235 | 4260 | * future versions. Please call $frame->expand() on it anyway so that your code keeps |
4236 | 4261 | * working if/when this is changed. |
4237 | 4262 | * |
4238 | 4263 | * If you want whitespace to be trimmed from $args, you need to do it yourself, post- |
4239 | 4264 | * expansion. |
4240 | 4265 | * |
4241 | | - * Please read the documentation in includes/parser/Preprocessor.php for more information |
| 4266 | + * Please read the documentation in includes/parser/Preprocessor.php for more information |
4242 | 4267 | * about the methods available in PPFrame and PPNode. |
4243 | 4268 | * |
4244 | 4269 | * @return The old callback function for this name, if any |
— | — | @@ -4354,7 +4379,7 @@ |
4355 | 4380 | unset( $params[ 'href' ] ); |
4356 | 4381 | } else { |
4357 | 4382 | # Non-link <a> tag |
4358 | | - return Xml::openElement( 'a', $params ) . $content . Xml::closeElement( 'a' ); |
| 4383 | + return Xml::openElement( 'a', $params ) . $content . Xml::closeElement( 'a' ); |
4359 | 4384 | } |
4360 | 4385 | |
4361 | 4386 | $sk = $this->mOptions->getSkin(); |
— | — | @@ -4411,7 +4436,7 @@ |
4412 | 4437 | if ( count( $matches ) == 0 ) { |
4413 | 4438 | continue; |
4414 | 4439 | } |
4415 | | - |
| 4440 | + |
4416 | 4441 | if ( strpos( $matches[0], '%' ) !== false ) |
4417 | 4442 | $matches[1] = urldecode( $matches[1] ); |
4418 | 4443 | $tp = Title::newFromText( $matches[1]/*, NS_FILE*/ ); |
— | — | @@ -4499,7 +4524,7 @@ |
4500 | 4525 | # * upright reduce width for upright images, rounded to full __0 px |
4501 | 4526 | # * border draw a 1px border around the image |
4502 | 4527 | # * alt Text for HTML alt attribute (defaults to empty) |
4503 | | - # * link Set the target of the image link. Can be external, interwiki, or local |
| 4528 | + # * link Set the target of the image link. Can be external, interwiki, or local |
4504 | 4529 | # vertical-align values (no % or length right now): |
4505 | 4530 | # * baseline |
4506 | 4531 | # * sub |
— | — | @@ -4684,7 +4709,7 @@ |
4685 | 4710 | |
4686 | 4711 | return $ret; |
4687 | 4712 | } |
4688 | | - |
| 4713 | + |
4689 | 4714 | protected function stripAltText( $caption, $holders ) { |
4690 | 4715 | # Strip bad stuff out of the title (tooltip). We can't just use |
4691 | 4716 | # replaceLinkHoldersText() here, because if this function is called |
— | — | @@ -4700,7 +4725,7 @@ |
4701 | 4726 | # remove the tags |
4702 | 4727 | $tooltip = $this->mStripState->unstripBoth( $tooltip ); |
4703 | 4728 | $tooltip = Sanitizer::stripAllTags( $tooltip ); |
4704 | | - |
| 4729 | + |
4705 | 4730 | return $tooltip; |
4706 | 4731 | } |
4707 | 4732 | |
— | — | @@ -5136,7 +5161,7 @@ |
5137 | 5162 | $links['interwiki'][] = $this->mLinkHolders->interwiki[$key]; |
5138 | 5163 | $pos = $start_pos + strlen( "<!--IWLINK $key-->" ); |
5139 | 5164 | } |
5140 | | - |
| 5165 | + |
5141 | 5166 | $data['linkholder'] = $links; |
5142 | 5167 | |
5143 | 5168 | return $data; |
— | — | @@ -5145,7 +5170,7 @@ |
5146 | 5171 | function unserialiseHalfParsedText( $data, $intPrefix = null /* Unique identifying prefix */ ) { |
5147 | 5172 | if (!$intPrefix) |
5148 | 5173 | $intPrefix = $this->getRandomString(); |
5149 | | - |
| 5174 | + |
5150 | 5175 | // First, extract the strip state. |
5151 | 5176 | $stripState = $data['stripstate']; |
5152 | 5177 | $this->mStripState->general->merge( $stripState->general ); |
Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -349,7 +349,7 @@ |
350 | 350 | */ |
351 | 351 | public function setPageTitle( $name ) { |
352 | 352 | global $wgContLang; |
353 | | - $name = $wgContLang->convert( $name, true ); |
| 353 | + |
354 | 354 | # change "<script>foo&bar</script>" to "<script>foo&bar</script>" |
355 | 355 | # but leave "<i>foobar</i>" alone |
356 | 356 | $nameWithTags = Sanitizer::normalizeCharReferences( Sanitizer::removeHTMLtags( $name ) ); |
— | — | @@ -611,10 +611,14 @@ |
612 | 612 | } |
613 | 613 | } |
614 | 614 | // Page title |
615 | | - if( ( $dt = $parserOutput->getDisplayTitle() ) !== false ) |
| 615 | + $dt = $parserOutput->getDisplayTitle(); |
| 616 | + $title = $parserOutput->getTitleText(); |
| 617 | + if ( $dt !== false ) { |
616 | 618 | $this->setPageTitle( $dt ); |
617 | | - else if ( ( $title = $parserOutput->getTitleText() ) != '' ) |
| 619 | + } |
| 620 | + else if ( $title != '' ) { |
618 | 621 | $this->setPageTitle( $title ); |
| 622 | + } |
619 | 623 | |
620 | 624 | // Hooks registered in the object |
621 | 625 | global $wgParserOutputHooks; |
Index: trunk/phase3/includes/MagicWord.php |
— | — | @@ -161,6 +161,8 @@ |
162 | 162 | 'index', |
163 | 163 | 'noindex', |
164 | 164 | 'staticredirect', |
| 165 | + 'notitleconvert', |
| 166 | + 'nocontentconvert', |
165 | 167 | ); |
166 | 168 | |
167 | 169 | |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -987,6 +987,19 @@ |
988 | 988 | } |
989 | 989 | |
990 | 990 | /** |
| 991 | + * Is this a conversion table for the LanguageConverter? |
| 992 | + * @return \type{\bool} |
| 993 | + */ |
| 994 | + public function isConversionTable() { |
| 995 | + if($this->getNamespace() == NS_MEDIAWIKI |
| 996 | + && strpos( $this->getText(), 'Conversiontable' ) !== false ) { |
| 997 | + return true; |
| 998 | + } |
| 999 | + |
| 1000 | + return false; |
| 1001 | + } |
| 1002 | + |
| 1003 | + /** |
991 | 1004 | * Is $wgUser watching this page? |
992 | 1005 | * @return \type{\bool} |
993 | 1006 | */ |
Index: trunk/phase3/languages/LanguageConverter.php |
— | — | @@ -22,19 +22,14 @@ |
23 | 23 | var $mTablesLoaded = false; |
24 | 24 | var $mTables; |
25 | 25 | var $mNamespaceTables; |
26 | | - var $mDoTitleConvert = true, $mDoContentConvert = true; |
27 | 26 | // 'bidirectional' 'unidirectional' 'disable' for each variant |
28 | 27 | var $mManualLevel; |
29 | | - var $mTitleFromFlag = false; |
30 | 28 | var $mCacheKey; |
31 | 29 | var $mLangObj; |
32 | 30 | var $mMarkup; |
33 | 31 | var $mFlags; |
34 | 32 | var $mDescCodeSep = ':', $mDescVarSep = ';'; |
35 | 33 | var $mUcfirst = false; |
36 | | - var $mTitleOriginal = ''; |
37 | | - var $mTitleDisplay = ''; |
38 | | - var $mHeaderVariant = null; |
39 | 34 | |
40 | 35 | const CACHE_VERSION_KEY = 'VERSION 6'; |
41 | 36 | |
— | — | @@ -465,10 +460,6 @@ |
466 | 461 | // use syntax -{T|zh:TitleZh;zh-tw:TitleTw}- for custom |
467 | 462 | // conversion in title |
468 | 463 | $title = $convRule->getTitle(); |
469 | | - if ( $title ) { |
470 | | - $this->mTitleFromFlag = true; |
471 | | - $this->mTitleDisplay = $title; |
472 | | - } |
473 | 464 | |
474 | 465 | // apply manual conversion table to global table |
475 | 466 | $convTable = $convRule->getConvTable(); |
— | — | @@ -494,31 +485,6 @@ |
495 | 486 | } |
496 | 487 | |
497 | 488 | /** |
498 | | - * Convert text using a parser object for context. |
499 | | - * @public |
500 | | - */ |
501 | | - function parserConvert( $text, &$parser ) { |
502 | | - global $wgDisableLangConversion; |
503 | | - /* don't do anything if this is the conversion table */ |
504 | | - if ( $parser->getTitle()->getNamespace() == NS_MEDIAWIKI |
505 | | - && strpos( $parser->mTitle->getText(), |
506 | | - 'Conversiontable' ) !== false ) { |
507 | | - return $text; |
508 | | - } |
509 | | - |
510 | | - if ( $wgDisableLangConversion ) { |
511 | | - return $text; |
512 | | - } |
513 | | - |
514 | | - $text = $this->convert( $text ); |
515 | | - |
516 | | - $this->convertTitle(); |
517 | | - $parser->mOutput->setTitleText( $this->mTitleDisplay ); |
518 | | - |
519 | | - return $text; |
520 | | - } |
521 | | - |
522 | | - /** |
523 | 489 | * Convert namespace. |
524 | 490 | * @param string $title the title included namespace |
525 | 491 | * @return array of string |
— | — | @@ -537,37 +503,35 @@ |
538 | 504 | } |
539 | 505 | |
540 | 506 | /** |
541 | | - * Pre convert title. Store the original title $this->mTitleOrginal; |
542 | | - * store the default converted title to $this->mTitleDisplay. |
| 507 | + * Convert a text fragment. |
| 508 | + * |
| 509 | + * @param string $text text to be converted |
| 510 | + * @param string $plang preferred variant |
| 511 | + * @return string converted text |
543 | 512 | * @private |
544 | 513 | */ |
545 | | - function preConvertTitle( $text, $variant ) { |
546 | | - $this->mTitleOriginal = $text; |
| 514 | + function convertFragment( $text, $plang ) { |
| 515 | + $marked = explode( $this->mMarkup['begin'], $text, 2 ); |
| 516 | + $converted = ''; |
547 | 517 | |
548 | | - $text = $this->convertNamespace( $text, $variant ); |
549 | | - $this->mTitleDisplay = $this->convert( $text ); |
550 | | - } |
| 518 | + if ( $this->mDoContentConvert ) { |
| 519 | + // Bug 19620: should convert a string immediately after a |
| 520 | + // new rule added. |
| 521 | + $converted .= $this->autoConvert( $marked[0], $plang ); |
| 522 | + } else { |
| 523 | + $converted .= $marked[0]; |
| 524 | + } |
551 | 525 | |
552 | | - /** |
553 | | - * Convert title. |
554 | | - * @private |
555 | | - */ |
556 | | - function convertTitle() { |
557 | | - global $wgDisableTitleConversion, $wgUser, $wgRequest; |
558 | | - $isredir = $wgRequest->getText( 'redirect', 'yes' ); |
559 | | - $action = $wgRequest->getText( 'action' ); |
560 | | - $linkconvert = $wgRequest->getText( 'linkconvert', 'yes' ); |
561 | | - |
562 | | - // check for the global variable, __NOTC__ magic word, and user setting |
563 | | - if ( $wgDisableTitleConversion || !$this->mDoTitleConvert || |
564 | | - $wgUser->getOption( 'noconvertlink' ) == 1 ) { |
565 | | - $this->mTitleDisplay = $this->mTitleOriginal; |
566 | | - } elseif ( $isredir == 'no' |
567 | | - || $action == 'edit' |
568 | | - || $linkconvert == 'no' ) { |
569 | | - // check for GET params |
570 | | - $this->mTitleDisplay = $this->mTitleOriginal; |
| 526 | + if ( array_key_exists( 1, $marked ) ) { |
| 527 | + $crule = new ConverterRule( $marked[1], $this ); |
| 528 | + $crule->parse( $plang ); |
| 529 | + $converted .= $crule->getDisplay(); |
| 530 | + $this->applyManualConv( $crule ); |
| 531 | + } else { |
| 532 | + $converted .= $this->mMarkup['end']; |
571 | 533 | } |
| 534 | + |
| 535 | + return $converted; |
572 | 536 | } |
573 | 537 | |
574 | 538 | /** |
— | — | @@ -582,63 +546,27 @@ |
583 | 547 | * -{text}- in which case no conversion should take place for text |
584 | 548 | * |
585 | 549 | * @param string $text text to be converted |
586 | | - * @param bool $isTitle whether this conversion is for the article title |
587 | 550 | * @return string converted text |
588 | 551 | * @public |
589 | 552 | */ |
590 | | - function convert( $text, $isTitle = false ) { |
| 553 | + function convert( $text ) { |
| 554 | + if ( $wgDisableLangConversion ) return $text; |
591 | 555 | |
592 | | - $mw =& MagicWord::get( 'notitleconvert' ); |
593 | | - if ( $mw->matchAndRemove( $text ) ) { |
594 | | - $this->mDoTitleConvert = false; |
595 | | - } |
596 | | - $mw =& MagicWord::get( 'nocontentconvert' ); |
597 | | - if ( $mw->matchAndRemove( $text ) ) { |
598 | | - $this->mDoContentConvert = false; |
599 | | - } |
600 | | - |
601 | | - // no conversion if redirecting |
602 | | - $mw =& MagicWord::get( 'redirect' ); |
603 | | - if ( $mw->matchStart( $text ) ) { |
604 | | - return $text; |
605 | | - } |
606 | | - |
607 | 556 | $plang = $this->getPreferredVariant(); |
608 | | - |
609 | | - // for title convertion |
610 | | - if ( $isTitle ) { |
611 | | - $this->preConvertTitle( $text, $plang ); |
612 | | - return $text; |
613 | | - } |
614 | | - |
615 | 557 | $tarray = StringUtils::explode( $this->mMarkup['end'], $text ); |
616 | | - $text = ''; |
| 558 | + $converted = ''; |
617 | 559 | |
618 | 560 | foreach ( $tarray as $txt ) { |
619 | | - |
620 | | - $marked = explode( $this->mMarkup['begin'], $txt, 2 ); |
621 | | - |
622 | | - if ( $this->mDoContentConvert ) { |
623 | | - // Bug 19620: should convert a string immediately after a |
624 | | - // new rule added. |
625 | | - $text .= $this->autoConvert( $marked[0], $plang ); |
626 | | - } else { |
627 | | - $text .= $marked[0]; |
628 | | - } |
629 | | - |
630 | | - if ( array_key_exists( 1, $marked ) ) { |
631 | | - $crule = new ConverterRule( $marked[1], $this ); |
632 | | - $crule->parse( $plang ); |
633 | | - $text .= $crule->getDisplay(); |
634 | | - $this->applyManualConv( $crule ); |
635 | | - } else { |
636 | | - $text .= $this->mMarkup['end']; |
637 | | - } |
| 561 | + $converted .= $this->convertFragment( $txt, $plang ); |
638 | 562 | } |
639 | 563 | |
640 | 564 | // Remove the last delimiter (wasn't real) |
641 | | - $text = substr( $text, 0, - strlen( $this->mMarkup['end'] ) ); |
642 | | - return $text; |
| 565 | + $converted = substr( $converted, 0, - strlen( $this->mMarkup['end'] ) ); |
| 566 | + if ( $isTitle ) { |
| 567 | + error_log("title2: $converted\n"); |
| 568 | + $this->mConvertedTitle = $converted; |
| 569 | + } |
| 570 | + return $converted; |
643 | 571 | } |
644 | 572 | |
645 | 573 | /** |
— | — | @@ -725,15 +653,6 @@ |
726 | 654 | return '!' . $variant ; |
727 | 655 | } |
728 | 656 | |
729 | | - /** |
730 | | - * Get title text as defined in the body of the article text. |
731 | | - * |
732 | | - * @public |
733 | | - */ |
734 | | - function getParsedTitle() { |
735 | | - return $this->mTitleDisplay; |
736 | | - } |
737 | | - |
738 | 657 | /** |
739 | 658 | * Load default conversion tables. |
740 | 659 | * This method must be implemented in derived class. |
— | — | @@ -1356,15 +1275,15 @@ |
1357 | 1276 | // proces H,- flag or T only: output nothing |
1358 | 1277 | $this->mRuleDisplay = ''; |
1359 | 1278 | } elseif ( in_array( 'S', $flags ) ) { |
1360 | | - $this->mRuleDisplay = $this->getRuleConvertedStr( $variant, |
1361 | | - $this->mConverter->mDoContentConvert ); |
| 1279 | + // true hard-coded now since we shouldn't be called if we're not converting |
| 1280 | + $this->mRuleDisplay = $this->getRuleConvertedStr( $variant, true ); |
1362 | 1281 | } else { |
1363 | 1282 | $this->mRuleDisplay = $this->mManualCodeError; |
1364 | 1283 | } |
1365 | | - // proces T flag |
| 1284 | + // process T flag |
1366 | 1285 | if ( in_array( 'T', $flags ) ) { |
1367 | | - $this->mRuleTitle = $this->getRuleConvertedStr( $variant, |
1368 | | - $this->mConverter->mDoTitleConvert ); |
| 1286 | + // true hard-coded now since we shouldn't be called if we're not converting |
| 1287 | + $this->mRuleTitle = $this->getRuleConvertedStr( $variant, true ); |
1369 | 1288 | } |
1370 | 1289 | |
1371 | 1290 | if ( in_array( '-', $flags ) ) { |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -37,7 +37,6 @@ |
38 | 38 | function FakeConverter($langobj) {$this->mLang = $langobj;} |
39 | 39 | function autoConvertToAllVariants($text) {return $text;} |
40 | 40 | function convert($t, $i) {return $t;} |
41 | | - function parserConvert($t, $p) {return $t;} |
42 | 41 | function getVariants() { return array( $this->mLang->getCode() ); } |
43 | 42 | function getPreferredVariant() {return $this->mLang->getCode(); } |
44 | 43 | function findVariantLink(&$l, &$n, $ignoreOtherCond = false) {} |
— | — | @@ -2358,11 +2357,6 @@ |
2359 | 2358 | return $this->mConverter->convert($text, $isTitle); |
2360 | 2359 | } |
2361 | 2360 | |
2362 | | - # Convert text from within Parser |
2363 | | - function parserConvert( $text, &$parser ) { |
2364 | | - return $this->mConverter->parserConvert( $text, $parser ); |
2365 | | - } |
2366 | | - |
2367 | 2361 | # Check if this is a language with variants |
2368 | 2362 | function hasVariants(){ |
2369 | 2363 | return sizeof($this->getVariants())>1; |
Index: trunk/phase3/languages/classes/LanguageKk.php |
— | — | @@ -209,16 +209,6 @@ |
210 | 210 | return $carray; |
211 | 211 | } |
212 | 212 | |
213 | | - // Do not convert content on talk pages |
214 | | - function parserConvert( $text, &$parser ){ |
215 | | - if(is_object($parser->getTitle() ) && $parser->getTitle()->isTalkPage()) |
216 | | - $this->mDoContentConvert=false; |
217 | | - else |
218 | | - $this->mDoContentConvert=true; |
219 | | - |
220 | | - return parent::parserConvert($text, $parser ); |
221 | | - } |
222 | | - |
223 | 213 | /* |
224 | 214 | * A function wrapper: |
225 | 215 | * - if there is no selected variant, leave the link |
Index: trunk/phase3/languages/classes/LanguageKu.php |
— | — | @@ -132,16 +132,6 @@ |
133 | 133 | ); |
134 | 134 | } |
135 | 135 | |
136 | | - // Do not convert content on talk pages |
137 | | - function parserConvert( $text, &$parser ){ |
138 | | - if(is_object($parser->getTitle() ) && $parser->getTitle()->isTalkPage()) |
139 | | - $this->mDoContentConvert=false; |
140 | | - else |
141 | | - $this->mDoContentConvert=true; |
142 | | - |
143 | | - return parent::parserConvert($text, $parser ); |
144 | | - } |
145 | | - |
146 | 136 | /* |
147 | 137 | * A function wrapper: |
148 | 138 | * - if there is no selected variant, leave the link |
Index: trunk/phase3/languages/classes/LanguageSr.php |
— | — | @@ -76,16 +76,6 @@ |
77 | 77 | return $carray; |
78 | 78 | } |
79 | 79 | |
80 | | - // Do not convert content on talk pages |
81 | | - function parserConvert( $text, &$parser ){ |
82 | | - if(is_object($parser->getTitle() ) && $parser->getTitle()->isTalkPage()) |
83 | | - $this->mDoContentConvert=false; |
84 | | - else |
85 | | - $this->mDoContentConvert=true; |
86 | | - |
87 | | - return parent::parserConvert($text, $parser ); |
88 | | - } |
89 | | - |
90 | 80 | /* |
91 | 81 | * A function wrapper: |
92 | 82 | * - if there is no selected variant, leave the link |