r62538 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62537‎ | r62538 | r62539 >
Date:20:15, 15 February 2010
Author:aaron
Status:ok
Tags:
Comment:
truncateHtml() edge case and doc tweaks
Modified paths:
  • /trunk/extensions/CodeReview/backend/CodeCommentLinker.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/backend/CodeCommentLinker.php
@@ -21,11 +21,12 @@
2222 }
2323
2424 /*
25 - * Truncate a valid HTML string with self-contained tags only
 25+ * Truncate a valid HTML string with self-contained tags only.
 26+ * Intended for styled/linked text (tags like <span> and <a>).
2627 * Note: tries to fix broken HTML with MWTidy
2728 * @TODO: cleanup and move to language.php
2829 * @param string $text
29 - * @param int $maxLen, (greater than zero)
 30+ * @param int $maxLen
3031 * @param string $ellipsis
3132 * @returns string
3233 */
@@ -33,9 +34,11 @@
3435 global $wgLang;
3536 if( strlen($text) <= $maxLen ) {
3637 return $text; // string short enough even *with* HTML
 38+ } elseif ( $maxLen <= 0 ) {
 39+ return ''; // no text shown, nothing to format
3740 }
3841 $text = parser::tidy( $text ); // fix tags
39 - $displayLen = 0;
 42+ $displayLen = 0; // innerHTML legth so far
4043 $doTruncate = true; // truncated string plus '...' shorter than original?
4144 $tagType = 0; // 0-open, 1-close
4245 $bracketState = 0; // 1-tag start, 2-tag name, 3-tag params, 0-neither

Follow-up revisions

RevisionCommit summaryAuthorDate
r62588Follow up r62488, r62538: consistency fix for $maxLen=0 case; no display text...aaron19:48, 16 February 2010

Status & tagging log