/** * Get smarty template * @return Smarty smarty object */ public static function getSmartyTemplate() { $smarty = new \SmartyBC(); $useTheme = !defined('OPENBIZ_USE_THEME') ? 0 : OPENBIZ_USE_THEME; if ($useTheme) { $theme = Openbizx::$app->getCurrentTheme(); $themePath = $theme; // Openbizx::$app->getConfiguration()->GetThemePath($theme); if (is_dir(OPENBIZ_THEME_PATH . "/" . $themePath . "/template")) { $templateRoot = OPENBIZ_THEME_PATH . "/" . $themePath . "/template"; } else { $templateRoot = OPENBIZ_THEME_PATH . "/" . $themePath . "/templates"; } $smarty->setTemplateDir($templateRoot); $compileDir = defined('OPENBIZ_SMARTY_CPL_PATH') ? OPENBIZ_SMARTY_CPL_PATH . "/" . $themePath : $templateRoot . "/cpl"; $smarty->setCompileDir($compileDir); $smarty->setConfigDir($templateRoot . "/cfg"); $smarty->config_load('tpl.conf'); } else { if (defined('SMARTY_TPL_PATH')) { $smarty->setTemplateDir(SMARTY_TPL_PATH); } if (defined('OPENBIZ_SMARTY_CPL_PATH')) { $smarty->setCompileDir(OPENBIZ_SMARTY_CPL_PATH . "/" . $themePath); } if (defined('SMARTY_CFG_PATH')) { $smarty->setConfigDir(SMARTY_CFG_PATH); } } if (!is_dir($smarty->compile_dir)) { mkdir($smarty->compile_dir, 0777); } // load the config file which has the images and css url defined $smarty->assign('app_url', OPENBIZ_APP_URL); $smarty->assign('app_index', OPENBIZ_APP_INDEX_URL); $smarty->assign('js_url', OPENBIZ_JS_URL); $smarty->assign('css_url', OPENBIZ_THEME_URL . "/" . $theme . "/css"); $smarty->assign('resource_url', OPENBIZ_RESOURCE_URL); $smarty->assign('resource_php', OPENBIZ_RESOURCE_PHP); $smarty->assign('theme_js_url', OPENBIZ_THEME_URL . "/" . $theme . "/js"); $smarty->assign('theme_url', OPENBIZ_THEME_URL . "/" . $theme); $smarty->assign('image_url', OPENBIZ_THEME_URL . "/" . $theme . "/images"); $smarty->assign('lang', strtolower(I18n::getCurrentLangCode())); $smarty->assign('lang_name', I18n::getCurrentLangCode()); return $smarty; }
/** * @return \SmartyBC * @throws \Kohana_Exception */ public static function init() { $tmp = new \SmartyBC(); $tmp->muteExpectedErrors(); //loading config file smarty $conf = \Kohana::$config->load('smarty')->get('smarty_config'); $tmp->addTemplateDir($conf['template_dir']); $tmp->setCompileDir($conf['compile_dir']); $tmp->setCacheDir($conf['cache_dir']); $tmp->setConfigDir($conf['config_dir']); $tmp->setPluginsDir($conf['plugins_dir']); $tmp->assign('base_UI', $conf['base_UI']); $tmp->assign('debugging', $conf['debugging']); $tmp->debugging = $conf['debugging']; $tmp->debugging_ctrl = $conf['debugging_ctrl']; $tmp->error_reporting = $conf['error_reporting']; return $tmp; }
<?php require_once $basedir . "/vendor/autoload.php"; $smarty = new SmartyBC(); $smarty->setTemplateDir($basedir . '/templates'); $smarty->setCompileDir($basedir . '/templates_c'); $smarty->setCacheDir($basedir . '/cache'); $smarty->setConfigDir($basedir . '/configs'); $smarty->security = false; $smarty->setCaching(Smarty::CACHING_LIFETIME_SAVED); $smarty->assign('baseurl', $baseurl);
public function smart_view($view, $vars = array(), $return = FALSE) { $orgin_view = $view; if (!strpos($view, ".php") && !strpos($view, ".tpl")) { $view .= ".tpl"; } PC::preparing_view($view); $view_name = $view; $smarty = new SmartyBC(); $config =& get_config(); $this->caching = 1; $smarty->setCompileDir(APPPATH . '/third_party/Smarty-3.1.8/templates_c'); $smarty->setConfigDir(APPPATH . '/third_party/Smarty-3.1.8/configs'); $smarty->setCacheDir(APPPATH . '/cache'); if (strpos($this->_module, '_child') !== false) { list($path, $_view) = Modules::find($view, $this->_module, 'views/'); if ($path == FALSE) { list($path, $_view) = Modules::find($view, str_replace("_child", "", $this->_module), 'views/'); } } else { list($path, $_view) = Modules::find($view, $this->_module . "_child", 'views/'); if ($path == FALSE) { list($path, $_view) = Modules::find($view, $this->_module, 'views/'); } } if ($path == FALSE) { list($path, $_view) = Modules::find($orgin_view . ".php", $this->_module, 'views/'); if ($path != FALSE) { $view = $orgin_view . ".php"; $view_name = $view; } } if ($path == FALSE && strpos($this->_module, '_child') !== false) { list($path, $_view) = Modules::find($view, str_replace("_child", "", $this->_module), 'views/'); } if ($path != FALSE) { $this->_ci_view_paths = array($path => TRUE) + $this->_ci_view_paths; $view = $_view; } $path_fragment = explode("/", $path); if ($path_fragment[0] == "modules") { global $active_show; $controller =& $active_show->controller; $theme_path = "themes/" . $controller->BuilderEngine->get_option('active_frontend_theme') . "/modules/" . $this->_module; $theme_file = $theme_path . "/" . $_view . ".php"; if (file_exists($theme_file)) { $path = "../../" . $theme_path; $this->_ci_view_paths = array($path => TRUE) + $this->_ci_view_paths; $view = $path . "/" . $_view; } // To be updated $view_name = basename($view_name); } global $active_show; global $BuilderEngine; $vars['BuilderEngine'] =& $BuilderEngine; $vars['versions'] =& $active_show->controller->versions; $vars['user'] =& $active_show->controller->user; $vars['this'] =& $this; $smarty->setTemplateDir($path); foreach ($vars as $key => $value) { $smarty->assign($key, $value); } $smarty->assign("test_var", "qweqweqwe"); if ($return) { ob_start(); $smarty->display($view_name); $output = ob_get_contents(); ob_end_clean(); return $output; } else { $smarty->display($view_name); } /* global $active_show; global $BuilderEngine; $vars['BuilderEngine'] = &$BuilderEngine; $vars['versions'] = &$active_show->controller->versions; $vars['user'] = &$active_show->controller->user; return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return)); */ }
<?php ini_set("display_errors", 1); error_reporting(E_ALL); require "setup.php"; define("PROJECT_DIR", $local_project_dir); define("SMARTY_DIR", "smarty-3.1.27/libs/"); require SMARTY_DIR . "Smarty.class.php"; $smarty = new SmartyBC(); $smarty->setTemplateDir(PROJECT_DIR . "smarty/templates"); $smarty->setCompileDir(PROJECT_DIR . "smarty/templates_c"); $smarty->setCacheDir(PROJECT_DIR . "smarty/cache"); $smarty->setConfigDir(PROJECT_DIR . "smarty/config"); $smarty->assign('lbr', '{'); $smarty->assign('rbr', '}');