Skip to content

Commit

Permalink
Version 0.27
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronef committed Sep 19, 2019
2 parents ac39253 + 0c446b5 commit 18e0407
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 43 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ A library with various tools facilitating your work.
* [(MODX)EvolutionCMS](https://github.com/evolution-cms/evolution) >= 1.0.10
* [PHP.libraries.phpThumb](http://phpthumb.sourceforge.net) 1.7.13-201406261000 (included)


___
Visit the following [link](http://code.divandesign.biz/modx/ddtools) to read the documentation, instructions & changelog.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dd/modxevo-library-ddtools",
"type": "modxevo-library-ddtools",
"version": "0.26.0",
"version": "0.27.0",
"description": "A library with various tools facilitating your work.",
"keywords": [
"modx",
Expand Down
89 changes: 47 additions & 42 deletions modx.ddtools.class.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* EvolutionCMS.libraries.ddTools
* @version 0.26 (2019-09-09)
* @version 0.27 (2019-09-19)
*
* @see README.md
*
Expand Down Expand Up @@ -667,62 +667,67 @@ public static function escapeForJS($str){

/**
* encodedStringToArray
* @version 1.0.3 (2018-06-26)
* @version 1.1 (2019-09-19)
*
* @desc Converts encoded strings to arrays.
* Supported formats:
* — JSON (https://en.wikipedia.org/wiki/JSON);
* — Query string (https://en.wikipedia.org/wiki/Query_string).
*
* @param $inputString {string} — Input string. @required
* @param $inputString {string_json|string_queryFormated} — Input string. @required
*
* @return {array}
*/
public static function encodedStringToArray($inputString){
$result = [];

if (!empty($inputString)){
//JSON (first letter is “{” or “[”)
if (in_array(
substr(
$inputString,
0,
1
),
[
'{',
'['
]
)){
try {
$result = json_decode(
//If array is passed, just return it (sometimes it's convenient to not think about it)
if (is_array($inputString)){
$result = $inputString;
}else{
if (!empty($inputString)){
//JSON (first letter is “{” or “[”)
if (in_array(
substr(
$inputString,
true
);
}catch (\Exception $e){
//Flag
$result = [];
0,
1
),
[
'{',
'['
]
)){
try {
$result = json_decode(
$inputString,
true
);
}catch (\Exception $e){
//Flag
$result = [];
}
}
}

//Not JSON
if (empty($result)){
//Query string (has the “=” sign)
if (strpos(
$inputString,
'='
) !== false){
parse_str(

//Not JSON
if (empty($result)){
//Query string (has the “=” sign)
if (strpos(
$inputString,
$result
);
//The old deprecated format where string is separated by '||' and '::'
}else{
$result = self::explodeAssoc($inputString);

self::logEvent([
'message' => '<p>Strings separated by “::” && “||” in parameters are deprecated. Use <a href="https://en.wikipedia.org/wiki/JSON" target="_blank">JSON</a> or <a href="https://en.wikipedia.org/wiki/Query_string" target="_blank">Query string</a> instead.</p>'
]);
'='
) !== false){
parse_str(
$inputString,
$result
);
//The old deprecated format where string is separated by '||' and '::'
}else{
$result = self::explodeAssoc($inputString);

self::logEvent([
'message' => '<p>Strings separated by “::” && “||” in parameters are deprecated. Use <a href="https://en.wikipedia.org/wiki/JSON" target="_blank">JSON</a> or <a href="https://en.wikipedia.org/wiki/Query_string" target="_blank">Query string</a> instead.</p>'
]);
}
}
}
}
Expand Down

0 comments on commit 18e0407

Please sign in to comment.