From 01dc5be820cb43eab96adc6b637f7d2fabbca12d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carsten=20G=C3=B6tzinger?= Date: Thu, 15 Feb 2018 06:27:02 +0100 Subject: [PATCH] =?UTF-8?q?Korrektes=20JSON=20zur=C3=BCckgeben?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Resources/contao/classes/RateIt.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Resources/contao/classes/RateIt.php b/src/Resources/contao/classes/RateIt.php index b662067..1c01c2d 100644 --- a/src/Resources/contao/classes/RateIt.php +++ b/src/Resources/contao/classes/RateIt.php @@ -87,7 +87,7 @@ class RateIt extends \Frontend { foreach ($arrRkey as $key) { if (!is_numeric($key)) { $return = [$GLOBALS['TL_LANG']['rateit']['error']['invalid_rating']]; - return new JsonResponse($return); + return new JsonResponse(array('result' => 'error', 'data' => $return)); } $id = $rkey; } @@ -96,7 +96,7 @@ class RateIt extends \Frontend { $id = $rkey; } else { $return = [$GLOBALS['TL_LANG']['rateit']['error']['invalid_rating']]; - return new JsonResponse($return); + return new JsonResponse(array('result' => 'error', 'data' => $return)); } } @@ -105,13 +105,13 @@ class RateIt extends \Frontend { $rating = $percent; } else { $return = [$GLOBALS['TL_LANG']['rateit']['error']['invalid_rating']]; - return new JsonResponse($return); + return new JsonResponse(array('result' => 'error', 'data' => $return)); } //Make sure that the ratable type is 'page' or 'ce' or 'module' if (!($type === 'page' || $type === 'article' || $type === 'ce' || $type === 'module' || $type === 'news' || $type === 'faq' || $type === 'galpic' || $type === 'news4ward')) { $return = [$GLOBALS['TL_LANG']['rateit']['error']['invalid_type']]; - return new JsonResponse($return); + return new JsonResponse(array('result' => 'error', 'data' => $return)); } $strHash = sha1(session_id() . (!$GLOBALS['TL_CONFIG']['disableIpCheck'] ? \Environment::get('ip') : '') . 'FE_USER_AUTH'); @@ -169,13 +169,13 @@ class RateIt extends \Frontend { ->execute(); } else { $return = [$GLOBALS['TL_LANG']['rateit']['error']['duplicate_vote']]; - return new JsonResponse($return); + return new JsonResponse(array('result' => 'error', 'data' => $return)); } $rating = $this->rateItFrontend->loadRating($id, $type); $return = [$this->rateItFrontend->getStarMessage($rating)]; - return new JsonResponse($return); + return new JsonResponse(array('result' => 'success', 'data' => $return)); } } ?>