r38784 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38783‎ | r38784 | r38785 >
Date:14:26, 7 August 2008
Author:shinjiman
Status:old
Tags:
Comment:
* Added $wgDisableTitleConversion to disabling the conversion for all pages on the wiki (this one is useful for some wikis that do not need the title conversion for the entire wiki like Wiktionary)
* Added 'noconvertlink' toogle that can be set per user preferences, also added 'convertlink=no|yes' on GET requests whether have the link titles being converted or not
patches by PhiLiP
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialPreferences.php (modified) (history)
  • /trunk/phase3/languages/LanguageConverter.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesYue.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesZh_classical.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesZh_hans.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesZh_hant.php (modified) (history)
  • /trunk/phase3/maintenance/language/messageTypes.inc (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES
@@ -47,6 +47,11 @@
4848 * (bug 14377) Add a date selector to history pages
4949 * (bug 15007) New 'pagetitle-view-mainpage' message allows the HTML <title> of
5050 the main page to be customized
 51+* Added $wgDisableTitleConversion to disabling the conversion for all pages on
 52+ the wiki
 53+* Added 'noconvertlink' toogle that can be set per user preferences, also
 54+ added 'convertlink=no|yes' on GET requests whether have the link titles
 55+ being converted or not
5156
5257 === Bug fixes in 1.14 ===
5358
Index: trunk/phase3/languages/messages/MessagesYue.php
@@ -180,6 +180,7 @@
181181 'tog-ccmeonemails' => '當我寄電郵畀其他人嗰陣寄返封副本畀我',
182182 'tog-diffonly' => '響差異下面唔顯示頁面內容',
183183 'tog-showhiddencats' => '顯示隱藏類',
 184+'tog-noconvertlink' => '唔轉連結標題',
184185
185186 'underline-always' => '全部',
186187 'underline-never' => '永不',
Index: trunk/phase3/languages/messages/MessagesZh_classical.php
@@ -109,6 +109,7 @@
110110 'tog-watchlisthideown' => '不哨己文',
111111 'tog-watchlisthidebots' => '不哨僕文',
112112 'tog-showhiddencats' => '示隱類',
 113+'tog-noconvertlink' => '非轉鍵題',
113114
114115 'underline-always' => '恆',
115116 'underline-never' => '絕',
Index: trunk/phase3/languages/messages/MessagesZh_hans.php
@@ -123,6 +123,7 @@
124124 'tog-ccmeonemails' => '把我发送给其他用户的邮件同时发送副本给我自己',
125125 'tog-diffonly' => '在比较两个修订版本差异时不显示页面内容',
126126 'tog-showhiddencats' => '显示隐藏分类',
 127+'tog-noconvertlink' => '不转换链接标题',
127128
128129 'underline-always' => '总是使用',
129130 'underline-never' => '从不使用',
Index: trunk/phase3/languages/messages/MessagesZh_hant.php
@@ -105,6 +105,7 @@
106106 'tog-ccmeonemails' => '當我寄電子郵件給其他用戶時,也寄一份複本到我的信箱。',
107107 'tog-diffonly' => '在比較兩個修訂版本差異時不顯示頁面內容',
108108 'tog-showhiddencats' => '顯示隱藏分類',
 109+'tog-noconvertlink' => '不轉換連結標題',
109110
110111 'underline-always' => '總是使用',
111112 'underline-never' => '從不使用',
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -532,6 +532,7 @@
533533 'tog-ccmeonemails' => 'Send me copies of e-mails I send to other users',
534534 'tog-diffonly' => 'Do not show page content below diffs',
535535 'tog-showhiddencats' => 'Show hidden categories',
 536+'tog-noconvertlink' => 'Disable titles conversion', # only translate this message to other languages if you have to change it
536537
537538 'underline-always' => 'Always',
538539 'underline-never' => 'Never',
Index: trunk/phase3/languages/LanguageConverter.php
@@ -374,8 +374,10 @@
375375 * @private
376376 */
377377 function convertTitle($text){
378 - // check for __NOTC__ tag
379 - if( !$this->mDoTitleConvert ) {
 378+ global $wgDisableTitleConversion, $wgUser;
 379+
 380+ // check for global param and __NOTC__ tag
 381+ if( $wgDisableTitleConversion || !$this->mDoTitleConvert || $wgUser->getOption('noconvertlink') == 1 ) {
380382 $this->mTitleDisplay = $text;
381383 return $text;
382384 }
@@ -389,7 +391,8 @@
390392 global $wgRequest;
391393 $isredir = $wgRequest->getText( 'redirect', 'yes' );
392394 $action = $wgRequest->getText( 'action' );
393 - if ( $isredir == 'no' || $action == 'edit' ) {
 395+ $linkconvert = $wgRequest->getText( 'linkconvert', 'yes' );
 396+ if ( $isredir == 'no' || $action == 'edit' || $linkconvert == 'no' ) {
394397 return $text;
395398 } else {
396399 $this->mTitleDisplay = $this->convert($text);
@@ -467,11 +470,20 @@
468471 * @public
469472 */
470473 function findVariantLink( &$link, &$nt ) {
471 - global $wgDisableLangConversion;
 474+ global $wgDisableLangConversion, $wgDisableTitleConversion, $wgRequest, $wgUser;
 475+ $isredir = $wgRequest->getText( 'redirect', 'yes' );
 476+ $action = $wgRequest->getText( 'action' );
 477+ $linkconvert = $wgRequest->getText( 'linkconvert', 'yes' );
 478+ $disableLinkConversion = $wgDisableLangConversion || $wgDisableTitleConversion;
472479 $linkBatch = new LinkBatch();
473480
474481 $ns=NS_MAIN;
475482
 483+ if ( $disableLinkConversion || $isredir == 'no' || $action == 'edit'
 484+ || $linkconvert == 'no' || $wgUser->getOption('noconvertlink') == 1 ) {
 485+ return;
 486+ }
 487+
476488 if(is_object($nt))
477489 $ns = $nt->getNamespace();
478490
@@ -497,8 +509,7 @@
498510 foreach( $titles as $varnt ) {
499511 if( $varnt->getArticleID() > 0 ) {
500512 $nt = $varnt;
501 - if( !$wgDisableLangConversion )
502 - $link = $v;
 513+ $link = $v;
503514 break;
504515 }
505516 }
Index: trunk/phase3/maintenance/language/messages.inc
@@ -52,6 +52,7 @@
5353 'tog-ccmeonemails',
5454 'tog-diffonly',
5555 'tog-showhiddencats',
 56+ 'tog-noconvertlink',
5657 ),
5758 'underline' => array(
5859 'underline-always',
Index: trunk/phase3/maintenance/language/messageTypes.inc
@@ -163,6 +163,7 @@
164164 'unit-pixel',
165165 'userrights-irreversible-marker',
166166 'tog-nolangconversion',
 167+ 'tog-noconvertlink',
167168 'yourvariant',
168169 'variantname-zh-hans',
169170 'variantname-zh-hant',
Index: trunk/phase3/includes/DefaultSettings.php
@@ -861,6 +861,9 @@
862862 /** Whether to enable language variant conversion. */
863863 $wgDisableLangConversion = false;
864864
 865+/** Whether to enable language variant conversion for links. */
 866+$wgDisableTitleConversion = false;
 867+
865868 /** Default variant code, if false, the default will be the language code */
866869 $wgDefaultLanguageVariant = false;
867870
@@ -2226,6 +2229,7 @@
22272230 'watchdefault' => 0,
22282231 'watchmoves' => 0,
22292232 'watchdeletion' => 0,
 2233+ 'convertlink' => 0,
22302234 );
22312235
22322236 /** Whether or not to allow and use real name fields. Defaults to true. */
Index: trunk/phase3/includes/specials/SpecialPreferences.php
@@ -513,7 +513,7 @@
514514 function mainPrefsForm( $status , $message = '' ) {
515515 global $wgUser, $wgOut, $wgLang, $wgContLang;
516516 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
517 - global $wgDisableLangConversion;
 517+ global $wgDisableLangConversion, $wgDisableTitleConversion;
518518 global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
519519 global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
520520 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
@@ -734,6 +734,16 @@
735735 )
736736 );
737737 }
 738+
 739+ if(count($variantArray) > 1 && !$wgDisableLangConversion && !$wgDisableTitleConversion) {
 740+ $wgOut->addHtml(
 741+ Xml::tags( 'tr', null,
 742+ Xml::tags( 'td', array( 'colspan' => '2' ),
 743+ $this->getToggle( "noconvertlink" )
 744+ )
 745+ )
 746+ );
 747+ }
738748 }
739749
740750 # Password
Index: trunk/phase3/includes/User.php
@@ -88,6 +88,7 @@
8989 'ccmeonemails',
9090 'diffonly',
9191 'showhiddencats',
 92+ 'noconvertlink',
9293 );
9394
9495 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r38791follow up and fixing some leftovers for r38784shinjiman15:52, 7 August 2008
r38917Localisation updates Cantonese, Chinese and Old/Late Time Chinese...shinjiman17:06, 8 August 2008
r39076Fix for r38784: force the noconvertlink toggle to be marked as used, otherwis...ialex18:17, 10 August 2008
r39466sequel of r38784, adding the test case for the 'submit' action...shinjiman10:09, 16 August 2008

Status & tagging log