fusionpbx/resources/templates/engine/smarty/plugins/modifiercompiler.wordwrap.php

40 lines
1.1 KiB
PHP
Raw Normal View History

2013-11-09 21:02:56 +01:00
<?php
/**
* Smarty plugin
*
2018-11-07 08:18:14 +01:00
* @package Smarty
2013-11-09 21:02:56 +01:00
* @subpackage PluginsModifierCompiler
*/
/**
* Smarty wordwrap modifier plugin
2018-11-07 08:18:14 +01:00
* Type: modifier
* Name: wordwrap
2013-11-09 21:02:56 +01:00
* Purpose: wrap a string of text at a given length
*
2018-11-07 08:18:14 +01:00
* @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
2013-11-09 21:02:56 +01:00
* @author Uwe Tews
2018-11-07 08:18:14 +01:00
*
* @param array $params parameters
* @param \Smarty_Internal_TemplateCompilerBase $compiler
*
2013-11-09 21:02:56 +01:00
* @return string with compiled code
2018-11-07 08:18:14 +01:00
* @throws \SmartyException
2013-11-09 21:02:56 +01:00
*/
2018-11-07 08:18:14 +01:00
function smarty_modifiercompiler_wordwrap($params, Smarty_Internal_TemplateCompilerBase $compiler)
2013-11-09 21:02:56 +01:00
{
2018-11-07 08:18:14 +01:00
if (!isset($params[ 1 ])) {
$params[ 1 ] = 80;
2013-11-09 21:02:56 +01:00
}
2018-11-07 08:18:14 +01:00
if (!isset($params[ 2 ])) {
$params[ 2 ] = '"\n"';
2013-11-09 21:02:56 +01:00
}
2018-11-07 08:18:14 +01:00
if (!isset($params[ 3 ])) {
$params[ 3 ] = 'false';
2013-11-09 21:02:56 +01:00
}
$function = 'wordwrap';
if (Smarty::$_MBSTRING) {
2018-11-07 08:18:14 +01:00
$function = $compiler->getPlugin('mb_wordwrap', 'modifier');
2013-11-09 21:02:56 +01:00
}
2018-11-07 08:18:14 +01:00
return $function . '(' . $params[ 0 ] . ',' . $params[ 1 ] . ',' . $params[ 2 ] . ',' . $params[ 3 ] . ')';
2013-11-09 21:02:56 +01:00
}