Index: trunk/phase3/maintenance/archives/patch-page_no_title_convert.sql |
— | — | @@ -1,7 +0,0 @@ |
2 | | - |
3 | | -ALTER TABLE /*$wgDBprefix*/page |
4 | | - ADD page_no_title_convert bool NOT NULL default 0; |
Index: trunk/phase3/maintenance/updaters.inc |
— | — | @@ -57,7 +57,6 @@ |
58 | 58 | array( 'ipblocks', 'ipb_range_start', 'patch-ipb_range_start.sql' ), |
59 | 59 | array( 'site_stats', 'ss_images', 'patch-ss_images.sql' ), |
60 | 60 | array( 'ipblocks', 'ipb_anon_only', 'patch-ipb_anon_only.sql' ), |
61 | | - array( 'page', 'page_no_title_convert','patch-page_no_title_convert.sql' ), |
62 | 61 | ); |
63 | 62 | |
64 | 63 | function rename_table( $from, $to, $patch ) { |
Index: trunk/phase3/maintenance/mysql5/tables.sql |
— | — | @@ -218,10 +218,6 @@ |
219 | 219 | -- Uncompressed length in bytes of the page's current source text. |
220 | 220 | page_len int(8) unsigned NOT NULL, |
221 | 221 | |
222 | | - -- Set to 1 if the page contains __NOTITLECONVERT__ magic word. |
223 | | - -- Used only for languages with variants to prevent title conversion |
224 | | - page_no_title_convert bool NOT NULL default 0, |
225 | | - |
226 | 222 | PRIMARY KEY page_id (page_id), |
227 | 223 | UNIQUE INDEX name_title (page_namespace,page_title), |
228 | 224 | |
Index: trunk/phase3/maintenance/tables.sql |
— | — | @@ -206,10 +206,6 @@ |
207 | 207 | -- Uncompressed length in bytes of the page's current source text. |
208 | 208 | page_len int(8) unsigned NOT NULL, |
209 | 209 | |
210 | | - -- Set to 1 if the page contains __NOTITLECONVERT__ magic word. |
211 | | - -- Used only for languages with variants to prevent title conversion |
212 | | - page_no_title_convert bool NOT NULL default 0, |
213 | | - |
214 | 210 | PRIMARY KEY page_id (page_id), |
215 | 211 | UNIQUE INDEX name_title (page_namespace,page_title), |
216 | 212 | |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -30,8 +30,6 @@ |
31 | 31 | var $mGoodAdjustment; //!< |
32 | 32 | var $mLatest; //!< |
33 | 33 | var $mMinorEdit; //!< |
34 | | - var $mNoTitleConvert; //!< |
35 | | - var $mNoTitleConvertParser; //!< |
36 | 34 | var $mOldId; //!< |
37 | 35 | var $mRedirectedFrom; //!< |
38 | 36 | var $mRedirectUrl; //!< |
— | — | @@ -132,8 +130,6 @@ |
133 | 131 | $this->mRevIdFetched = 0; |
134 | 132 | $this->mRedirectUrl = false; |
135 | 133 | $this->mLatest = false; |
136 | | - $this->mNoTitleConvert = false; |
137 | | - $this->mNoTitleConvertParser = false; |
138 | 134 | } |
139 | 135 | |
140 | 136 | /** |
— | — | @@ -271,8 +267,7 @@ |
272 | 268 | 'page_random', |
273 | 269 | 'page_touched', |
274 | 270 | 'page_latest', |
275 | | - 'page_len', |
276 | | - 'page_no_title_convert') ; |
| 271 | + 'page_len' ) ; |
277 | 272 | wfRunHooks( 'ArticlePageDataBefore', array( &$this , &$fields ) ) ; |
278 | 273 | $row = $dbr->selectRow( 'page', |
279 | 274 | $fields, |
— | — | @@ -308,8 +303,6 @@ |
309 | 304 | * @private |
310 | 305 | */ |
311 | 306 | function loadPageData( $data = 'fromdb' ) { |
312 | | - global $wgContLang; |
313 | | - |
314 | 307 | if ( $data === 'fromdb' ) { |
315 | 308 | $dbr =& $this->getDB(); |
316 | 309 | $data = $this->pageDataFromId( $dbr, $this->getId() ); |
— | — | @@ -327,10 +320,6 @@ |
328 | 321 | $this->mTouched = wfTimestamp( TS_MW, $data->page_touched ); |
329 | 322 | $this->mIsRedirect = $data->page_is_redirect; |
330 | 323 | $this->mLatest = $data->page_latest; |
331 | | - $this->mNoTitleConvert = $data->page_no_title_convert; |
332 | | - |
333 | | - if($this->mNoTitleConvert) |
334 | | - $wgContLang->setNoTitleConvert(); |
335 | 324 | } else { |
336 | 325 | if ( is_object( $this->mTitle ) ) { |
337 | 326 | $lc->addBadLinkObj( $this->mTitle ); |
— | — | @@ -995,7 +984,6 @@ |
996 | 985 | 'page_touched' => $dbw->timestamp(), |
997 | 986 | 'page_latest' => 0, # Fill this in shortly... |
998 | 987 | 'page_len' => 0, # Fill this in shortly... |
999 | | - 'page_no_title_convert' => 0, |
1000 | 988 | ), __METHOD__ ); |
1001 | 989 | $newid = $dbw->insertId(); |
1002 | 990 | |
— | — | @@ -1035,21 +1023,12 @@ |
1036 | 1024 | 'page_is_new' => ($lastRevision === 0) ? 1 : 0, |
1037 | 1025 | 'page_is_redirect' => Article::isRedirect( $text ) ? 1 : 0, |
1038 | 1026 | 'page_len' => strlen( $text ), |
1039 | | - 'page_no_title_convert' => ($this->mNoTitleConvertParser)? 1 : 0, |
1040 | 1027 | ), |
1041 | 1028 | $conditions, |
1042 | 1029 | __METHOD__ ); |
1043 | 1030 | |
1044 | | - $succ = $dbw->affectedRows() != 0; |
1045 | | - |
1046 | | - // check if no title magic word has been changed |
1047 | | - if($succ && $this->mNoTitleConvert != $this->mNoTitleConvertParser){ |
1048 | | - // Clear caches |
1049 | | - Article::onArticleCreate( $this->mTitle ); |
1050 | | - } |
1051 | | - |
1052 | 1031 | wfProfileOut( __METHOD__ ); |
1053 | | - return $succ; |
| 1032 | + return ( $dbw->affectedRows() != 0 ); |
1054 | 1033 | } |
1055 | 1034 | |
1056 | 1035 | /** |
— | — | @@ -1215,7 +1194,7 @@ |
1216 | 1195 | * @return bool success |
1217 | 1196 | */ |
1218 | 1197 | function doEdit( $text, $summary, $flags = 0 ) { |
1219 | | - global $wgUser, $wgDBtransactions, $wgContLang; |
| 1198 | + global $wgUser, $wgDBtransactions; |
1220 | 1199 | |
1221 | 1200 | wfProfileIn( __METHOD__ ); |
1222 | 1201 | $good = true; |
— | — | @@ -1242,15 +1221,6 @@ |
1243 | 1222 | $isminor = ( $flags & EDIT_MINOR ) && $wgUser->isAllowed('minoredit'); |
1244 | 1223 | $bot = $wgUser->isAllowed( 'bot' ) || ( $flags & EDIT_FORCE_BOT ); |
1245 | 1224 | |
1246 | | - // process the notitleconvert magic for languages with variants |
1247 | | - $this->mNoTitleConvertParser = false; |
1248 | | - if(sizeof($wgContLang->getVariants())>1){ |
1249 | | - $mw =& MagicWord::get( 'notitleconvert' ); |
1250 | | - if( $mw->match( $text ) ){ |
1251 | | - $this->mNoTitleConvertParser = true; |
1252 | | - } |
1253 | | - } |
1254 | | - |
1255 | 1225 | $text = $this->preSaveTransform( $text ); |
1256 | 1226 | |
1257 | 1227 | $dbw =& wfGetDB( DB_MASTER ); |
Index: trunk/phase3/includes/SearchEngine.php |
— | — | @@ -51,7 +51,6 @@ |
52 | 52 | * @private |
53 | 53 | */ |
54 | 54 | function getNearMatch( $term ) { |
55 | | - global $wgContLang; |
56 | 55 | # Exact match? No need to look further. |
57 | 56 | $title = Title::newFromText( $term ); |
58 | 57 | if (is_null($title)) |
— | — | @@ -63,27 +62,33 @@ |
64 | 63 | |
65 | 64 | # Now try all lower case (i.e. first letter capitalized) |
66 | 65 | # |
67 | | - $title = Title::newFromText( $wgContLang->lc( $term ) ); |
| 66 | + $title = Title::newFromText( strtolower( $term ) ); |
68 | 67 | if ( $title->exists() ) { |
69 | 68 | return $title; |
70 | 69 | } |
71 | 70 | |
72 | 71 | # Now try capitalized string |
73 | 72 | # |
74 | | - $title = Title::newFromText( $wgContLang->ucwords( $term ) ); |
| 73 | + $title = Title::newFromText( ucwords( strtolower( $term ) ) ); |
75 | 74 | if ( $title->exists() ) { |
76 | 75 | return $title; |
77 | 76 | } |
78 | 77 | |
79 | 78 | # Now try all upper case |
80 | 79 | # |
81 | | - $title = Title::newFromText( $wgContLang->uc( $term ) ); |
| 80 | + $title = Title::newFromText( strtoupper( $term ) ); |
82 | 81 | if ( $title->exists() ) { |
83 | 82 | return $title; |
84 | 83 | } |
85 | 84 | |
86 | 85 | # Now try Word-Caps-Breaking-At-Word-Breaks, for hyphenated names etc |
87 | | - $title = Title::newFromText( $wgContLang->ucwordbreaks($term) ); |
| 86 | + $title = Title::newFromText( preg_replace_callback( |
| 87 | + '/\b([\w\x80-\xff]+)\b/', |
| 88 | + create_function( '$matches', ' |
| 89 | + global $wgContLang; |
| 90 | + return $wgContLang->ucfirst($matches[1]); |
| 91 | + ' ), |
| 92 | + $term ) ); |
88 | 93 | if ( $title->exists() ) { |
89 | 94 | return $title; |
90 | 95 | } |
Index: trunk/phase3/includes/Parser.php |
— | — | @@ -1507,6 +1507,7 @@ |
1508 | 1508 | } |
1509 | 1509 | |
1510 | 1510 | $selflink = $this->mTitle->getPrefixedText(); |
| 1511 | + $checkVariantLink = sizeof($wgContLang->getVariants())>1; |
1511 | 1512 | $useSubpages = $this->areSubpagesAllowed(); |
1512 | 1513 | wfProfileOut( $fname.'-setup' ); |
1513 | 1514 | |
— | — | @@ -1601,6 +1602,13 @@ |
1602 | 1603 | continue; |
1603 | 1604 | } |
1604 | 1605 | |
| 1606 | + #check other language variants of the link |
| 1607 | + #if the article does not exist |
| 1608 | + if( $checkVariantLink |
| 1609 | + && $nt->getArticleID() == 0 ) { |
| 1610 | + $wgContLang->findVariantLink($link, $nt); |
| 1611 | + } |
| 1612 | + |
1605 | 1613 | $ns = $nt->getNamespace(); |
1606 | 1614 | $iw = $nt->getInterWiki(); |
1607 | 1615 | wfProfileOut( "$fname-title" ); |
— | — | @@ -3889,7 +3897,6 @@ |
3890 | 3898 | function replaceLinkHolders( &$text, $options = 0 ) { |
3891 | 3899 | global $wgUser; |
3892 | 3900 | global $wgOutputReplace; |
3893 | | - global $wgContLang, $wgLanguageCode; |
3894 | 3901 | |
3895 | 3902 | $fname = 'Parser::replaceLinkHolders'; |
3896 | 3903 | wfProfileIn( $fname ); |
— | — | @@ -3980,97 +3987,6 @@ |
3981 | 3988 | } |
3982 | 3989 | wfProfileOut( $fname.'-check' ); |
3983 | 3990 | |
3984 | | - # Do a second query for different language variants of links (if needed) |
3985 | | - if($wgContLang->hasVariants()){ |
3986 | | - $linkBatch = new LinkBatch(); |
3987 | | - $variantMap = array(); // maps $pdbkey_Variant => $pdbkey_original |
3988 | | - |
3989 | | - // Add variants of links to link batch |
3990 | | - foreach ( $this->mLinkHolders['namespaces'] as $key => $ns ) { |
3991 | | - $title = $this->mLinkHolders['titles'][$key]; |
3992 | | - if ( is_null( $title ) ) |
3993 | | - continue; |
3994 | | - |
3995 | | - $pdbk = $title->getPrefixedDBkey(); |
3996 | | - |
3997 | | - // add the original text into query to check for notitleconvert pages |
3998 | | - $variantTitle = Title::makeTitle( $ns, $title->getText() ); |
3999 | | - $linkBatch->addObj( $variantTitle ); |
4000 | | - $variantMap[$variantTitle->getPrefixedDBkey()][] = $key; |
4001 | | - |
4002 | | - // generate all variants of the link title text |
4003 | | - $allTextVariants = $wgContLang->convertLinkToAllVariants($title->getText()); |
4004 | | - |
4005 | | - // if link was not found (in first query), add all variants to query |
4006 | | - if ( !isset($colours[$pdbk]) ){ |
4007 | | - foreach($allTextVariants as $textVariant){ |
4008 | | - $variantTitle = Title::makeTitle( $ns, $textVariant ); |
4009 | | - if(is_null($variantTitle)) continue; |
4010 | | - $linkBatch->addObj( $variantTitle ); |
4011 | | - $variantMap[$variantTitle->getPrefixedDBkey()][] = $key; |
4012 | | - } |
4013 | | - } |
4014 | | - } |
4015 | | - |
4016 | | - # construct query |
4017 | | - $titleClause = $linkBatch->constructSet('page', $dbr); |
4018 | | - $variantQuery = "SELECT page_id, page_namespace, page_title"; |
4019 | | - if ( $threshold > 0 ) { |
4020 | | - $variantQuery .= ', page_len, page_is_redirect'; |
4021 | | - } |
4022 | | - $variantQuery .= ", page_no_title_convert FROM $page WHERE $titleClause"; |
4023 | | - if ( $options & RLH_FOR_UPDATE ) { |
4024 | | - $query .= ' FOR UPDATE'; |
4025 | | - } |
4026 | | - |
4027 | | - $varRes = $dbr->query( $variantQuery, $fname ); |
4028 | | - |
4029 | | - # for each found variants, figure out link holders and replace |
4030 | | - while ( $s = $dbr->fetchObject($varRes) ) { |
4031 | | - |
4032 | | - $variantTitle = Title::makeTitle( $s->page_namespace, $s->page_title ); |
4033 | | - $varPdbk = $variantTitle->getPrefixedDBkey(); |
4034 | | - $linkCache->addGoodLinkObj( $s->page_id, $variantTitle ); |
4035 | | - $this->mOutput->addLink( $variantTitle, $s->page_id ); |
4036 | | - |
4037 | | - $noTitleConvert = $s->page_no_title_convert; |
4038 | | - |
4039 | | - $holderKeys = $variantMap[$varPdbk]; |
4040 | | - |
4041 | | - // loop over link holders |
4042 | | - foreach($holderKeys as $key){ |
4043 | | - $title = $this->mLinkHolders['titles'][$key]; |
4044 | | - if ( is_null( $title ) ) continue; |
4045 | | - |
4046 | | - $pdbk = $title->getPrefixedDBkey(); |
4047 | | - |
4048 | | - if(!isset($colours[$pdbk]) || ($noTitleConvert && $colours[$pdbk] == 1)){ |
4049 | | - // found link in some of the variants, replace the link holder data |
4050 | | - $this->mLinkHolders['titles'][$key] = $variantTitle; |
4051 | | - $this->mLinkHolders['dbkeys'][$key] = $variantTitle->getDBkey(); |
4052 | | - |
4053 | | - // prevent link conversion if needed |
4054 | | - if($noTitleConvert) |
4055 | | - $this->mLinkHolders['texts'][$key] = $wgContLang->markNoConversion($variantTitle->getText(),true); |
4056 | | - |
4057 | | - // set pdbk and colour |
4058 | | - $pdbks[$key] = $varPdbk; |
4059 | | - if ( $threshold > 0 ) { |
4060 | | - $size = $s->page_len; |
4061 | | - if ( $s->page_is_redirect || $s->page_namespace != 0 || $size >= $threshold ) { |
4062 | | - $colours[$varPdbk] = 1; |
4063 | | - } else { |
4064 | | - $colours[$varPdbk] = 2; |
4065 | | - } |
4066 | | - } |
4067 | | - else { |
4068 | | - $colours[$varPdbk] = 1; |
4069 | | - } |
4070 | | - } |
4071 | | - } |
4072 | | - } |
4073 | | - } |
4074 | | - |
4075 | 3991 | # Construct search and replace arrays |
4076 | 3992 | wfProfileIn( $fname.'-construct' ); |
4077 | 3993 | $wgOutputReplace = array(); |
Index: trunk/phase3/includes/SpecialSearch.php |
— | — | @@ -77,7 +77,6 @@ |
78 | 78 | function goResult( $term ) { |
79 | 79 | global $wgOut; |
80 | 80 | global $wgGoToEdit; |
81 | | - global $wgContLang; |
82 | 81 | |
83 | 82 | $this->setupPage( $term ); |
84 | 83 | |
— | — | @@ -97,20 +96,6 @@ |
98 | 97 | return; |
99 | 98 | } |
100 | 99 | |
101 | | - # if language supports variants, search in all variants |
102 | | - if($wgContLang->hasVariants()){ |
103 | | - $allTermVariants = $wgContLang->convertLinkToAllVariants($term); |
104 | | - |
105 | | - foreach($allTermVariants as $termVariant){ |
106 | | - $t = SearchEngine::getNearMatch( $termVariant ); |
107 | | - if( !is_null( $t ) ) { |
108 | | - $wgOut->redirect( $t->getFullURL() ); |
109 | | - wfProfileOut( $fname ); |
110 | | - return; |
111 | | - } |
112 | | - } |
113 | | - } |
114 | | - |
115 | 100 | # No match, generate an edit URL |
116 | 101 | $t = Title::newFromText( $term ); |
117 | 102 | if( is_null( $t ) ) { |
Index: trunk/phase3/languages/MessagesSr_el.php |
— | — | @@ -175,7 +175,7 @@ |
176 | 176 | 'servername' => array( 0, 'SERVERNAME', 'IMESERVERA' ), |
177 | 177 | 'scriptpath' => array( 0, 'SCRIPTPATH', 'SKRIPTA' ), |
178 | 178 | 'grammar' => array( 0, 'GRAMMAR:', 'GRAMATIKA:' ), |
179 | | - 'notitleconvert' => array( 0, '__NOTITLECONVERT__', '__NOTC__', '__БЕЗКН__', '__BEZKN__' ), |
| 179 | + 'notitleconvert' => array( 0, '__NOTITLECONVERT__', '__NOTC__', '__BEZTC__' ), |
180 | 180 | 'nocontentconvert' => array( 0, '__NOCONTENTCONVERT__', '__NOCC__', '__BEZCC__' ), |
181 | 181 | 'currentweek' => array( 1, 'CURRENTWEEK', 'TRENUTNANEDELjA' ), |
182 | 182 | 'currentdow' => array( 1, 'CURRENTDOW', 'TRENUTNIDOV' ), |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -49,10 +49,9 @@ |
50 | 50 | function findVariantLink(&$l, &$n) {} |
51 | 51 | function getExtraHashOptions() {return '';} |
52 | 52 | function getParsedTitle() {return '';} |
53 | | - function markNoConversion($text, $noParse=false) {return $text;} |
| 53 | + function markNoConversion($text) {return $text;} |
54 | 54 | function convertCategoryKey( $key ) {return $key; } |
55 | | - function convertLinkToAllVariants($text){ return array( $this->mLang->getCode() => $text); } |
56 | | - function setNoTitleConvert(){} |
| 55 | + |
57 | 56 | } |
58 | 57 | |
59 | 58 | #-------------------------------------------------------------------------- |
— | — | @@ -713,34 +712,6 @@ |
714 | 713 | return iconv( $in, $out, $string ); |
715 | 714 | } |
716 | 715 | |
717 | | - // callback functions for uc(), lc(), ucwords(), ucwordbreaks() |
718 | | - function ucwordbreaksCallbackAscii($matches){ |
719 | | - return $this->ucfirst($matches[1]); |
720 | | - } |
721 | | - |
722 | | - function ucwordbreaksCallbackMB($matches){ |
723 | | - return mb_strtoupper($matches[0]); |
724 | | - } |
725 | | - |
726 | | - function ucCallback($matches){ |
727 | | - global $wikiUpperChars; |
728 | | - return strtr( $matches[1] , $wikiUpperChars ); |
729 | | - } |
730 | | - |
731 | | - function lcCallback($matches){ |
732 | | - global $wikiLowerChars; |
733 | | - return strtr( $matches[1] , $wikiLowerChars ); |
734 | | - } |
735 | | - |
736 | | - function ucwordsCallbackMB($matches){ |
737 | | - return mb_strtoupper($matches[0]); |
738 | | - } |
739 | | - |
740 | | - function ucwordsCallbackWiki($matches){ |
741 | | - global $wikiUpperChars; |
742 | | - return strtr( $matches[0] , $wikiUpperChars ); |
743 | | - } |
744 | | - |
745 | 716 | function ucfirst( $str ) { |
746 | 717 | return self::uc( $str, true ); |
747 | 718 | } |
— | — | @@ -758,9 +729,9 @@ |
759 | 730 | if ( self::isMultibyte( $str ) ) { |
760 | 731 | list( $wikiUpperChars ) = $this->getCaseMaps(); |
761 | 732 | $x = $first ? '^' : ''; |
762 | | - return preg_replace_callback( |
763 | | - "/$x([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)/", |
764 | | - array($this,"ucCallback"), |
| 733 | + return preg_replace( |
| 734 | + "/$x([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)/e", |
| 735 | + "strtr( \"\$1\" , \$wikiUpperChars )", |
765 | 736 | $str |
766 | 737 | ); |
767 | 738 | } else |
— | — | @@ -784,9 +755,9 @@ |
785 | 756 | if ( self::isMultibyte( $str ) ) { |
786 | 757 | list( , $wikiLowerChars ) = self::getCaseMaps(); |
787 | 758 | $x = $first ? '^' : ''; |
788 | | - return preg_replace_callback( |
789 | | - "/$x([A-Z]|[\\xc0-\\xff][\\x80-\\xbf]*)/", |
790 | | - array($this,"lcCallback"), |
| 759 | + return preg_replace( |
| 760 | + "/$x([A-Z]|[\\xc0-\\xff][\\x80-\\xbf]*)/e", |
| 761 | + "strtr( \"\$1\" , \$wikiLowerChars )", |
791 | 762 | $str |
792 | 763 | ); |
793 | 764 | } else |
— | — | @@ -797,66 +768,6 @@ |
798 | 769 | return (bool)preg_match( '/[\x80-\xff]/', $str ); |
799 | 770 | } |
800 | 771 | |
801 | | - function ucwords($str) { |
802 | | - global $wikiUpperChars; |
803 | | - |
804 | | - if ( self::isMultibyte( $str ) ) { |
805 | | - $str = self::lc($str); |
806 | | - |
807 | | - // regexp to find first letter in each word (i.e. after each space) |
808 | | - $replaceRegexp = "/^([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)| ([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)/"; |
809 | | - |
810 | | - // function to use to capitalize a single char |
811 | | - if ( function_exists( 'mb_strtoupper' ) ) |
812 | | - return preg_replace_callback( |
813 | | - $replaceRegexp, |
814 | | - array($this,"ucwordsCallbackMB"), |
815 | | - $str |
816 | | - ); |
817 | | - else |
818 | | - return preg_replace_callback( |
819 | | - $replaceRegexp, |
820 | | - array($this,"ucwordsCallbackWiki"), |
821 | | - $str |
822 | | - ); |
823 | | - } |
824 | | - else |
825 | | - return ucwords( strtolower( $str ) ); |
826 | | - } |
827 | | - |
828 | | - # capitalize words at word breaks |
829 | | - function ucwordbreaks($str){ |
830 | | - global $wikiUpperChars; |
831 | | - |
832 | | - if (self::isMultibyte( $str ) ) { |
833 | | - $str = self::lc($str); |
834 | | - |
835 | | - // since \b doesn't work for UTF-8, we explicitely define word break chars |
836 | | - $breaks= "[ \-\(\)\}\{\.,\?!]"; |
837 | | - |
838 | | - // find first letter after word break |
839 | | - $replaceRegexp = "/^([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)|$breaks([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)/"; |
840 | | - |
841 | | - if ( function_exists( 'mb_strtoupper' ) ) |
842 | | - return preg_replace_callback( |
843 | | - $replaceRegexp, |
844 | | - array($this,"ucwordbreaksCallbackMB"), |
845 | | - $str |
846 | | - ); |
847 | | - else |
848 | | - return preg_replace_callback( |
849 | | - $replaceRegexp, |
850 | | - array($this,"ucwordsCallbackWiki"), |
851 | | - $str |
852 | | - ); |
853 | | - } |
854 | | - else |
855 | | - return preg_replace_callback( |
856 | | - '/\b([\w\x80-\xff]+)\b/', |
857 | | - array($this,"ucwordbreaksCallbackAscii"), |
858 | | - $str ); |
859 | | - } |
860 | | - |
861 | 772 | function checkTitleEncoding( $s ) { |
862 | 773 | if( is_array( $s ) ) { |
863 | 774 | wfDebugDieBacktrace( 'Given array to checkTitleEncoding.' ); |
— | — | @@ -1258,17 +1169,6 @@ |
1259 | 1170 | return $this->mConverter->parserConvert( $text, $parser ); |
1260 | 1171 | } |
1261 | 1172 | |
1262 | | - # Tell the converter that it shouldn't convert titles |
1263 | | - function setNoTitleConvert(){ |
1264 | | - $this->mConverter->setNotitleConvert(); |
1265 | | - } |
1266 | | - |
1267 | | - # Check if this is a language with variants |
1268 | | - function hasVariants(){ |
1269 | | - return sizeof($this->getVariants())>1; |
1270 | | - } |
1271 | | - |
1272 | | - |
1273 | 1173 | /** |
1274 | 1174 | * Perform output conversion on a string, and encode for safe HTML output. |
1275 | 1175 | * @param string $text |
— | — | @@ -1314,17 +1214,6 @@ |
1315 | 1215 | } |
1316 | 1216 | |
1317 | 1217 | /** |
1318 | | - * If a language supports multiple variants, converts text |
1319 | | - * into an array of all possible variants of the text: |
1320 | | - * 'variant' => text in that variant |
1321 | | - */ |
1322 | | - |
1323 | | - function convertLinkToAllVariants($text){ |
1324 | | - return $this->mConverter->convertLinkToAllVariants($text); |
1325 | | - } |
1326 | | - |
1327 | | - |
1328 | | - /** |
1329 | 1218 | * returns language specific options used by User::getPageRenderHash() |
1330 | 1219 | * for example, the preferred language variant |
1331 | 1220 | * |
— | — | @@ -1353,8 +1242,8 @@ |
1354 | 1243 | * @param string $text text to be tagged for no conversion |
1355 | 1244 | * @return string the tagged text |
1356 | 1245 | */ |
1357 | | - function markNoConversion( $text, $noParse=false ) { |
1358 | | - return $this->mConverter->markNoConversion( $text, $noParse ); |
| 1246 | + function markNoConversion( $text ) { |
| 1247 | + return $this->mConverter->markNoConversion( $text ); |
1359 | 1248 | } |
1360 | 1249 | |
1361 | 1250 | /** |
Index: trunk/phase3/languages/MessagesSr_ec.php |
— | — | @@ -173,7 +173,7 @@ |
174 | 174 | 'servername' => array( 0, 'SERVERNAME', 'ИМЕСЕРВЕРА' ), |
175 | 175 | 'scriptpath' => array( 0, 'SCRIPTPATH', 'СКРИПТА' ), |
176 | 176 | 'grammar' => array( 0, 'GRAMMAR:', 'ГРАМАТИКА:' ), |
177 | | - 'notitleconvert' => array( 0, '__NOTITLECONVERT__', '__NOTC__', '__БЕЗКН__', '__BEZKN__' ), |
| 177 | + 'notitleconvert' => array( 0, '__NOTITLECONVERT__', '__NOTC__', '__БЕЗТЦ__' ), |
178 | 178 | 'nocontentconvert' => array( 0, '__NOCONTENTCONVERT__', '__NOCC__', '__БЕЗЦЦ__' ), |
179 | 179 | 'currentweek' => array( 1, 'CURRENTWEEK', 'ТРЕНУТНАНЕДЕЉА' ), |
180 | 180 | 'currentdow' => array( 1, 'CURRENTDOW', 'ТРЕНУТНИДОВ' ), |
Index: trunk/phase3/languages/LanguageConverter.php |
— | — | @@ -22,7 +22,6 @@ |
23 | 23 | var $mMarkup; |
24 | 24 | var $mFlags; |
25 | 25 | var $mUcfirst = false; |
26 | | - var $mNoTitleConvert = false; |
27 | 26 | /** |
28 | 27 | * Constructor |
29 | 28 | * |
— | — | @@ -39,7 +38,6 @@ |
40 | 39 | $markup=array(), |
41 | 40 | $flags = array()) { |
42 | 41 | global $wgDBname; |
43 | | - global $wgLegalTitleChars; |
44 | 42 | $this->mLangObj = $langobj; |
45 | 43 | $this->mMainLanguageCode = $maincode; |
46 | 44 | $this->mVariants = $variants; |
— | — | @@ -157,17 +155,14 @@ |
158 | 156 | $marker = ""; |
159 | 157 | |
160 | 158 | // this one is needed when the text is inside an html markup |
161 | | - $htmlfix = '|<[^>]+$|^[^<>]*>'; |
| 159 | + $htmlfix = '|<[^>]+=\"[^(>=)]*$|^[^(<>=\")]*\"[^>]*>'; |
162 | 160 | |
163 | | - // disable convert to variants between <code></code> tags |
164 | | - $codefix = '<code>.+?<\/code>|'; |
165 | | - |
166 | | - $reg = '/'.$codefix.'<[^>]+>|&[a-z#][a-z0-9]+;' . $marker . $htmlfix . '/s'; |
| 161 | + $reg = '/<[^>]+>|&[a-z#][a-z0-9]+;' . $marker . $htmlfix . '/'; |
167 | 162 | |
168 | 163 | $matches = preg_split($reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE); |
169 | 164 | |
170 | | - $m = array_shift($matches); |
171 | 165 | |
| 166 | + $m = array_shift($matches); |
172 | 167 | $ret = $this->translate($m[0], $toVariant); |
173 | 168 | $mstart = $m[1]+strlen($m[0]); |
174 | 169 | foreach($matches as $m) { |
— | — | @@ -202,7 +197,7 @@ |
203 | 198 | * |
204 | 199 | * @param string $text the text to be converted |
205 | 200 | * @return array of string |
206 | | - * @public |
| 201 | + * @private |
207 | 202 | */ |
208 | 203 | function autoConvertToAllVariants($text) { |
209 | 204 | $fname="LanguageConverter::autoConvertToAllVariants"; |
— | — | @@ -214,52 +209,18 @@ |
215 | 210 | foreach($this->mVariants as $variant) { |
216 | 211 | $ret[$variant] = $this->translate($text, $variant); |
217 | 212 | } |
218 | | - |
219 | 213 | wfProfileOut( $fname ); |
220 | 214 | return $ret; |
221 | 215 | } |
222 | 216 | |
223 | 217 | /** |
224 | | - * convert link text to all supported variants |
225 | | - * |
226 | | - * @param string $text the text to be converted |
227 | | - * @return array of string |
228 | | - * @public |
229 | | - */ |
230 | | - function convertLinkToAllVariants($text) { |
231 | | - if( !$this->mTablesLoaded ) |
232 | | - $this->loadTables(); |
233 | | - |
234 | | - $ret = array(); |
235 | | - $tarray = explode($this->mMarkup['begin'], $text); |
236 | | - $tfirst = array_shift($tarray); |
237 | | - |
238 | | - foreach($this->mVariants as $variant) |
239 | | - $ret[$variant] = $this->translate($tfirst,$variant); |
240 | | - |
241 | | - foreach($tarray as $txt) { |
242 | | - $marked = explode($this->mMarkup['end'], $txt, 2); |
243 | | - |
244 | | - foreach($this->mVariants as $variant){ |
245 | | - $ret[$variant] .= $this->mMarkup['begin'].$marked[0].$this->mMarkup['end']; |
246 | | - if(array_key_exists(1, $marked)) |
247 | | - $ret[$variant] .= $this->translate($marked[1],$variant); |
248 | | - } |
249 | | - |
250 | | - } |
251 | | - |
252 | | - return $ret; |
253 | | - } |
254 | | - |
255 | | - |
256 | | - /** |
257 | 218 | * Convert text using a parser object for context |
258 | 219 | */ |
259 | 220 | function parserConvert( $text, &$parser ) { |
260 | 221 | global $wgDisableLangConversion; |
261 | 222 | /* don't do anything if this is the conversion table */ |
262 | 223 | if ( $parser->mTitle->getNamespace() == NS_MEDIAWIKI && |
263 | | - strpos($parser->mTitle->getText(), "Conversiontable") !== false ) |
| 224 | + strpos($parser->mTitle->getText, "Conversiontable") !== false ) |
264 | 225 | { |
265 | 226 | return $text; |
266 | 227 | } |
— | — | @@ -303,11 +264,6 @@ |
304 | 265 | return $text; |
305 | 266 | |
306 | 267 | if( $isTitle ) { |
307 | | - if($this->mNoTitleConvert){ |
308 | | - $this->mTitleDisplay = $text; |
309 | | - return $text; |
310 | | - } |
311 | | - |
312 | 268 | if( !$this->mDoTitleConvert ) { |
313 | 269 | $this->mTitleDisplay = $text; |
314 | 270 | return $text; |
— | — | @@ -322,7 +278,7 @@ |
323 | 279 | return $text; |
324 | 280 | } |
325 | 281 | else { |
326 | | - $this->mTitleDisplay = $this->convert($text); |
| 282 | + $this->mTitleDisplay = $this->autoConvert($text); |
327 | 283 | return $this->mTitleDisplay; |
328 | 284 | } |
329 | 285 | } |
— | — | @@ -359,7 +315,7 @@ |
360 | 316 | else |
361 | 317 | $rules = $marked[0]; |
362 | 318 | |
363 | | - //FIXME: may cause trouble here... |
| 319 | +#FIXME: may cause trouble here... |
364 | 320 | //strip since it interferes with the parsing, plus, |
365 | 321 | //all spaces should be stripped in this tag anyway. |
366 | 322 | $rules = str_replace(' ', '', $rules); |
— | — | @@ -454,16 +410,23 @@ |
455 | 411 | * @access public |
456 | 412 | */ |
457 | 413 | function findVariantLink( &$link, &$nt ) { |
| 414 | + static $count=0; //used to limit this operation |
| 415 | + static $cache=array(); |
458 | 416 | global $wgDisableLangConversion; |
459 | 417 | $pref = $this->getPreferredVariant(); |
460 | 418 | $ns=0; |
461 | 419 | if(is_object($nt)) |
462 | 420 | $ns = $nt->getNamespace(); |
463 | | - |
| 421 | + if( $count > 50 && $ns != NS_CATEGORY ) |
| 422 | + return; |
| 423 | + $count++; |
464 | 424 | $variants = $this->autoConvertToAllVariants($link); |
465 | 425 | if($variants == false) //give up |
466 | 426 | return; |
467 | 427 | foreach( $variants as $v ) { |
| 428 | + if(isset($cache[$v])) |
| 429 | + continue; |
| 430 | + $cache[$v] = 1; |
468 | 431 | $varnt = Title::newFromText( $v, $ns ); |
469 | 432 | if( $varnt && $varnt->getArticleID() > 0 ) { |
470 | 433 | $nt = $varnt; |
— | — | @@ -692,7 +655,7 @@ |
693 | 656 | * @param string $text text to be tagged for no conversion |
694 | 657 | * @return string the tagged text |
695 | 658 | */ |
696 | | - function markNoConversion($text, $noParse=false) { |
| 659 | + function markNoConversion($text) { |
697 | 660 | # don't mark if already marked |
698 | 661 | if(strpos($text, $this->mMarkup['begin']) || |
699 | 662 | strpos($text, $this->mMarkup['end'])) |
— | — | @@ -733,11 +696,6 @@ |
734 | 697 | } |
735 | 698 | return true; |
736 | 699 | } |
737 | | - |
738 | | - function setNoTitleConvert(){ |
739 | | - $this->mNoTitleConvert = true; |
740 | | - } |
741 | | - |
742 | 700 | } |
743 | 701 | |
744 | 702 | ?> |
Index: trunk/phase3/languages/LanguageSr.php |
— | — | @@ -169,8 +169,8 @@ |
170 | 170 | * We want our external link captions to be converted in variants, |
171 | 171 | * so we return the original text instead -{$text}-, except for URLs |
172 | 172 | */ |
173 | | - function markNoConversion($text, $noParse=false) { |
174 | | - if($noParse || preg_match("/^https?:\/\/|ftp:\/\/|irc:\/\//",$text)) |
| 173 | + function markNoConversion($text) { |
| 174 | + if(preg_match("/^https?:\/\/|ftp:\/\/|irc:\/\//",$text)) |
175 | 175 | return parent::markNoConversion($text); |
176 | 176 | return $text; |
177 | 177 | } |
— | — | @@ -188,51 +188,22 @@ |
189 | 189 | return parent::autoConvert($text,$toVariant); |
190 | 190 | } |
191 | 191 | |
192 | | - /** |
193 | | - * It translates text into variant, specials: |
194 | | - * - ommiting roman numbers |
195 | | - */ |
196 | | - function translate($text, $toVariant){ |
197 | | - $breaks = '[^\w\x80-\xff]'; |
198 | 192 | |
199 | | - // regexp for roman numbers |
200 | | - $roman = 'M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})'; |
201 | | - |
202 | | - $reg = '/^'.$roman.'$|^'.$roman.$breaks.'|'.$breaks.$roman.'$|'.$breaks.$roman.$breaks.'/'; |
203 | | - |
204 | | - $matches = preg_split($reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE); |
205 | | - |
206 | | - $m = array_shift($matches); |
207 | | - $ret = strtr($m[0], $this->mTables[$toVariant]); |
208 | | - $mstart = $m[1]+strlen($m[0]); |
209 | | - foreach($matches as $m) { |
210 | | - $ret .= substr($text, $mstart, $m[1]-$mstart); |
211 | | - $ret .= parent::translate($m[0], $toVariant); |
212 | | - $mstart = $m[1] + strlen($m[0]); |
213 | | - } |
214 | | - |
215 | | - return $ret; |
216 | | - } |
217 | | - |
218 | | - |
219 | 193 | } |
220 | 194 | |
221 | 195 | class LanguageSr extends LanguageSr_ec { |
222 | 196 | function __construct() { |
223 | 197 | global $wgHooks; |
224 | | - |
225 | 198 | parent::__construct(); |
226 | 199 | |
227 | | - // these variants are currently UNUSED: |
228 | | - // 'sr-jc', 'sr-jl' |
229 | | - $variants = array('sr', 'sr-ec', 'sr-el'); |
| 200 | + $variants = array('sr', 'sr-ec', 'sr-jc', 'sr-el', 'sr-jl'); |
230 | 201 | $variantfallbacks = array( |
231 | 202 | 'sr' => 'sr-ec', |
232 | | - 'sr-ec' => 'sr-ec', |
233 | | - 'sr-el' => 'sr-el', |
234 | | - ); |
235 | | - |
236 | | - |
| 203 | + 'sr-ec' => 'sr-jc', |
| 204 | + 'sr-jc' => 'sr-ec', |
| 205 | + 'sr-el' => 'sr-jl', |
| 206 | + 'sr-jl' => 'sr-el' |
| 207 | + ); |
237 | 208 | $marker = array();//don't mess with these, leave them as they are |
238 | 209 | $flags = array( |
239 | 210 | 'S' => 'S', 'писмо' => 'S', 'pismo' => 'S', |