View/Abstract.php

Show: PublicProtectedPrivateinherited
Table of Contents
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 license@zend.com so we can send you a copy immediately.
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_View  
Version
$Id$  

\Zend_View_Abstract

Package: Zend_View
Abstract class for Zend_View to help enforce private constructs.
Implements
Children
\Zend_View
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Properties

>VPropertyprivatestring $_encoding = 'UTF-8'
Encoding to use in escaping mechanisms; defaults to utf-8
Default value'UTF-8'Details
Type
string
>VPropertyprivatestring $_escape = 'htmlspecialchars'
Callback for escaping.
Default value'htmlspecialchars'Details
Type
string
>VPropertyprivatestring $_file = null
Script file name to execute
Default valuenullDetails
Type
string
>VPropertyprivatearray $_filter = array()
Stack of Zend_View_Filter names to apply as filters.
Default valuearray()Details
Type
array
>VPropertyprivatearray $_filterClass = array()
Stack of Zend_View_Filter objects that have been loaded
Default valuearray()Details
Type
array
>VPropertyprivatearray $_filterLoaded = array()
Map of filter => class pairs to help in determining filter class from name
Default valuearray()Details
Type
array
>VPropertyprivatearray $_filterLoadedDir = array()
Map of filter => classfile pairs to aid in determining filter classfile
Default valuearray()Details
Type
array
>VPropertyprivatearray $_helper = array()
Instances of helper objects.
Default valuearray()Details
Type
array
>VPropertyprivatearray $_helperLoaded = array()
Map of helper => class pairs to help in determining helper class from name
Default valuearray()Details
Type
array
>VPropertyprivatearray $_helperLoadedDir = array()
Map of helper => classfile pairs to aid in determining helper classfile
Default valuearray()Details
Type
array
>VPropertyprivatebool $_lfiProtectionOn = true
Flag indicating whether or not LFI protection for rendering view scripts is enabled
Default valuetrueDetails
Type
bool
>VPropertyprivatearray $_loaderTypes = array('filter', 'helper')
Plugin types
Default valuearray('filter', 'helper')Details
Type
array
>VPropertyprivatearray $_loaders = array()
Plugin loaders
Default valuearray()Details
Type
array
>VPropertyprivatearray $_path = array('script' => array(), 'helper' => array(), 'filter' => array())
Path stack for script, helper, and filter directories.
Default valuearray('script' => array(), 'helper' => array(), 'filter' => array())Details
Type
array
>VPropertyprivateboolean $_strictVars = false
Strict variables flag; when on, undefined variables accessed in the view scripts will trigger notices
Default valuefalseDetails
Type
boolean

Methods

methodpublic__call(string $name, array $args) : string

Accesses a helper object from within a script.

If the helper class has a 'view' property, sets it with the current view object.
Parameters
NameTypeDescription
$namestring

The helper name.

$argsarray

The parameters for the helper.

Returns
TypeDescription
stringThe result of the helper output.
methodpublic__construct(array $config = array()) : void

Constructor.

Parameters
NameTypeDescription
$configarray

Configuration key-value pairs.

methodpublic__get(string $key) : null

Prevent E_NOTICE for nonexistent values

If {@link strictVars()} is on, raises a notice.
Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
null
methodpublic__isset(string $key) : boolean

Allows testing with empty() and isset() to work inside templates.

Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
boolean
methodpublic__set(string $key, mixed $val) : void

Directly assigns a variable to the view script.

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.
Parameters
NameTypeDescription
$keystring

The variable name.

$valmixed

The variable value.

Throws
ExceptionDescription
\Zend_View_Exceptionif an attempt to set a private or protected member is detected
methodpublic__unset(string $key) : void

Allows unset() on object properties to work

Parameters
NameTypeDescription
$keystring
methodprivate_addPath(string $type, string | array $path, string $prefix = null) : void

Adds paths to the path stack in LIFO order.

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.
Parameters
NameTypeDescription
$typestring

The path type ('script', 'helper', or 'filter').

$pathstring | array

The path specification.

$prefixstring

Class prefix to use with path (helpers and filters only)

methodprivate_addPluginPath(string $type, string $classPrefix, array $paths) : \Zend_View_Abstract

Add a prefixPath for a plugin type

Parameters
NameTypeDescription
$typestring
$classPrefixstring
$pathsarray
Returns
TypeDescription
\Zend_View_Abstract
methodprivate_filter(string $buffer) : string

Applies the filter callback to a buffer.

Parameters
NameTypeDescription
$bufferstring

The buffer contents.

Returns
TypeDescription
stringThe filtered buffer.
methodprivate_getPaths(string $type) : array

Return all paths for a given path type

Parameters
NameTypeDescription
$typestring

The path type ('helper', 'filter', 'script')

Returns
TypeDescription
array
methodprivate_getPlugin(string $type, string $name) : object

Retrieve a plugin object

Parameters
NameTypeDescription
$typestring
$namestring
Returns
TypeDescription
object
methodprivate_getPluginPath(string $type, string $name) : string | false

Get a path to a given plugin class of a given type

Parameters
NameTypeDescription
$typestring
$namestring
Returns
TypeDescription
string | false
methodprotected_run() : mixed
abstract

Use to include the view script in a scope that only allows public members.

Returns
TypeDescription
mixed
methodprotected_script(string $name) : void

Finds a view script from the available directories.

Parameters
NameTypeDescription
$namestring

The base name of the script.

methodprivate_setFilterClass(string $name, string $class, string $file) : void

Register filter class as loaded

Parameters
NameTypeDescription
$namestring
$classstring
$filestring

path to class file

methodprivate_setHelperClass(string $name, string $class, string $file) : void

Register helper class as loaded

Parameters
NameTypeDescription
$namestring
$classstring
$filestring

path to class file

methodprivate_setPath(string $type, string | array $path, string $classPrefix = null) : void

Resets the path stack for helpers and filters.

Parameters
NameTypeDescription
$typestring

The path type ('helper' or 'filter').

$pathstring | array

The directory (-ies) to set as the path.

$classPrefixstring

Class prefix to apply to elements of $path

methodpublicaddBasePath(string $path,  $classPrefix = 'Zend_View') : \Zend_View_Abstract

Given a base path, add script, helper, and filter paths relative to it

Assumes a directory structure of: basePath/ scripts/ helpers/ filters/
Parameters
NameTypeDescription
$pathstring
$classPrefix
Returns
TypeDescription
\Zend_View_Abstract
methodpublicaddFilter( $name) : \Zend_View_Abstract

Add one or more filters to the stack in FIFO order.

Parameters
NameTypeDescription
$name
Returns
TypeDescription
\Zend_View_Abstract
methodpublicaddFilterPath( $path, string $classPrefix = 'Zend_View_Filter_') : \Zend_View_Abstract

Adds to the stack of filter paths in LIFO order.

Parameters
NameTypeDescription
$path
$classPrefixstring

Class prefix to use with classes in this directory; defaults to Zend_View_Filter

Returns
TypeDescription
\Zend_View_Abstract
methodpublicaddHelperPath( $path, string $classPrefix = 'Zend_View_Helper_') : \Zend_View_Abstract

Adds to the stack of helper paths in LIFO order.

Parameters
NameTypeDescription
$path
$classPrefixstring

Class prefix to use with classes in this directory; defaults to Zend_View_Helper

Returns
TypeDescription
\Zend_View_Abstract
methodpublicaddScriptPath( $path) : \Zend_View_Abstract

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

Parameters
NameTypeDescription
$path
Returns
TypeDescription
\Zend_View_Abstract
methodpublicassign( $spec,  $value = null) : \Zend_View_Abstract

Assigns variables to the view script via differing strategies.

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).
Parameters
NameTypeDescription
$spec
$value
Returns
TypeDescription
\Zend_View_AbstractFluent interface
Throws
ExceptionDescription
\Zend_View_Exceptionif $spec is neither a string nor an array, or if an attempt to set a private or protected member is detected
Details
See
 
methodpublicclearVars() : void

Clear all assigned variables

Clears all variables assigned to Zend_View either via {@link assign()} or property overloading ({@link __set()}).
methodpublicescape(mixed $var) : mixed

Escapes a value for output in a view script.

If escaping mechanism is one of htmlspecialchars or htmlentities, uses {@link $_encoding} setting.
Parameters
NameTypeDescription
$varmixed

The output to escape.

Returns
TypeDescription
mixedThe escaped value.
methodpublicgetAllPaths() : array

Return associative array of path types => paths

Returns
TypeDescription
array
methodpublicgetEncoding() : string

Return current escape encoding

Returns
TypeDescription
string
methodpublicgetEngine() : \Zend_View_Abstract

Return the template engine object

Returns the object instance, as it is its own template engine
Returns
TypeDescription
\Zend_View_Abstract
methodpublicgetFilter(string $name) : object

Get a filter object by name

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
object
methodpublicgetFilterPath(string $name) : string | false

Get full path to a filter class file specified by $name

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
string | falseFalse on failure, path on success
methodpublicgetFilterPaths() : array

Returns an array of all currently set filter paths

Returns
TypeDescription
array
methodpublicgetFilters() : array

Return array of all currently active filters

Only returns those that have already been instantiated.
Returns
TypeDescription
array
methodpublicgetHelper(string $name) : object

Get a helper by name

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
object
methodpublicgetHelperPath(string $name) : string | false

Get full path to a helper class file specified by $name

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
string | falseFalse on failure, path on success
methodpublicgetHelperPaths() : array

Returns an array of all currently set helper paths

Returns
TypeDescription
array
methodpublicgetHelpers() : array

Get array of all active helpers

Only returns those that have already been instantiated.
Returns
TypeDescription
array
methodpublicgetPluginLoader(string $type) : \Zend_Loader_PluginLoader

Retrieve plugin loader for a specific plugin type

Parameters
NameTypeDescription
$typestring
Returns
TypeDescription
\Zend_Loader_PluginLoader
methodpublicgetScriptPath(string $name) : false | string

Return full path to a view script specified by $name

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
false | stringFalse if script not found
Throws
ExceptionDescription
\Zend_View_Exceptionif no script directory set
methodpublicgetScriptPaths() : array

Returns an array of all currently set script paths

Returns
TypeDescription
array
methodpublicgetVars() : array

Return list of all assigned variables

Returns all public properties of the object. Reflection is not used here as testing reflection properties for visibility is buggy.
Returns
TypeDescription
array
methodpublicinit() : void

Allow custom object initialization when extending Zend_View_Abstract or Zend_View

Triggered by {@link __construct() the constructor} as its final action.
methodpublicisLfiProtectionOn() : bool

Return status of LFI protection flag

Returns
TypeDescription
bool
methodpublicregisterHelper(\Zend_View_Helper_Abstract | object $helper, string $name) : \Zend_View_Abstract

Registers a helper object, bypassing plugin loader

Parameters
NameTypeDescription
$helper\Zend_View_Helper_Abstract | object
$namestring
Returns
TypeDescription
\Zend_View_Abstract
Throws
ExceptionDescription
\Zend_View_Exception
methodpublicrender(string $name) : string

Processes a view script and returns the output.

Parameters
NameTypeDescription
$namestring

The script name to process.

Returns
TypeDescription
stringThe script output.
methodpublicsetBasePath(string $path,  $classPrefix = 'Zend_View') : \Zend_View_Abstract

Given a base path, sets the script, helper, and filter paths relative to it

Assumes a directory structure of: basePath/ scripts/ helpers/ filters/
Parameters
NameTypeDescription
$pathstring
$classPrefix
Returns
TypeDescription
\Zend_View_Abstract
methodpublicsetEncoding(string $encoding) : \Zend_View_Abstract

Set encoding to use with htmlentities() and htmlspecialchars()

Parameters
NameTypeDescription
$encodingstring
Returns
TypeDescription
\Zend_View_Abstract
methodpublicsetEscape(mixed $spec) : \Zend_View_Abstract

Sets the _escape() callback.

Parameters
NameTypeDescription
$specmixed

The callback for _escape() to use.

Returns
TypeDescription
\Zend_View_Abstract
methodpublicsetFilter( $name) : \Zend_View_Abstract

Resets the filter stack.

To clear all filters, use Zend_View::setFilter(null).
Parameters
NameTypeDescription
$name
Returns
TypeDescription
\Zend_View_Abstract
methodpublicsetFilterPath( $path, string $classPrefix = 'Zend_View_Filter_') : \Zend_View_Abstract

Resets the stack of filter paths.

To clear all paths, use Zend_View::setFilterPath(null).
Parameters
NameTypeDescription
$path
$classPrefixstring

The class prefix to apply to all elements in $path; defaults to Zend_View_Filter

Returns
TypeDescription
\Zend_View_Abstract
methodpublicsetHelperPath(string | array $path, string $classPrefix = 'Zend_View_Helper_') : \Zend_View_Abstract

Resets the stack of helper paths.

To clear all paths, use Zend_View::setHelperPath(null).
Parameters
NameTypeDescription
$pathstring | array

The directory (-ies) to set as the path.

$classPrefixstring

The class prefix to apply to all elements in $path; defaults to Zend_View_Helper

Returns
TypeDescription
\Zend_View_Abstract
methodpublicsetLfiProtection(bool $flag) : \Zend_View_Abstract

Set LFI protection flag

Parameters
NameTypeDescription
$flagbool
Returns
TypeDescription
\Zend_View_Abstract
methodpublicsetPluginLoader(\Zend_Loader_PluginLoader $loader, string $type) : \Zend_View_Abstract

Set plugin loader for a particular plugin type

Parameters
NameTypeDescription
$loader\Zend_Loader_PluginLoader
$typestring
Returns
TypeDescription
\Zend_View_Abstract
methodpublicsetScriptPath( $path) : \Zend_View_Abstract

Resets the stack of view script paths.

To clear all paths, use Zend_View::setScriptPath(null).
Parameters
NameTypeDescription
$path
Returns
TypeDescription
\Zend_View_Abstract
methodpublicstrictVars(boolean $flag = true) : \Zend_View_Abstract

Enable or disable strict vars

If strict variables are enabled, {@link __get()} will raise a notice when a variable is not defined. Use in conjunction with {@link Zend_View_Helper_DeclareVars the declareVars() helper} to enforce strict variable handling in your view scripts.
Parameters
NameTypeDescription
$flagboolean
Returns
TypeDescription
\Zend_View_Abstract
Documentation was generated by phpDocumentor 2.2.0 .