equal
deleted
inserted
replaced
1 <?php |
|
2 /** |
|
3 * Smarty plugin |
|
4 * |
|
5 * @package Smarty |
|
6 * @subpackage PluginsModifierCompiler |
|
7 */ |
|
8 |
|
9 /** |
|
10 * Smarty wordwrap modifier plugin |
|
11 * Type: modifier<br> |
|
12 * Name: wordwrap<br> |
|
13 * Purpose: wrap a string of text at a given length |
|
14 * |
|
15 * @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual) |
|
16 * @author Uwe Tews |
|
17 * |
|
18 * @param array $params parameters |
|
19 * @param $compiler |
|
20 * |
|
21 * @return string with compiled code |
|
22 */ |
|
23 function smarty_modifiercompiler_wordwrap($params, $compiler) { |
|
24 if (!isset($params[1])) { |
|
25 $params[1] = 80; |
|
26 } |
|
27 if (!isset($params[2])) { |
|
28 $params[2] = '"\n"'; |
|
29 } |
|
30 if (!isset($params[3])) { |
|
31 $params[3] = 'false'; |
|
32 } |
|
33 $function = 'wordwrap'; |
|
34 if (Smarty::$_MBSTRING) { |
|
35 if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) { |
|
36 $compiler->template->required_plugins['nocache']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php'; |
|
37 $compiler->template->required_plugins['nocache']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap'; |
|
38 } else { |
|
39 $compiler->template->required_plugins['compiled']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php'; |
|
40 $compiler->template->required_plugins['compiled']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap'; |
|
41 } |
|
42 $function = 'smarty_mb_wordwrap'; |
|
43 } |
|
44 |
|
45 return $function . '(' . $params[0] . ',' . $params[1] . ',' . $params[2] . ',' . $params[3] . ')'; |
|
46 } |
|