Index: trunk/extensions/CodeReview/backend/CodeCommentLinker.php |
— | — | @@ -21,11 +21,12 @@ |
22 | 22 | } |
23 | 23 | |
24 | 24 | /* |
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>). |
26 | 27 | * Note: tries to fix broken HTML with MWTidy |
27 | 28 | * @TODO: cleanup and move to language.php |
28 | 29 | * @param string $text |
29 | | - * @param int $maxLen, (greater than zero) |
| 30 | + * @param int $maxLen |
30 | 31 | * @param string $ellipsis |
31 | 32 | * @returns string |
32 | 33 | */ |
— | — | @@ -33,9 +34,11 @@ |
34 | 35 | global $wgLang; |
35 | 36 | if( strlen($text) <= $maxLen ) { |
36 | 37 | return $text; // string short enough even *with* HTML |
| 38 | + } elseif ( $maxLen <= 0 ) { |
| 39 | + return ''; // no text shown, nothing to format |
37 | 40 | } |
38 | 41 | $text = parser::tidy( $text ); // fix tags |
39 | | - $displayLen = 0; |
| 42 | + $displayLen = 0; // innerHTML legth so far |
40 | 43 | $doTruncate = true; // truncated string plus '...' shorter than original? |
41 | 44 | $tagType = 0; // 0-open, 1-close |
42 | 45 | $bracketState = 0; // 1-tag start, 2-tag name, 3-tag params, 0-neither |