[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/template/smarty/plugins/ -> modifier.utf8_truncate.php (source)

   1  <?php
   2  lt_include(PLOG_CLASS_PATH.'class/data/utf8/utf8_funcs.php');
   3  
   4  /**
   5   * Smarty truncate modifier plugin
   6   *
   7   * Type:     modifier<br>
   8   * Name:     utf8_truncate<br>
   9   * @param string
  10   * @param integer
  11   * @param string
  12   * @param boolean
  13   * @return string
  14   */
  15  function smarty_modifier_utf8_truncate($string, $length = 80, $etc = '...',
  16                                    $break_words = false)
  17  {
  18      if ($length == 0)
  19          return '';
  20  
  21      if (utf8_strlen($string) > $length) {
  22          $length -= strlen($etc);
  23          if (!$break_words)
  24              $string = preg_replace('/\s+?(\w+)?$/', '', utf8_substr($string, 0, $length+1));
  25        
  26          return utf8_substr($string, 0, $length).$etc;
  27      } else
  28          return $string;
  29  }
  30  
  31  /* vim: set expandtab: */
  32  
  33  ?>


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics