To participate you must create an account on apostrophenow.com. If you have already done so, click Login.

Changeset 1814

Show
Ignore:
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:
1 modified

Legend:

Unmodified
Added
Removed
  • plugins/apostrophePlugin/branches/1.4/lib/toolkit/aHtml.class.php

    r1755 r1814  
    428428  ); 
    429429 
    430         public static function limitWords($string, $word_limit) 
     430        public static function limitWords($string, $word_limit, $options = array()) 
    431431        { 
    432432    # TBB: tag-aware, doesn't split in the middle of tags  
     
    443443    $result = ""; 
    444444    $count = 0; 
     445                $num_words = count($words); 
    445446    foreach ($words as $word) { 
    446447      if ($count >= $word_limit) { 
     
    479480      } 
    480481    } 
     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 
    481493    for ($i = count($open) - 1; ($i >= 0); $i--) { 
    482494      $result .= "</" . $open[$i] . ">";