/** * Initializes php error levels and frontend error levels arrays * Displays index log settings page * * @param string error message * @return void */ private function show_template_edit($error = NULL) { onapp_debug(__CLASS__ . ' :: ' . __FUNCTION__); $params = array('title' => onapp_string($this->config['title']), 'log_levels_frontend' => onapp_get_frontend_errors(), 'php_error_levels' => onapp_get_php_errors(), 'error' => onapp_string($error), 'language_list' => onapp_get_dir_list('lang'), 'templates_list' => onapp_get_dir_list(ONAPP_SMARTY_TEMPLATE_DIR), 'controllers_list' => onapp_get_dir_list('controllers'), 'template' => $this->config['template'], 'info_title' => onapp_string('EDIT_' . $this->config['info_title']), 'info_body' => onapp_string('EDIT_' . $this->config['info_body'])); //TODO check is variable $this->template['edit'] defined onapp_show_template($this->config['template'] . '_edit', $params); }
/** * This function is called from controller classes to display proper view and * template depends on controller and method. Uses Smarty template engine. * * @param string $view Name of a Smarty template file to display. * * @param string $template Name of a particular template. Not realised yet! * * @param array $params Array consists of variables' keys and values need to be * passed to Smarty template view file. * * @todo VERIFICATION IF TEMPLATE FILE EXSITS! * * @return void * */ function onapp_show_template($view, $params = array()) { global $_ALIASES, $_SCREEN_IDS; onapp_debug('Show templates'); onapp_debug("onapp_show_template: view => {$view}, params => " . print_r($params, true)); $template = ONAPP_PATH . ONAPP_DS . 'templates' . ONAPP_DS . ONAPP_TEMPLATE . ONAPP_DS . 'views' . ONAPP_DS . str_replace('_', ONAPP_DS, $view) . '.tpl'; if (!file_exists($template)) { die("File {$template} not found"); } $globals = array('navigation' => $_SCREEN_IDS, '_ALIASES' => $_ALIASES, 'langs' => onapp_get_dir_list('lang')); $smarty_params = is_array($params) ? array_merge($params, $globals) : $globals; require_once ONAPP_PATH . ONAPP_DS . 'libs' . ONAPP_DS . 'smarty' . ONAPP_DS . 'Smarty.class.php'; $smarty = new Smarty(); $smarty->template_dir = ONAPP_SMARTY_TEMPLATE_DIR; $smarty->compile_dir = ONAPP_SMARTY_COMPILE_DIR; $smarty->cache_dir = ONAPP_SMARTY_CACHE_DIR; $smarty->caching = ONAPP_SMARTY_CACHING_ENABLE; //in seconds $smarty->cache_lifetime = ONAPP_SMARTY_CACHING_LIFETIME; // set false for best performance when no templates changes needed $smarty->compile_check = ONAPP_SMARTY_COMPILE_CHECK; // set false for best performance when no templates changes needed $smarty->force_compile = ONAPP_SMARTY_FORCE_COMPILE; foreach ($smarty_params as $key => $value) { $smarty->assign("{$key}", $value); } $smarty->display($template); unset($_SESSION['message']); onapp_debug('Display Smarty Template'); }