Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
2809 rexy 1
<?php
2
/**
3
 * Smarty plugin
4
 *
5
 * @package    Smarty
6
 * @subpackage PluginsModifierCompiler
7
 */
8
/**
9
 * Smarty wordwrap modifier plugin
10
 * Type:     modifier
11
 * Name:     wordwrap
12
 * Purpose:  wrap a string of text at a given length
13
 *
14
 * @link   http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
15
 * @author Uwe Tews
16
 *
17
 * @param array                                 $params parameters
18
 * @param \Smarty_Internal_TemplateCompilerBase $compiler
19
 *
20
 * @return string with compiled code
21
 * @throws \SmartyException
22
 */
23
function smarty_modifiercompiler_wordwrap($params, Smarty_Internal_TemplateCompilerBase $compiler)
24
{
25
    if (!isset($params[ 1 ])) {
26
        $params[ 1 ] = 80;
27
    }
28
    if (!isset($params[ 2 ])) {
29
        $params[ 2 ] = '"\n"';
30
    }
31
    if (!isset($params[ 3 ])) {
32
        $params[ 3 ] = 'false';
33
    }
34
    $function = 'wordwrap';
35
    if (Smarty::$_MBSTRING) {
36
        $function = $compiler->getPlugin('mb_wordwrap', 'modifier');
37
    }
38
    return $function . '(' . $params[ 0 ] . ',' . $params[ 1 ] . ',' . $params[ 2 ] . ',' . $params[ 3 ] . ')';
39
}