From ed30c60150ffda0301eb1f8d30c93cac94de41df Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Mon, 25 Jul 2011 10:38:22 -0400
Subject: [PATCH] Fixed some warnings in the installer.
---
interface/lib/classes/tpl.inc.php | 185 ++++++++++-----------------------------------
1 files changed, 42 insertions(+), 143 deletions(-)
diff --git a/interface/lib/classes/tpl.inc.php b/interface/lib/classes/tpl.inc.php
index d76c48d..3bd310f 100644
--- a/interface/lib/classes/tpl.inc.php
+++ b/interface/lib/classes/tpl.inc.php
@@ -22,12 +22,12 @@
//
// $Id: class.tpl.inc.php,v 1.1 2003/07/08 12:31:10 platinum Exp $
-//** check to avoid multiple including of class
+//** check and avoid multiple loading of class
if (!defined('vlibTemplateClassLoaded')) {
+
define('vlibTemplateClassLoaded', 1);
- global $conf;
- include_once ($conf['classpath'].'/tpl_error.inc.php');
- include_once ($conf['classpath'].'/tpl_ini.inc.php');
+ include_once (ISPC_CLASS_PATH.'/tpl_error.inc.php');
+ include_once (ISPC_CLASS_PATH.'/tpl_ini.inc.php');
class tpl{
@@ -148,19 +148,18 @@
/**
- * 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
*/
public function newTemplate($tmplfile)
{
- if (!$tfile = $this->_fileSearch($tmplfile)) vlibTemplateError::raiseError('VT_ERROR_NOFILE',KILL,$tmplfile);
+ if (!$tfile = $this->_fileSearch($tmplfile)){
+ vlibTemplateError::raiseError('VT_ERROR_NOFILE', KILL, $tmplfile);
+ }
//* make sure that any parsing vars are cleared for the new template
$this->_tmplfile = null;
@@ -172,19 +171,17 @@
$this->_totalparsetime = null;
//* reset debug module
- if ($this->_debug) $this->_debugReset();
-
+ if ($this->_debug){
+ $this->_debugReset();
+ }
$this->_tmplfilename = $tfile;
return true;
}
/**
- * 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
@@ -211,12 +208,9 @@
}
/**
- * 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
@@ -235,11 +229,8 @@
}
/**
- * 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
@@ -259,39 +250,28 @@
}
/**
- * FUNCTION: getVars
- *
* Gets all vars currently set in global namespace.
- *
* @return array
* @access public
*/
public function getVars()
{
- if (empty($this->_vars)) return false;
- return $this->_vars;
+ return empty($this->_vars) ? false : $this->_vars;
}
/**
- * FUNCTION: getVar
- *
* Gets a single var from the global namespace
- *
* @return var
* @access public
*/
public function getVar($var)
{
if ($this->OPTIONS['CASELESS']) $var = strtolower($var);
- if (empty($var) || !isset($this->_vars[$var])) return false;
- return $this->_vars[$var];
+ return (empty($var) || !isset($this->_vars[$var])) ? false : $this->_vars[$var];
}
/**
- * FUNCTION: setContextVars
- *
* sets the GLOBAL_CONTEXT_VARS
- *
* @return true
* @access public
*/
@@ -312,10 +292,7 @@
}
/**
- * 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
@@ -328,17 +305,15 @@
$this->_arrvars[$k] = array();
if ($this->OPTIONS['SET_LOOP_VAR'] && !empty($v)) $this->setvar($k, 1);
if (($this->_arrvars[$k] = $this->_arrayBuild($v)) == false) {
- vlibTemplateError::raiseError('VT_WARNING_INVALID_ARR',WARNING,$k);
+ vlibTemplateError::raiseError('VT_WARNING_INVALID_ARR', WARNING, $k);
}
}
return true;
}
/**
- * 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.
@@ -347,18 +322,20 @@
*/
public function setDbLoop($loopname, $result, $db_type = 'MYSQL')
{
- $db_type = strtoupper($db_type);
+ /*
+ $db_type = strtoupper($db_type);
if (!in_array($db_type, $this->allowed_loop_dbs)) {
- vlibTemplateError::raiseError('VT_WARNING_INVALID_LOOP_DB',WARNING, $db_type);
+ vlibTemplateError::raiseError('VT_WARNING_INVALID_LOOP_DB', WARNING, $db_type);
return false;
}
$loop_arr = array();
+ // TODO: Are all these necessary as were onyl using mysql and possible postgres ? - pedro
switch ($db_type) {
case 'MYSQL':
if (get_resource_type($result) != 'mysql result') {
- vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE',WARNING, $db_type);
+ vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
return false;
}
while($r = mysql_fetch_assoc($result)) {
@@ -368,7 +345,7 @@
case 'POSTGRESQL':
if (get_resource_type($result) != 'pgsql result') {
- vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE',WARNING, $db_type);
+ vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
return false;
}
@@ -381,7 +358,7 @@
case 'INFORMIX':
if (!$result) {
- vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE',WARNING, $db_type);
+ vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
return false;
}
while($r = ifx_fetch_row($result, 'NEXT')) {
@@ -391,7 +368,7 @@
case 'INTERBASE':
if (get_resource_type($result) != 'interbase result') {
- vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE',WARNING, $db_type);
+ vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
return false;
}
while($r = ibase_fetch_row($result)) {
@@ -401,7 +378,7 @@
case 'INGRES':
if (!$result) {
- vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE',WARNING, $db_type);
+ vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
return false;
}
while($r = ingres_fetch_array(INGRES_ASSOC, $result)) {
@@ -411,7 +388,7 @@
case 'MSSQL':
if (get_resource_type($result) != 'mssql result') {
- vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE',WARNING, $db_type);
+ vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
return false;
}
while($r = mssql_fetch_array($result)) {
@@ -421,7 +398,7 @@
case 'MSQL':
if (get_resource_type($result) != 'msql result') {
- vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE',WARNING, $db_type);
+ vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
return false;
}
while($r = msql_fetch_array($result, MSQL_ASSOC)) {
@@ -431,7 +408,7 @@
case 'OCI8':
if (get_resource_type($result) != 'oci8 statement') {
- vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE',WARNING, $db_type);
+ vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
return false;
}
while(OCIFetchInto($result, &$r, OCI_ASSOC+OCI_RETURN_LOBS)) {
@@ -441,7 +418,7 @@
case 'ORACLE':
if (get_resource_type($result) != 'oracle Cursor') {
- vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE',WARNING, $db_type);
+ vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
return false;
}
while(ora_fetch_into($result, &$r, ORA_FETCHINTO_ASSOC)) {
@@ -451,7 +428,7 @@
case 'OVRIMOS':
if (!$result) {
- vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE',WARNING, $db_type);
+ vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
return false;
}
while(ovrimos_fetch_into($result, &$r, 'NEXT')) {
@@ -461,7 +438,7 @@
case 'SYBASE':
if (get_resource_type($result) != 'sybase-db result') {
- vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE',WARNING, $db_type);
+ vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
return false;
}
@@ -472,13 +449,11 @@
}
$this->setLoop($loopname, $loop_arr);
return true;
+ */
}
/**
- * 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
@@ -495,10 +470,7 @@
}
/**
- * 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
@@ -509,7 +481,7 @@
if (!$loopname) $loopname = $this->_currloopname[(count($this->_currloopname)-1)];
if (!isset($this->_currloop[$loopname]) || empty($this->_currloopname)) {
- vlibTemplateError::raiseError('VT_WARNING_LOOP_NOT_SET',WARNING);
+ vlibTemplateError::raiseError('VT_WARNING_LOOP_NOT_SET', WARNING);
return false;
}
if (is_array($row)) {
@@ -521,11 +493,8 @@
}
/**
- * 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
@@ -554,11 +523,8 @@
}
/**
- * 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
@@ -578,11 +544,8 @@
}
/**
- * 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
*/
@@ -604,10 +567,7 @@
}
/**
- * FUNCTION: clearVars
- *
* Unsets all variables in the template
- *
* @return boolean true
* @access public
*/
@@ -618,10 +578,7 @@
}
/**
- * FUNCTION: clearLoops
- *
* Unsets all loops in the template
- *
* @return boolean true
* @access public
*/
@@ -634,10 +591,7 @@
}
/**
- * FUNCTION: clearAll
- *
* Unsets all variables and loops set using setVar/Loop()
- *
* @return boolean true
* @access public
*/
@@ -649,11 +603,8 @@
}
/**
- * 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
*/
@@ -663,10 +614,7 @@
}
/**
- * FUNCTION: unknowns
- *
* Alias for unknownsExist.
- *
* @access public
*/
public function unknowns()
@@ -675,11 +623,8 @@
}
/**
- * 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
*/
@@ -689,11 +634,8 @@
}
/**
- * 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
@@ -709,8 +651,6 @@
}
/**
- * 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');
@@ -736,8 +676,6 @@
}
/**
- * 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'.
@@ -755,8 +693,6 @@
/**
- * 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.
@@ -773,10 +709,7 @@
/**
- * FUNCTION: pparse
- *
* Calls parse, and then prints out $this->_tmploutput
- *
* @access public
* @return boolean true/false
*/
@@ -788,10 +721,7 @@
}
/**
- * FUNCTION: pprint
- *
* Alias for pparse()
- *
* @access public
*/
public function pprint()
@@ -801,8 +731,6 @@
/**
- * FUNCTION: grab
- *
* Returns the parsed output, ready for printing, passing to mail() ...etc.
* Invokes $this->_parse() if template has not yet been parsed.
*
@@ -820,11 +748,8 @@
\-----------------------------------------------------------------------------*/
/**
- * 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
@@ -860,8 +785,7 @@
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
@@ -875,7 +799,9 @@
if ($this->_includedepth > $this->OPTIONS['MAX_INCLUDES'] || $tmplfile == false) {
return;
} else {
- if ($this->_debug) array_push ($this->_debugIncludedfiles, $tmplfile);
+ if ($this->_debug){
+ array_push ($this->_debugIncludedfiles, $tmplfile);
+ }
if ($do_eval) {
array_push($this->_currentincludedir, dirname($tmplfile));
$this->_includedepth++;
@@ -945,10 +871,7 @@
}
/**
- * 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
@@ -1002,12 +925,9 @@
}
/**
- * 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
@@ -1045,9 +965,7 @@
}
/**
- * FUNCTION: _parseIf
* returns a string used for parsing in tmpl_if statements.
- *
* @param string $varname
* @param string $value
* @param string $op
@@ -1102,9 +1020,7 @@
/**
- * FUNCTION: _parseLoop
* returns a string used for parsing in tmpl_loop statements.
- *
* @param string $varname
* @access private
* @return string used for eval'ing
@@ -1122,10 +1038,7 @@
}
/**
- * FUNCTION: _parseVar
- *
* returns a string used for parsing in tmpl_var statements.
- *
* @param string $wholetag
* @param string $tag
* @param string $varname
@@ -1184,7 +1097,7 @@
switch (strtolower($this->OPTIONS['UNKNOWNS'])) {
case 'comment':
- $comment = addcslashes('<!-- unknown variable '.ereg_replace('<!--|-->', '', $wholetag).'//-->', '"');
+ $comment = addcslashes('<!-- unknown variable '.preg_replace('/<!--|-->/', '', $wholetag).'//-->', '"');
$retstr .= ' else { print("'.$comment.'"); $this->_setUnknown("'.$varname.'"); }';
return $retstr;
@@ -1208,7 +1121,6 @@
}
/**
- * FUNCTION: _parseTag
* takes values from preg_replace in $this->_intparse() and determines
* the replace string.
*
@@ -1304,8 +1216,6 @@
}
/**
- * 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']
@@ -1316,16 +1226,14 @@
*/
private function _intParse ()
{
- $mqrt = get_magic_quotes_runtime();
- set_magic_quotes_runtime(0);
+ //$mqrt = get_magic_quotes_runtime();
+ //set_magic_quotes_runtime(0);
$this->_tmplfilep = '?>'.$this->_getData($this->_tmplfilename).'<?php return true;';
- set_magic_quotes_runtime($mqrt);
+ //set_magic_quotes_runtime($mqrt);
return true;
}
/**
- * FUNCTION: _parse
- *
* Calls _intParse, and eval()s $this->tmplfilep
* and outputs the results to $this->tmploutput
*
@@ -1362,8 +1270,6 @@
}
/**
- * 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 ..]);
@@ -1413,11 +1319,8 @@
}
/**
- * 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
*/
@@ -1427,9 +1330,7 @@
}
/**
- * FUNCTION: _getMicrotime
* Returns microtime as a float number
- *
* @return float microtime
* @access private
*/
@@ -1440,9 +1341,7 @@
}
/**
- * 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
@@ -1468,8 +1367,8 @@
function setCacheExtension() {vlibTemplateError::raiseError('VT_WARNING_NOT_CACHE_OBJ', WARNING, 'setCacheExtension()');}
} // << end class Def
- //include_once ($conf['classpath'].'/vlibTemplate/debug.php');
- include_once ($conf['classpath'].'/tpl_cache.inc.php');
+ //include_once (ISPC_CLASS_PATH.'/vlibTemplate/debug.php');
+ include_once (ISPC_CLASS_PATH.'/tpl_cache.inc.php');
} // << end if(!defined())..
?>
\ No newline at end of file
--
Gitblit v1.9.1