r84663 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84662‎ | r84663 | r84664 >
Date:03:43, 24 March 2011
Author:bawolff
Status:ok
Tags:
Comment:
(follow-up 79778; continuation r84660) Change truncate to count the ellipsis in length. Update extensions that seem to be
expecting the other behaviour. Didn't update extensions that seem to be expecting the behaviour i changed it to.
Modified paths:
  • /trunk/extensions/ImageTagging/ImageTagging.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/specials/MV_SpecialMediaSearch.php (modified) (history)
  • /trunk/extensions/ReplaceText/SpecialReplaceText.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MetavidWiki/includes/specials/MV_SpecialMediaSearch.php
@@ -675,12 +675,12 @@
676676 continue;
677677 }
678678 -- $contextlines;
679 - $pre = $wgContLang->truncate( $m[1], - $contextchars );
 679+ $pre = $wgContLang->truncate( $m[1], - $contextchars, '...', false );
680680
681681 if ( count( $m ) < 3 ) {
682682 $post = '';
683683 } else {
684 - $post = $wgContLang->truncate( $m[3], $contextchars );
 684+ $post = $wgContLang->truncate( $m[3], $contextchars, '...', false );
685685 }
686686
687687 $found = $m[2];
@@ -694,7 +694,7 @@
695695 }
696696 // if we found no matches just return the first line:
697697 if ( $extract == '' )
698 - return ' ' . $wgContLang->truncate( $text, ( $contextchars * 2 ) ) . '';
 698+ return ' ' . $wgContLang->truncate( $text, ( $contextchars * 2 ), '...', false ) . '';
699699 // wfProfileOut( "$fname-extract" );
700700 // wfProfileOut( $fname );
701701 // return "<li>{$link} ({$size}){$extract}</li>\n";
@@ -1160,4 +1160,4 @@
11611161 $start_day
11621162 ), 'ed' => date( 'm/d/Y', $end_day ), 'sdays' => $sDays ), $obj_name );
11631163 }
1164 -}
\ No newline at end of file
 1164+}
Index: trunk/extensions/ImageTagging/ImageTagging.php
@@ -319,12 +319,12 @@
320320 continue;
321321 }
322322 $contextlines--;
323 - $pre = $wgContLang->truncate( $m[1], -$contextchars );
 323+ $pre = $wgContLang->truncate( $m[1], -$contextchars, '...', false );
324324
325325 if ( count( $m ) < 3 ) {
326326 $post = '';
327327 } else {
328 - $post = $wgContLang->truncate( $m[3], $contextchars );
 328+ $post = $wgContLang->truncate( $m[3], $contextchars, '...', false );
329329 }
330330
331331 $found = $m[2];
@@ -434,4 +434,4 @@
435435
436436 wfProfileOut( __METHOD__ );
437437 return true;
438 -}
\ No newline at end of file
 438+}
Index: trunk/extensions/ReplaceText/SpecialReplaceText.php
@@ -485,7 +485,9 @@
486486 $context = '';
487487 foreach ( $cuts as $_ ) {
488488 list( $index, $len, ) = $_;
489 - $context .= self::convertWhiteSpaceToHTML( $wgLang->truncate( substr( $text, 0, $index ), - $cw ) );
 489+ $context .= self::convertWhiteSpaceToHTML(
 490+ $wgLang->truncate( substr( $text, 0, $index ), - $cw, '...', false )
 491+ );
490492 $snippet = self::convertWhiteSpaceToHTML( substr( $text, $index, $len ) );
491493 if ( $use_regex ) {
492494 $targetStr = "/$target/U";
@@ -495,7 +497,9 @@
496498 }
497499 $context .= preg_replace( $targetStr, '<span class="searchmatch">\0</span>', $snippet );
498500
499 - $context .= self::convertWhiteSpaceToHTML( $wgLang->truncate( substr( $text, $index + $len ), $cw ) );
 501+ $context .= self::convertWhiteSpaceToHTML(
 502+ $wgLang->truncate( substr( $text, $index + $len ), $cw, '...', false )
 503+ );
500504 }
501505 return $context;
502506 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84660(follow-up 79778) Make $wgLang->truncate function consider the length of the ...bawolff02:54, 24 March 2011

Status & tagging log