Index: trunk/phase3/includes/Parser.php |
— | — | @@ -1911,7 +1911,7 @@ |
1912 | 1912 | # It loops through all headlines, collects the necessary data, then splits up the |
1913 | 1913 | # string and re-inserts the newly formatted headlines. |
1914 | 1914 | /* private */ function formatHeadings( $text, $isMain=true ) { |
1915 | | - global $wgInputEncoding, $wgMaxTocLevel, $wgLang; |
| 1915 | + global $wgInputEncoding, $wgMaxTocLevel, $wgLang, $wgLinkHolders; |
1916 | 1916 | |
1917 | 1917 | $doNumberHeadings = $this->mOptions->getNumberHeadings(); |
1918 | 1918 | $doShowToc = $this->mOptions->getShowToc(); |
— | — | @@ -2022,10 +2022,13 @@ |
2023 | 2023 | $canonized_headline = $this->unstripNoWiki( $headline, $this->mStripState ); |
2024 | 2024 | |
2025 | 2025 | # Remove link placeholders by the link text. |
2026 | | - # <!--LINK namespace page_title link text with suffix--> |
| 2026 | + # <!--LINK number--> |
2027 | 2027 | # turns into |
2028 | 2028 | # link text with suffix |
2029 | | - $canonized_headline = preg_replace( '/<!--LINK [0-9]* [^ ]* *(.*?)-->/','$1', $canonized_headline ); |
| 2029 | + $canonized_headline = preg_replace( '/<!--LINK ([0-9]*)-->/e', |
| 2030 | + "\$wgLinkHolders['texts'][\$1]", |
| 2031 | + $canonized_headline ); |
| 2032 | + |
2030 | 2033 | # strip out HTML |
2031 | 2034 | $canonized_headline = preg_replace( '/<.*?' . '>/','',$canonized_headline ); |
2032 | 2035 | $tocline = trim( $canonized_headline ); |
Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -810,7 +810,7 @@ |
811 | 811 | * $options is a bit field, RLH_FOR_UPDATE to select for update |
812 | 812 | */ |
813 | 813 | function replaceLinkHolders( &$text, $options = 0 ) { |
814 | | - global $wgUser, $wgLinkCache, $wgUseOldExistenceCheck; |
| 814 | + global $wgUser, $wgLinkCache, $wgUseOldExistenceCheck, $wgLinkHolders; |
815 | 815 | |
816 | 816 | if ( $wgUseOldExistenceCheck ) { |
817 | 817 | return array(); |
— | — | @@ -819,36 +819,25 @@ |
820 | 820 | $fname = 'OutputPage::replaceLinkHolders'; |
821 | 821 | wfProfileIn( $fname ); |
822 | 822 | |
823 | | - $titles = array(); |
824 | 823 | $pdbks = array(); |
825 | 824 | $colours = array(); |
826 | 825 | |
827 | | - # Get placeholders from body |
828 | | - wfProfileIn( $fname.'-match' ); |
829 | | - preg_match_all( "/<!--LINK (.*?) (.*?) (.*?) (.*?)-->/", $text, $tmpLinks ); |
830 | | - wfProfileOut( $fname.'-match' ); |
831 | | - |
832 | | - if ( !empty( $tmpLinks[0] ) ) { |
| 826 | + #if ( !empty( $tmpLinks[0] ) ) { #TODO |
| 827 | + if ( !empty( $wgLinkHolders['namespaces'] ) ) { |
833 | 828 | wfProfileIn( $fname.'-check' ); |
834 | 829 | $dbr =& wfGetDB( DB_SLAVE ); |
835 | 830 | $cur = $dbr->tableName( 'cur' ); |
836 | 831 | $sk = $wgUser->getSkin(); |
837 | 832 | $threshold = $wgUser->getOption('stubthreshold'); |
838 | 833 | |
839 | | - $namespaces =& $tmpLinks[1]; |
840 | | - $dbkeys =& $tmpLinks[2]; |
841 | | - $queries =& $tmpLinks[3]; |
842 | | - $texts =& $tmpLinks[4]; |
843 | | - |
844 | 834 | # Sort by namespace |
845 | | - asort( $namespaces ); |
| 835 | + asort( $wgLinkHolders['namespaces'] ); |
846 | 836 | |
847 | 837 | # Generate query |
848 | 838 | $query = false; |
849 | | - foreach ( $namespaces as $key => $val ) { |
| 839 | + foreach ( $wgLinkHolders['namespaces'] as $key => $val ) { |
850 | 840 | # Make title object |
851 | | - $dbk = $dbkeys[$key]; |
852 | | - $title = $titles[$key] = Title::makeTitleSafe( $val, $dbk ); |
| 841 | + $title = $wgLinkHolders['titles'][$key]; |
853 | 842 | |
854 | 843 | # Skip invalid entries. |
855 | 844 | # Result will be ugly, but prevents crash. |
— | — | @@ -878,7 +867,7 @@ |
879 | 868 | $query .= ', '; |
880 | 869 | } |
881 | 870 | |
882 | | - $query .= $dbr->addQuotes( $dbkeys[$key] ); |
| 871 | + $query .= $dbr->addQuotes( $wgLinkHolders['dbkeys'][$key] ); |
883 | 872 | } |
884 | 873 | } |
885 | 874 | if ( $query ) { |
— | — | @@ -916,18 +905,24 @@ |
917 | 906 | wfProfileIn( $fname.'-construct' ); |
918 | 907 | global $outputReplace; |
919 | 908 | $outputReplace = array(); |
920 | | - foreach ( $namespaces as $key => $ns ) { |
| 909 | + foreach ( $wgLinkHolders['namespaces'] as $key => $ns ) { |
921 | 910 | $pdbk = $pdbks[$key]; |
922 | | - $searchkey = $tmpLinks[0][$key]; |
923 | | - $title = $titles[$key]; |
| 911 | + $searchkey = '<!--LINK '.$key.'-->'; |
| 912 | + $title = $wgLinkHolders['titles'][$key]; |
924 | 913 | if ( empty( $colours[$pdbk] ) ) { |
925 | 914 | $wgLinkCache->addBadLink( $pdbk ); |
926 | 915 | $colours[$pdbk] = 0; |
927 | | - $outputReplace[$searchkey] = $sk->makeBrokenLinkObj( $title, $texts[$key], $queries[$key] ); |
| 916 | + $outputReplace[$searchkey] = $sk->makeBrokenLinkObj( $title, |
| 917 | + $wgLinkHolders['texts'][$key], |
| 918 | + $wgLinkHolders['queries'][$key] ); |
928 | 919 | } elseif ( $colours[$pdbk] == 1 ) { |
929 | | - $outputReplace[$searchkey] = $sk->makeKnownLinkObj( $title, $texts[$key], $queries[$key] ); |
| 920 | + $outputReplace[$searchkey] = $sk->makeKnownLinkObj( $title, |
| 921 | + $wgLinkHolders['texts'][$key], |
| 922 | + $wgLinkHolders['queries'][$key] ); |
930 | 923 | } elseif ( $colours[$pdbk] == 2 ) { |
931 | | - $outputReplace[$searchkey] = $sk->makeStubLinkObj( $title, $texts[$key], $queries[$key] ); |
| 924 | + $outputReplace[$searchkey] = $sk->makeStubLinkObj( $title, |
| 925 | + $wgLinkHolders['texts'][$key], |
| 926 | + $wgLinkHolders['queries'][$key] ); |
932 | 927 | } |
933 | 928 | } |
934 | 929 | wfProfileOut( $fname.'-construct' ); |
— | — | @@ -936,7 +931,7 @@ |
937 | 932 | wfProfileIn( $fname.'-replace' ); |
938 | 933 | |
939 | 934 | $text = preg_replace_callback( |
940 | | - '/(<!--LINK .*? .*? .*? .*?-->)/', |
| 935 | + '/(<!--LINK .*?-->)/', |
941 | 936 | "outputReplaceMatches", |
942 | 937 | $text); |
943 | 938 | wfProfileOut( $fname.'-replace' ); |