aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/smarty/smarty/libs/plugins/modifier.mb_wordwrap.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/smarty/smarty/libs/plugins/modifier.mb_wordwrap.php')
-rw-r--r--vendor/smarty/smarty/libs/plugins/modifier.mb_wordwrap.php26
1 files changed, 11 insertions, 15 deletions
diff --git a/vendor/smarty/smarty/libs/plugins/modifier.mb_wordwrap.php b/vendor/smarty/smarty/libs/plugins/modifier.mb_wordwrap.php
index 93c6241ec..1cd625b64 100644
--- a/vendor/smarty/smarty/libs/plugins/modifier.mb_wordwrap.php
+++ b/vendor/smarty/smarty/libs/plugins/modifier.mb_wordwrap.php
@@ -11,13 +11,12 @@
* Name: mb_wordwrap
* Purpose: Wrap a string to a given number of characters
*
-
* @link http://php.net/manual/en/function.wordwrap.php for similarity
*
- * @param string $str the string to wrap
- * @param int $width the width of the output
- * @param string $break the character used to break the line
- * @param boolean $cut ignored parameter, just for the sake of
+ * @param string $str the string to wrap
+ * @param int $width the width of the output
+ * @param string $break the character used to break the line
+ * @param boolean $cut ignored parameter, just for the sake of
*
* @return string wrapped string
* @author Rodney Rehm
@@ -30,30 +29,28 @@ function smarty_modifier_mb_wordwrap($str, $width = 75, $break = "\n", $cut = fa
$t = '';
$_previous = false;
$_space = false;
-
foreach ($tokens as $_token) {
$token_length = mb_strlen($_token, Smarty::$_CHARSET);
$_tokens = array($_token);
if ($token_length > $width) {
if ($cut) {
- $_tokens = preg_split('!(.{' . $width . '})!S' . Smarty::$_UTF8_MODIFIER,
- $_token,
- -1,
- PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE);
+ $_tokens = preg_split(
+ '!(.{' . $width . '})!S' . Smarty::$_UTF8_MODIFIER,
+ $_token,
+ -1,
+ PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE
+ );
}
}
-
foreach ($_tokens as $token) {
$_space = !!preg_match('!^\s$!S' . Smarty::$_UTF8_MODIFIER, $token);
$token_length = mb_strlen($token, Smarty::$_CHARSET);
$length += $token_length;
-
if ($length > $width) {
// remove space before inserted break
if ($_previous) {
$t = mb_substr($t, 0, -1, Smarty::$_CHARSET);
}
-
if (!$_space) {
// add the break before the token
if (!empty($t)) {
@@ -61,7 +58,7 @@ function smarty_modifier_mb_wordwrap($str, $width = 75, $break = "\n", $cut = fa
}
$length = $token_length;
}
- } else if ($token === "\n") {
+ } elseif ($token === "\n") {
// hard break must reset counters
$length = 0;
}
@@ -70,6 +67,5 @@ function smarty_modifier_mb_wordwrap($str, $width = 75, $break = "\n", $cut = fa
$t .= $token;
}
}
-
return $t;
}