| version 1.11, 2002/08/04 18:15:50 |
version 1.12, 2002/08/12 23:07:30 |
|
|
| // NOT APPLICABLE NOW! It is printed "as is" outside <?php ?> tags. |
// NOT APPLICABLE NOW! It is printed "as is" outside <?php ?> tags. |
| */ |
*/ |
| |
|
| if (! isset($__phpTemplate_fnc_idx)) { |
if (! isset($phpTemplate_cfg)) { |
| $__phpTemplate_fnc_idx = 0; |
$phpTemplate_cfg = array( |
| |
'load_function' => null, |
| |
'method_function_name' => '__phpTemplate_function_', |
| |
'method_function_idx' => 0 |
| |
); |
| } |
} |
| |
|
| /* Output method (bit array) */ |
/* Output method (bit array) */ |
| Line 54 class phpTemplate |
|
| Line 58 class phpTemplate |
|
| var $_set_vars = null; |
var $_set_vars = null; |
| var $_method = null; |
var $_method = null; |
| var $_filename = null; |
var $_filename = null; |
| |
var $_load_fnc = null; |
| var $_debug = 1; |
var $_debug = 1; |
| var $_prepended = 0; |
var $_prepended = 0; |
| |
|
| function phpTemplate($filename = '', $method = PHP_TEMPLATE_METHOD_NORMAL) |
function phpTemplate($filename = '', $method = PHP_TEMPLATE_METHOD_NORMAL) |
| { |
{ |
| |
global $phpTemplate_cfg; |
| |
|
| foreach (array_keys($this->_tag) as $key) { |
foreach (array_keys($this->_tag) as $key) { |
| $this->_tag[$key] = preg_quote($this->_tag[$key]); |
$this->_tag[$key] = preg_quote($this->_tag[$key]); |
| $this->_tag[$key.'_striped'] = stripslashes($this->_tag[$key]); |
$this->_tag[$key.'_striped'] = stripslashes($this->_tag[$key]); |
| } |
} |
| |
|
| $this->_method = $method; |
$this->_method = $method; |
| $this->_filename = $filename; |
$this->_filename = $filename; |
| |
$this->_load_fnc = $phpTemplate_cfg['load_function']; |
| $this->reload(); |
$this->reload(); |
| |
|
| return true; |
return true; |
| Line 85 class phpTemplate |
|
| Line 93 class phpTemplate |
|
| $this->_method = $method; |
$this->_method = $method; |
| } |
} |
| |
|
| |
function setLoadFunction($function_name) |
| |
{ |
| |
if (isset($this)) { |
| |
$this->_load_fnc = $function_name; |
| |
} else { |
| |
global $phpTemplate_cfg; |
| |
$phpTemplate_cfg['load_function'] = $function_name; |
| |
} |
| |
} |
| |
|
| function _load($filename) |
function _load($filename) |
| { |
{ |
| if ($f = fopen($filename, 'r')) { |
if (isset($this->_load_fnc)) { |
| |
$load_fnc = $this->_load_fnc; |
| |
$data = $load_fnc($filename); |
| |
} else { |
| $data = ''; |
$data = ''; |
| while ($tmp_data = fread($f, 1024)) { |
if ($f = fopen($filename, 'r')) { |
| $data .= $tmp_data; |
while ($tmp_data = fread($f, 1024)) { |
| |
$data .= $tmp_data; |
| |
} |
| |
fclose($f); |
| } |
} |
| fclose($f); |
|
| return $this->_stringTransform($data); |
|
| } |
} |
| |
|
| return array('phpTemplate DEBUG: file not found: '.$filename); |
if (! isset($data) || $data === false) { |
| |
return array('phpTemplate ERROR: cannot load template: '.$filename); |
| |
} |
| |
|
| |
return $this->_stringTransform($data); |
| } |
} |
| |
|
| function load($filename) |
function load($filename) |
| Line 380 class phpTemplate |
|
| Line 406 class phpTemplate |
|
| |
|
| if ($this->_method & PHP_TEMPLATE_METHOD_FUNCTION) { |
if ($this->_method & PHP_TEMPLATE_METHOD_FUNCTION) { |
| /* getting function name */ |
/* getting function name */ |
| global $__phpTemplate_fnc_idx; |
global $phpTemplate_cfg; |
| $function_name = '__phpTemplate_function_'.$__phpTemplate_fnc_idx; |
$function_name = $phpTemplate_cfg['method_function_prefix'] |
| $__phpTemplate_fnc_idx++; |
. $phpTemplate_cfg['method_function_idx']; |
| |
$phpTemplate_cfg['method_function_idx']++; |
| |
|
| return "if (! function_exists('$function_name')) {" |
return "if (! function_exists('$function_name')) {" |
| ." function $function_name() {\n" |
." function $function_name() {\n" |