/** * Compiles all source templates below the source scheme directory * including subdirectories * * @param string $ root directory name * @param string $ path relative to root * @return void * @access protected */ function recursive_compile_all($root, $path) { if ($dh = opendir($root . $path)) { while (($file = readdir($dh)) !== false) { if (substr($file, 0, 1) == '.') { continue; } if (is_dir($root . $path . $file)) { recursive_compile_all($root, $path . $file . '/'); continue; } if (substr($file, -5, 5) == '.html') { compile_template_file($path . $file); } else if (substr($file, -5, 5) == '.vars') { compile_var_file($path . $file); } } closedir($dh); } }
/** * Constructs template * * @param string $ name of (source) template file (relative or full path) * @access public */ function template($file, $resolve_path = true) { $this->file = $file; if ($resolve_path) { if (!($srcfile = resolve_template_source_file_name($file))) { error('template file not found', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('file' => $file)); } } else { $srcfile = $file; } $this->codefile = resolve_template_compiled_file_name($srcfile, TMPL_INCLUDE); if (!isset($GLOBALS['template_render'][$this->codefile])) { if (get_ini_option('config.ini', 'templates', 'force_compile')) { compile_template_file($file, $resolve_path); } if (!file_exists($this->codefile)) { compile_template_file($file, $resolve_path); } $errorlevel = error_reporting(); error_reporting($errorlevel & ~E_WARNING); $parse_error = (include_once $this->codefile); error_reporting($errorlevel); } $this->render_function = $GLOBALS['template_render'][$this->codefile]; $func = $GLOBALS['template_construct'][$this->codefile]; $func($this); }
/** * Constructs template * * @param string $ name of (source) template file (relative or full path) * @access public */ function template($file) { $this->file = $file; $srcfile = resolve_template_source_file_name($file, TMPL_INCLUDE); $this->codefile = resolve_template_compiled_file_name($srcfile, TMPL_INCLUDE); if (!isset($GLOBALS['template_render'][$this->codefile])) { if (get_ini_option('config.ini', 'templates', 'force_compile')) { compile_template_file($file); } if (!file_exists($this->codefile)) { compile_template_file($file); } $errorlevel = error_reporting(); error_reporting($errorlevel & ~E_WARNING); $parse_error = (include_once $this->codefile); error_reporting($errorlevel); } $this->render_function = $GLOBALS['template_render'][$this->codefile]; $func = $GLOBALS['template_construct'][$this->codefile]; $func($this); }