/** * @ignore */ private static function _expand_filename($in) { $smarty = \Smarty_CMS::get_instance(); $config = \cms_config::get_instance(); $smarty->assign('root_url', $config['root_url']); $smarty->assign('root_path', $config['root_path']); return trim($smarty->fetch('string:' . $in)); }
/** * get_instance method * * @return object $this */ public static function &get_instance() { if (!is_object(self::$_instance)) { self::$_instance = new self(); } // Merge variables self::$_instance->tpl_vars = array_merge(self::$_instance->tpl_vars, parent::get_instance()->tpl_vars); return self::$_instance; }
/** * @ignore */ public function InitializeFrontend() { $smarty = \Smarty_CMS::get_instance(); if (!$smarty) { return; } // register our functions. $smarty->register_function('cghm_config_set', '\\CGHeadMaster\\smarty_plugins::cghm_config_set'); $smarty->register_function('cghm_set', '\\CGHeadMaster\\smarty_plugins::cghm_set'); $smarty->register_function('cghm_unset', '\\CGHeadMaster\\smarty_plugins::cghm_unset'); $smarty->register_function('cghm_hide', '\\CGHeadMaster\\smarty_plugins::cghm_hide'); $smarty->register_function('cghm_render', '\\CGHeadMaster\\smarty_plugins::cghm_render'); // load standard fields $files = $this->get_module_files('config', 'fields.ini'); if (!count($files)) { throw new \RuntimeException('Could not find field definition file(s) named fields.ini'); } $files = array_reverse($files); $this->_fields = array(); foreach ($files as $file) { $tmp = parse_ini_file($file, TRUE); if (count($tmp)) { $this->_fields = array_merge($this->_fields, $tmp); } } // load the cgsm_config vars $sysconfig = \cms_config::get_instance(); $fn = $sysconfig['root_path'] . '/config.php'; include $fn; unset($sysconfig); $this->_config = array(); foreach ($config as $key => $val) { if (!startswith($key, 'cghm_')) { continue; } $this->_config[$key] = $val; } }
/** * Get a handle to the CMS Smarty object. If it does not yet * exist, this method will instantiate it. As of version 1.8, * CMS Made Simple uses version 2.6.25 of Smarty. * * @final * @see Smarty_CMS * @link http://www.smarty.net/manual/en/ * @return Smarty_CMS handle to the Smarty object */ public function &GetSmarty() { return Smarty_CMS::get_instance(); }
/** * A convenience method to generate a new smarty template object given a resource string, * and a prefix. This method will also automatically assign a few common smarty variables * to the new scope. * * Note: the parent smarty scope depends on how this function is called. If called directly from a module action for the same module * the parent will be the current smarty scope. If called from any method that is using a different module than the * action module, then the parent scope will be the global smarty scope. * * @param string $template_name The desired template name. * @param string $prefix an optional prefix for database templates. * @param string $cache_id An optional smarty cache id. * @param string $compile_id An optional smarty compile id. * @return object */ public function CreateSmartyTemplate($template_name, $prefix = null, $cache_id = null, $compile_id = null) { $smarty = null; if (version_compare(CMS_VERSION, '2.0.1') >= 0) { $smarty = $this->GetActionTemplateObject(); } if (!$smarty) { $smarty = Smarty_CMS::get_instance(); } $mod = $smarty->getTemplateVars('mod'); $tpl = $smarty->createTemplate($this->CGGetTemplateResource($template_name, $prefix), $cache_id, $compile_id, $smarty); // for convenience, I assign a few smarty variables. $tpl->assign($this->GetName(), $this); $tpl->assign('mod', $this); if ($actionid = $smarty->getTemplateVars('actionid')) { $tpl->assign('actionid', $actionid); } if ($actionparams = $smarty->getTemplateVars('actionparams')) { $tpl->assign('actionparams', $actionparams); } return $tpl; }
/** * Get a handle to the CMS Smarty object. If it does not yet * exist, this method will instantiate it. As of version 1.8, * CMS Made Simple uses version 2.6.25 of Smarty. * * @final * @see Smarty_CMS * @link http://www.smarty.net/manual/en/ * @return Smarty_CMS handle to the Smarty object */ public function &GetSmarty() { /* Check to see if a Smarty object has been instantiated yet, and, if not, go ahead an create the instance. */ return Smarty_CMS::get_instance(); }