Setting headers and shit

This commit is contained in:
Josh Sherman 2014-09-24 23:26:00 -04:00
parent 0fdf2149be
commit e299d268c8
2 changed files with 22 additions and 18 deletions

View file

@ -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']));
}
}

View file

@ -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