* Replace hardcoded '...' as indication of a truncation with the 'ellipsis' message
authorRaimond Spekking <raymond@users.mediawiki.org>
Fri, 13 Feb 2009 19:13:48 +0000 (19:13 +0000)
committerRaimond Spekking <raymond@users.mediawiki.org>
Fri, 13 Feb 2009 19:13:48 +0000 (19:13 +0000)
Per Brion's suggestion in http://lists.wikimedia.org/pipermail/wikitech-l/2008-December/040796.html

RELEASE-NOTES
includes/Article.php
includes/EditPage.php
includes/ImageGallery.php
includes/SearchEngine.php
includes/specials/SpecialAllpages.php
languages/Language.php
maintenance/orphans.php

index d3ab9e6..154ffb8 100644 (file)
@@ -98,6 +98,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   the active users data from site_stats.
 * (bug 13040) Gender-aware user namespace aliases
 * Add a <link rel="canonical"> tag on redirected page views
+* Replace hardcoded '...' as indication of a truncation with the
+  'ellipsis' message
 
 === Bug fixes in 1.15 ===
 * (bug 16968) Special:Upload no longer throws useless warnings.
index 82e3388..71e230a 100644 (file)
@@ -2175,7 +2175,7 @@ class Article {
                // Calculate the maximum amount of chars to get
                // Max content length = max comment length - length of the comment (excl. $1) - '...'
                $maxLength = 255 - (strlen( $reason ) - 2) - 3;
-               $contents = $wgContLang->truncate( $contents, $maxLength, '...' );
+               $contents = $wgContLang->truncate( $contents, $maxLength );
                // Remove possible unfinished links
                $contents = preg_replace( '/\[\[([^\]]*)\]?$/', '$1', $contents );
                // Now replace the '$1' placeholder
@@ -3482,8 +3482,7 @@ class Article {
                        global $wgContLang;
                        $truncatedtext = $wgContLang->truncate(
                                str_replace("\n", ' ', $newtext),
-                               max( 0, 200 - strlen( wfMsgForContent( 'autosumm-new' ) ) ),
-                               '...' );
+                               max( 0, 200 - strlen( wfMsgForContent( 'autosumm-new' ) ) ) );
                        return wfMsgForContent( 'autosumm-new', $truncatedtext );
                }
 
@@ -3495,9 +3494,7 @@ class Article {
                        global $wgContLang;
                        $truncatedtext = $wgContLang->truncate(
                                $newtext,
-                               max( 0, 200 - strlen( wfMsgForContent( 'autosumm-replace' ) ) ),
-                               '...'
-                       );
+                               max( 0, 200 - strlen( wfMsgForContent( 'autosumm-replace' ) ) ) );
                        return wfMsgForContent( 'autosumm-replace', $truncatedtext );
                }
 
index 2b45444..acb2d7c 100644 (file)
@@ -554,7 +554,7 @@ class EditPage {
                        $this->textbox2 = $this->safeUnicodeInput( $request, 'wpTextbox2' );
                        $this->mMetaData = rtrim( $request->getText( 'metadata' ) );
                        # Truncate for whole multibyte characters. +5 bytes for ellipsis
-                       $this->summary = $wgLang->truncate( $request->getText( 'wpSummary' ), 250 );
+                       $this->summary = $wgLang->truncate( $request->getText( 'wpSummary' ), 250, '' );
 
                        # Remove extra headings from summaries and new sections.
                        $this->summary = preg_replace('/^\s*=+\s*(.*?)\s*=+\s*$/', '$1', $this->summary);
index f3f525c..8a38bed 100644 (file)
@@ -289,7 +289,7 @@ class ImageGallery
                        }
 
                        $textlink = $this->mShowFilename ?
-                               $sk->makeKnownLinkObj( $nt, htmlspecialchars( $wgLang->truncate( $nt->getText(), 20, '...' ) ) ) . "<br />\n" :
+                               $sk->makeKnownLinkObj( $nt, htmlspecialchars( $wgLang->truncate( $nt->getText(), 20 ) ) ) . "<br />\n" :
                                '' ;
 
                        # ATTENTION: The newline after <div class="gallerytext"> is needed to accommodate htmltidy which
index f69ae83..cd8f804 100644 (file)
@@ -1165,12 +1165,12 @@ class SearchHighlighter {
                 continue;
             }
             --$contextlines;
-            $pre = $wgContLang->truncate( $m[1], -$contextchars, ' ... ' );
+            $pre = $wgContLang->truncate( $m[1], -$contextchars );
 
             if ( count( $m ) < 3 ) {
                 $post = '';
             } else {
-                $post = $wgContLang->truncate( $m[3], $contextchars, ' ... ' );
+                $post = $wgContLang->truncate( $m[3], $contextchars );
             }
 
             $found = $m[2];
index c6c1ca3..15c5591 100644 (file)
@@ -237,8 +237,8 @@ class SpecialAllpages extends IncludableSpecialPage {
                $inpointf = htmlspecialchars( str_replace( '_', ' ', $inpoint ) );
                $outpointf = htmlspecialchars( str_replace( '_', ' ', $outpoint ) );
                // Don't let the length runaway
-               $inpointf = $wgContLang->truncate( $inpointf, $this->maxPageLength, '...' );
-               $outpointf = $wgContLang->truncate( $outpointf, $this->maxPageLength, '...' );
+               $inpointf = $wgContLang->truncate( $inpointf, $this->maxPageLength );
+               $outpointf = $wgContLang->truncate( $outpointf, $this->maxPageLength );
 
                $queryparams = $namespace ? "namespace=$namespace&" : '';
                $special = $this->getTitle();
index 9828383..0876792 100644 (file)
@@ -2028,7 +2028,12 @@ class Language {
         * @param $ellipsis String to append to the truncated text
         * @return string
         */
-       function truncate( $string, $length, $ellipsis = "" ) {
+       function truncate( $string, $length, $ellipsis = '...' ) {
+               # Use the localized ellipsis character
+               if( $ellipsis == '...' ) {
+                       $ellipsis = wfMsgExt( 'ellipsis', array( 'escapenoentities', 'language' => $this ) );
+               }
+
                if( $length == 0 ) {
                        return $ellipsis;
                }
@@ -2045,7 +2050,7 @@ class Language {
                        } elseif( $char >= 0x80 &&
                                  preg_match( '/^(.*)(?:[\xe0-\xef][\x80-\xbf]|' .
                                              '[\xf0-\xf7][\x80-\xbf]{1,2})$/', $string, $m ) ) {
-                           # We chopped in the middle of a character; remove it
+                               # We chopped in the middle of a character; remove it
                                $string = $m[1];
                        }
                        return $string . $ellipsis;
index 8ecd9b8..480b722 100644 (file)
@@ -63,12 +63,12 @@ function checkOrphans( $fix ) {
                while( $row = $dbw->fetchObject( $result ) ) {
                        $comment = ( $row->rev_comment == '' )
                                ? ''
-                               : '(' . $wgContLang->truncate( $row->rev_comment, 40, '...' ) . ')';
+                               : '(' . $wgContLang->truncate( $row->rev_comment, 40 ) . ')';
                        printf( "%10d %10d %14s %20s %s\n",
                                $row->rev_id,
                                $row->rev_page,
                                $row->rev_timestamp,
-                               $wgContLang->truncate( $row->rev_user_text, 17, '...' ),
+                               $wgContLang->truncate( $row->rev_user_text, 17 ),
                                $comment );
                        if( $fix ) {
                                $dbw->delete( 'revision', array( 'rev_id' => $row->rev_id ) );