The SquirrelMail Template class.
Basic template class for capturing values and pluging them into a template. This class uses a similar API to Smarty.
Methods that must be implemented by subclasses are as follows (see method stubs below for further information about expected behavior):
assign() assign_by_ref() clear_all_assign() get_template_vars() append() append_by_ref() apply_template()
Located in /class/template/Template.class.php (line 44)
Class | Description |
---|---|
Smarty_Template | The SquirrelMail Smarty Template class. Extends the base Template class for use with Smarty template pages. |
PHP_Template | The SquirrelMail PHP Template class. Extends the base Template class for use with PHP template pages. |
The content type for this template set
The fall-back template directory (relative path from the main SquirrelMail directory (SM_PATH))
The fall-back template engine (please use constants defined in constants.php)
The fall-back template ID
Extra template engine class objects for rendering templates that require a different engine than the one for the current template set. Keys should be the name of the template engine, values are the corresponding class objects.
The template set base directory (relative path from the main SquirrelMail directory (SM_PATH))
The template engine (please use constants defined in constants.php)
Template file cache. Structured as an array, whose keys
are all the template file names (with path information relative to the template set's base directory, e.g., "css/style.css") found in all parent template sets including the ultimate fall-back template set. Array values are sub-arrays with the following key-value pairs:
PATH -- file path, relative to SM_PATH SET_ID -- the ID of the template set that this file belongs to ENGINE -- the engine needed to render this template file
The template ID
Obtain template file hierarchy from cache.
If the file hierarchy does not exist in session, it is constructed and stored in session before being returned to the caller.
Determine the relative template directory path for the given template ID.
Determine the relative images directory path for the given template ID.
Traverse template hierarchy and catalogue all template files (for storing in cache).
Paths to all files in all parent, grand-parent, great grand parent, etc. template sets (including the fallback template) are catalogued; for identically named files, the file earlier in the hierarchy (closest to this template set) is used.
Refuses to traverse directories called ".svn"
Construct Template
This method should always be called instead of trying to get a Template object from the normal/default constructor, and is necessary in order to control the return value.
Determine what the default template set is.
NOTE that if the default setting cannot be found in the main SquirrelMail configuration settings that the value of $default is returned.
Determine what the ultimate fallback template set is.
NOTE that if the fallback setting cannot be found in the main SquirrelMail configuration settings that the value of $default is returned.
Determine what the RPC template set is.
NOTE that if the default setting cannot be found in the main SquirrelMail configuration settings that the value of $default is returned.
Get template set config setting
Given a template set ID and setting name, returns the setting's value. Note that settings are cached in session, so "live" changes to template configuration won't be reflected until the user logs out and back in again.
Constructor
Please do not call directly. Use Template::construct_template().
Appends values to template variables
Note: this is an abstract method that must be implemented by subclass.
Appends values to template variables by reference
Note: this is an abstract method that must be implemented by subclass.
Applys the template and generates final output destined for the user's browser
Note: this is an abstract method that must be implemented by subclass.
Assigns values to template variables
Note: this is an abstract method that must be implemented by subclass.
Assigns values to template variables by reference
Note: this is an abstract method that must be implemented by subclass.
Clears the values of all assigned varaiables.
Display the template
Applies the template and returns the resultant content string.
Push out any other stylesheet links as provided (for stylesheets not included with the current template set)
Subclasses can override this function if stylesheets are created differently for the template set's target output interface.
Generate a link to the right-to-left stylesheet for
this template set by getting the "rtl.css" file from this template set, its parent (or grandparent, etc.) template set, the fall-back template set, or finally, fall back to SquirrelMail's own "rtl.css" if need be.
Subclasses can override this function if stylesheets are created differently for the template set's target output interface.
Generate links to all this template set's standard stylesheets
Subclasses can override this function if stylesheets are created differently for the template set's target output interface.
Look for a template file in a plugin; add to template file cache if found.
The file is searched for in the following order:
Return all alternate stylesheets provided by template.
All (non-empty) directories found in the template set's "css/alternates" directory (and that of its ancestors) are returned.
Note that prettified names are constructed herein by taking the directory name, changing underscores to spaces and capitalizing each word in the resultant name.
Return the content-type for this template set.
Return the relative template directory path for the fallback template set.
Return the template ID for the fallback template set.
Return all JavaScript files provided by the template.
All files found in the template set's "js" directory (and that of its ancestors) with the extension ".js" are returned.
Get template engine needed to render given template file.
If at all possible, just returns a reference to $this, but some template files may require a different engine, thus an object for that engine (which will subsequently be kept in this object for future use) is returned.
Return all standard stylsheets provided by the template.
All files found in the template set's "css" directory (and that of its ancestors) with the extension ".css" except "rtl.css" (which is dealt with separately) are returned.
Instantiate and return correct subclass for this template set's templating engine.
Return the relative template directory path for this template set.
Find the right template file.
The template file is taken from the template file cache, thus the file is taken from the current template, one of its ancestors or the fallback template.
Note that it is perfectly acceptable to load template files from template subdirectories. For example, JavaScript templates found in the js/ subdirectory would be loaded by passing "js/<javascript file name>" as the $filename.
Note that the caller can also ask for ALL files in a directory (and those in the same directory for all ancestor template sets) by giving a $filename that is a directory name (ending with a slash).
If not found and the file is a plugin template file (indicated by the presence of "plugins/" on the beginning of $filename), the target plugin is searched for a substitue template file before just returning nothing.
Plugin authors must note that the $filename MUST be prefaced with "plugins/<plugin name>/" in order to correctly resolve the template file.
Returns assigned variable value(s).
Send HTTP header(s) to browser.
Subclasses can override this function if headers are managed differently in the engine's target output interface.
Allow template set to override plugin configuration by either adding or removing plugins.
NOTE: due to when this code executes, plugins activated here do not have access to the config_override and loading_prefs hooks; instead, such plugins can use the "template_plugins_override_after" hook defined below.
Set up internal attributes
This method does most of the work for setting up newly constructed objects.
Documentation generated on Mon, 13 Jan 2020 04:23:41 +0100 by phpDocumentor 1.4.3