Skip to content

Commit

Permalink
Merge pull request #47 from nguyenanhung/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
hungnguyenhp authored Oct 24, 2023
2 parents a7c209e + f7f61d7 commit a2ed4b2
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 94 deletions.
27 changes: 0 additions & 27 deletions helpers/array_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ function arrayToObject($array = array())
$object->$name = arrayToObject($value);
}
}

return $object;
}

return false;
}
}
Expand All @@ -58,10 +56,8 @@ function arrayToXml($array = array(), $namespace = '', $file_output = null)
$xml_object = new SimpleXMLElement("<?xml version=\"1.0\"?><" . $namespace . "></" . $namespace . ">"); // creating object of SimpleXMLElement
convertArrayToXml($array, $xml_object); // function call to convert array to xml
$xml_file = $file_output !== null ? $xml_object->asXML($file_output) : $xml_object->asXML(); // saving generated xml file

return !empty($xml_file) ? $xml_file : null;
}

return null;
}
}
Expand Down Expand Up @@ -112,7 +108,6 @@ function removeArrayElementWithValue($array, $key, $value)
unset($array[$subKey]);
}
}

return $array;
}
}
Expand All @@ -131,7 +126,6 @@ function removeArrayElementWithValue($array, $key, $value)
function arrayRecursiveDiff($aArray1, $aArray2)
{
$aReturn = array();

foreach ($aArray1 as $mKey => $mValue) {
if (array_key_exists($mKey, $aArray2)) {
if (is_array($mValue)) {
Expand All @@ -146,7 +140,6 @@ function arrayRecursiveDiff($aArray1, $aArray2)
$aReturn[$mKey] = $mValue;
}
}

return $aReturn;
}
}
Expand Down Expand Up @@ -185,7 +178,6 @@ function arrayIsAssoc($array)
if (!is_array($array) || $array === array()) {
return false;
}

return array_keys($array) !== range(0, count($array) - 1);
}
}
Expand Down Expand Up @@ -301,22 +293,17 @@ function arrayGetElement($key, $array)
{
if (is_string($key) && is_array($array)) {
$keys = explode('.', $key);

while (count($keys) >= 1) {
$k = array_shift($keys);

if (!isset($array[$k])) {
return null;
}

if (count($keys) === 0) {
return $array[$k];
}

$array = &$array[$k];
}
}

return null;
}
}
Expand Down Expand Up @@ -385,31 +372,23 @@ function arrayGetElement($key, $array)
function arraySetElement($key, $value, &$array)
{
if (is_string($key) && !empty($key)) {

$keys = explode('.', $key);
$arrTmp = &$array;

while (count($keys) >= 1) {
$k = array_shift($keys);

if (!is_array($arrTmp)) {
$arrTmp = array();
}

if (!isset($arrTmp[$k])) {
$arrTmp[$k] = array();
}

if (count($keys) === 0) {
$arrTmp[$k] = $value;

return true;
}

$arrTmp = &$arrTmp[$k];
}
}

return false;
}
}
Expand Down Expand Up @@ -462,11 +441,9 @@ function to_array($var)
if (is_string($var)) {
return str_split($var);
}

if (is_object($var)) {
return json_decode(json_encode($var), true);
}

return null;
}
}
Expand All @@ -481,21 +458,17 @@ function to_array($var)
function arrayToAttributes($attr)
{
$attr_str = '';

foreach ((array) $attr as $property => $value) {
// Ignore null/false
if ($value === null || $value === false) {
continue;
}

// If the key is numeric then it must be something like selected="selected"
if (is_numeric($property)) {
$property = $value;
}

$attr_str .= $property . '="' . str_replace('"', '&quot;', $value) . '" ';
}

// We strip off the last space for return
return trim($attr_str);
}
Expand Down
7 changes: 0 additions & 7 deletions helpers/blogspot_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ function blogspotDescSortWithPublishedTime($item1, $item2)
if ($item1['published']['$t'] === $item2['published']['$t']) {
return 0;
}

return ($item1['published']['$t'] < $item2['published']['$t']) ? 1 : -1;
}
}
if (!function_exists('blogspotUSort')) {
function blogspotUSort($data)
{
usort($data, 'blogspotDescSortWithPublishedTime');

return $data;
}
}
Expand All @@ -33,28 +31,23 @@ function blogspotFormatInformationItem($blog)
} else {
$blogThumb = 'https://c2.staticflickr.com/8/7858/32668285888_8da8a3c105_z.jpg';
}

$blogThumb = str_replace(
array('/s72-c-d/', '/s72-c/', '/s72-d/', 'http://'),
array('/s320/', '/s320/', '/s320/', 'https://'),
$blogThumb
);

$blogTitle = trim($blog['title']['$t']);
$cleanBlogTitle = strip_quotes($blogTitle);
$cleanBlogTitle = stripslashes($cleanBlogTitle);
$blogLink = '';

foreach ($blog['link'] as $link) {
if ($link['rel'] === 'alternate') {
$blogLink .= $link['href'];
} else {
$blogLink .= '';
}
}

$blogPublished = trim($blog['published']['$t']);

return array(
'thumb' => $blogThumb,
'name' => $blogTitle,
Expand Down
5 changes: 0 additions & 5 deletions helpers/byte_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,18 @@ function bytesHumanFormat($size)
if ($size <= 0) {
return '0 bytes';
}

if ($size === 1) {
return '1 byte';
}

if ($size < 1024) {
return $size . ' bytes';
}

$i = 0;
$iec = array('bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');

while (($size / 1024) > 1) {
$size /= 1024;
++$i;
}

return number_format($size, 2) . ' ' . $iec[$i];
}
}
3 changes: 0 additions & 3 deletions helpers/common_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ function smart_bear_copyright_line()
{
$helper = new \nguyenanhung\CodeIgniter\BasicHelper\BaseHelper();
$author = $helper->getAuthor();

return '&copy; <a href="' . $author['web'] . '" title="' . $author['full_name'] . '">' . $author['name'] . '</a>';
}
}
Expand All @@ -27,7 +26,6 @@ function smart_bear_copyright_powered_line()
{
$helper = new \nguyenanhung\CodeIgniter\BasicHelper\BaseHelper();
$author = $helper->getAuthor();

return 'Powered by <a href="' . $author['web'] . '" title="' . $author['full_name'] . '">' . $author['name'] . '</a>';
}
}
Expand All @@ -41,7 +39,6 @@ function smart_bear_basic_helper_version()
function smart_bear_basic_helper_author()
{
$helper = new \nguyenanhung\CodeIgniter\BasicHelper\BaseHelper();

return $helper->getAuthor();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/BaseHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
*/
class BaseHelper
{
const VERSION = '1.5.9.2';
const LAST_MODIFIED = '2023-10-05';
const VERSION = '1.5.9.3';
const LAST_MODIFIED = '2023-11-24';
const PROJECT_NAME = 'CodeIgniter - Basic Helper';
const AUTHOR_NAME = 'Hung Nguyen';
const AUTHOR_FULL_NAME = 'Hung Nguyen';
Expand Down
Loading

0 comments on commit a2ed4b2

Please sign in to comment.