get_template_file_directory() . 'config.php'; if (!file_exists($template_config_file)) { trigger_error('No template configuration file was found where expected: ("' . $template_config_file . '")', E_USER_ERROR); } else { require($template_config_file); // instantiate and set up Smarty object // //LEFT OFF HERE - check for this as empty or not require($smarty_path); $this->smarty_template = new Smarty(); //LEFT OFF HERE - check for these as empty or not.... I think we at least need compile dir? $this->smarty_template->compile_dir = $smarty_compile_dir; $this->smarty_template->cache_dir = $smarty_cache_dir; $this->smarty_template->config_dir = $smarty_config_dir; // note that we do not use Smarty's template_dir // because SquirrelMail has its own method of // determining template file paths // //$this->smarty_template->template_dir = } } /** * Assigns values to template variables * * @param array|string $tpl_var the template variable name(s) * @param mixed $value the value to assign FIXME: Proposed idea to add a parameter here that turns variable encoding on, so that we can make sure output is always run through something like htmlspecialchars() (maybe even nl2br()?) * */ function assign($tpl_var, $value = NULL) { $this->smarty_template->assign($tpl_var, $value); } /** * Assigns values to template variables by reference * * @param string $tpl_var the template variable name * @param mixed $value the referenced value to assign FIXME: Proposed idea to add a parameter here that turns variable encoding on, so that we can make sure output is always run through something like htmlspecialchars() (maybe even nl2br()?) * */ function assign_by_ref($tpl_var, &$value) { $this->smarty_template->assign_by_ref($tpl_var, $value); } /** * Appends values to template variables * * @param array|string $tpl_var the template variable name(s) * @param mixed $value the value to append * @param boolean $merge when $value is given as an array, * this indicates whether or not that * array itself should be appended as * a new template variable value or if * that array's values should be merged * into the existing array of template * variable values FIXME: Proposed idea to add a parameter here that turns variable encoding on, so that we can make sure output is always run through something like htmlspecialchars() (maybe even nl2br()?) * */ function append($tpl_var, $value = NULL, $merge = FALSE) { $this->smarty_template->append($tpl_var, $value, $merge); } /** * Appends values to template variables by reference * * @param string $tpl_var the template variable name * @param mixed $value the referenced value to append * @param boolean $merge when $value is given as an array, * this indicates whether or not that * array itself should be appended as * a new template variable value or if * that array's values should be merged * into the existing array of template * variable values FIXME: Proposed idea to add a parameter here that turns variable encoding on, so that we can make sure output is always run through something like htmlspecialchars() (maybe even nl2br()?) * */ function append_by_ref($tpl_var, &$value, $merge = FALSE) { $this->smarty_template->append_by_ref($tpl_var, $value, $merge); } /** * Applys the template and generates final output destined * for the user's browser * * @param string $filepath The full file path to the template to be applied * * @return string The output for the given template * */ function apply_template($filepath) { // if being passed a raw .css or .js file, default // Smarty delimiters will cause errors // if (strrpos($filepath, '.css') === (strlen($filepath) - 4) || strrpos($filepath, '.js') === (strlen($filepath) - 3)) { $this->smarty_template->left_delimiter = '{='; $this->smarty_template->right_delimiter = '=}'; } // Smarty wants absolute paths // if (strpos($filepath, '/') === 0) return $this->smarty_template->fetch('file:' . $filepath); else return $this->smarty_template->fetch('file:' . getcwd() . '/' . $filepath); } }