Phpfox_Template

Description

Template Loads all templates and converts it into PHP code and then caches it.

Class is also able to:

  • Assign variables to templates.
  • Identify a pages title.
  • Identify a pages breadcrumb structure.
  • Create meta tags.
  • Load CSS and JavaScript files.

  • author: Raymond Benc
  • version: $Id: template.class.php 1822 2010-09-21 07:30:34Z Raymond_Benc $
  • copyright: [PHPFOX_COPYRIGHT]

Located in /include/library/phpfox/template/template.class.php (line 24)


	
			
Direct descendents
Class Description
 class Phpfox_Template_Cache Template Cache Class handles the caching of a template file and converts any custom code into PHP code. Class is only loaded if the template cache file does not exist.
Method Summary
 Phpfox_Template __construct ()
 object Returns assign (mixed $mVars, [string $sValue = ''])
 void clean ([mixed $mName = ''])
 void clearBreadCrumb ()
 array getBreadCrumb ()
 string getBuiltTemplate (string $sLayout, string $sCacheName)
 string getHeader ()
 mixed getHeaderFile ()
 string getKeywords (string $sTitle)
 mixed getLayout (string $sName, [bool $bReturn = false])
 string getLayoutFile (string $sName)
 array getMenu ([sting $sConnection = null])
 string getMobileHeader ()
 string getStyle ([string $sType = 'css'], [string $sValue = null], [string $sModule = null])
 string getStyleLogo ()
 mixed getTemplate (string $sTemplate, [bool $bReturn = false])
 string getTemplateFile (string $sTemplate, [bool $bCheckDb = false])
 array getThemeCache ()
 string getThemeFolder ()
 string getThemeLayout ()
 string getTitle ()
 string getVar (string $sName)
 string getXml (string $sXml)
 object Return rebuildMenu (string $sConnection, array $aNewUrl)
 object Return removeUrl (string $sConnection, string $sUrl)
 object Returns setBreadCrumb (string $sPhrase, [string $sLink = ''], [bool $bIsTitle = false])
 object Returns setEditor ([array $aParams = array()])
 object Returns setFullSite ()
 object Returns setHeader (unknown_type $mHeaders, [ $mValue = null])
 unknown setImage (unknown_type $aImages)
 void setLayout (string $sName)
 object Returns setMeta (array $mMeta, [string $sValue = null])
 object Returns setMobileHeader (unknown_type $mHeaders, [ $mValue = null])
 object Returns setPhrase (array $mPhrases)
 void setStyle (array $aTheme)
 object Returns setTemplate (string $sLayout)
 object Returns setTitle (string $sTitle)
 object Return setUrl (string $sUrl)
 bool testStyle (int $iId)
 string _getCachedName (string $sName)
 void _getFromCache (string $sFile)
 array _getMenu ([string $sConnection = null], [int $iParent = 0])
 bool _isCached (string $sName)
 void _register ( $sType,  $sFunction,  $sImplementation)
 unknown _returnLayout ()
Variables
static string $_sStaticThemeFolder = null (line 244)

Static variable of the current theme folder.

  • access: protected
bool $bIsSample = false (line 38)

Check to see if we are displaying a sample page.

  • access: public
int $iThemeId = 0 (line 45)

Theme ID#

  • access: public
string $sDisplayLayout = 'template' (line 31)

Default template name.

  • access: public
string $sLeftDelim = '{' (line 59)

Left delimiter for custom functions. It is: {

  • access: protected
string $sReservedVarname = 'phpfox' (line 52)

Reserved variable name. Which is $phpfox.

  • access: protected
string $sRightDelim = '}' (line 66)

Right delimiter for custom functions. It is: }

  • access: protected
array $_aBreadCrumbs = array() (line 108)

List of breadcrumbs.

  • access: private
array $_aBreadCrumbTitle = array() (line 115)

Information about the title of the current page, which is part of the breadcrumb.

  • access: private
array $_aCacheHeaders = array() (line 222)

Cache of all the <head></head> content being loaded.

  • access: private
array $_aEditor = array() (line 178)

Information about the text editor.

  • access: private
array $_aHeaders = array() (line 101)

List of data to add within the templates HTML <head></head>.

  • access: private
array $_aImages = array() (line 215)

List of images to be loaded and converted into a JavaScript object.

  • access: private
array $_aMeta = array() (line 164)

List of meta data.

  • access: private
array $_aMobileHeaders = array() (line 236)

Mobile headers.

  • access: private
array $_aNewUrl = array() (line 201)

Rebuild URL brought from cache.

  • access: private
array $_aPhrases = array() (line 171)

List of phrases to load and create JavaScript variables for.

  • access: private
array $_aPlugins = array() (line 73)

List of plugins.

  • access: protected
array $_aRemoveUrl = array() (line 208)

Remove URL brought from cache.

  • access: private
array $_aSections = array() (line 80)

List of sections.

  • access: private
array $_aTheme = array(
'theme_parent_id' => 0
)
(line 192)

Information about the current theme we are using.

  • access: private
array $_aTitles = array() (line 94)

List of titles assigned to a page.

  • access: private
array $_aVars = array('bUseFullSite' => false) (line 87)

List of all the variables assigned to templates.

  • access: private
bool $_bIsAdminCp = false (line 136)

Check to see if a template is part of the AdminCP.

  • access: private
bool $_bIsTestMode = false (line 229)

Check to see if we are currently in test mode.

  • access: private
int $_iCacheTime = 60 (line 122)

Default file cache time.

  • access: private
bool $_sSetLayout = false (line 129)

Override the layout of the current theme being used.

  • access: private
string $_sStyleFolder (line 157)

Folder of the style being used.

  • access: private
string $_sThemeFolder (line 143)

Folder of the theme being used.

  • access: private
string $_sThemeLayout (line 150)

Theme layout to load.

  • access: private
string $_sUrl = null (line 185)

URL of the current page we are on.

  • access: private
Methods
Constructor __construct (line 251)

Class constructor we use to build the current theme and style we are using.

  • access: public
Phpfox_Template __construct ()

Redefined in descendants as:
assign (line 1535)

Assign a variable so we can use it within an HTML template.

PHP assign:

  1.  Phpfox::getLib('template')->assign('foo''bar');

HTML usage:

  1.  {$foo}
  2.  // Above will output: bar

  • return: self.
  • access: public
object Returns assign (mixed $mVars, [string $sValue = ''])
  • mixed $mVars: STRING variable name or ARRAY of variables to assign with both keys and values.
  • string $sValue: Variable value, only if the 1st argument is a STRING.
clean (line 1567)

Clean all or a specific variable from memory.

  • access: public
void clean ([mixed $mName = ''])
  • mixed $mName: Variable name to destroy, or leave blank to destory all variables or pass an ARRAY of variables to destroy.
clearBreadCrumb (line 648)

Clear the breadcrumb information.

  • access: public
void clearBreadCrumb ()
getBreadCrumb (line 639)

Get all the breadcrumbs we have loaded so far.

  • access: public
array getBreadCrumb ()
getBuiltTemplate (line 1730)

Get a template that has already been built.

  • return: HTML layout of the file.
  • access: public
string getBuiltTemplate (string $sLayout, string $sCacheName)
  • string $sLayout: Template name.
  • string $sCacheName: Cache name of the file.
getHeader (line 900)

Gets any data we plan to place within the HTML tags <head></head>.

This method also groups the data to give the template a nice clean look.

  • return: Returns the HTML data to be placed within <head></head>
  • access: public
string getHeader ()
getHeaderFile (line 1423)

Get the template header file if it exists.

  • return: File path if it exists, otherwise FALSE.
  • access: public
mixed getHeaderFile ()
getKeywords (line 801)

Gets all the keywords from a string.

  • return: Splits all the keywords from a title.
  • access: public
string getKeywords (string $sTitle)
  • string $sTitle: Title to parse.
getLayout (line 1594)

Loads the current template.

  • return: STRING if 2nd argument is TRUE. Otherwise NULL.
  • access: public
mixed getLayout (string $sName, [bool $bReturn = false])
  • string $sName: Layout name.
  • bool $bReturn: TRUE to return the template code, FALSE will echo it.
getLayoutFile (line 1610)

Get the full path of the current layout file.

  • return: Full path to the layout file.
  • access: public
string getLayoutFile (string $sName)
  • string $sName: Name of the layout file.
getMenu (line 1860)

Gets all the sites custom menus, such as the Main, Header, Footer and Sub menus.

Since information is stored in the database we cache the information so we only run the query once.

  • return: Is an array of the menus data
  • access: public
array getMenu ([sting $sConnection = null])
  • sting $sConnection: Current page we are viewing (Example: account/login)
getMobileHeader (line 859)

Gets any data we plan to place within the HTML tags <head></head> for mobile devices.

This method also groups the data to give the template a nice clean look.

  • return: Returns the HTML data to be placed within <head></head>
  • access: public
string getMobileHeader ()
getStyle (line 1442)

Gets the full path of a file based on the current style being used.

  • return: Returns the full path to the item.
  • access: public
string getStyle ([string $sType = 'css'], [string $sValue = null], [string $sModule = null])
  • string $sType: Type of file we are working with.
  • string $sValue: File name.
  • string $sModule: Module name. Only if its part of a module.
getStyleLogo (line 518)

Get the logo for the site based on the style being used.

  • access: public
string getStyleLogo ()
getTemplate (line 1771)

Get the current template data.

  • return: STRING content only if the 2nd argument is TRUE.
  • access: public
mixed getTemplate (string $sTemplate, [bool $bReturn = false])
  • string $sTemplate: Template name.
  • bool $bReturn: TRUE to return its content or FALSE to just echo it.
getTemplateFile (line 1637)

Get the full path to the modular template file we are loading.

  • return: Full path to the file we are loading.
  • access: public
string getTemplateFile (string $sTemplate, [bool $bCheckDb = false])
  • string $sTemplate: Name of the file.
  • bool $bCheckDb: TRUE to check the database if the file exists there.
getThemeCache (line 428)

Get the cached information about the theme we are using.

  • access: public
array getThemeCache ()
getThemeFolder (line 508)

Get the theme folder being used.

  • access: public
string getThemeFolder ()
getThemeLayout (line 418)

Get the current theme we are using.

  • access: public
string getThemeLayout ()
getTitle (line 767)

Get the title for the current page beind displayed.

All titles are added earlier in the script using self::setTitle(). Each title is split with a delimiter specificed from the Admin CP.

string getTitle ()
getVar (line 1557)

Get a variable we assigned with the method assign().

  • return: Variable value.
  • see: self::assign()
  • access: public
string getVar (string $sName)
  • string $sName: Variable name.
getXml (line 2103)

Load and get the XML information about the theme used when custom designing a profile.

  • return: ARRAY of XML data.
  • access: public
string getXml (string $sXml)
  • string $sXml: XML id.
rebuildMenu (line 1831)

Rebuild a cached menu.

  • return: self.
  • access: public
object Return rebuildMenu (string $sConnection, array $aNewUrl)
  • string $sConnection: Menu connection.
  • array $aNewUrl: ARRAY of the new values.
removeUrl (line 1845)

Remove a URL from a built cached menu.

  • return: self.
  • access: public
object Return removeUrl (string $sConnection, string $sUrl)
  • string $sConnection: Menu connection.
  • string $sUrl: URL value to identify what menu to remove.
setBreadCrumb (line 616)

Sets the breadcrumb structure for the site.

  • return: self.
  • access: public
object Returns setBreadCrumb (string $sPhrase, [string $sLink = ''], [bool $bIsTitle = false])
  • string $sPhrase: Breadcrumb title.
  • string $sLink: Breadcrumb link.
  • bool $bIsTitle: TRUE if this is the title breadcrumb for the page.
setEditor (line 747)

Set settings for the text editor in use.

  • return: self.
  • access: public
object Returns setEditor ([array $aParams = array()])
  • array $aParams: ARRAY of settings.
setFullSite (line 565)

Force the page to use its full width and not display anything within the sidepanel.

  • return: self.
  • access: public
object Returns setFullSite ()
setHeader (line 692)

All data placed between the HTML tags <head></head> can be added with this method.

Since we rely on custom templates we need the header data to be custom as well. Current support is for: css & JavaScript All HTML added here is coded under XHTML standards.

  • return: self.
  • access: public
object Returns setHeader (unknown_type $mHeaders, [ $mValue = null])
  • unknown_type $mHeaders
  • $mValue
setImage (line 403)

Sets all the images we plan on using within JavaScript.

PHP usage:

  1.  Phpfox::getLib('template')->setImage(array('layout_sample_image''layout/sample.png'));

In JavaScript the above image can be accessed by:

  1.  oJsImages['layout_sample_image'];

  • access: public
unknown setImage (unknown_type $aImages)
  • unknown_type $aImages
setLayout (line 555)

Override the layout of the site.

  • access: public
void setLayout (string $sName)
  • string $sName: Layout we should load.
setMeta (line 831)

Set all the meta tags to be used on the site.

  • return: self.
  • access: public
object Returns setMeta (array $mMeta, [string $sValue = null])
  • array $mMeta: ARRAY of meta tags.
  • string $sValue: Value of meta tags in case the 1st argument is a string.
setMobileHeader (line 729)

All data placed between the HTML tags <head></head> can be added with this method for mobile devices.

Since we rely on custom templates we need the header data to be custom as well. Current support is for: css & JavaScript All HTML added here is coded under XHTML standards.

  • return: self.
  • access: public
object Returns setMobileHeader (unknown_type $mHeaders, [ $mValue = null])
  • unknown_type $mHeaders
  • $mValue
setPhrase (line 578)

Sets phrases we can later use in JavaScript.

  • return: self.
  • access: public
object Returns setPhrase (array $mPhrases)
  • array $mPhrases: ARRAY of pharses to build.
setStyle (line 438)

Override the current theme.

  • access: public
void setStyle (array $aTheme)
  • array $aTheme: ARRAY of values to override.
setTemplate (line 675)

Set the current template for the site.

  • return: self.
  • access: public
object Returns setTemplate (string $sLayout)
  • string $sLayout: Template name.
setTitle (line 662)

Set the page title in a public array so we can get it later and display within the template.

object Returns setTitle (string $sTitle)
  • string $sTitle: Title to display on a specific page
setUrl (line 2090)

Set the current URL for the site.

  • return: self.
  • access: public
object Return setUrl (string $sUrl)
  • string $sUrl: URL value.
testStyle (line 453)

Test a style by attempting to load and display it for the user.

This is used when a user is trying to demo a style.

  • return: TRUE if style can be loaded, FALSE if not.
  • access: public
bool testStyle (int $iId)
  • int $iId: ID of the style.
_getCachedName (line 2235)

Gets the full path of the cached template file

  • return: Full path to cached template
  • access: private
string _getCachedName (string $sName)
  • string $sName: Name of the template
_getFromCache (line 2174)

Gets a template file from cache. If the file does not exist we re-cache the template.

  • access: private
void _getFromCache (string $sFile)
  • string $sFile: Full path of the template we are loading.
_getMenu (line 2143)

Get a menu.

  • return: ARRAY of menus.
  • access: private
array _getMenu ([string $sConnection = null], [int $iParent = 0])
  • string $sConnection: Connection for the menu.
  • int $iParent: Parent ID# number for the menu.
_isCached (line 2203)

Checks to see if a template has already been cached or not.

  • return: TRUE is cached, FALSE is not cached.
  • access: private
bool _isCached (string $sName)
  • string $sName: Full path to the template file.
_register (line 2240)
  • access: private
void _register ( $sType,  $sFunction,  $sImplementation)
  • $sType
  • $sFunction
  • $sImplementation
_returnLayout (line 2160)

Returns the content of a template that has already been echoed.

  • access: private
unknown _returnLayout ()

Documentation generated on Tue, 28 Sep 2010 10:36:44 +0200 by phpDocumentor 1.4.0a2