Zend Framework  1.12
Public Member Functions | Protected Member Functions | List of all members
Zend_View_Abstract Class Reference

Public Member Functions

 __construct ($config=array())
 Constructor.
 
 getEngine ()
 Return the template engine object.
 
 init ()
 Allow custom object initialization when extending Zend_View_Abstract or Zend_View.
 
 __get ($key)
 Prevent E_NOTICE for nonexistent values.
 
 __isset ($key)
 Allows testing with empty() and isset() to work inside templates.
 
 __set ($key, $val)
 Directly assigns a variable to the view script.
 
 __unset ($key)
 Allows unset() on object properties to work.
 
 __call ($name, $args)
 Accesses a helper object from within a script.
 
 setBasePath ($path, $classPrefix= 'Zend_View')
 Given a base path, sets the script, helper, and filter paths relative to it.
 
 addBasePath ($path, $classPrefix= 'Zend_View')
 Given a base path, add script, helper, and filter paths relative to it.
 
 addScriptPath ($path)
 Adds to the stack of view script paths in LIFO order.
 
 setScriptPath ($path)
 Resets the stack of view script paths.
 
 getScriptPath ($name)
 Return full path to a view script specified by $name.
 
 getScriptPaths ()
 Returns an array of all currently set script paths.
 
 setPluginLoader (Zend_Loader_PluginLoader $loader, $type)
 Set plugin loader for a particular plugin type.
 
 getPluginLoader ($type)
 Retrieve plugin loader for a specific plugin type.
 
 addHelperPath ($path, $classPrefix= 'Zend_View_Helper_')
 Adds to the stack of helper paths in LIFO order.
 
 setHelperPath ($path, $classPrefix= 'Zend_View_Helper_')
 Resets the stack of helper paths.
 
 getHelperPath ($name)
 Get full path to a helper class file specified by $name.
 
 getHelperPaths ()
 Returns an array of all currently set helper paths.
 
 registerHelper ($helper, $name)
 Registers a helper object, bypassing plugin loader.
 
 getHelper ($name)
 Get a helper by name.
 
 getHelpers ()
 Get array of all active helpers.
 
 addFilterPath ($path, $classPrefix= 'Zend_View_Filter_')
 Adds to the stack of filter paths in LIFO order.
 
 setFilterPath ($path, $classPrefix= 'Zend_View_Filter_')
 Resets the stack of filter paths.
 
 getFilterPath ($name)
 Get full path to a filter class file specified by $name.
 
 getFilter ($name)
 Get a filter object by name.
 
 getFilters ()
 Return array of all currently active filters.
 
 getFilterPaths ()
 Returns an array of all currently set filter paths.
 
 getAllPaths ()
 Return associative array of path types => paths.
 
 addFilter ($name)
 Add one or more filters to the stack in FIFO order.
 
 setFilter ($name)
 Resets the filter stack.
 
 setEscape ($spec)
 Sets the _escape() callback.
 
 setLfiProtection ($flag)
 Set LFI protection flag.
 
 isLfiProtectionOn ()
 Return status of LFI protection flag.
 
 assign ($spec, $value=null)
 Assigns variables to the view script via differing strategies.
 
 getVars ()
 Return list of all assigned variables.
 
 clearVars ()
 Clear all assigned variables.
 
 render ($name)
 Processes a view script and returns the output.
 
 escape ($var)
 Escapes a value for output in a view script.
 
 setEncoding ($encoding)
 Set encoding to use with htmlentities() and htmlspecialchars()
 
 getEncoding ()
 Return current escape encoding.
 
 strictVars ($flag=true)
 Enable or disable strict vars.
 

Protected Member Functions

 _script ($name)
 Finds a view script from the available directories.
 
 _run ()
 Use to include the view script in a scope that only allows public members.
 

Constructor & Destructor Documentation

__construct (   $config = array())

Constructor.

Parameters
array$configConfiguration key-value pairs.

Member Function Documentation

__call (   $name,
  $args 
)

Accesses a helper object from within a script.

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

Parameters
string$nameThe helper name.
array$argsThe parameters for the helper.
Returns
string The result of the helper output.
__get (   $key)

Prevent E_NOTICE for nonexistent values.

If strictVars() is on, raises a notice.

Parameters
string$key
Returns
null
__isset (   $key)

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

Parameters
string$key
Returns
boolean

Implements Zend_View_Interface.

__set (   $key,
  $val 
)

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
string$keyThe variable name.
mixed$valThe variable value.
Returns
void
Exceptions
Zend_View_Exceptionif an attempt to set a private or protected member is detected

Implements Zend_View_Interface.

__unset (   $key)

Allows unset() on object properties to work.

Parameters
string$key
Returns
void

Implements Zend_View_Interface.

_run ( )
abstractprotected

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

Returns
mixed
_script (   $name)
protected

Finds a view script from the available directories.

Parameters
string$nameThe base name of the script.
Returns
void
addBasePath (   $path,
  $classPrefix = 'Zend_View' 
)

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

Assumes a directory structure of: basePath/ scripts/ helpers/ filters/

Parameters
string$path
string$prefixPrefix to use for helper and filter paths
Returns
Zend_View_Abstract

Implements Zend_View_Interface.

addFilter (   $name)

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

Parameters
string|arrayOne or more filters to add.
Returns
Zend_View_Abstract
addFilterPath (   $path,
  $classPrefix = 'Zend_View_Filter_' 
)

Adds to the stack of filter paths in LIFO order.

Parameters
string|arrayThe directory (-ies) to add.
string$classPrefixClass prefix to use with classes in this directory; defaults to Zend_View_Filter
Returns
Zend_View_Abstract
addHelperPath (   $path,
  $classPrefix = 'Zend_View_Helper_' 
)

Adds to the stack of helper paths in LIFO order.

Parameters
string|arrayThe directory (-ies) to add.
string$classPrefixClass prefix to use with classes in this directory; defaults to Zend_View_Helper
Returns
Zend_View_Abstract
addScriptPath (   $path)

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

Parameters
string|arrayThe directory (-ies) to add.
Returns
Zend_View_Abstract
assign (   $spec,
  $value = null 
)

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).

See Also
__set()
Parameters
string|arrayThe assignment strategy to use.
mixed(Optional) If assigning a named variable, use this as the value.
Returns
Zend_View_Abstract Fluent interface
Exceptions
Zend_View_Exceptionif $spec is neither a string nor an array, or if an attempt to set a private or protected member is detected

Implements Zend_View_Interface.

clearVars ( )

Clear all assigned variables.

Clears all variables assigned to Zend_View either via assign() or property overloading (__set()).

Returns
void

Implements Zend_View_Interface.

escape (   $var)

Escapes a value for output in a view script.

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

Parameters
mixed$varThe output to escape.
Returns
mixed The escaped value.
getAllPaths ( )

Return associative array of path types => paths.

Returns
array
getEncoding ( )

Return current escape encoding.

Returns
string
getEngine ( )

Return the template engine object.

Returns the object instance, as it is its own template engine

Returns
Zend_View_Abstract

Implements Zend_View_Interface.

getFilter (   $name)

Get a filter object by name.

Parameters
string$name
Returns
object
getFilterPath (   $name)

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

Parameters
string$name
Returns
string|false False on failure, path on success
getFilterPaths ( )

Returns an array of all currently set filter paths.

Returns
array
getFilters ( )

Return array of all currently active filters.

Only returns those that have already been instantiated.

Returns
array
getHelper (   $name)

Get a helper by name.

Parameters
string$name
Returns
object
getHelperPath (   $name)

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

Parameters
string$name
Returns
string|false False on failure, path on success
getHelperPaths ( )

Returns an array of all currently set helper paths.

Returns
array
getHelpers ( )

Get array of all active helpers.

Only returns those that have already been instantiated.

Returns
array
getPluginLoader (   $type)

Retrieve plugin loader for a specific plugin type.

Parameters
string$type
Returns
Zend_Loader_PluginLoader
getScriptPath (   $name)

Return full path to a view script specified by $name.

Parameters
string$name
Returns
false|string False if script not found
Exceptions
Zend_View_Exceptionif no script directory set
getScriptPaths ( )

Returns an array of all currently set script paths.

Returns
array

Implements Zend_View_Interface.

getVars ( )

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
array
init ( )

Allow custom object initialization when extending Zend_View_Abstract or Zend_View.

Triggered by the constructor as its final action.

Returns
void
isLfiProtectionOn ( )

Return status of LFI protection flag.

Returns
bool
registerHelper (   $helper,
  $name 
)

Registers a helper object, bypassing plugin loader.

Parameters
Zend_View_Helper_Abstract | object$helper
string$name
Returns
Zend_View_Abstract
Exceptions
Zend_View_Exception
render (   $name)

Processes a view script and returns the output.

Parameters
string$nameThe script name to process.
Returns
string The script output.

Implements Zend_View_Interface.

setBasePath (   $path,
  $classPrefix = 'Zend_View' 
)

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

Assumes a directory structure of: basePath/ scripts/ helpers/ filters/

Parameters
string$path
string$prefixPrefix to use for helper and filter paths
Returns
Zend_View_Abstract

Implements Zend_View_Interface.

setEncoding (   $encoding)

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

Parameters
string$encoding
Returns
Zend_View_Abstract
setEscape (   $spec)

Sets the _escape() callback.

Parameters
mixed$specThe callback for _escape() to use.
Returns
Zend_View_Abstract
setFilter (   $name)

Resets the filter stack.

To clear all filters, use Zend_View::setFilter(null).

Parameters
string|arrayOne or more filters to set.
Returns
Zend_View_Abstract
setFilterPath (   $path,
  $classPrefix = 'Zend_View_Filter_' 
)

Resets the stack of filter paths.

To clear all paths, use Zend_View::setFilterPath(null).

Parameters
string|arrayThe directory (-ies) to set as the path.
string$classPrefixThe class prefix to apply to all elements in $path; defaults to Zend_View_Filter
Returns
Zend_View_Abstract
setHelperPath (   $path,
  $classPrefix = 'Zend_View_Helper_' 
)

Resets the stack of helper paths.

To clear all paths, use Zend_View::setHelperPath(null).

Parameters
string | array$pathThe directory (-ies) to set as the path.
string$classPrefixThe class prefix to apply to all elements in $path; defaults to Zend_View_Helper
Returns
Zend_View_Abstract
setLfiProtection (   $flag)

Set LFI protection flag.

Parameters
bool$flag
Returns
Zend_View_Abstract
setPluginLoader ( Zend_Loader_PluginLoader  $loader,
  $type 
)

Set plugin loader for a particular plugin type.

Parameters
Zend_Loader_PluginLoader$loader
string$type
Returns
Zend_View_Abstract
setScriptPath (   $path)

Resets the stack of view script paths.

To clear all paths, use Zend_View::setScriptPath(null).

Parameters
string|arrayThe directory (-ies) to set as the path.
Returns
Zend_View_Abstract

Implements Zend_View_Interface.

strictVars (   $flag = true)

Enable or disable strict vars.

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.

Parameters
boolean$flag
Returns
Zend_View_Abstract