Skip to content

Commit

Permalink
core: helper/utils.php minor fixes and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
abolabo committed Dec 5, 2016
1 parent 700814c commit 9931e55
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions public_html/core/helper/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ function getFilesInDir($dir, $file_ext = '') {
}

//Custom function for version compare between store version and extensions
//NOTE: Function will return false if major versions donot match.
//NOTE: Function will return false if major versions do not match.
function versionCompare($version1, $version2, $operator) {
$version1 = explode('.', preg_replace('/[^0-9\.]/', '', $version1));
$version2 = explode('.', preg_replace('/[^0-9\.]/', '', $version2));
Expand Down Expand Up @@ -427,7 +427,7 @@ function dateFromFormat($string_date, $date_format, $timezone = null) {
*/
function DateTimeCreateFromFormat($date_format, $string_date) {
// convert date format first from format of date() to format of strftime()
$caracs = array(
$chars = array(
// Day - no strf eq : S
'd' => '%d', 'D' => '%a', 'j' => '%e', 'l' => '%A', 'N' => '%u', 'w' => '%w', 'z' => '%j',
// Week - no date eq : %U, %W
Expand All @@ -443,7 +443,7 @@ function DateTimeCreateFromFormat($date_format, $string_date) {
// Full Date / Time - no strf eq : c, r; no date eq : %c, %D, %F, %x
'U' => '%s'
);
$strftime_format = strtr((string)$date_format, $caracs);
$strftime_format = strtr((string)$date_format, $chars);

$date_parsed = strptime($string_date, $strftime_format);
$int_date = mktime($date_parsed["tm_hour"],$date_parsed["tm_min"],$date_parsed["tm_sec"],$date_parsed["tm_mon"]+1,($date_parsed["tm_mday"]),(1900+$date_parsed["tm_year"]));
Expand All @@ -462,8 +462,8 @@ function strptime($date, $format) {
'%S' => '(?P<S>[0-9]{2})',
);

$rexep = "#".strtr(preg_quote($format), $masks)."#";
if(!preg_match($rexep, $date, $out))
$regexp = "#".strtr(preg_quote($format), $masks)."#";
if(!preg_match($regexp, $date, $out))
return false;

$ret = array(
Expand All @@ -480,7 +480,7 @@ function strptime($date, $format) {

/**
* @param string $extension_txt_id
* @return SimpleXMLElement | bool
* @return SimpleXMLElement | false
*/
function getExtensionConfigXml($extension_txt_id) {
$registry = Registry::getInstance();
Expand All @@ -492,6 +492,9 @@ function getExtensionConfigXml($extension_txt_id) {

$extension_txt_id = str_replace('../', '', $extension_txt_id);
$filename = DIR_EXT . $extension_txt_id . '/config.xml';
/**
* @var $ext_configs SimpleXMLElement|false
*/
$ext_configs = simplexml_load_file($filename);

if($ext_configs === false){
Expand Down Expand Up @@ -563,7 +566,7 @@ function getExtensionConfigXml($extension_txt_id) {
$item_id = $extension_txt_id.'_'.$attr['id'];
$is_exists = $ext_configs->xpath('/extension/settings/item[@id=\''.$item_id.'\']');
if(!$is_exists){
// remove item that was appended on previous cicle from additional xml (override)
// remove item that was appended on previous cycle from additional xml (override)
$qry = "/extension/settings/item[@id='".$item_id."']";
$existed = $xpath->query($qry);
if(!is_null($existed)){
Expand Down Expand Up @@ -714,7 +717,7 @@ function is_html($test_string) {
*
* @param string $email The email address
* @param int|string $s Size in pixels, defaults to 80px [ 1 - 2048 ]
* @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
* @param string $d Default image set to use [ 404 | mm | identicon | monsterid | wavatar ]
* @param string $r Maximum rating (inclusive) [ g | pg | r | x ]
* @return String containing either just a URL or a complete image tag
*/
Expand Down Expand Up @@ -820,9 +823,9 @@ function gzip($src, $level = 5, $dst = false){
* @return string
*/
function randomWord($length = 4){
$newcode_length=0;
$newcode='';
while($newcode_length < $length) {
$new_code_length=0;
$new_code='';
while($new_code_length < $length) {
$x=1;
$y=3;
$part = rand($x,$y);
Expand All @@ -839,10 +842,10 @@ function randomWord($length = 4){
$b=122;
}
$code_part=chr(rand($a,$b));
$newcode_length = $newcode_length + 1;
$newcode = $newcode.$code_part;
$new_code_length = $new_code_length + 1;
$new_code = $new_code.$code_part;
}
return $newcode;
return $new_code;
}


Expand Down Expand Up @@ -1104,7 +1107,6 @@ function js_echo($text) {
* Function output string with html-entities
*
* @param string $html
* @return string
*/
function echo_html2view($html){
echo htmlspecialchars($html,ENT_QUOTES,'UTF-8');
Expand Down

0 comments on commit 9931e55

Please sign in to comment.