Output

The Output system class outputs response objects. It currently outputs objects as json, but it is preprared to output different data formats.

Functions

Output::screen

Definition

Name
screen
Syntax
Void = Output::screen( Mixed $object [, Array $_options ] );

Description

The function outputs data objects as json objects.

Parameters

$object
Mixed The data to be printed.
Options
format
Is pr default json.
type
If type is 'error' cms_staus will be set to error. Any posted values will not be returned.
reset_messages
Reset_messages is per default true. Set to false in order to keep messages.

Returns

Void prints out json object.

Examples

Example 1
$object = ["user" => "elisabeth", "age" => 27, "gender" => "woman"] message()->addMessage("Hello, this is Elisabeth"); $output = new Output(); $output->screen($object);

Outputs data object as json and resets messages in the message class. Output:

{ "cms_object": { "user":"elisabeth", "age":27, "gender":"woman" }, "cms_status":"success", "cms_message": { "message":[ "Hello, this is Elisabeth" ] }, "return_to":false }
Example 2
$object = ["user" => "elisabeth", "age" => 27, "gender" => "woman"] message()->addMessage("Hello, this is Elisabeth", array("type" => "error")); $output = new Output(); $output->screen($object, ["type" => "error", "reset_messages" => false]);

Outputs data object as json with cms_status error. Does not reset messages in the message class. Output:

{ "cms_object": { "user":"elisabeth", "age":27, "gender":"woman" }, "cms_status":"error", "cms_message": [ "Hello, this is Elisabeth" ] }

Dependencies

PHP
  • json_encode
Janitor
  • message()->getMessages
  • message()->resetMessages()
  • getPost()