2013-07-14 22:15:45 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Smarty plugin
|
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @package Smarty
|
2013-07-14 22:15:45 +00:00
|
|
|
* @subpackage PluginsModifierCompiler
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* Smarty wordwrap modifier plugin
|
2017-11-11 07:11:33 +01:00
|
|
|
* Type: modifier
|
|
|
|
* Name: wordwrap
|
2013-07-14 22:15:45 +00:00
|
|
|
* Purpose: wrap a string of text at a given length
|
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
|
2013-07-14 22:15:45 +00:00
|
|
|
* @author Uwe Tews
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2018-06-12 09:58:15 +02:00
|
|
|
* @param array $params parameters
|
2017-10-26 10:25:41 +02:00
|
|
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2013-07-14 22:15:45 +00:00
|
|
|
* @return string with compiled code
|
2017-10-26 10:25:41 +02:00
|
|
|
* @throws \SmartyException
|
2013-07-14 22:15:45 +00:00
|
|
|
*/
|
2017-08-05 19:59:23 +02:00
|
|
|
function smarty_modifiercompiler_wordwrap($params, Smarty_Internal_TemplateCompilerBase $compiler)
|
2013-07-14 22:15:45 +00:00
|
|
|
{
|
2016-02-09 01:27:15 +01:00
|
|
|
if (!isset($params[ 1 ])) {
|
|
|
|
$params[ 1 ] = 80;
|
2013-07-14 22:15:45 +00:00
|
|
|
}
|
2016-02-09 01:27:15 +01:00
|
|
|
if (!isset($params[ 2 ])) {
|
|
|
|
$params[ 2 ] = '"\n"';
|
2013-07-14 22:15:45 +00:00
|
|
|
}
|
2016-02-09 01:27:15 +01:00
|
|
|
if (!isset($params[ 3 ])) {
|
|
|
|
$params[ 3 ] = 'false';
|
2013-07-14 22:15:45 +00:00
|
|
|
}
|
|
|
|
$function = 'wordwrap';
|
|
|
|
if (Smarty::$_MBSTRING) {
|
2018-06-12 09:58:15 +02:00
|
|
|
$function = $compiler->getPlugin('mb_wordwrap', 'modifier');
|
2013-07-14 22:15:45 +00:00
|
|
|
}
|
2016-02-09 01:27:15 +01:00
|
|
|
return $function . '(' . $params[ 0 ] . ',' . $params[ 1 ] . ',' . $params[ 2 ] . ',' . $params[ 3 ] . ')';
|
2013-07-14 22:15:45 +00:00
|
|
|
}
|