| | |
| | | |
| | | |
| | | /** |
| | | * FUNCTION: newTemplate |
| | | * |
| | | * Usually called by the class constructor. |
| | | * Stores the filename in $this->_tmplfilename. |
| | | * Raises an error if the template file is not found. |
| | | * |
| | | * @param string $tmplfile full path to template file |
| | | * @return boolean true |
| | | * @access public |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: setVar |
| | | * |
| | | * Sets variables to be used by the template |
| | | * If $k is an array, then it will treat it as an associative array |
| | | * using the keys as variable names and the values as variable values. |
| | | * |
| | | * @param mixed $k key to define variable name |
| | | * @param mixed $v variable to assign to $k |
| | | * @return boolean true/false |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: setInclude |
| | | * |
| | | * Sets dynamic includes to be used by the template |
| | | * If $k is an array, then it will treat it as an associative array |
| | | * using the keys as variable names and the values as variable values. |
| | | * |
| | | * @param mixed $k key to define variable name |
| | | * @param mixed $v variable to assign to $k |
| | | * @return boolean true/false |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: unsetVar |
| | | * |
| | | * Unsets a variable which has already been set |
| | | * Parse in all vars wanted for deletion in seperate parametres |
| | | * |
| | | * @param string var name to remove use: vlibTemplate::unsetVar(var[, var..]) |
| | | * @return boolean true/false returns true unless called with 0 params |
| | | * @access public |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: getVars |
| | | * |
| | | * Gets all vars currently set in global namespace. |
| | | * |
| | | * @return array |
| | | * @access public |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: getVar |
| | | * |
| | | * Gets a single var from the global namespace |
| | | * |
| | | * @return var |
| | | * @access public |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: setContextVars |
| | | * |
| | | * sets the GLOBAL_CONTEXT_VARS |
| | | * |
| | | * @return true |
| | | * @access public |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: setLoop |
| | | * |
| | | * Builds the loop construct for use with <TMPL_LOOP>. |
| | | * |
| | | * @param string $k string to define loop name |
| | | * @param array $v array to assign to $k |
| | | * @return boolean true/false |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: setDbLoop [** EXPERIMENTAL **] |
| | | * |
| | | * [** EXPERIMENTAL **] |
| | | * Function to create a loop from a Db result resource link. |
| | | * |
| | | * @param string $loopname to commit loop. If not set, will use last loopname set using newLoop() |
| | | * @param string $result link to a Db result resource |
| | | * @param string $db_type, type of db that the result resource belongs to. |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: newLoop |
| | | * |
| | | * Sets the name for the curent loop in the 3 step loop process. |
| | | * |
| | | * @param string $name string to define loop name |
| | | * @return boolean true/false |
| | | * @access public |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: addRow |
| | | * |
| | | * Adds a row to the current loop in the 3 step loop process. |
| | | * |
| | | * @param array $row loop row to add to current loop |
| | | * @param string $loopname loop to which you want to add row, if not set will use last loop set using newLoop(). |
| | | * @return boolean true/false |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: addLoop |
| | | * |
| | | * Completes the 3 step loop process. This assigns the rows and resets |
| | | * the variables used. |
| | | * |
| | | * @param string $loopname to commit loop. If not set, will use last loopname set using newLoop() |
| | | * @return boolean true/false |
| | | * @access public |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: unsetLoop |
| | | * |
| | | * Unsets a loop which has already been set. |
| | | * Can only unset top level loops. |
| | | * |
| | | * @param string loop to remove use: vlibTemplate::unsetLoop(loop[, loop..]) |
| | | * @return boolean true/false returns true unless called with 0 params |
| | | * @access public |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: reset |
| | | * |
| | | * Resets the vlibTemplate object. After using vlibTemplate::reset() you must |
| | | * use vlibTemplate::newTemplate(tmpl) to reuse, not passing in the options array. |
| | | * |
| | | * @return boolean true |
| | | * @access public |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: clearVars |
| | | * |
| | | * Unsets all variables in the template |
| | | * |
| | | * @return boolean true |
| | | * @access public |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: clearLoops |
| | | * |
| | | * Unsets all loops in the template |
| | | * |
| | | * @return boolean true |
| | | * @access public |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: clearAll |
| | | * |
| | | * Unsets all variables and loops set using setVar/Loop() |
| | | * |
| | | * @return boolean true |
| | | * @access public |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: unknownsExist |
| | | * |
| | | * Returns true if unknowns were found after parsing. |
| | | * Function MUST be called AFTER one of the parsing functions to have any relevance. |
| | | * |
| | | * @return boolean true/false |
| | | * @access public |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: unknowns |
| | | * |
| | | * Alias for unknownsExist. |
| | | * |
| | | * @access public |
| | | */ |
| | | public function unknowns() |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: getUnknowns |
| | | * |
| | | * Returns an array of all unknown vars found when parsing. |
| | | * This function is only relevant after parsing a document. |
| | | * |
| | | * @return array |
| | | * @access public |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: setUnknowns |
| | | * |
| | | * Sets how you want to handle variables that were found in the |
| | | * Sets how you want to handle variables that were found in the |
| | | * template but not set in vlibTemplate using vlibTemplate::setVar(). |
| | | * |
| | | * @param string $arg ignore, remove, print, leave or comment |
| | | * @return boolean |
| | | * @access public |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: setPath |
| | | * |
| | | * function sets the paths to use when including files. |
| | | * Use of this function: vlibTemplate::setPath(string path [, string path, ..]); |
| | | * i.e. if $tmpl is your template object do: $tmpl->setPath('/web/htdocs/templates','/web/htdocs/www'); |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: getParseTime |
| | | * |
| | | * After using one of the parse functions, this will allow you |
| | | * access the time taken to parse the template. |
| | | * see OPTION 'TIME_PARSE'. |
| | |
| | | |
| | | |
| | | /** |
| | | * FUNCTION: fastPrint |
| | | * |
| | | * Identical to pparse() except that it uses output buffering w/ gz compression thus |
| | | * printing the output directly and compressed if poss. |
| | | * Will possibly if parsing a huge template. |
| | |
| | | |
| | | |
| | | /** |
| | | * FUNCTION: pparse |
| | | * |
| | | * Calls parse, and then prints out $this->_tmploutput |
| | | * |
| | | * @access public |
| | | * @return boolean true/false |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: pprint |
| | | * |
| | | * Alias for pparse() |
| | | * |
| | | * @access public |
| | | */ |
| | | public function pprint() |
| | |
| | | |
| | | |
| | | /** |
| | | * FUNCTION: grab |
| | | * |
| | | * Returns the parsed output, ready for printing, passing to mail() ...etc. |
| | | * Invokes $this->_parse() if template has not yet been parsed. |
| | | * |
| | |
| | | \-----------------------------------------------------------------------------*/ |
| | | |
| | | /** |
| | | * FUNCTION: vlibTemplate |
| | | * |
| | | * vlibTemplate constructor. |
| | | * if $tmplfile has been passed to it, it will send to $this->newTemplate() |
| | | * |
| | | * @param string $tmplfile full path to template file |
| | | * @param array $options see above |
| | | * @return boolean true/false |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** FUNCTION: _getData |
| | | * |
| | | /** |
| | | * function returns the text from the file, or if we're using cache, the text |
| | | * from the cache file. MUST RETURN DATA. |
| | | * @param string tmplfile contains path to template file |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: _fileSearch |
| | | * |
| | | * Searches for all possible instances of file { $file } |
| | | * |
| | | * @param string $file path of file we're looking for |
| | | * @access private |
| | | * @return mixed fullpath to file or boolean false |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: _arrayBuild |
| | | * |
| | | * Modifies the array $arr to add Template variables, __FIRST__, __LAST__ ..etc |
| | | * if $this->OPTIONS['LOOP_CONTEXT_VARS'] is true. |
| | | * Used by $this->setloop(). |
| | | * |
| | | * @param array $arr |
| | | * @return array new look array |
| | | * @access private |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: _parseIf |
| | | * returns a string used for parsing in tmpl_if statements. |
| | | * |
| | | * @param string $varname |
| | | * @param string $value |
| | | * @param string $op |
| | |
| | | |
| | | |
| | | /** |
| | | * FUNCTION: _parseLoop |
| | | * returns a string used for parsing in tmpl_loop statements. |
| | | * |
| | | * @param string $varname |
| | | * @access private |
| | | * @return string used for eval'ing |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: _parseVar |
| | | * |
| | | * returns a string used for parsing in tmpl_var statements. |
| | | * |
| | | * @param string $wholetag |
| | | * @param string $tag |
| | | * @param string $varname |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: _parseTag |
| | | * takes values from preg_replace in $this->_intparse() and determines |
| | | * the replace string. |
| | | * |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: _intParse |
| | | * |
| | | * Parses $this->_tmplfile into correct format for eval() to work |
| | | * Called by $this->_parse(), or $this->fastPrint, this replaces all <tmpl_*> references |
| | | * with their correct php representation, i.e. <tmpl_var title> becomes $this->vars['title'] |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: _parse |
| | | * |
| | | * Calls _intParse, and eval()s $this->tmplfilep |
| | | * and outputs the results to $this->tmploutput |
| | | * |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: _setOption |
| | | * |
| | | * Sets one or more of the boolean options 1/0, that control certain actions in the template. |
| | | * Use of this function: |
| | | * either: vlibTemplate::_setOptions(string option_name, bool option_val [, string option_name, bool option_val ..]); |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: _setUnknown |
| | | * |
| | | * Used during parsing, this function sets an unknown var checking to see if it |
| | | * has been previously set. |
| | | * |
| | | * @param string var |
| | | * @access private |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: _getMicrotime |
| | | * Returns microtime as a float number |
| | | * |
| | | * @return float microtime |
| | | * @access private |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * FUNCTION: _escape_hex |
| | | * Returns str encoded to hex code. |
| | | * |
| | | * @param string str to be encoded |
| | | * @param bool true/false specify whether to use hex_entity |
| | | * @return string encoded in hex |