import v2.0.0.0_RC3 | 2012-07-01
https://github.com/lucanos/CommunityID -> http://www.itadmins.net/archives/357
This commit is contained in:
@ -16,7 +16,7 @@
|
||||
* @package Zend_Text
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: MultiByte.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
* @version $Id: MultiByte.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -42,32 +42,32 @@ class Zend_Text_MultiByte
|
||||
public static function wordWrap($string, $width = 75, $break = "\n", $cut = false, $charset = 'UTF-8')
|
||||
{
|
||||
$result = array();
|
||||
|
||||
|
||||
while (($stringLength = iconv_strlen($string, $charset)) > 0) {
|
||||
$subString = iconv_substr($string, 0, $width, $charset);
|
||||
|
||||
|
||||
if ($subString === $string) {
|
||||
$cutLength = null;
|
||||
} else {
|
||||
$nextChar = iconv_substr($string, $width, 1, $charset);
|
||||
|
||||
|
||||
if ($nextChar === ' ' || $nextChar === $break) {
|
||||
$afterNextChar = iconv_substr($string, $width + 1, 1, $charset);
|
||||
|
||||
|
||||
if ($afterNextChar === false) {
|
||||
$subString .= $nextChar;
|
||||
$subString .= $nextChar;
|
||||
}
|
||||
|
||||
|
||||
$cutLength = iconv_strlen($subString, $charset) + 1;
|
||||
} else {
|
||||
$spacePos = iconv_strrpos($subString, ' ', $charset);
|
||||
|
||||
|
||||
if ($spacePos !== false) {
|
||||
$subString = iconv_substr($subString, 0, $spacePos, $charset);
|
||||
$cutLength = $spacePos + 1;
|
||||
} else if ($cut === false) {
|
||||
$spacePos = iconv_strpos($string, ' ', 0, $charset);
|
||||
|
||||
|
||||
if ($spacePos !== false) {
|
||||
$subString = iconv_substr($string, 0, $spacePos, $charset);
|
||||
$cutLength = $spacePos + 1;
|
||||
@ -77,7 +77,7 @@ class Zend_Text_MultiByte
|
||||
}
|
||||
} else {
|
||||
$breakPos = iconv_strpos($subString, $break, 0, $charset);
|
||||
|
||||
|
||||
if ($breakPos !== false) {
|
||||
$subString = iconv_substr($subString, 0, $breakPos, $charset);
|
||||
$cutLength = $breakPos + 1;
|
||||
@ -88,16 +88,16 @@ class Zend_Text_MultiByte
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result[] = $subString;
|
||||
|
||||
|
||||
if ($cutLength !== null) {
|
||||
$string = iconv_substr($string, $cutLength, ($stringLength - $cutLength), $charset);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return implode($break, $result);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user