From e299d268c8da3ccc296d620851fb06bbaf126989 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Wed, 24 Sep 2014 23:26:00 -0400 Subject: [PATCH] Setting headers and shit --- src/classes/Display.php | 27 ++++++++++++++++----------- src/classes/Module.php | 13 ++++++------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/classes/Display.php b/src/classes/Display.php index 40760ef..59bd53c 100644 --- a/src/classes/Display.php +++ b/src/classes/Display.php @@ -87,7 +87,7 @@ class Display extends Object $loaded = false; - if ($return_template) + if ($return_template && $this->module->templates) { // Determines if we're using a custom class or not $dynamic_class = (class_exists('CustomDynamic') ? 'CustomDynamic' : 'Dynamic'); @@ -127,25 +127,30 @@ class Display extends Object } } - $meta = [ - 'status' => $this->module->status, - 'message' => $this->module->message, - ]; - - $response = [ - 'meta' => $meta, - 'response' => $this->module->response, - ]; - if (!$loaded) { + if (!$return_template || !$this->module->templates) + { + $meta = [ + 'status' => $this->module->status, + 'message' => $this->module->message, + ]; + + $response = [ + 'meta' => $meta, + 'response' => $this->module->response, + ]; + } + if ($return_json) { + header('Content-type: application/json'); $pretty = isset($_REQUEST['pretty']) ? JSON_PRETTY_PRINT : false; echo json_encode($response, $pretty); } elseif ($return_xml) { + header('Content-type: text/xml'); echo Convert::arrayToXML($response, isset($_REQUEST['pretty'])); } } diff --git a/src/classes/Module.php b/src/classes/Module.php index 65a376c..78ec6af 100644 --- a/src/classes/Module.php +++ b/src/classes/Module.php @@ -25,7 +25,7 @@ * be JSON encoded. In the future this may need to be changed out for logic * that allows the requested module to specify what display type(s) it can use. */ -class Module extends Object +abstract class Module extends Object { /** * Page Title @@ -181,13 +181,12 @@ class Module extends Object /** * Default "Magic" Method * - * This function is overloaded by the module. The __default() method is - * where you want to place any code that needs to be executed at runtime. + * The __default() method is where you want to place any code that needs to + * be executed at runtime. + * + * @abstract */ - public function __default() - { - - } + abstract public function __default(); /** * Magic Setter Method