Skip to content
This repository has been archived by the owner on Mar 8, 2021. It is now read-only.

Commit

Permalink
Refactor $modx->parseProperties()
Browse files Browse the repository at this point in the history
  • Loading branch information
yama committed Mar 4, 2016
1 parent 3b2af67 commit e0ffb3e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions manager/includes/document.parser.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -3822,10 +3822,12 @@ function invokeEvent($evtName, $extParams= array ()) {
*/
function parseProperties($propertyString, $elementName = null, $elementType = null) {

$property = array();
$propertyString = trim($propertyString);
$token = substr($propertyString,0,1);

if (!empty ($propertyString)) {

This comment has been minimized.

Copy link
@MrSwed

MrSwed May 16, 2016

Contributor

$propertyString is still can be an empty array()

Error : trim() expects parameter 1 to be string, array given
Error information
ErrorType[num] WARNING[2]
File .../manager/includes/document.parser.class.inc.php
Line 4040
Source $propertyString = trim($propertyString);

upd. for snippet loaded by LoadElement

if ($token=='&') {
$props= explode('&', $propertyString);
$property = array();
foreach ($props as $prop) {

if (strpos($prop, '=')===false) {
Expand All @@ -3843,6 +3845,9 @@ function parseProperties($propertyString, $elementName = null, $elementType = nu
$property[$key] = $value;
}
}
// elseif($token=='[' || $token=='{') {
// $property = json_decode($propertyString, true);
// }
else $property = array();

if(!empty($elementName) && !empty($elementType)){
Expand Down

0 comments on commit e0ffb3e

Please sign in to comment.