From 8ca6cc32b2c789a3149861159ad258f2cb9491e3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:39:39 +0200 Subject: Adding upstream version 2.11.4. Signed-off-by: Daniel Baumann --- library/vendor/Zend/View/Helper/Json.php | 86 ++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 library/vendor/Zend/View/Helper/Json.php (limited to 'library/vendor/Zend/View/Helper/Json.php') diff --git a/library/vendor/Zend/View/Helper/Json.php b/library/vendor/Zend/View/Helper/Json.php new file mode 100644 index 0000000..62bf079 --- /dev/null +++ b/library/vendor/Zend/View/Helper/Json.php @@ -0,0 +1,86 @@ +true|false + * this array can contains a 'keepLayout'=>true|false and/or 'encodeData'=>true|false + * that will not be passed to Zend_Json::encode method but will be used here + * @param bool $encodeData + * @return string|void + */ + public function json($data, $keepLayouts = false, $encodeData = true) + { + $options = array(); + if (is_array($keepLayouts)) { + $options = $keepLayouts; + + $keepLayouts = false; + if (array_key_exists('keepLayouts', $options)) { + $keepLayouts = $options['keepLayouts']; + unset($options['keepLayouts']); + } + + if (array_key_exists('encodeData', $options)) { + $encodeData = $options['encodeData']; + unset($options['encodeData']); + } + } + + if ($encodeData) { + $data = Zend_Json::encode($data, null, $options); + } + if (!$keepLayouts) { + $layout = Zend_Layout::getMvcInstance(); + if ($layout instanceof Zend_Layout) { + $layout->disableLayout(); + } + } + + $response = Zend_Controller_Front::getInstance()->getResponse(); + $response->setHeader('Content-Type', 'application/json', true); + return $data; + } +} -- cgit v1.2.3