Pluf Framework

Pluf Framework Commit Details


Date:2009-10-01 11:06:15 (15 years 2 months ago)
Author:Loic d'Anterroches
Branch:develop, master
Commit:2c53e24b69818c86a0721e07e09b2637089eaafa
Parents: da8f39b1e20ce1e99fbc685eb7a0cb162402bc7e
Message:Fixed some wrapping issues.

Changes:

File differences

src/Pluf/Text.php
5252
5353
5454
55
55
56
5657
5758
5859
5960
6061
61
62
63
64
6265
6366
6467
65
68
69
70
6671
6772
68
73
74
75
6976
7077
7178
7279
73
80
81
82
83
7484
75
76
85
86
7787
7888
79
80
81
82
83
84
85
89
90
91
92
8693
87
88
89
90
91
94
95
9296
97
98
99
100
101
102
103
104
105
106
107
108
109
110
93111
94112
95113
$char = mb_substr($string, $i, 1);
/** HTML Begins */
if ($char === '<') {
if(!empty($word)) {
if (!empty($word)) {
$line_len += mb_strlen($word);
$wrapped .= $word;
$word = '';
}
$html = true;
$wrapped .= $char;
} elseif ($char === '>') {
continue;
}
if ($char === '>') {
/** HTML ends */
$html = false;
$wrapped .= $char;
} elseif ($html) {
continue;
}
if ($html) {
/** If this is inside HTML -> append to the wrapped string */
$wrapped .= $char;
} elseif ($char === "\n") {
continue;
}
if ($char === $wrapString) {
/** Whitespace characted / new line */
$wrapped .= $word.$char;
$word = '';
$line_len = 0;
} elseif ($char === ' ' || $char === "\t") {
continue;
}
if (in_array($char, array(' ', "\t"))) {
// Word delimiter, check if split before it needed
$word .= $char;
if(strlen($word) + $line_len <= $length) {
$line_len += strlen($word);
if (mb_strlen($word) + $line_len <= $length) {
$line_len += mb_strlen($word);
$wrapped .= $word;
$word = '';
}
} else {
/** Check chars */
$word .= $char;
if (mb_strlen($word) >= $length) {
$wrapped .= $word.$wrapString;
} else {
// If we add the word, it will be above the limit
$line_len = mb_strlen($word);
$wrapped .= $wrapString.$word;
$word = '';
$line_len = 0;
} elseif (mb_strlen($word) + $line_len > $length) {
$wrapped .= $wrapString;
$line_len = 0;
}
}
continue;
}
/** Check chars */
$word .= $char;
if (mb_strlen($word) + $line_len > $length) {
$wrapped .= $wrapString;
$line_len = 0;
continue;
}
if (mb_strlen($word) >= $length) {
$wrapped .= $word.$wrapString;
$word = '';
$line_len = 0;
continue;
}
}
if ($word !== '') {
$wrapped .= $word;

Archive Download the corresponding diff file

Branches

Tags

Number of commits:
Page rendered in 0.06302s using 13 queries.