To participate you must create an account on apostrophenow.com. If you have already done so, click Login.
Changeset 1814
- Timestamp:
- 07/21/2010 07:41:14 PM (6 weeks ago)
- Author:
- johnnyoffline
- Message:
-
updated the aHtml::limitWords to accept the append_ellipses option that aString::limitWord already accepts -- 1.4 and trunk
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r1755
|
r1814
|
|
| 428 | 428 | ); |
| 429 | 429 | |
| 430 | | public static function limitWords($string, $word_limit) |
| | 430 | public static function limitWords($string, $word_limit, $options = array()) |
| 431 | 431 | { |
| 432 | 432 | # TBB: tag-aware, doesn't split in the middle of tags |
| … |
… |
|
| 443 | 443 | $result = ""; |
| 444 | 444 | $count = 0; |
| | 445 | $num_words = count($words); |
| 445 | 446 | foreach ($words as $word) { |
| 446 | 447 | if ($count >= $word_limit) { |
| … |
… |
|
| 479 | 480 | } |
| 480 | 481 | } |
| | 482 | |
| | 483 | $append_ellipsis = false; |
| | 484 | if (isset($options['append_ellipsis'])) |
| | 485 | { |
| | 486 | $append_ellipsis = $options['append_ellipsis']; |
| | 487 | } |
| | 488 | if ($append_ellipsis == true && $num_words > $word_limit) |
| | 489 | { |
| | 490 | $result .= '…'; |
| | 491 | } |
| | 492 | |
| 481 | 493 | for ($i = count($open) - 1; ($i >= 0); $i--) { |
| 482 | 494 | $result .= "</" . $open[$i] . ">"; |
Download in other formats: