View.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_View
- Version
- $Id: View.php 24593 2012-01-05 20:35:02Z matthew $
\Zend_View
Concrete class for handling view scripts.
- Parent(s)
- \Zend_View_Abstract
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Properties


string $_encoding = 'UTF-8'
Encoding to use in escaping mechanisms; defaults to utf-8
Inherited from: \Zend_View_Abstract::$$_encoding'UTF-8'
Details- Type
- string
- Inherited_from
- \Zend_View_Abstract::$$_encoding


string $_escape = 'htmlspecialchars'
'htmlspecialchars'
Details- Type
- string
- Inherited_from
- \Zend_View_Abstract::$$_escape


string $_file = null
null
Details- Type
- string
- Inherited_from
- \Zend_View_Abstract::$$_file


array $_filter = array()
Stack of Zend_View_Filter names to apply as filters.
Inherited from: \Zend_View_Abstract::$$_filterarray()
Details- Type
- array
- Inherited_from
- \Zend_View_Abstract::$$_filter


array $_filterClass = array()
Stack of Zend_View_Filter objects that have been loaded
Inherited from: \Zend_View_Abstract::$$_filterClassarray()
Details- Type
- array
- Inherited_from
- \Zend_View_Abstract::$$_filterClass


array $_filterLoaded = array()
Map of filter => class pairs to help in determining filter class from name
Inherited from: \Zend_View_Abstract::$$_filterLoadedarray()
Details- Type
- array
- Inherited_from
- \Zend_View_Abstract::$$_filterLoaded


array $_filterLoadedDir = array()
Map of filter => classfile pairs to aid in determining filter classfile
Inherited from: \Zend_View_Abstract::$$_filterLoadedDirarray()
Details- Type
- array
- Inherited_from
- \Zend_View_Abstract::$$_filterLoadedDir


array $_helper = array()
array()
Details- Type
- array
- Inherited_from
- \Zend_View_Abstract::$$_helper


array $_helperLoaded = array()
Map of helper => class pairs to help in determining helper class from name
Inherited from: \Zend_View_Abstract::$$_helperLoadedarray()
Details- Type
- array
- Inherited_from
- \Zend_View_Abstract::$$_helperLoaded


array $_helperLoadedDir = array()
Map of helper => classfile pairs to aid in determining helper classfile
Inherited from: \Zend_View_Abstract::$$_helperLoadedDirarray()
Details- Type
- array
- Inherited_from
- \Zend_View_Abstract::$$_helperLoadedDir


bool $_lfiProtectionOn = true
Flag indicating whether or not LFI protection for rendering view scripts is enabled
Inherited from: \Zend_View_Abstract::$$_lfiProtectionOntrue
Details- Type
- bool
- Inherited_from
- \Zend_View_Abstract::$$_lfiProtectionOn


array $_loaderTypes = array('filter', 'helper')
array('filter', 'helper')
Details- Type
- array
- Inherited_from
- \Zend_View_Abstract::$$_loaderTypes


array $_loaders = array()
array()
Details- Type
- array
- Inherited_from
- \Zend_View_Abstract::$$_loaders


array $_path = array('script' => array(), 'helper' => array(), 'filter' => array())
Path stack for script, helper, and filter directories.
Inherited from: \Zend_View_Abstract::$$_patharray('script' => array(), 'helper' => array(), 'filter' => array())
Details- Type
- array
- Inherited_from
- \Zend_View_Abstract::$$_path


boolean $_strictVars = false
Strict variables flag; when on, undefined variables accessed in the view scripts will trigger notices
Inherited from: \Zend_View_Abstract::$$_strictVarsfalse
Details- Type
- boolean
- Inherited_from
- \Zend_View_Abstract::$$_strictVars


bool $_useStreamWrapper = false
Whether or not to use stream wrapper if short_open_tag is false
false
Details- Type
- bool
Methods


__call(string $name, array $args) : string
Accesses a helper object from within a script.
Inherited from: \Zend_View_Abstract::__call()If the helper class has a 'view' property, sets it with the current view object.
Name | Type | Description |
---|---|---|
$name | string | The helper name. |
$args | array | The parameters for the helper. |
Type | Description |
---|---|
string | The result of the helper output. |


__construct(array $config = array()) : void
Constructor
Register Zend_View_Stream stream wrapper if short tags are disabled.
Name | Type | Description |
---|---|---|
$config | array |


__get(string $key) : null
If strictVars() is on, raises a notice.
Name | Type | Description |
---|---|---|
$key | string |
Type | Description |
---|---|
null |


__isset(string $key) : boolean
Allows testing with empty() and isset() to work inside templates.
Inherited from: \Zend_View_Abstract::__isset()Name | Type | Description |
---|---|---|
$key | string |
Type | Description |
---|---|
boolean |


__set(string $key, mixed $val) : void
Directly assigns a variable to the view script.
Inherited from: \Zend_View_Abstract::__set()Checks first to ensure that the caller is not attempting to set a protected or private member (by checking for a prefixed underscore); if not, the public member is set; otherwise, an exception is raised.
Name | Type | Description |
---|---|---|
$key | string | The variable name. |
$val | mixed | The variable value. |
Exception | Description |
---|---|
\Zend_View_Exception | if an attempt to set a private or protected member is detected |


_addPath(string $type, string | array $path, string $prefix = null) : void
Adds paths to the path stack in LIFO order.
Inherited from: \Zend_View_Abstract::_addPath()Zend_View::_addPath($type, 'dirname') adds one directory to the path stack.
Zend_View::_addPath($type, $array) adds one directory for each array element value.
In the case of filter and helper paths, $prefix should be used to specify what class prefix to use with the given path.
Name | Type | Description |
---|---|---|
$type | string | The path type ('script', 'helper', or 'filter'). |
$path | string | array | The path specification. |
$prefix | string | Class prefix to use with path (helpers and filters only) |


_addPluginPath(string $type, string $classPrefix, array $paths) : \Zend_View_Abstract
Name | Type | Description |
---|---|---|
$type | string | |
$classPrefix | string | |
$paths | array |
Type | Description |
---|---|
\Zend_View_Abstract |


_filter(string $buffer) : string
Name | Type | Description |
---|---|---|
$buffer | string | The buffer contents. |
Type | Description |
---|---|
string | The filtered buffer. |


_getPaths(string $type) : array
Name | Type | Description |
---|---|---|
$type | string | The path type ('helper', 'filter', 'script') |
Type | Description |
---|---|
array |


_getPlugin(string $type, string $name) : object
Name | Type | Description |
---|---|---|
$type | string | |
$name | string |
Type | Description |
---|---|
object |


_getPluginPath(string $type, string $name) : string | false
Get a path to a given plugin class of a given type
Inherited from: \Zend_View_Abstract::_getPluginPath()Name | Type | Description |
---|---|---|
$type | string | |
$name | string |
Type | Description |
---|---|
string | false |


_run() : mixed
Includes the view script in a scope with only public $this variables.
Type | Description |
---|---|
mixed |


_script(string $name) : void
Finds a view script from the available directories.
Inherited from: \Zend_View_Abstract::_script()Name | Type | Description |
---|---|---|
$name | string | The base name of the script. |


_setFilterClass(string $name, string $class, string $file) : void
Name | Type | Description |
---|---|---|
$name | string | |
$class | string | |
$file | string | path to class file |


_setHelperClass(string $name, string $class, string $file) : void
Name | Type | Description |
---|---|---|
$name | string | |
$class | string | |
$file | string | path to class file |


_setPath(string $type, string | array $path, string $classPrefix = null) : void
Resets the path stack for helpers and filters.
Inherited from: \Zend_View_Abstract::_setPath()Name | Type | Description |
---|---|---|
$type | string | The path type ('helper' or 'filter'). |
$path | string | array | The directory (-ies) to set as the path. |
$classPrefix | string | Class prefix to apply to elements of $path |


addBasePath(string $path, $classPrefix = 'Zend_View') : \Zend_View_Abstract
Given a base path, add script, helper, and filter paths relative to it
Inherited from: \Zend_View_Abstract::addBasePath()Assumes a directory structure of:
basePath/
scripts/
helpers/
filters/
Name | Type | Description |
---|---|---|
$path | string | |
$classPrefix |
Type | Description |
---|---|
\Zend_View_Abstract |


addFilter(string | array $name) : \Zend_View_Abstract
Add one or more filters to the stack in FIFO order.
Inherited from: \Zend_View_Abstract::addFilter()Name | Type | Description |
---|---|---|
$name | string | array | One or more filters to add. |
Type | Description |
---|---|
\Zend_View_Abstract |


addFilterPath(string | array $path, string $classPrefix = 'Zend_View_Filter_') : \Zend_View_Abstract
Adds to the stack of filter paths in LIFO order.
Inherited from: \Zend_View_Abstract::addFilterPath()Name | Type | Description |
---|---|---|
$path | string | array | The directory (-ies) to add. |
$classPrefix | string | Class prefix to use with classes in this directory; defaults to Zend_View_Filter |
Type | Description |
---|---|
\Zend_View_Abstract |


addHelperPath(string | array $path, string $classPrefix = 'Zend_View_Helper_') : \Zend_View_Abstract
Adds to the stack of helper paths in LIFO order.
Inherited from: \Zend_View_Abstract::addHelperPath()Name | Type | Description |
---|---|---|
$path | string | array | The directory (-ies) to add. |
$classPrefix | string | Class prefix to use with classes in this directory; defaults to Zend_View_Helper |
Type | Description |
---|---|
\Zend_View_Abstract |


addScriptPath(string | array $path) : \Zend_View_Abstract
Adds to the stack of view script paths in LIFO order.
Inherited from: \Zend_View_Abstract::addScriptPath()Name | Type | Description |
---|---|---|
$path | string | array | The directory (-ies) to add. |
Type | Description |
---|---|
\Zend_View_Abstract |


assign(string | array $spec, mixed $value = null) : \Zend_View_Abstract
Assigns variables to the view script via differing strategies.
Inherited from: \Zend_View_Abstract::assign()Zend_View::assign('name', $value) assigns a variable called 'name' with the corresponding $value.
Zend_View::assign($array) assigns the array keys as variable names (with the corresponding array values).
Name | Type | Description |
---|---|---|
$spec | string | array | The assignment strategy to use. |
$value | mixed | (Optional) If assigning a named variable, use this as the value. |
Type | Description |
---|---|
\Zend_View_Abstract | Fluent interface |
Exception | Description |
---|---|
\Zend_View_Exception | if $spec is neither a string nor an array, or if an attempt to set a private or protected member is detected |
- See
- \global\__set()


escape(mixed $var) : mixed
If escaping mechanism is one of htmlspecialchars or htmlentities, uses $_encoding setting.
Name | Type | Description |
---|---|---|
$var | mixed | The output to escape. |
Type | Description |
---|---|
mixed | The escaped value. |


getAllPaths() : array
Return associative array of path types => paths
Inherited from: \Zend_View_Abstract::getAllPaths()Type | Description |
---|---|
array |


getEngine() : \Zend_View_Abstract
Returns the object instance, as it is its own template engine
Type | Description |
---|---|
\Zend_View_Abstract |


getFilter(string $name) : object
Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
object |


getFilterPath(string $name) : string | false
Get full path to a filter class file specified by $name
Inherited from: \Zend_View_Abstract::getFilterPath()Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
string | false | False on failure, path on success |


getFilterPaths() : array
Returns an array of all currently set filter paths
Inherited from: \Zend_View_Abstract::getFilterPaths()Type | Description |
---|---|
array |


getFilters() : array
Return array of all currently active filters
Inherited from: \Zend_View_Abstract::getFilters()Only returns those that have already been instantiated.
Type | Description |
---|---|
array |


getHelper(string $name) : object
Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
object |


getHelperPath(string $name) : string | false
Get full path to a helper class file specified by $name
Inherited from: \Zend_View_Abstract::getHelperPath()Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
string | false | False on failure, path on success |


getHelperPaths() : array
Returns an array of all currently set helper paths
Inherited from: \Zend_View_Abstract::getHelperPaths()Type | Description |
---|---|
array |


getHelpers() : array
Only returns those that have already been instantiated.
Type | Description |
---|---|
array |


getPluginLoader(string $type) : \Zend_Loader_PluginLoader
Retrieve plugin loader for a specific plugin type
Inherited from: \Zend_View_Abstract::getPluginLoader()Name | Type | Description |
---|---|---|
$type | string |
Type | Description |
---|---|
\Zend_Loader_PluginLoader |


getScriptPath(string $name) : false | string
Return full path to a view script specified by $name
Inherited from: \Zend_View_Abstract::getScriptPath()Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
false | string | False if script not found |
Exception | Description |
---|---|
\Zend_View_Exception | if no script directory set |


getScriptPaths() : array
Returns an array of all currently set script paths
Inherited from: \Zend_View_Abstract::getScriptPaths()Type | Description |
---|---|
array |


getVars() : array
Returns all public properties of the object. Reflection is not used here as testing reflection properties for visibility is buggy.
Type | Description |
---|---|
array |


init() : void
Allow custom object initialization when extending Zend_View_Abstract or Zend_View
Inherited from: \Zend_View_Abstract::init()Triggered by the constructor as its final action.


isLfiProtectionOn() : bool
Return status of LFI protection flag
Inherited from: \Zend_View_Abstract::isLfiProtectionOn()Type | Description |
---|---|
bool |


registerHelper(\Zend_View_Helper_Abstract | object $helper, string $name) : \Zend_View_Abstract
Registers a helper object, bypassing plugin loader
Inherited from: \Zend_View_Abstract::registerHelper()Name | Type | Description |
---|---|---|
$helper | \Zend_View_Helper_Abstract | object | |
$name | string |
Type | Description |
---|---|
\Zend_View_Abstract |
Exception | Description |
---|---|
\Zend_View_Exception |


render(string $name) : string
Processes a view script and returns the output.
Inherited from: \Zend_View_Abstract::render()Name | Type | Description |
---|---|---|
$name | string | The script name to process. |
Type | Description |
---|---|
string | The script output. |


setBasePath(string $path, $classPrefix = 'Zend_View') : \Zend_View_Abstract
Given a base path, sets the script, helper, and filter paths relative to it
Inherited from: \Zend_View_Abstract::setBasePath()Assumes a directory structure of:
basePath/
scripts/
helpers/
filters/
Name | Type | Description |
---|---|---|
$path | string | |
$classPrefix |
Type | Description |
---|---|
\Zend_View_Abstract |


setEncoding(string $encoding) : \Zend_View_Abstract
Set encoding to use with htmlentities() and htmlspecialchars()
Inherited from: \Zend_View_Abstract::setEncoding()Name | Type | Description |
---|---|---|
$encoding | string |
Type | Description |
---|---|
\Zend_View_Abstract |


setEscape(mixed $spec) : \Zend_View_Abstract
Name | Type | Description |
---|---|---|
$spec | mixed | The callback for _escape() to use. |
Type | Description |
---|---|
\Zend_View_Abstract |


setFilter(string | array $name) : \Zend_View_Abstract
To clear all filters, use Zend_View::setFilter(null).
Name | Type | Description |
---|---|---|
$name | string | array | One or more filters to set. |
Type | Description |
---|---|
\Zend_View_Abstract |


setFilterPath(string | array $path, string $classPrefix = 'Zend_View_Filter_') : \Zend_View_Abstract
To clear all paths, use Zend_View::setFilterPath(null).
Name | Type | Description |
---|---|---|
$path | string | array | The directory (-ies) to set as the path. |
$classPrefix | string | The class prefix to apply to all elements in $path; defaults to Zend_View_Filter |
Type | Description |
---|---|
\Zend_View_Abstract |


setHelperPath(string | array $path, string $classPrefix = 'Zend_View_Helper_') : \Zend_View_Abstract
To clear all paths, use Zend_View::setHelperPath(null).
Name | Type | Description |
---|---|---|
$path | string | array | The directory (-ies) to set as the path. |
$classPrefix | string | The class prefix to apply to all elements in $path; defaults to Zend_View_Helper |
Type | Description |
---|---|
\Zend_View_Abstract |


setLfiProtection(bool $flag) : \Zend_View_Abstract
Name | Type | Description |
---|---|---|
$flag | bool |
Type | Description |
---|---|
\Zend_View_Abstract |


setPluginLoader(\Zend_Loader_PluginLoader $loader, string $type) : \Zend_View_Abstract
Set plugin loader for a particular plugin type
Inherited from: \Zend_View_Abstract::setPluginLoader()Name | Type | Description |
---|---|---|
$loader | \Zend_Loader_PluginLoader | |
$type | string |
Type | Description |
---|---|
\Zend_View_Abstract |


setScriptPath(string | array $path) : \Zend_View_Abstract
Resets the stack of view script paths.
Inherited from: \Zend_View_Abstract::setScriptPath()To clear all paths, use Zend_View::setScriptPath(null).
Name | Type | Description |
---|---|---|
$path | string | array | The directory (-ies) to set as the path. |
Type | Description |
---|---|
\Zend_View_Abstract |


setUseStreamWrapper(bool $flag) : \Zend_View
Set flag indicating if stream wrapper should be used if short_open_tag is off
Name | Type | Description |
---|---|---|
$flag | bool |
Type | Description |
---|---|
\Zend_View |


strictVars(boolean $flag = true) : \Zend_View_Abstract
If strict variables are enabled, __get() will raise a notice when a variable is not defined.
Use in conjunction with the declareVars() helper to enforce strict variable handling in your view scripts.
Name | Type | Description |
---|---|---|
$flag | boolean |
Type | Description |
---|---|
\Zend_View_Abstract |