summaryrefslogtreecommitdiffstats
path: root/application/service/renderer.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/service/renderer.php')
-rw-r--r--application/service/renderer.php41
1 files changed, 25 insertions, 16 deletions
diff --git a/application/service/renderer.php b/application/service/renderer.php
index 6f57e7458..325b4f1f7 100644
--- a/application/service/renderer.php
+++ b/application/service/renderer.php
@@ -10,6 +10,9 @@
namespace service;
class renderer {
+ private $output_cache;
+ private $mfile;
+ private $data;
/**
* @param $output_cache output cache object
@@ -158,23 +161,29 @@ class renderer {
*/
private function reformat_json($lexer, $linecount, $content)
{
- if ($lexer === "json" && $linecount === 1) {
- $decoded_json = json_decode($content);
- if ($decoded_json !== null && $decoded_json !== false) {
- $pretty_json = json_encode($decoded_json, JSON_PRETTY_PRINT);
- if ($pretty_json !== false) {
- $content = $pretty_json;
- $this->output_cache->render_now(
- array(
- "error_type" => "alert-info",
- "error_message" => "<p>The file below has been reformated for readability. It may differ from the original.</p>"
- ),
- "file/fragments/alert-wide"
- );
- }
- }
+ if ($lexer !== "json" || $linecount !== 1) {
+ return $content;
+ }
+
+ $decoded_json = json_decode($content);
+ if ($decoded_json === null || $decoded_json === false) {
+ return $content;
}
- return $content;
+
+ $pretty_json = json_encode($decoded_json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
+ if ($pretty_json === false) {
+ return $content;
+ }
+
+ $this->output_cache->render_now(
+ array(
+ "error_type" => "alert-info",
+ "error_message" => "<p>The file below has been reformated for readability. It may differ from the original.</p>"
+ ),
+ "file/fragments/alert-wide"
+ );
+
+ return $pretty_json;
}