category OSS
package OSS_View
copyright Copyright (c) 2007 - 2012, Open Source Solutions Limited, Dublin, Ireland
license New BSD License

 Methods

This is needed for {@link clearVars()} to work properly.

__clone() : void

It automatically runs (PHP 5) after the "clone" operator did it's job. More descriptions at clearVars() .

Constructor

__construct(string $tmplPath, array $extraParams) : void

Parameters

$tmplPath

string

$extraParams

array

Retrieve an assigned variable

__get(string $key) : mixed

Parameters

$key

string

The variable name.

Returns

mixedThe variable value.

Allows testing with empty() and isset() to work

__isset(string $key) : bool

Parameters

$key

string

Returns

bool

Assign a variable to the template

__set(string $key, mixed $val) : void

Parameters

$key

string

The variable name.

$val

mixed

The variable value.

Allows unset() on object properties to work

__unset(string $key) : void

Parameters

$key

string

Alias for setScriptPath

addBasePath(string $path, string $prefix) : void

Parameters

$path

string

$prefix

string

Unused

Assign variables to the template

assign(string | array $spec, mixed $value) : void

Allows setting a specific key to the specified value, OR passing an array of key => value pairs to set en masse.

see \global\__set()

Parameters

$spec

stringarray

The assignment strategy to use (key or array of key => value pairs)

$value

mixed

(Optional) If assigning a named variable, use this as the value.

Clear all assigned variables

clearVars() 

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

Both Zend_View_Helper_Action::cloneView() and Zend_View_Helper_Partial::cloneView() executes a "$view->clearVars();" line after a "$view = clone $this->view;" . Because of how the "clone" operator works internally (object references are also copied, so a clone of this object will point to the same Smarty object instance as this, the "$view->clearVars();" unsets all the Smarty template variables. To solve this, there is the __clone() method in this class which is called by the "clone" operator just after it did it's cloning job.

This sets a flag ($this->_isBeingCloned) for use below to avoid clearing the template variables in the cloned object.

If for any reason this doesn't work, neither after amending __clone(), an other "solution" is in the method, but commented out. That will also work, but it is relatively slow and, not nice at all. That takes a look on it's backtrace, and if finds a function name "cloneView" then does NOT execute Smarty's clearAllAssign().

Or just make this an empty function if neither the above works.

Processes a template and sends the output.

display(string $name) : void

Parameters

$name

string

The template to process.

Return the template engine object

getEngine() : \Smarty

Returns

\Smarty

Retrieve the current template directory

getScriptPaths() : string

Returns

string

Return the name of the skin in use or false if default.

getSkin() : string

Returns

stringThe name of the skin in use or false if default.

Add a new message to the stack

ossAddMessage(\OSS_Message $message) : bool

Parameters

$message

\OSS_Message

An instance of the OSS_Message class

Returns

bool

Register a class for access to static methods / constants in a template.

registerClass(string $n, string $c) 

Especially useful for classes outside the standard namespace.

From the Smarty developers:

We have decided not to integrate namespace support into the template syntax. The goal of Smarty is to speparate the design as much as possible from the business logic. With namespace syntax we would more and more of business logic into the templates.

Instead ou can register a class with optional namespace for the use in the template like:

$smarty->registerClass("FOO","\Fully\Qualified\Name\Foo");

see \global\http://www.smarty.net/forums/viewtopic.php?p=65279

Parameters

$n

string

The variable name for the class within the template

$c

string

The fully qualified class name

Processes a template and returns the output.

render(string $name) : string

Parameters

$name

string

The template to process.

Returns

string

Alias for setScriptPath

setBasePath(string $path, string $prefix) : void

Parameters

$path

string

$prefix

string

Unused

Set the path to the templates

setScriptPath(string $path) : void

Parameters

$path

string

The directory to set as the path.

Exceptions

\Exception If path is not readable

Set the skin to use

setSkin(string $s) 

Parameters

$s

string

The name of the skin

Exceptions

\Exception

Checks to see if the named template exists in the current skin

skinTemplateExists(string $name) : boolean

Parameters

$name

string

The template to look for

Returns

boolean

Checks to see if the named template exists

templateExists(string $name) : bool

Parameters

$name

string

The template to look for

Returns

bool

Run

_run() : void

This function "resolves" a given template name into an appropriate template file depending on whether we're using skins or not.

resolveTemplate(string $name) : string

If we're using skins and if a template exists in the skin, then it'll be used. Otherwise we'll use the default templates.

Parameters

$name

string

The name of the template to use

Returns

stringThe resolved template name

 Properties

 

Is being cloned?

$_isBeingCloned : bool
 

Should we use a custom skin?

$_skin : string
 

Smarty object

$_smarty : \Smarty