Skip to content

Commit

Permalink
remove change
Browse files Browse the repository at this point in the history
  • Loading branch information
ddevsr committed Feb 10, 2024
1 parent 11db748 commit aed6e96
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
37 changes: 32 additions & 5 deletions system/Helpers/html_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ function _list(string $type = 'ul', $list = [], $attributes = '', int $depth = 0
foreach ($list as $key => $val) {
$out .= str_repeat(' ', $depth + 2) . '<li>';

$out .= ! is_array($val) ? $val : $key . "\n" . _list($type, $val, '', $depth + 4) . str_repeat(' ', $depth + 2);
if (! is_array($val)) {
$out .= $val;
} else {
$out .= $key
. "\n"
. _list($type, $val, '', $depth + 4)
. str_repeat(' ', $depth + 2);
}

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

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

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

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

$video = '<video';

$video .= _has_protocol($src) ? ' src="' . $src . '"' : ($indexPage === true ? ' src="' . site_url($src) . '"' : ' src="' . slash_item('baseURL') . $src . '"');
if (_has_protocol($src)) {
$video .= ' src="' . $src . '"';
} elseif ($indexPage === true) {
$video .= ' src="' . site_url($src) . '"';
} else {
$video .= ' src="' . slash_item('baseURL') . $src . '"';
}

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

$audio = '<audio';

$audio .= _has_protocol($src) ? ' src="' . $src . '"' : ($indexPage === true ? ' src="' . site_url($src) . '"' : ' src="' . slash_item('baseURL') . $src . '"');
if (_has_protocol($src)) {
$audio .= ' src="' . $src . '"';
} elseif ($indexPage === true) {
$audio .= ' src="' . site_url($src) . '"';
} else {
$audio .= ' src="' . slash_item('baseURL') . $src . '"';
}

if ($attributes !== '') {
$audio .= ' ' . $attributes;
Expand Down
12 changes: 10 additions & 2 deletions system/Helpers/text_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,11 @@ function word_wrap(string $str, int $charlim = 76): string

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

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

$end = $position === 1 ? mb_substr($str, 0, -($maxLength - mb_strlen($beg))) : mb_substr($str, -($maxLength - mb_strlen($beg)));
if ($position === 1) {
$end = mb_substr($str, 0, -($maxLength - mb_strlen($beg)));
} else {
$end = mb_substr($str, -($maxLength - mb_strlen($beg)));
}

return $beg . $ellipsis . $end;
}
Expand Down

0 comments on commit aed6e96

Please sign in to comment.