/** * Renders JSON output, also takes care of setting the correct headers * * @param array $content The array to render * * @return boolean */ public function renderJSON($text = array()) { $this->getResponse()->setContentType('application/json'); $this->getResponse()->setDecoration(Response::DECORATE_NONE); if (false && \caspar\core\Caspar::isDebugMode()) { $json_data = $text; \caspar\core\Caspar::getDebugger()->setJsonOutput($json_data); $json_data['csp-debugger'] = \caspar\core\Caspar::getDebugger()->returnCurrentPageRow(); echo json_encode($json_data); return true; } echo json_encode($text); return true; }
public function ajaxResponseText($code, $error) { $ob_status = ob_get_status(); if (!empty($ob_status) && (isset($ob_status['status']) && $ob_status['status'] != PHP_OUTPUT_HANDLER_END || isset($ob_status['flags']) && !($ob_status['flags'] & PHP_OUTPUT_HANDLER_END))) { ob_end_clean(); } $this->setContentType('application/json'); $this->setHttpStatus($code); $this->renderHeaders(); if (\caspar\core\Caspar::isDebugMode()) { $json_data = array('error' => $error); \caspar\core\Caspar::getDebugger()->setJsonOutput($json_data); $json_data['csp-debugger'] = \caspar\core\Caspar::getDebugger()->returnCurrentPageRow(); echo json_encode($json_data); die; } echo json_encode(array('error' => $error)); die; }
.rounded_box {background: transparent; margin:0px; border-radius: 5px; border: 1px solid #CCC; box-shadow: 0 0 3px rgba(0, 0, 0, 0.3); padding: 0; } .rounded_box h4 { margin-bottom: 0px; margin-top: 7px; font-size: 14px; } .error_content { padding: 10px; } .description { padding: 3px 3px 3px 0;} pre { overflow: scroll; padding: 5px; } </style> <!--[if IE]> <style> body { background-color: #DFDFDF; font-family: sans-serif; font-size: 13px; } </style> <![endif]--> </head> <body> <div class="rounded_box" style="margin: 30px auto 30px auto; width: 700px;"> <?php if (!Caspar::isDebugMode()) { ?> <h1>Woops! An error occured</h1> <div style="padding: 10px;"> Go back to the <a href="http://www.thebuggenie.com">frontpage</a>? </div> <?php } else { ?> <h1>An error occured in Caspar</h1> <div class="error_content"> <h2><?php echo isset($exception) ? $exception->getMessage() : $error; ?> </h2> <?php