Message

Handles status messages on single pages or across redirects

copyright CONTREXX CMS - COMVATION AG
author Reto Kohli
version 3.0.0
package contrexx
subpackage core
todo Distinguish between flash and deferred messages

 Methods

Adds a message of the given class

add(string $message, string $class) 
Static

The optional $class defaults to the CLASS_INFO class constant. May be empty, or one of CLASS_OK, CLASS_INFO, CLASS_WARN, or CLASS_ERROR.

author Reto Kohli
static

Parameters

$message

string

The message to add

$class

string

The optional class. Defaults to CLASS_INFO

Clears the messages

clear() 
Static

Adds a message of class "error"

error(string $message) : boolean
Static

Returns false for convenience.

author Reto Kohli
static

Parameters

$message

string

The message to add

Returns

booleanFalse

Returns a message string, if any are present

get() : string
Static

Frontend use only. Returns a concatenation of messages by looking for them in the order defined by the $message_classes array. Only messages of the first class found are used. Does not {@see clear()} the messages; either do that yourself if necessary, or call {@see show()} after this.

Returns

stringThe message string, if any, or null

Returns true if there are messages present

have($class) : string: boolean
Static

The optional $class parameter restricts the test to the given class of messages, so true is only returned iff there is at least one message of that class.

Parameters

$class

Returns

string$class If set, restrict the test to that message class.
booleanTrue if there are messages, false otherwise

Adds a message of class "information"

information(string $message) 
Static
author Reto Kohli
static

Parameters

$message

string

The message to add

Adds a message of class "ok"

ok(string $message) : boolean
Static

Returns true for convenience.

author Reto Kohli
static

Parameters

$message

string

The message to add

Returns

booleanTrue

Returns a random message class (for testing purposes only)

random_class() : string
Static

Returns

stringA random message class

Restores the messages from the stack, if any.

restore() 
Static

If the stack is empty, clears the current messages.

Saves the current messages on the stack

save() 
Static

Clears the current messages. If there are no messages, does nothing. Restore the previous state by calling {@see restore}.

Shows the collected messages

show(\Cx\Core\Html\Sigma $objTemplateLocal) 
Static

Decides which view to use, and clears the messages

Parameters

$objTemplateLocal

\Cx\Core\Html\Sigma

The optional Template

Adds a message of class "warning"

warning(string $message) 
Static
author Reto Kohli
static

Parameters

$message

string

The message to add

Shows the collected messages, if any

show_backend(\Cx\Core\Html\Sigma $objTemplateLocal) 
Static

Backend use only.

todo Add the missing classes CLASS_INFO and CLASS_WARN to the backend views
todo Unify the placeholders, and add the message block

Parameters

$objTemplateLocal

\Cx\Core\Html\Sigma

The optional Template

Shows the collected messages, if any

show_frontend(\Cx\Core\Html\Sigma $objTemplateLocal) : boolean
Static

Frontend use only. Returns a status according to the message classes: - null, if no message is present - false, if any message of class CLASS_ERROR is encountered - true, if no messages of class CLASS_ERROR are found

Parameters

$objTemplateLocal

\Cx\Core\Html\Sigma

The optional Template

Returns

booleanThe status

 Properties

 

$message_classes : array

Messages are grouped by class and shown in the order used here. Note: The order here is relevant, because some modules may only use one message class, which must then be the most urgent one! See {@see show_frontend()} for an example.

 Constants

 

The Message class names

CLASS_ERROR 
 

CLASS_INFO

CLASS_INFO 
 

CLASS_OK

CLASS_OK 
 

CLASS_WARN

CLASS_WARN 
© Copyright 2014 by Comvation AG
Generated on 2014-07-11T08:39:21+02:00.