diff options
Diffstat (limited to 'vendor/smarty/smarty/libs/plugins/block.textformat.php')
-rw-r--r-- | vendor/smarty/smarty/libs/plugins/block.textformat.php | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/vendor/smarty/smarty/libs/plugins/block.textformat.php b/vendor/smarty/smarty/libs/plugins/block.textformat.php index e2c5e3de4..310a420ee 100644 --- a/vendor/smarty/smarty/libs/plugins/block.textformat.php +++ b/vendor/smarty/smarty/libs/plugins/block.textformat.php @@ -5,22 +5,21 @@ * @package Smarty * @subpackage PluginsBlock */ - /** * Smarty {textformat}{/textformat} block plugin - * Type: block function<br> - * Name: textformat<br> + * Type: block function + * Name: textformat * Purpose: format text a certain way with preset styles - * or custom wrap/indent settings<br> + * or custom wrap/indent settings * Params: - * <pre> + * * - style - string (email) * - indent - integer (0) * - wrap - integer (80) * - wrap_char - string ("\n") * - indent_char - string (" ") * - wrap_boundary - boolean (true) - * </pre> + * * * @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat} * (Smarty online manual) @@ -32,14 +31,16 @@ * * @return string content re-formatted * @author Monte Ohrt <monte at ohrt dot com> + * @throws \SmartyException */ -function smarty_block_textformat($params, $content, $template, &$repeat) +function smarty_block_textformat($params, $content, Smarty_Internal_Template $template, &$repeat) { if (is_null($content)) { return; } - if (Smarty::$_MBSTRING && !is_callable('smarty_mb_wordwrap')) { - require_once(SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php'); + if (Smarty::$_MBSTRING) { + $template->_checkPlugins(array(array('function' => 'smarty_modifier_mb_wordwrap', + 'file' => SMARTY_PLUGINS_DIR . 'modifier.mb_wordwrap.php'))); } $style = null; @@ -71,11 +72,11 @@ function smarty_block_textformat($params, $content, $template, &$repeat) break; default: - trigger_error("textformat: unknown attribute '$_key'"); + trigger_error("textformat: unknown attribute '{$_key}'"); } } - if ($style == 'email') { + if ($style === 'email') { $wrap = 72; } // split into paragraphs @@ -87,15 +88,17 @@ function smarty_block_textformat($params, $content, $template, &$repeat) } // convert mult. spaces & special chars to single space $_paragraph = - preg_replace(array('!\s+!' . Smarty::$_UTF8_MODIFIER, '!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER), - array(' ', ''), $_paragraph); + preg_replace(array('!\s+!' . Smarty::$_UTF8_MODIFIER, + '!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER), + array(' ', + ''), $_paragraph); // indent first line if ($indent_first > 0) { $_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph; } // wordwrap sentences if (Smarty::$_MBSTRING) { - $_paragraph = smarty_mb_wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut); + $_paragraph = smarty_modifier_mb_wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut); } else { $_paragraph = wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut); } |