9cbd11cda03c200567b2a5da9817c689c85d1b76
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2015
43 * Smarty mb_truncate modifier plugin
46 * Name: mb_truncate<br>
47 * Purpose: Truncate a string to a certain length if necessary,
48 * optionally splitting in the middle of a word, and
49 * appending the $etc string. Multibyte version.
50 * @link http://smarty.php.net/manual/en/language.modifier.truncate.php
51 * truncate (Smarty online manual)
53 * @param string $string
56 * @param bool $break_words
60 function smarty_modifier_mb_truncate($string, $length = 80, $etc = '...',
63 if (function_exists('mb_internal_encoding') and function_exists('mb_strlen') and function_exists('mb_substr')) {
64 mb_internal_encoding('UTF-8');
65 $strlen = 'mb_strlen';
66 $substr = 'mb_substr';
79 if ($strlen($string) > $length) {
80 $length -= $strlen($etc);
82 $string = preg_replace('/\s+?(\S+)?$/', '', $substr($string, 0, $length +
1));
85 return $substr($string, 0, $length) . $etc;
92 /* vim: set expandtab: */