1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-06 06:38:00 +02:00

Merge pull request #2421 from lonalore/master

Fix for inline editing.
This commit is contained in:
Cameron
2017-02-13 07:25:27 -08:00
committed by GitHub
2 changed files with 14 additions and 2 deletions

View File

@@ -2171,9 +2171,15 @@ class e_parse extends e_parser
* We use HTML-safe strings, with several characters escaped. * We use HTML-safe strings, with several characters escaped.
* *
* @param mixed $var * @param mixed $var
* PHP variable.
* @param bool $force_object
* True: Outputs an object rather than an array when a non-associative
* array is used. Especially useful when the recipient of the output
* is expecting an object and the array is empty.
*
* @return string * @return string
*/ */
public function toJSON($var) public function toJSON($var, $force_object = false)
{ {
// The PHP version cannot change within a request. // The PHP version cannot change within a request.
static $php530; static $php530;
@@ -2185,6 +2191,12 @@ class e_parse extends e_parser
if($php530) if($php530)
{ {
if($force_object === true)
{
// Encode <, >, ', &, and " using the json_encode() options parameter.
return json_encode($var, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_FORCE_OBJECT);
}
// Encode <, >, ', &, and " using the json_encode() options parameter. // Encode <, >, ', &, and " using the json_encode() options parameter.
return json_encode($var, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT); return json_encode($var, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT);
} }

View File

@@ -3919,7 +3919,7 @@ class e_form
} }
} }
$source = e107::getParser()->toJSON($jsonArray); $source = e107::getParser()->toJSON($jsonArray, true);
$mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], '')); $mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], ''));