Skip to content

Commit cabdb7e

Browse files
authored
Merge pull request #33 from nguyenanhung/develop
Release next-gen version
2 parents 44436ba + da3dd16 commit cabdb7e

8 files changed

Lines changed: 70 additions & 13 deletions

File tree

helpers/common_helper.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ function isEmpty($input = '')
9191
*/
9292
function defaultCompressHtmlOutput($html = '')
9393
{
94+
if (empty($html)) {
95+
return $html;
96+
}
9497
$search = array(
9598
'/\n/', // replace end of line by a space
9699
'/\>[^\S ]+/s', // strip whitespaces after tags, except space

helpers/escape_helper.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
if (!function_exists('bear_framework_basic_clean_str')) {
1111
function bear_framework_basic_clean_str($str = '')
1212
{
13+
if (empty($str)) {
14+
return $str;
15+
}
1316
$str = trim($str);
1417
$str = strip_tags($str);
1518
$str = htmlspecialchars($str, ENT_QUOTES | ENT_HTML5 | ENT_XHTML, 'UTF-8');

helpers/meta_helper.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
*/
2121
function setupMetaDnsPrefetch($dns = '')
2222
{
23+
if (empty($dns)) {
24+
return $dns;
25+
}
2326
if (is_array($dns)) {
2427
$html = '';
2528
foreach ($dns as $domain) {

helpers/string_helper.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@
2020
*/
2121
function countStringsInText($str)
2222
{
23+
if (empty($str)) {
24+
return 0;
25+
}
2326
$str = strip_tags($str);
2427
$str = str_replace(PHP_EOL, '', $str);
2528
$arr = explode(' ', $str);
2629

2730
return count($arr);
2831
}
2932
}
30-
if (!function_exists('countStringsInText')) {
33+
if (!function_exists('findMiddleInString')) {
3134
/**
3235
* Function findMiddleInString - Hàm lấy chuỗi ở giữa chuỗi bắt đầu và chuỗi kết thúc
3336
*
@@ -426,7 +429,7 @@ function str_ignore_contains($needle, $haystack)
426429
function str_starts_with($needle, $haystack)
427430
{
428431
foreach ((array) $needle as $ndl) {
429-
if ($ndl !== '' && substr($haystack, 0, strlen($ndl)) === (string) $ndl) {
432+
if ($ndl !== '' && strpos($haystack, (string) $ndl) === 0) {
430433
return true;
431434
}
432435
}
@@ -474,7 +477,7 @@ function str_ignore_starts_with($needle, $haystack)
474477

475478
foreach ((array) $needle as $ndl) {
476479
$n = strtolower($ndl);
477-
if ($n !== '' && substr($hs, 0, strlen($n)) === $n) {
480+
if ($n !== '' && strpos($hs, $n) === 0) {
478481
return true;
479482
}
480483
}

helpers/text_helper.php

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
*/
2121
function convert_string_utf8_to_vietnamese($str = '')
2222
{
23+
if (empty($str)) {
24+
return $str;
25+
}
2326
$str = trim($str);
2427
if ($str !== '') {
2528
$str = str_replace(
@@ -82,6 +85,9 @@ function clean_allowfullscreen($att = '')
8285
*/
8386
function clean_text($text = '')
8487
{
88+
if (empty($text)) {
89+
return $text;
90+
}
8591
$output = trim($text);
8692
if ($output !== '') {
8793
$output = convert_string_utf8_to_vietnamese($output);
@@ -105,8 +111,8 @@ function clean_text($text = '')
105111
*/
106112
function clean_title($text)
107113
{
108-
if ($text === null) {
109-
return null;
114+
if (empty($text)) {
115+
return $text;
110116
}
111117
$output = trim($text);
112118
if ($output !== '') {
@@ -125,16 +131,19 @@ function clean_title($text)
125131
/**
126132
* Function clean_text_mobile
127133
*
128-
* @param string $att
134+
* @param string $text
129135
*
130136
* @return string|string[]
131137
* @author : 713uk13m <dev@nguyenanhung.com>
132138
* @copyright: 713uk13m <dev@nguyenanhung.com>
133139
* @time : 12/10/2020 36:37
134140
*/
135-
function clean_text_mobile($att = '')
141+
function clean_text_mobile($text = '')
136142
{
137-
$output = $att;
143+
if (empty($text)) {
144+
return $text;
145+
}
146+
$output = $text;
138147
if ($output !== '') {
139148
$output = clean_text($output);
140149
$output = str_replace(
@@ -169,6 +178,9 @@ function clean_text_mobile($att = '')
169178
*/
170179
function bodautru($string = '')
171180
{
181+
if (empty($string)) {
182+
return $string;
183+
}
172184
$output = $string;
173185
if ($output !== '') {
174186
$output = str_replace('-', '', $output);
@@ -190,6 +202,9 @@ function bodautru($string = '')
190202
*/
191203
function bodaunhay($string = '')
192204
{
205+
if (empty($string)) {
206+
return $string;
207+
}
193208
$output = $string;
194209
if ($output !== '') {
195210
$output = str_replace(array('"', "'"), '', $output);
@@ -211,6 +226,9 @@ function bodaunhay($string = '')
211226
*/
212227
function searchs_snippets($keywords = '')
213228
{
229+
if (empty($keywords)) {
230+
return $keywords;
231+
}
214232
$output = $keywords;
215233
if ($output !== '') {
216234
$output = urldecode($output);
@@ -235,6 +253,9 @@ function searchs_snippets($keywords = '')
235253
*/
236254
function tags_snippets($tags = '')
237255
{
256+
if (empty($tags)) {
257+
return $tags;
258+
}
238259
$output = $tags;
239260
if ($output !== '') {
240261
$output = urldecode($output);
@@ -260,6 +281,9 @@ function tags_snippets($tags = '')
260281
*/
261282
function tags_clean($tags = '')
262283
{
284+
if (empty($tags)) {
285+
return $tags;
286+
}
263287
$output = $tags;
264288
if ($output !== '') {
265289
$output = urldecode($output);

helpers/url_helper.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ function specialCharToNormalChar($string = '')
209209
*/
210210
function alphabetOnly($string = '')
211211
{
212+
if (empty($string)) {
213+
return $string;
214+
}
212215
$output = $string;
213216
// replace no alphabet character
214217
$output = preg_replace("/[^a-zA-Z0-9]/", "-", $output);
@@ -287,6 +290,9 @@ function boDauTiengViet($input_string = '')
287290
*/
288291
function removeSpecialChar($input_string = '')
289292
{
293+
if (empty($input_string)) {
294+
return $input_string;
295+
}
290296
$str = trim($input_string);
291297
if ($str) {
292298
$str = str_replace(
@@ -321,6 +327,9 @@ function removeSpecialChar($input_string = '')
321327
*/
322328
function getPermalinksSEO($input_string = '')
323329
{
330+
if (empty($input_string)) {
331+
return $input_string;
332+
}
324333
$str = $input_string;
325334
if ($str !== '') {
326335
$str = str_replace(array(' ', '---'), '-', boDauTiengViet(trim($str)));

helpers/video_embed_helper.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
if (!function_exists('convert_video_embed_vimeo')) {
1111
function convert_video_embed_vimeo($vimeo)
1212
{
13+
if (empty($vimeo)) {
14+
return $vimeo;
15+
}
1316
$vimeo = str_replace(
1417
array(
1518
'https://vimeo.com/',
@@ -24,7 +27,9 @@ function convert_video_embed_vimeo($vimeo)
2427
}
2528
if (!function_exists('convert_video_embed_dailymotion')) {
2629
function convert_video_embed_dailymotion($dailymotion)
27-
{
30+
{if (empty($dailymotion)) {
31+
return $dailymotion;
32+
}
2833
$dailymotion = str_replace(
2934
array(
3035
'https://www.dailymotion.com/video/',
@@ -39,7 +44,9 @@ function convert_video_embed_dailymotion($dailymotion)
3944
}
4045
if (!function_exists('convert_video_v_embed_youtube')) {
4146
function convert_video_v_embed_youtube($youtube)
42-
{
47+
{if (empty($youtube)) {
48+
return $youtube;
49+
}
4350
$youtube = str_replace(
4451
array(
4552
'https://www.youtube.com/watch?v=',
@@ -56,7 +63,9 @@ function convert_video_v_embed_youtube($youtube)
5663
}
5764
if (!function_exists('convert_video_embed_youtube')) {
5865
function convert_video_embed_youtube($youtube)
59-
{
66+
{if (empty($youtube)) {
67+
return $youtube;
68+
}
6069
$youtube = str_replace(
6170
array(
6271
'https://www.youtube.com/watch?v=',
@@ -74,6 +83,9 @@ function convert_video_embed_youtube($youtube)
7483
if (!function_exists('clean_youtube_allow_fullscreen')) {
7584
function clean_youtube_allow_fullscreen($youtube)
7685
{
86+
if (empty($youtube)) {
87+
return $youtube;
88+
}
7789
if ($youtube !== '') {
7890
$youtube = str_replace(
7991
array(

src/BaseHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
*/
2020
class BaseHelper
2121
{
22-
const VERSION = '1.4.7';
23-
const LAST_MODIFIED = '2023-08-02';
22+
const VERSION = '1.4.8';
23+
const LAST_MODIFIED = '2023-08-04';
2424
const PROJECT_NAME = 'CodeIgniter - Basic Helper';
2525
const AUTHOR_NAME = 'Hung Nguyen';
2626
const AUTHOR_FULL_NAME = 'Hung Nguyen';

0 commit comments

Comments
 (0)