r41041 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41040‎ | r41041 | r41042 >
Date:18:47, 19 September 2008
Author:brion
Status:old
Tags:
Comment:
Quickie example adding $wgLang->commaList() to encapsulate use of 'comma-separator' message.
Fixme: being in a hurry, I didn't make it work correctly for non-UI languages. It should grab from the appropriate lang, not just wfMsgExt.
Modified paths:
  • /trunk/phase3/includes/Exif.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialPreferences.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUpload.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Exif.php
@@ -799,7 +799,7 @@
800800 $fullTag = $tag . '-' . $subTag ;
801801 $flashMsgs[] = $this->msg( $fullTag, $subValue );
802802 }
803 - $tags[$tag] = implode( wfMsg( 'comma-separator' ), $flashMsgs );
 803+ $tags[$tag] = $wgLang->commaList( $flashMsgs );
804804 break;
805805
806806 case 'FocalPlaneResolutionUnit':
Index: trunk/phase3/includes/specials/SpecialPreferences.php
@@ -633,7 +633,7 @@
634634
635635 $this->tableRow(
636636 wfMsgExt( 'prefs-memberingroups', array( 'parseinline' ), count( $userEffectiveGroupsArray ) ),
637 - implode( wfMsg( 'comma-separator' ), $userEffectiveGroupsArray ) .
 637+ $wgLang->commaList( $userEffectiveGroupsArray ) .
638638 '<br />(' . implode( ' | ', $toolLinks ) . ')'
639639 ) .
640640
Index: trunk/phase3/includes/specials/SpecialUpload.php
@@ -328,10 +328,7 @@
329329 wfMsgExt( 'filetype-banned-type',
330330 array( 'parseinline' ),
331331 htmlspecialchars( $finalExt ),
332 - implode(
333 - wfMsgExt( 'comma-separator', array( 'escapenoentities' ) ),
334 - $wgFileExtensions
335 - ),
 332+ $wgLang->commaList( $wgFileExtensions ),
336333 $wgLang->formatNum( count($wgFileExtensions) )
337334 )
338335 );
@@ -520,10 +517,7 @@
521518 wfMsgExt( 'filetype-unwanted-type',
522519 array( 'parseinline' ),
523520 htmlspecialchars( $finalExt ),
524 - implode(
525 - wfMsgExt( 'comma-separator', array( 'escapenoentities' ) ),
526 - $wgFileExtensions
527 - ),
 521+ $wgLang->commaList( $wgFileExtensions ),
528522 $wgLang->formatNum( count($wgFileExtensions) )
529523 ) . '</li>';
530524 }
@@ -1005,21 +999,20 @@
10061000
10071001 $allowedExtensions = '';
10081002 if( $wgCheckFileExtensions ) {
1009 - $delim = wfMsgExt( 'comma-separator', array( 'escapenoentities' ) );
10101003 if( $wgStrictFileExtensions ) {
10111004 # Everything not permitted is banned
10121005 $extensionsList =
10131006 '<div id="mw-upload-permitted">' .
1014 - wfMsgWikiHtml( 'upload-permitted', implode( $wgFileExtensions, $delim ) ) .
 1007+ wfMsgWikiHtml( 'upload-permitted', $wgLang->commaList( $wgFileExtensions ) ) .
10151008 "</div>\n";
10161009 } else {
10171010 # We have to list both preferred and prohibited
10181011 $extensionsList =
10191012 '<div id="mw-upload-preferred">' .
1020 - wfMsgWikiHtml( 'upload-preferred', implode( $wgFileExtensions, $delim ) ) .
 1013+ wfMsgWikiHtml( 'upload-preferred', $wgLang->commaList( $wgFileExtensions ) ) .
10211014 "</div>\n" .
10221015 '<div id="mw-upload-prohibited">' .
1023 - wfMsgWikiHtml( 'upload-prohibited', implode( $wgFileBlacklist, $delim ) ) .
 1016+ wfMsgWikiHtml( 'upload-prohibited', $wgLang->commaList( $wgFileBlacklist ) ) .
10241017 "</div>\n";
10251018 }
10261019 } else {
Index: trunk/phase3/languages/Language.php
@@ -1898,6 +1898,17 @@
18991899 }
19001900 return $s;
19011901 }
 1902+
 1903+ /**
 1904+ * Take a list of strings and build a locale-friendly comma-separated
 1905+ * list, using the local comma-separator message.
 1906+ * @fixme Fix this so it can work for $wgContLang too
 1907+ */
 1908+ function commaList( $list ) {
 1909+ return implode(
 1910+ $list,
 1911+ wfMsgExt( 'comma-separator', 'escape-noentities' ) );
 1912+ }
19021913
19031914 /**
19041915 * Truncate a string to a specified length in bytes, appending an optional

Follow-up revisions

RevisionCommit summaryAuthorDate
r41043Cleanup to r41041. escape-noentities => escapenoentitiesdemon19:06, 19 September 2008