r25266 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25265‎ | r25266 | r25267 >
Date:01:34, 29 August 2007
Author:robchurch
Status:old
Tags:
Comment:
Update documentation for Language::truncate()
Modified paths:
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/Language.php
@@ -1271,13 +1271,21 @@
12721272 return $s;
12731273 }
12741274
1275 - # Crop a string from the beginning or end to a certain number of bytes.
1276 - # (Bytes are used because our storage has limited byte lengths for some
1277 - # columns in the database.) Multibyte charsets will need to make sure that
1278 - # only whole characters are included!
1279 - #
1280 - # $length does not include the optional ellipsis.
1281 - # If $length is negative, snip from the beginning
 1275+ /**
 1276+ * Truncate a string to a specified length in bytes, appending an optional
 1277+ * string (e.g. for ellipses)
 1278+ *
 1279+ * The database offers limited byte lengths for some columns in the database;
 1280+ * multi-byte character sets mean we need to ensure that only whole characters
 1281+ * are included, otherwise broken characters can be passed to the user
 1282+ *
 1283+ * If $length is negative, the string will be truncated from the beginning
 1284+ *
 1285+ * @param string $string String to truncate
 1286+ * @param int $length Maximum length (excluding ellipses)
 1287+ * @param string $ellipses String to append to the truncated text
 1288+ * @return string
 1289+ */
12821290 function truncate( $string, $length, $ellipsis = "" ) {
12831291 if( $length == 0 ) {
12841292 return $ellipsis;

Follow-up revisions

RevisionCommit summaryAuthorDate
r25303Merged revisions 25215-25302 via svnmerge from...david07:10, 30 August 2007

Status & tagging log