Skip to content

Commit aed6e96

Browse files
committed
remove change
1 parent 11db748 commit aed6e96

File tree

2 files changed

+42
-7
lines changed

2 files changed

+42
-7
lines changed

system/Helpers/html_helper.php

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,14 @@ function _list(string $type = 'ul', $list = [], $attributes = '', int $depth = 0
6666
foreach ($list as $key => $val) {
6767
$out .= str_repeat(' ', $depth + 2) . '<li>';
6868

69-
$out .= ! is_array($val) ? $val : $key . "\n" . _list($type, $val, '', $depth + 4) . str_repeat(' ', $depth + 2);
69+
if (! is_array($val)) {
70+
$out .= $val;
71+
} else {
72+
$out .= $key
73+
. "\n"
74+
. _list($type, $val, '', $depth + 4)
75+
. str_repeat(' ', $depth + 2);
76+
}
7077

7178
$out .= "</li>\n";
7279
}
@@ -102,7 +109,11 @@ function img($src = '', bool $indexPage = false, $attributes = ''): string
102109

103110
// Check for a relative URI
104111
if (! preg_match('#^([a-z]+:)?//#i', $src['src']) && strpos($src['src'], 'data:') !== 0) {
105-
$img .= $indexPage === true ? ' src="' . site_url($src['src']) . '"' : ' src="' . slash_item('baseURL') . $src['src'] . '"';
112+
if ($indexPage === true) {
113+
$img .= ' src="' . site_url($src['src']) . '"';
114+
} else {
115+
$img .= ' src="' . slash_item('baseURL') . $src['src'] . '"';
116+
}
106117

107118
unset($src['src']);
108119
}
@@ -192,7 +203,11 @@ function script_tag($src = '', bool $indexPage = false): string
192203

193204
foreach ($src as $k => $v) {
194205
if ($k === 'src' && ! preg_match('#^([a-z]+:)?//#i', $v)) {
195-
$script .= $indexPage === true ? 'src="' . site_url($v) . '" ' : 'src="' . slash_item('baseURL') . $v . '" ';
206+
if ($indexPage === true) {
207+
$script .= 'src="' . site_url($v) . '" ';
208+
} else {
209+
$script .= 'src="' . slash_item('baseURL') . $v . '" ';
210+
}
196211
} else {
197212
// for attributes without values, like async or defer, use NULL.
198213
$script .= $k . (null === $v ? ' ' : '="' . $v . '" ');
@@ -280,7 +295,13 @@ function video($src, string $unsupportedMessage = '', string $attributes = '', a
280295

281296
$video = '<video';
282297

283-
$video .= _has_protocol($src) ? ' src="' . $src . '"' : ($indexPage === true ? ' src="' . site_url($src) . '"' : ' src="' . slash_item('baseURL') . $src . '"');
298+
if (_has_protocol($src)) {
299+
$video .= ' src="' . $src . '"';
300+
} elseif ($indexPage === true) {
301+
$video .= ' src="' . site_url($src) . '"';
302+
} else {
303+
$video .= ' src="' . slash_item('baseURL') . $src . '"';
304+
}
284305

285306
if ($attributes !== '') {
286307
$video .= ' ' . $attributes;
@@ -320,7 +341,13 @@ function audio($src, string $unsupportedMessage = '', string $attributes = '', a
320341

321342
$audio = '<audio';
322343

323-
$audio .= _has_protocol($src) ? ' src="' . $src . '"' : ($indexPage === true ? ' src="' . site_url($src) . '"' : ' src="' . slash_item('baseURL') . $src . '"');
344+
if (_has_protocol($src)) {
345+
$audio .= ' src="' . $src . '"';
346+
} elseif ($indexPage === true) {
347+
$audio .= ' src="' . site_url($src) . '"';
348+
} else {
349+
$audio .= ' src="' . slash_item('baseURL') . $src . '"';
350+
}
324351

325352
if ($attributes !== '') {
326353
$audio .= ' ' . $attributes;

system/Helpers/text_helper.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,11 @@ function word_wrap(string $str, int $charlim = 76): string
387387

388388
// If $temp contains data it means we had to split up an over-length
389389
// word into smaller chunks so we'll add it back to our current line
390-
$output .= $temp !== '' ? $temp . "\n" . $line . "\n" : $line . "\n";
390+
if ($temp !== '') {
391+
$output .= $temp . "\n" . $line . "\n";
392+
} else {
393+
$output .= $line . "\n";
394+
}
391395
}
392396

393397
// Put our markers back
@@ -426,7 +430,11 @@ function ellipsize(string $str, int $maxLength, $position = 1, string $ellipsis
426430
$beg = mb_substr($str, 0, (int) floor($maxLength * $position));
427431
$position = ($position > 1) ? 1 : $position;
428432

429-
$end = $position === 1 ? mb_substr($str, 0, -($maxLength - mb_strlen($beg))) : mb_substr($str, -($maxLength - mb_strlen($beg)));
433+
if ($position === 1) {
434+
$end = mb_substr($str, 0, -($maxLength - mb_strlen($beg)));
435+
} else {
436+
$end = mb_substr($str, -($maxLength - mb_strlen($beg)));
437+
}
430438

431439
return $beg . $ellipsis . $end;
432440
}

0 commit comments

Comments
 (0)