Axiom (v1.2.0)

A lightweight PHP framework
axViewManager Class Reference

View Manager Class. More...

Public Member Functions

 __construct ($layout, $view_paths=null, $default_format= 'html', array $layout_vars=array())
 Constructor.
 add ($view)
 Add a view directory.
 load ()
 Loads a view.
 setOutputCallback ($callback)
 Set the output callback.
 setOutputFormat ($format)
 Set the output format (sends the content-type header)
 setLayout ($layout, $format=null)
 Set the layout name and optionaly format.
 getVar ($name)
 Get the given layout variable.
 setVar ($name, $value)
 Set the given layout variable.
 addAll (array $vars, $method=self::MERGE_VARS)
 Add a collection to the registered view variables.
 __get ($key)
 __get implementeation, alias of axViewManager::getVar()
 __set ($key, $value)
 __set implementeation, alias of axViewManager::setVar()
 __isset ($key)
 __isset implementation, check whenever a layout variable is set or not
 __unset ($key)
 __unset implementation, unset the given layout variable

Data Fields

const MERGE_VARS = "merge"
const ADD_VARS = "add"

Protected Member Functions

 _findLayout ($layout, $format)
 _findView ($section, $view, $format)
 Find the proper view according to the $section, $view, and $format parameters.
 _loadView ($__path, array $__vars=array())
 Load (include) the view and returns the produced buffer.
 _loadLayout ($__path, array $__vars=array())
 Load (include) the layout and returns the produced buffer.

Protected Attributes

 $_viewPaths
 Registered view paths.
 $_outputCallback
 Output (transformation) callback.
 $_layout
 Layout name.
 $_defaultFormat
 Default view format.
 $_layoutVars
 Layout variables.

Detailed Description

View Manager Class.

Todo:
axViewManager class description
Author:
Delespierre
License:
http://www.gnu.org/licenses/lgpl.html Lesser General Public Licence version 3

Definition at line 17 of file axViewManager.class.php.


Constructor & Destructor Documentation

axViewManager::__construct ( layout,
view_paths = null,
default_format = 'html',
array $  layout_vars = array() 
)

Constructor.

Parameters:
string$layout
array$view_paths[optional] [default null]
string$default_format[optional] [default "html"]
array$layout_vars[optional] [default array()]

Definition at line 56 of file axViewManager.class.php.


Member Function Documentation

__get implementeation, alias of axViewManager::getVar()

See also:
axViewManager::getVar
Parameters:
string$key
Returns:
mixed

Definition at line 270 of file axViewManager.class.php.

__isset implementation, check whenever a layout variable is set or not

Parameters:
string$key
Returns:
boolean

Definition at line 292 of file axViewManager.class.php.

axViewManager::__set ( key,
value 
)

__set implementeation, alias of axViewManager::setVar()

See also:
axViewManager::setVar
Parameters:
string$key
mixed$value
Returns:
void

Definition at line 282 of file axViewManager.class.php.

__unset implementation, unset the given layout variable

Parameters:
string$key
Returns:
void

Definition at line 302 of file axViewManager.class.php.

axViewManager::_findLayout ( layout,
format 
) [protected]

Find the proper layout according to the `$layout` and `$format` parameters

Returns the path in case of success, false on errors.

Parameters:
string$layout
string$format
Returns:
string

Definition at line 315 of file axViewManager.class.php.

axViewManager::_findView ( section,
view,
format 
) [protected]

Find the proper view according to the $section, $view, and $format parameters.

Return the path in case of success, false on errors.

Parameters:
string$section
string$view
string$format
Returns:
string

Definition at line 338 of file axViewManager.class.php.

axViewManager::_loadLayout ( __path,
array $  __vars = array() 
) [protected]

Load (include) the layout and returns the produced buffer.

Parameters:
string$__path
array$__vars[optional] [default array()]
Returns:
string

Definition at line 376 of file axViewManager.class.php.

axViewManager::_loadView ( __path,
array $  __vars = array() 
) [protected]

Load (include) the view and returns the produced buffer.

Parameters:
string$__path
array$__vars[optional] [default array()]
Returns:
string

Definition at line 357 of file axViewManager.class.php.

axViewManager::add ( view)

Add a view directory.

Parameters:
string$viewThe directory path to add
Exceptions:
axMissingFileExceptionIf the directory does'nt exists
Returns:
axViewManager

Definition at line 71 of file axViewManager.class.php.

axViewManager::addAll ( array $  vars,
method = self::MERGE_VARS 
)

Add a collection to the registered view variables.

Parameters:
array$varsThe map of variables to add
string$method[optional] [default axViewManager::MERGE_VARS] The adding method
Returns:
axViewManager

Definition at line 249 of file axViewManager.class.php.

axViewManager::getVar ( name)

Get the given layout variable.

Parameters:
sring$name
Returns:
mixed

Definition at line 228 of file axViewManager.class.php.

Loads a view.

This methods has 3 different prototypes:

In the first and third forms, the view path is determined using the $section and $view parameters (which are extracted from the $response object in the first form) and by seeking for the appropriate file according to registered view paths (added with axViewManager::add()).

In all cases, the complete page buffer is returned.

A RuntimeException is thrown if

  • the calculated view path is invalid (the file simply doesn't exist)
  • the layout for this view / format cannot be found
  • the view cannot be loaded
  • the layout cannot be loaded
Exceptions:
RuntimeException
Returns:
string

First form: axViewManager::load(axResponse $response);

Todo:
Add scripts, stylesheet and messages incorporation here

Second Form: axViewManager::load($path, array $vars = array());

Third From: axViewManager::load($section, $view, $format = "html", array $vars = array(), $layout = null);

Todo:
send headers as well here !

Definition at line 101 of file axViewManager.class.php.

axViewManager::setLayout ( layout,
format = null 
)

Set the layout name and optionaly format.

Parameters:
string$layout
string$format[optional] [default null] If not provided, the default format is used (as per set in the constructor)
Returns:
axViewManager

Definition at line 218 of file axViewManager.class.php.

Set the output callback.

Parameters:
callback$callback
Returns:
axViewManager

Definition at line 186 of file axViewManager.class.php.

Set the output format (sends the content-type header)

Parameters:
string$formatMust be one of `html`,`json`,`csv`,`xml`,`text`
Returns:
axViewManager

Definition at line 198 of file axViewManager.class.php.

axViewManager::setVar ( name,
value 
)

Set the given layout variable.

Parameters:
string$name
mixed$value
Returns:
axViewManager

Definition at line 238 of file axViewManager.class.php.


Field Documentation

string axViewManager::$_defaultFormat [protected]

Default view format.

Definition at line 41 of file axViewManager.class.php.

string axViewManager::$_layout [protected]

Layout name.

Definition at line 35 of file axViewManager.class.php.

array axViewManager::$_layoutVars [protected]

Layout variables.

Definition at line 47 of file axViewManager.class.php.

callback axViewManager::$_outputCallback [protected]

Output (transformation) callback.

Definition at line 29 of file axViewManager.class.php.

array axViewManager::$_viewPaths [protected]

Registered view paths.

Definition at line 23 of file axViewManager.class.php.

const axViewManager::ADD_VARS = "add"

Definition at line 396 of file axViewManager.class.php.

const axViewManager::MERGE_VARS = "merge"

Definition at line 395 of file axViewManager.class.php.


The documentation for this class was generated from the following file:
 All Data Structures Files Functions Variables