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...).
public
|
#
__construct( array $config = array() )
Public constructor. Instantiates a FOFView object.
Public constructor. Instantiates a FOFView object.
Parameters
- $config
array - $config The configuration data array
Overrides
|
public
boolean
|
#
loadAnyTemplate( string $path = '', array $forceParams = array() )
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
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.
Parameters
- $path
string - $path See above
- $forceParams
array - $forceParams A hash array of variables to be extracted in the local scope of the
template file
Returns
boolean - False if loading failed
|
public
mixed
|
#
display( string $tpl = null )
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!
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!
Parameters
- $tpl
string - $tpl The name of the template file to parse
Returns
mixed - A string if successful, otherwise a JError object.
|
public
boolean
|
#
assign( )
Assigns variables to the view script via differing strategies.
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.
Deprecated
13.3 Use native PHP syntax.
Returns
boolean - True on success, false on failure.
|
public
boolean
|
#
assignRef( string $key, mixed & $val )
Assign variable for the view (by reference).
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.
Deprecated
13.3 Use native PHP syntax.
Parameters
- $key
string - $key The name for the reference in the view.
- $val
mixed - &$val The referenced variable.
Returns
boolean - True on success, false on failure.
|
public
mixed
|
#
escape( mixed $var )
Escapes a value for output in a view script.
Escapes a value for output in a view script.
If escaping mechanism is either htmlspecialchars or htmlentities, uses $_encoding setting.
Parameters
- $var
mixed - $var The output to escape.
Returns
mixed - The escaped value.
|
public
mixed
|
#
get( string $property, string $default = null )
Method to get data from a registered model or a property of the view
Method to get data from a registered model or a property of the view
Parameters
- $property
string - $property The name of the method to call on the model or the property to get
- $default
string - $default The name of the model to reference or the default value [optional]
Returns
mixed - The return value of the method
Overrides
|
public
mixed
|
#
getModel( string $name = null )
Method to get the model object
Method to get the model object
Parameters
- $name
string - $name The name of the model (optional)
Returns
mixed - FOFModel object
|
public
string
|
#
getLayout( )
Get the layout.
Returns
string - The layout name
|
public
string
|
|
public
string
|
#
getName( )
Method to get the view name
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
Returns
string - The name of the model
|
public
object
|
#
setModel( FOFMOdel $model, boolean $default = false, String $name = null )
Method to add a model to the view.
Method to add a model to the view.
Parameters
- $model
FOFMOdel - $model The model to add to the view.
- $default
boolean - $default Is this the default model?
- $name
String - $name optional index name to store the model
Returns
object - The added model.
|
public
string
|
#
setLayout( string $layout )
Sets the layout name to use
Sets the layout name to use
Parameters
- $layout
string - $layout The layout name or a string in format <template>:<layout
file>
Returns
string - Previous value.
|
public
string
|
#
setLayoutExt( string $value )
Allows a different extension for the layout files to be used
Allows a different extension for the layout files to be used
Parameters
- $value
string - $value The extension.
Returns
string - Previous value
|
public
|
#
setEscape( mixed $spec )
Sets the _escape() callback.
Sets the _escape() callback.
Deprecated
2.1 Override FOFView::escape() instead.
Parameters
- $spec
mixed - $spec The callback for _escape() to use.
|
public
|
#
addTemplatePath( mixed $path )
Adds to the stack of view script paths in LIFO order.
Adds to the stack of view script paths in LIFO order.
Parameters
- $path
mixed - $path A directory path or an array of paths.
|
public
|
#
addHelperPath( mixed $path )
Adds to the stack of helper script paths in LIFO order.
Adds to the stack of helper script paths in LIFO order.
Parameters
- $path
mixed - $path A directory path or an array of paths.
|
public
mixed
|
#
loadTemplate( string $tpl = null, boolean $strict = false )
Overrides the built-in loadTemplate function with an FOF-specific one. Our
overriden function uses loadAnyTemplate to provide smarter view template
loading.
Overrides the built-in loadTemplate function with an FOF-specific one. Our
overriden function uses loadAnyTemplate to provide smarter view template
loading.
Parameters
- $tpl
string - $tpl The name of the template file to parse
- $strict
boolean - $strict Should we use strict naming, i.e. force a non-empty $tpl?
Returns
mixed - A string if successful, otherwise a JError object
|
public
FOFRenderAbstract
&
|
#
getRenderer( )
Get the renderer object for this view
Get the renderer object for this view
Returns
|
public
|
|
protected
FOFRenderAbstract
|
#
findRenderer( )
Finds a suitable renderer
Finds a suitable renderer
Returns
|
public static
|
|
public
|
#
setPreRender( boolean $value )
Sets the pre-render flag
Parameters
- $value
boolean - $value True to enable the pre-render step
|
public
|
#
setPostRender( boolean $value )
Sets the post-render flag
Sets the post-render flag
Parameters
- $value
boolean - $value True to enable the post-render step
|
public
|
#
loadHelper( string $hlp = null )
Load a helper file
Parameters
- $hlp
string - $hlp The name of the helper source file automatically searches the helper paths
and compiles as needed.
|
public
array
|
#
getViewOptionAndName( )
Returns the view's option (component name) and view name in an associative
array.
Returns the view's option (component name) and view name in an associative
array.
Returns
array
|
protected
|
#
_setPath( string $type, mixed $path )
Sets an entire array of search paths for templates or resources.
Sets an entire array of search paths for templates or resources.
Parameters
- $type
string - $type The type of path to set, typically 'template'.
- $path
mixed - $path The new search path, or an array of search paths. If null or false, resets
to the current directory only.
|
protected
|
#
_addPath( string $type, mixed $path )
Adds to the search path for templates and resources.
Adds to the search path for templates and resources.
Parameters
- $type
string - $type The type of path to add.
- $path
mixed - $path The directory or stream, or an array of either, to search.
|
protected
string
|
#
_createFileName( string $type, array $parts = array() )
Create the filename for a resource
Create the filename for a resource
Parameters
- $type
string - $type The resource type to create the filename for
- $parts
array - $parts An associative array of filename information
Returns
string - The filename
|
protected
array
|
$_name
|
|
protected
array
|
$_models
|
|
protected
string
|
$_basePath
|
#
The base path of the view
The base path of the view
|
protected
string
|
$_defaultModel
|
|
protected
string
|
$_layout
|
|
protected
string
|
$_layoutExt
|
|
protected
string
|
$_layoutTemplate
|
|
protected
array
|
$_path
|
#
The set of search directories for resources (templates)
The set of search directories for resources (templates)
|
protected
string
|
$_template
|
#
The name of the default template source file.
The name of the default template source file.
|
protected
string
|
$_output
|
#
The output of the template script.
The output of the template script.
|
protected
string
|
$_escape
|
#
Callback for escaping.
Deprecated
13.3
|
protected
string
|
$_charset
|
#
Charset to use in escaping mechanisms; defaults to urf8 (UTF-8)
Charset to use in escaping mechanisms; defaults to urf8 (UTF-8)
|
public static
array
|
$renderers
|
#
The available renderer objects we can use to render views
The available renderer objects we can use to render views
|
protected
array
|
$config
|
#
Cache of the configuration array
Cache of the configuration array
|
protected
FOFInput
|
$input
|
#
The input object of this view
The input object of this view
|
protected
FOFRenderAbstract
|
$rendererObject
|
#
The chosen renderer object
The chosen renderer object
|
protected
boolean
|
$doPreRender
|
#
Should I run the pre-render step?
Should I run the pre-render step?
|
protected
boolean
|
$doPostRender
|
#
Should I run the post-render step?
Should I run the post-render step?
|