Class Controller

Description

The Controller class loads all modules and executes requested action

  • Object created on instantiation.
  • Modules added with add_module()
  • Default action set with set_default()
  • Exceptions added with add_exception()
Modules are classes. Actions are the declared class methods. The module constructor is called by the controller in add_module().

The URLs sent to the browser are encoded so as to hide the internal functionality of the application.

Located in /phpfw.php (line 251)


	
			
Variable Summary
Method Summary
Controller Controller ()
void add_exception (string $exception)
void add_module (string $module_name)
array check_module_action (string $module_action)
string decode_url ()
string encode_ajax_url (string $module, string $action, string $ajax_element, [string $params = 0])
string encode_url (string $module, string $action, [string $params = 0])
void execute ()
void set_default (string $default)
Variables
array $default (line 267)
  • var:

    The default module:action to execute if unspecified

    Contains a single default module:action declaration that is called if no action is specified.

    $default['module_name'] = 'module_action';

array $exceptions (line 277)
  • var:

    List of module:action exceptions

    Exceptions that can be called directly on the URL instead of requiring encoding.

    $exceptions[] = 'module_name:module_action';

bool $is_mobile_browser (line 288)
  • var:

    The remote browser type

    This gets set to true if the remote browser is on a mobile device with a small screen. False otherwise.

    This value can be used to generate a different output based on the limited capabilities of the viewing browser.

array $modules (line 257)
  • var:

    Associative array of module objects

    modules['module_name'] = new module_name();

Methods
Constructor Controller (line 295)

Constructor for the Controller class

Zero initializes members.

Controller Controller ()
add_exception (line 422)

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_module (line 360)

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
check_module_action (line 460)

Checks the module:action syntax and if corresponding class and method exist

Called by add_exception(), set_default(), Module::exec_module_action(), etc.

  • return: Returns the module and action as an array('module_name', 'action_name')
array check_module_action (string $module_action)
  • string $module_action: The module:action string to check for syntax and existance
decode_url (line 548)

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.

  • return: The corresponding query string for the hash
string decode_url ()
encode_ajax_url (line 530)

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.

  • return: A random hash corresponding to this URL - "?url=HASHVALUE" wrapped in an AJAX call
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&param=value" format. (default: 0)
encode_url (line 490)

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'].

  • return: A random hash corresponding to this URL - "?url=HASHVALUE"
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&param=value" format. (default: 0)
execute (line 590)

Execute the module:action specified, or select default action

void execute ()
get_mobile_browser (line 310)

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_default (line 439)

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

Documentation generated on Sat, 23 Jun 2007 21:28:26 -0500 by phpDocumentor 1.3.2