Abstract Class FOFView

Description

FrameworkOnFramework View class. The View is the MVC component which gets the raw data from a Model and renders it in a way that makes sense. The usual rendering is HTML, but you can also output JSON, CSV, XML, or even media (images, videos, ...) and documents (Word, PDF, Excel...).

  • abstract:
  • since: 1.0

Located in /libraries/fof/view/view.php (line 20)

JObject
   |
   --FOFView
Direct descendents
Class Description
 class FOFViewRaw FrameworkOnFramework raw output class. It works like an HTML view, but the output is bare HTML.
Variable Summary
 static array $renderers
 array $config
 boolean $doPostRender
 boolean $doPreRender
 string $_basePath
 string $_charset
 string $_escape
 string $_layout
 string $_layoutExt
 array $_models
 array $_name
 string $_output
 array $_path
 string $_template
Method Summary
 static void registerRenderer (FOFRenderAbstract &$renderer)
 FOFView __construct ([array $config = array()])
 void addHelperPath (mixed $path)
 void addTemplatePath (mixed $path)
 boolean assign ()
 boolean assignRef (string $key, mixed &$val)
 mixed display ([string $tpl = null])
 mixed escape (mixed $var)
 mixed get (string $property, [string $default = null])
 string getLayout ()
 string getLayoutTemplate ()
 mixed getModel ([string $name = null])
 string getName ()
 boolean loadAnyTemplate ([string $path = ''], [array $forceParams = array()])
 void loadHelper ([string $hlp = null])
 mixed loadTemplate ([string $tpl = null], [boolean $strict = false])
 void setEscape (mixed $spec)
 string setLayout (string $layout)
 string setLayoutExt (string $value)
 object The setModel (FOFMOdel $model, [boolean $default = false], [String $name = null])
 void setPostRender (boolean $value)
 void setPreRender (boolean $value)
 void setRenderer (FOFRenderAbstract &$renderer)
 void _addPath (string $type, mixed $path)
 string _createFileName (string $type, [array $parts = array()])
 void _setPath (string $type, mixed $path)
Variables
static array $renderers = array() (line 112)

The available renderer objects we can use to render views

  • var: Contains objects of the FOFRenderAbstract class
  • access: public
array $config = array() (line 119)

Cache of the configuration array

  • access: protected
boolean $doPostRender = true (line 147)

Should I run the post-render step?

  • access: protected
boolean $doPreRender = true (line 140)

Should I run the pre-render step?

  • access: protected
FOFInput $input = null (line 126)

The input object of this view

  • access: protected
FOFRenderAbstract $rendererObject = null (line 133)

The chosen renderer object

  • access: protected
string $_basePath = null (line 41)

The base path of the view

  • access: protected
string $_charset = 'UTF-8' (line 105)

Charset to use in escaping mechanisms; defaults to urf8 (UTF-8)

  • access: protected
string $_defaultModel = null (line 48)

The default model

  • access: protected
string $_escape = 'htmlspecialchars' (line 98)

Callback for escaping.

  • deprecated: 13.3
  • access: protected
string $_layout = 'default' (line 55)

Layout name

  • access: protected
string $_layoutExt = 'php' (line 62)

Layout extension

  • access: protected
string $_layoutTemplate = '_' (line 69)

Layout template

  • access: protected
array $_models = array() (line 34)

Registered models

  • access: protected
array $_name = null (line 27)

The name of the view

  • access: protected
string $_output = null (line 90)

The output of the template script.

  • access: protected
array $_path = array('template' => array(),'helper'=>array()) (line 76)

The set of search directories for resources (templates)

  • access: protected
string $_template = null (line 83)

The name of the default template source file.

  • access: protected

Inherited Variables

Inherited from JObject

JObject::$_errors
Methods
static registerRenderer (line 1006)

Registers a renderer object with the view

  • access: public
static void registerRenderer (FOFRenderAbstract &$renderer)
Constructor __construct (line 154)

Public constructor. Instantiates a FOFView object.

  • access: public
FOFView __construct ([array $config = array()])
  • array $config: The configuration data array

Redefinition of:
JObject::__construct()
Class constructor, overridden in descendant classes.

Redefined in descendants as:
addHelperPath (line 815)

Adds to the stack of helper script paths in LIFO order.

  • access: public
void addHelperPath (mixed $path)
  • mixed $path: A directory path or an array of paths.
addTemplatePath (line 803)

Adds to the stack of view script paths in LIFO order.

  • access: public
void addTemplatePath (mixed $path)
  • mixed $path: A directory path or an array of paths.
assign (line 499)

Assigns variables to the view script via differing strategies.

This method is overloaded; you can assign all the properties of an object, an associative array, or a single value by name.

You are not allowed to set variables that begin with an underscore; these are either private properties for FOFView or private variables within the template script itself.

  • return: True on success, false on failure.
  • deprecated: 13.3 Use native PHP syntax.
  • access: public
boolean assign ()
assignRef (line 566)

Assign variable for the view (by reference).

You are not allowed to set variables that begin with an underscore; these are either private properties for FOFView or private variables within the template script itself.

  • return: True on success, false on failure.
  • deprecated: 13.3 Use native PHP syntax.
  • access: public
boolean assignRef (string $key, mixed &$val)
  • string $key: The name for the reference in the view.
  • mixed &$val: The referenced variable.
display (line 469)

Overrides the default method to execute and display a template script.

Instead of loadTemplate is uses loadAnyTemplate which allows for automatic Joomla! version overrides. A little slice of awesome pie!

  • return: A string if successful, otherwise a JError object.
  • access: public
mixed display ([string $tpl = null])
  • string $tpl: The name of the template file to parse

Redefined in descendants as:
escape (line 590)

Escapes a value for output in a view script.

If escaping mechanism is either htmlspecialchars or htmlentities, uses $_encoding setting.

  • return: The escaped value.
  • access: public
mixed escape (mixed $var)
  • mixed $var: The output to escape.
findRenderer (line 941)

Finds a suitable renderer

  • access: protected
FOFRenderAbstract findRenderer ()
get (line 608)

Method to get data from a registered model or a property of the view

  • return: The return value of the method
  • access: public
mixed get (string $property, [string $default = null])
  • string $property: The name of the method to call on the model or the property to get
  • string $default: The name of the model to reference or the default value [optional]

Redefinition of:
JObject::get()
Returns a property of the object or the default value if the property is not set.
getLayout (line 664)

Get the layout.

  • return: The layout name
  • access: public
string getLayout ()
getLayoutTemplate (line 674)

Get the layout template.

  • return: The layout template name
  • access: public
string getLayoutTemplate ()
getModel (line 649)

Method to get the model object

  • return: FOFModel object
  • access: public
mixed getModel ([string $name = null])
  • string $name: The name of the model (optional)
getName (line 687)

Method to get the view name

The model name by default parsed using the classname, or it can be set by passing a $config['name'] in the class constructor

  • return: The name of the model
  • access: public
string getName ()
getRenderer (line 914)

Get the renderer object for this view

  • access: public
FOFRenderAbstract &getRenderer ()
getViewOptionAndName (line 1077)

Returns the view's option (component name) and view name in an associative array.

  • access: public
array getViewOptionAndName ()
loadAnyTemplate (line 350)

Loads a template given any path. The path is in the format: [admin|site]:com_foobar/viewname/templatename e.g. admin:com_foobar/myview/default

This function searches for Joomla! version override templates. For example, if you have run this under Joomla! 3.0 and you try to load admin:com_foobar/myview/default it will automatically search for the template files default.j30.php, default.j3.php and default.php, in this order.

  • return: False if loading failed
  • access: public
boolean loadAnyTemplate ([string $path = ''], [array $forceParams = array()])
  • string $path: See above
  • array $forceParams: A hash array of variables to be extracted in the local scope of the template file
loadHelper (line 1042)

Load a helper file

  • access: public
void loadHelper ([string $hlp = null])
  • string $hlp: The name of the helper source file automatically searches the helper paths and compiles as needed.
loadTemplate (line 830)

Overrides the built-in loadTemplate function with an FOF-specific one.

Our overriden function uses loadAnyTemplate to provide smarter view template loading.

  • return: A string if successful, otherwise a JError object
  • access: public
mixed loadTemplate ([string $tpl = null], [boolean $strict = false])
  • string $tpl: The name of the template file to parse
  • boolean $strict: Should we use strict naming, i.e. force a non-empty $tpl?
setEscape (line 789)

Sets the _escape() callback.

  • deprecated: 2.1 Override FOFView::escape() instead.
  • access: public
void setEscape (mixed $spec)
  • mixed $spec: The callback for _escape() to use.
setLayout (line 740)

Sets the layout name to use

  • return: Previous value.
  • access: public
string setLayout (string $layout)
  • string $layout: The layout name or a string in format <template>:<layout file>
setLayoutExt (line 768)

Allows a different extension for the layout files to be used

  • return: Previous value
  • access: public
string setLayoutExt (string $value)
  • string $value: The extension.
setModel (line 714)

Method to add a model to the view.

  • return: added model.
  • access: public
object The setModel (FOFMOdel $model, [boolean $default = false], [String $name = null])
  • FOFMOdel $model: The model to add to the view.
  • boolean $default: Is this the default model?
  • String $name: optional index name to store the model
setPostRender (line 1030)

Sets the post-render flag

  • access: public
void setPostRender (boolean $value)
  • boolean $value: True to enable the post-render step
setPreRender (line 1018)

Sets the pre-render flag

  • access: public
void setPreRender (boolean $value)
  • boolean $value: True to enable the pre-render step
setRenderer (line 931)

Sets the renderer object for this view

  • access: public
void setRenderer (FOFRenderAbstract &$renderer)
_addPath (line 1125)

Adds to the search path for templates and resources.

  • access: protected
void _addPath (string $type, mixed $path)
  • string $type: The type of path to add.
  • mixed $path: The directory or stream, or an array of either, to search.
_createFileName (line 1156)

Create the filename for a resource

  • return: The filename
  • access: protected
string _createFileName (string $type, [array $parts = array()])
  • string $type: The resource type to create the filename for
  • array $parts: An associative array of filename information
_setPath (line 1093)

Sets an entire array of search paths for templates or resources.

  • access: protected
void _setPath (string $type, mixed $path)
  • string $type: The type of path to set, typically 'template'.
  • mixed $path: The new search path, or an array of search paths. If null or false, resets to the current directory only.

Inherited Methods

Inherited From JObject

 JObject::__construct()
 JObject::def()
 JObject::get()
 JObject::getError()
 JObject::getErrors()
 JObject::getProperties()
 JObject::set()
 JObject::setError()
 JObject::setProperties()
 JObject::__toString()

Documentation generated on Tue, 19 Nov 2013 15:18:16 +0100 by phpDocumentor 1.4.3