Constructor for the Controller class
Zero initializes members.
Controller
Controller
()
Add a module:action exception
- Calls check_module_action()
- Adds exception to $exceptions associative array
void
add_exception
(string $exception)
-
string
$exception: The exception in module:action format to add to this controller
Add a module to the controller
- Checks if module class exists
- Creates an object of the module class
- Adds object to the $modules variable
void
add_module
(string $module_name)
-
string
$module_name: The name of the module or class to add to this controller
Checks the module:action syntax and if corresponding class and method exist
Called by add_exception(), set_default(), Module::exec_module_action(), etc.
array
check_module_action
(string $module_action)
-
string
$module_action: The module:action string to check for syntax and existance
Decode a query string sent by the browser.
Function looks up the query string hash in the $_SESSION['url_hash'] array and converts it into the corresponding URL.
- If there is no query string, default module:action is selected
- If there is a regular query string (not a hash) then verify that it is in
the exception list. If not, select default module:action.
string
decode_url
()
Encode an ajax query string to be sent to the browser
Function uses the Controller::encode_url() function to create the query and then makes an AJAX url out of it.
string
encode_ajax_url
(string $module, string $action, string $ajax_element, [string $params = 0])
-
string
$module: Name of the module
-
string
$action: Name of the action for this module
-
string
$ajax_element: The link will send it's output to this element using AJAX
-
string
$params: Parameters required for this module:action combination in "param=value¶m=value" format. (default: 0)
Encode a query string to be sent to the browser.
Function generates a random hash to be sent to the browser as a URL. The hash is decoded by the decode_url() function.
The resultant hashes are stored in $_SESSION['url_hash'].
string
encode_url
(string $module, string $action, [string $params = 0])
-
string
$module: Name of the module
-
string
$action: Name of the action for this module
-
string
$params: Parameters required for this module:action combination in "param=value¶m=value" format. (default: 0)
Execute the module:action specified, or select default action
void
execute
()
Set the remote browser type.
This function sets the value of $this->is_mobile_browser to true if the remote browser is on a mobile device. False otherwise.
Internally used by the Controller.
void
get_mobile_browser
()
Set a default module:action to execute when none is specified
- Checks if default is already set
- Calls check_module_action()
- Adds default to $default associative array
void
set_default
(string $default)
-
string
$default: The default in module:action format for this controller