Class: I2CE Template: Difference between revisions

From IHRIS Wiki
No edit summary
No edit summary
Line 1: Line 1:
This article desrcibes the class '''I2CE_Template''' which extends the class [[Class: I2CE_TemplateMeister | I2CE_TemplateMeister]]
This article desrcibes the class '''I2CE_Template'''.
*Extends the class: [[Class: I2CE_TemplateMeister | I2CE_TemplateMeister]].
It is contained in the module [[iHRIS Module List#pages|pages]] in the package [https://launchpad.net/i2ce I2CE]
It is contained in the module [[iHRIS Module List#pages|pages]] in the package [https://launchpad.net/i2ce I2CE]


Line 20: Line 21:
Helper method. Load a file into the spectified document as HTML
Helper method. Load a file into the spectified document as HTML
*Signature: public function _loadFile($doc,$contentfile)
*Signature: public function _loadFile($doc,$contentfile)
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean]  False on failure,
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]  False on failure,
Parameters:
Parameters:
* [http://www.php.net/manual/en/class.domdocument.php domdocument] $doc
* [http://www.php.net/manual/en/class.domdocument.php DOMDocument ] $doc
* [http://www.php.net/manual/en/language.types.string.php string] $contentfile<br/>the file to load
* [http://www.php.net/manual/en/language.types.string.php string ] $contentfile<br/>the file to load
===_loadText()===
===_loadText()===
Helper method.  Load text into the spectified document as XML
Helper method.  Load text into the spectified document as XML
@param string $contentfile the file to load
@param string $contentfile the file to load
*Signature: protected function _loadText($doc,$text,$setEncoding)
*Signature: protected function _loadText($doc,$text,$setEncoding)
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean]  False on failure,
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]  False on failure,
Parameters:
Parameters:
* [http://www.php.net/manual/en/class.domdocument.php domdocument] $doc
* [http://www.php.net/manual/en/class.domdocument.php DOMDocument ] $doc
*$text  
*$text  
* [http://www.php.net/manual/en/language.types.string.php string] $setEncoding<br/>Defaults to true.  If true, set the encoding to be that of the docuemnt.  Only useful as false for loading root template files
* [http://www.php.net/manual/en/language.types.string.php string ] $setEncoding<br/>Defaults to true.  If true, set the encoding to be that of the docuemnt.  Only useful as false for loading root template files
**Default Value: true
**Default Value: true
===addClass()===
===addClass()===
Line 50: Line 51:
*Signature: public function addHeaderLink($file,$attr,$use_filedump)
*Signature: public function addHeaderLink($file,$attr,$use_filedump)
Parameters:
Parameters:
* [http://www.php.net/manual/en/language.types.string.php string] $file
* [http://www.php.net/manual/en/language.types.string.php string ] $file
* [http://www.php.net/manual/en/language.pseudo-types.php mixed] $attr<br/>an array of attribute/value pairs.  Defaults to the empty array.  can also be a string
* [http://www.php.net/manual/en/language.pseudo-types.php mixed ] $attr<br/>an array of attribute/value pairs.  Defaults to the empty array.  can also be a string
**Default Value: array()
**Default Value: array()
* [http://www.php.net/manual/en/language.types.boolean.php boolean] $use_filedump<br/>default to true meaning that we should use the filedump utility
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $use_filedump<br/>default to true meaning that we should use the filedump utility
**Default Value: true
**Default Value: true
===addHeaderText()===
===addHeaderText()===
Line 63: Line 64:
id. If it is a DOMNode then we just append to that node
id. If it is a DOMNode then we just append to that node
*Signature: public function addHeaderText($text,$type,$as_separate_node,$init_text)
*Signature: public function addHeaderText($text,$type,$as_separate_node,$init_text)
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode] -- the node just created or appended to.  False on failure
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ] -- the node just created or appended to.  False on failure
Note the text does not have to be wrapped in <$tag> node.  If not, it will put it in a <$tag> node with reasonalbe
Note the text does not have to be wrapped in <$tag> node.  If not, it will put it in a <$tag> node with reasonalbe
attributes.
attributes.
Parameters:
Parameters:
* [http://www.php.net/manual/en/language.types.string.php string] $text
* [http://www.php.net/manual/en/language.types.string.php string ] $text
* [http://www.php.net/manual/en/language.types.string.php string] $type<br/>one of 'css',javascipt','vbscript'
* [http://www.php.net/manual/en/language.types.string.php string ] $type<br/>one of 'css',javascipt','vbscript'
*$as_separate_node  
*$as_separate_node  
**Default Value: false  
**Default Value: false  
* [http://www.php.net/manual/en/language.types.string.php string] $init_text<br/>the text we ar adding as a separate node and the node does not exist.  Defaults to the empty string
* [http://www.php.net/manual/en/language.types.string.php string ] $init_text<br/>the text we ar adding as a separate node and the node does not exist.  Defaults to the empty string
**Default Value: ''  
**Default Value: ''  
===checkRolesTasksAndPermissions()===
===checkRolesTasksAndPermissions()===
Line 83: Line 84:
*Signature: public function checkRolesTasksAndPermissions($node)
*Signature: public function checkRolesTasksAndPermissions($node)
Parameters:
Parameters:
* [http://www.php.net/manual/en/class.domnode.php domnode] $node<br/>Defaults to null, meaning we check the whole document.  Otherwise, we check
* [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node<br/>Defaults to null, meaning we check the whole document.  Otherwise, we check
**Default Value: null
**Default Value: null
===ensureCSSURLs()===
===ensureCSSURLs()===
Line 101: Line 102:
can override package versions of files.
can override package versions of files.
*Signature: public function findTemplate($template,$raise_error)
*Signature: public function findTemplate($template,$raise_error)
*Returns: [http://www.php.net/manual/en/language.pseudo-types.php mixed]
*Returns: [http://www.php.net/manual/en/language.pseudo-types.php mixed ]
Parameters:
Parameters:
* [http://www.php.net/manual/en/language.types.string.php string] $template<br/>The name of the template file.
* [http://www.php.net/manual/en/language.types.string.php string ] $template<br/>The name of the template file.
* [http://www.php.net/manual/en/language.types.boolean.php boolean] $raise_error<br/>Defaults to true.  Raise error if template is not found
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $raise_error<br/>Defaults to true.  Raise error if template is not found
**Default Value: true  
**Default Value: true  
===fixupAnchors()===
===fixupAnchors()===
Line 113: Line 114:
Returns the displayed page as a string
Returns the displayed page as a string
*Signature: public function getDisplay()
*Signature: public function getDisplay()
*Returns: [http://www.php.net/manual/en/language.types.string.php string]
*Returns: [http://www.php.net/manual/en/language.types.string.php string ]
===hasClass()===
===hasClass()===
*Signature: public function hasClass($node,$class)
*Signature: public function hasClass($node,$class)
Line 125: Line 126:
Process any arguments sent to the page
Process any arguments sent to the page
*Signature: public function processArgs($args)
*Signature: public function processArgs($args)
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean] true on sucess. false on failure
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ] true on sucess. false on failure
Parameters:
Parameters:
*$args  
*$args  
Line 133: Line 134:
*Signature: protected function processLoopCount($node,$designator,$count)
*Signature: protected function processLoopCount($node,$designator,$count)
Parameters:
Parameters:
* [http://www.php.net/manual/en/class.domnode.php domnode] $node
* [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node
* [http://www.php.net/manual/en/language.types.string.php string] $designator
* [http://www.php.net/manual/en/language.types.string.php string ] $designator
* integer $count
* integer $count
===removeClass()===
===removeClass()===
Line 149: Line 150:
*Signature: protected function replaceCount($node,$designator,$count)
*Signature: protected function replaceCount($node,$designator,$count)
Parameters:
Parameters:
* [http://www.php.net/manual/en/class.domnode.php domnode] $node
* [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node
* [http://www.php.net/manual/en/language.types.string.php string] $designator
* [http://www.php.net/manual/en/language.types.string.php string ] $designator
* integer $count
* integer $count
===setBase()===
===setBase()===
Line 161: Line 162:
*Signature: public function setBodyAttr($attr,$value)
*Signature: public function setBodyAttr($attr,$value)
Parameters:
Parameters:
* [http://www.php.net/manual/en/language.types.string.php string] $attr
* [http://www.php.net/manual/en/language.types.string.php string ] $attr
* [http://www.php.net/manual/en/language.types.string.php string] $value
* [http://www.php.net/manual/en/language.types.string.php string ] $value
===setBodyId()===
===setBodyId()===
Sets the id attribute for the body tag.
Sets the id attribute for the body tag.
Line 170: Line 171:
*Signature: public function setBodyId($id)
*Signature: public function setBodyId($id)
Parameters:
Parameters:
* [http://www.php.net/manual/en/language.types.string.php string] $id
* [http://www.php.net/manual/en/language.types.string.php string ] $id
===setTitle()===
===setTitle()===
Set the HTML title of the page.
Set the HTML title of the page.
Line 179: Line 180:
*Signature: public function setTitle($title)
*Signature: public function setTitle($title)
Parameters:
Parameters:
* [http://www.php.net/manual/en/language.types.string.php string] $title
* [http://www.php.net/manual/en/language.types.string.php string ] $title
===validate()===
===validate()===
No validation occcurs so always returns true
No validation occcurs so always returns true
*Signature: public function validate()
*Signature: public function validate()
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean]
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]
===wrapHeaderTextInTag()===
===wrapHeaderTextInTag()===
*Signature: protected function wrapHeaderTextInTag($text,$tag)
*Signature: protected function wrapHeaderTextInTag($text,$tag)

Revision as of 22:27, 16 October 2009

This article desrcibes the class I2CE_Template.

It is contained in the module pages in the package I2CE

The class is defined in the file: modules/Pages/lib/I2CE_Template.php

Variables

$files_loaded

An array of files that have been loaded so they're aren't added in twice. The keys are the file names, the value is true if it has been loaded, unset otherwise

  • Type: protected y $files_loaded

Methods

__construct()

I2CE_Template constructor method.

This constructor sets up the basic variables for all I2CE_Template objects. $loadOptions is set to zero.

  • Signature: public function __construct()

_loadFile()

Helper method. Load a file into the spectified document as HTML

  • Signature: public function _loadFile($doc,$contentfile)
  • Returns: boolean False on failure,

Parameters:

_loadText()

Helper method. Load text into the spectified document as XML @param string $contentfile the file to load

  • Signature: protected function _loadText($doc,$text,$setEncoding)
  • Returns: boolean False on failure,

Parameters:

  • DOMDocument $doc
  • $text
  • string $setEncoding
    Defaults to true. If true, set the encoding to be that of the docuemnt. Only useful as false for loading root template files
    • Default Value: true

addClass()

  • Signature: public function addClass($node,$class)

Parameters:

  • $node
  • $class

addHeaderLink()

Add a script or css to the header as a link

in which case it is the id that you want to give the import node. when looking for the script/css @returm DOMNode -- the node just created or appended to You might use this by calling addHeaderLink("printer.css",,array('media'=>'print')); Note: Uses the file's extension to determine the proper behavior. Valid ones are 'js', 'css', and 'vb'

  • Signature: public function addHeaderLink($file,$attr,$use_filedump)

Parameters:

  • string $file
  • mixed $attr
    an array of attribute/value pairs. Defaults to the empty array. can also be a string
    • Default Value: array()
  • boolean $use_filedump
    default to true meaning that we should use the filedump utility
    • Default Value: true

addHeaderText()

Add text to the header of the document.

@param mixed $as_serpate_node whether or not we want add the node as a seperate node or append it (default to false-- append). It will append it to the last node if so. If it is a string, then we create a new node and set the id of a node to the given string, or append to an existing node with that id. If it is a DOMNode then we just append to that node

  • Signature: public function addHeaderText($text,$type,$as_separate_node,$init_text)
  • Returns: DOMNode -- the node just created or appended to. False on failure

Note the text does not have to be wrapped in <$tag> node. If not, it will put it in a <$tag> node with reasonalbe attributes. Parameters:

  • string $text
  • string $type
    one of 'css',javascipt','vbscript'
  • $as_separate_node
    • Default Value: false
  • string $init_text
    the text we ar adding as a separate node and the node does not exist. Defaults to the empty string
    • Default Value:

checkRolesTasksAndPermissions()

Remove any restricted access elements of the page.

This method processes all elements in the document that have a role attribute. If there is no known user or the user doesn't have access to that role then the entire node will be removed from the document. @param I2CE_User $user relaive to that role

  • Signature: public function checkRolesTasksAndPermissions($node)

Parameters:

  • DOMNode $node
    Defaults to null, meaning we check the whole document. Otherwise, we check
    • Default Value: null

ensureCSSURLs()

  • Signature: static public function ensureCSSURLs($css)

Parameters:

  • $css

ensureURL()

  • Signature: static public function ensureURL($url)

Parameters:

  • $url

findTemplate()

This method finds the location of a template file. If the file is not an absolute path searches the class path 'TEMPLATES'

This method searches the template directory path from the global configuration array for the given template. If it exists it returns the full path to the file and if not it returns false. It seaches the path backwards so that later directories can override package versions of files.

  • Signature: public function findTemplate($template,$raise_error)
  • Returns: mixed

Parameters:

  • string $template
    The name of the template file.
  • boolean $raise_error
    Defaults to true. Raise error if template is not found
    • Default Value: true

fixupAnchors()

Fixes any href's starting with # so that they work properly Also makes sure that any relative URL include an index.php if .htaccess is not used.

  • Signature: protected function fixupAnchors()

getDisplay()

Returns the displayed page as a string

  • Signature: public function getDisplay()
  • Returns: string

hasClass()

  • Signature: public function hasClass($node,$class)

Parameters:

  • $node
  • $class

prepareDisplay()

Called to prepare the display.

  • Signature: public function prepareDisplay()

processArgs()

Process any arguments sent to the page

  • Signature: public function processArgs($args)
  • Returns: boolean true on sucess. false on failure

Parameters:

  • $args

processLoopCount()

Recursively process all child nodes that are being added in a loop to replace the designator text. @see replaceCount

  • Signature: protected function processLoopCount($node,$designator,$count)

Parameters:

removeClass()

  • Signature: public function removeClass($node,$class)

Parameters:

  • $node
  • $class

removeTranslatorComments()

  • Signature: protected function removeTranslatorComments()

replaceCount()

Replace the given designator text with the loop count of the template file being added.

If the node is a DOM element then the designator text with the number of the count.

  • Signature: protected function replaceCount($node,$designator,$count)

Parameters:

setBase()

  • Signature: protected function setBase()

setBodyAttr()

Adds an attribute to the body tag of this document.

This will find the body tag of the document and add or replace the given attribute with the given value.

  • Signature: public function setBodyAttr($attr,$value)

Parameters:

setBodyId()

Sets the id attribute for the body tag.

This will find the body tag of the document and add or replace the id attribute with the given id.

  • Signature: public function setBodyId($id)

Parameters:

setTitle()

Set the HTML title of the page.

This will find the first title element of the page and replace the text in it with the given title. There should only be one title element in a valid HTML page.

  • Signature: public function setTitle($title)

Parameters:

validate()

No validation occcurs so always returns true

  • Signature: public function validate()
  • Returns: boolean

wrapHeaderTextInTag()

  • Signature: protected function wrapHeaderTextInTag($text,$tag)

Parameters:

  • &$text
  • &$tag

Inherited Variables

$doc

Theis public variable is inherited from I2CE_TemplateMeister->$doc

$xpath

Theis protected variable is inherited from I2CE_TemplateMeister->$xpath

$user

Theis protected variable is inherited from I2CE_TemplateMeister->$user

$working_dir

Theis protected variable is inherited from I2CE_TemplateMeister->$working_dir

$loadOptions

Theis protected variable is inherited from I2CE_TemplateMeister->$loadOptions

$headers

Theis protected variable is inherited from I2CE_TemplateMeister->$headers

$verboseErrors

Theis protected variable is inherited from I2CE_TemplateMeister->$verboseErrors

Inherited Fuzzy Methods

userMessage()

This method is inherited from I2CE_Fuzzy->userMessage()

Fuzzy Methods

launchBackgroundProcess()

This method is implemented by I2CE_BackgroundProcess->launchBackgroundProcess()

launchBackgroundPHPScript()

This method is implemented by I2CE_BackgroundProcess->launchBackgroundPHPScript()

launchBackgroundPage()

This method is implemented by I2CE_BackgroundProcess->launchBackgroundPage()

addColorPickerTriple()

This method is implemented by I2CE_Module_ColorPicker->addColorPickerTriple()

setDisplayData()

This method is implemented by I2CE_DisplayData->setDisplayData()

setDisplayDataImmediate()

This method is implemented by I2CE_DisplayData->setDisplayDataImmediate()

selectOptionsImmediate()

This method is implemented by I2CE_DisplayData->selectOptionsImmediate()

addFormWorm()

This method is implemented by I2CE_Module_FormWorm->addFormWorm()

getClassValue()

This method is implemented by I2CE_MootoolsCore->getClassValue()

loadClassValues()

This method is implemented by I2CE_MootoolsCore->loadClassValues()

setClassValue()

This method is implemented by I2CE_MootoolsCore->setClassValue()

setClassValues()

This method is implemented by I2CE_MootoolsCore->setClassValues()

addOption()

This method is implemented by I2CE_Template_Options->addOption()

addOptions()

This method is implemented by I2CE_Template_Options->addOptions()

addAutoCompleteInputTreeById()

This method is implemented by I2CE_Module_TreeSelect->addAutoCompleteInputTreeById()

addAutoCompleteInputTree()

This method is implemented by I2CE_Module_TreeSelect->addAutoCompleteInputTree()

setForm()

This method is implemented by I2CE_Module_Forms->setForm()

getField()

This method is implemented by I2CE_Module_Forms->getField()

setReview()

This method is implemented by I2CE_Module_Forms->setReview()

isReview()

This method is implemented by I2CE_Module_Forms->isReview()

setShowForm()

This method is implemented by I2CE_Module_Forms->setShowForm()

showForm()

This method is implemented by I2CE_Module_Forms->showForm()

makeJumper()

This method is implemented by I2CE_Module_Jumper->makeJumper()

menuSelect()

This method is implemented by I2CE_Module_MenuSelect->menuSelect()

addUpdateSelect()

This method is implemented by I2CE_Module_MenuSelect->addUpdateSelect()

addAjaxUpdate()

This method is implemented by I2CE_Stub->addAjaxUpdate()

addAjaxToggle()

This method is implemented by I2CE_Stub->addAjaxToggle()

addAjaxRequestFunction()

This method is implemented by I2CE_Stub->addAjaxRequestFunction()

addAjaxCompleteFunction()

This method is implemented by I2CE_Stub->addAjaxCompleteFunction()

addAjaxToggleOnFunction()

This method is implemented by I2CE_Stub->addAjaxToggleOnFunction()

addAjaxToggleOffFunction()

This method is implemented by I2CE_Stub->addAjaxToggleOffFunction()

hasAjax()

This method is implemented by I2CE_Stub->hasAjaxFuzzy()

setDataTypePriority()

This method is implemented by I2CE_Module_TemplateData->setDataTypePriority()

setData()

This method is implemented by I2CE_Module_TemplateData->setData()

getData()

This method is implemented by I2CE_Module_TemplateData->getData()

getDefaultData()

This method is implemented by I2CE_Module_TemplateData->getDefaultData()

removeData()

This method is implemented by I2CE_Module_TemplateData->removeData()

getDataNames()

This method is implemented by I2CE_Module_TemplateData->getDataNames()

ensureNode()

This method is implemented by I2CE_Module_TemplateData->ensureNode()