public static function cache_end($tag_arg, &$smarty) { if (!cms_cache_handler::can_cache()) { return '}'; } if (!is_array(self::$_cge_cache_keystack) || count(self::$_cge_cache_keystack) == 0) { throw new Exception('in /cge_cache smarty tag without existing cache data'); } $key = array_pop(self::$_cge_cache_keystack); if ($key == '') { throw new Exception('in /cge_cache with invalid key'); } $output = "\${$key}=@ob_get_contents();@ob_end_clean();echo \${$key};cms_cache_handler::get_instance()->set('{$key}',\${$key},'cge_cache');}"; return $output; }
public function DoAction($name, $id, $params, $returnid = '') { if (!method_exists($this, 'set_action_id') && $this->GetName() != 'CGExtensions') { die('FATAL ERROR: A module derived from CGExtensions is not handling the set_action_id method'); } $this->set_action_id($id); // handle the stupid input type='image' problem. foreach ($params as $key => $value) { if (endswith($key, '_x')) { $base = substr($key, 0, strlen($key) - 2); if (isset($params[$base . '_y']) && !isset($params[$base])) { $params[$base] = $base; } } } $smarty = cmsms()->GetSmarty(); $smarty->assign('actionid', $id); $smarty->assign('actionparams', $params); $smarty->assign('returnid', $returnid); $smarty->assign_by_ref('mod', $this); $smarty->assign_by_ref($this->GetName(), $this); cge_tmpdata::set('module', $this->GetName()); if ($returnid == '') { if (isset($params['cg_activetab'])) { $this->_current_tab = trim($params['cg_activetab']); unset($params['cg_activetab']); } if (isset($params['cg_error'])) { $this->_errormsg = explode(':err:', $params['cg_error']); unset($params['cg_error']); } if (isset($params['cg_message'])) { $this->_messages = explode(':msg:', $params['cg_message']); unset($params['cg_message']); } $this->DisplayErrors(); $this->DisplayMessages(); } $cge = $this->GetModuleInstance('CGExtensions'); if ($cge->GetPreference('cache_modulecalls', 0) && (!isset($params['nocache']) || !$params['nocache']) && cms_cache_handler::can_cache()) { $key = ''; if (isset($params['cache_key'])) { $key = trim($params['cache_key']); } else { $tmp = debug_backtrace(); $bt = array(); foreach ($tmp as $elem) { $bt[] = $elem['file'] . ':' . $elem['line']; } $key = 'm' . md5($this->GetName() . serialize($params) . serialize($bt) . $id . $returnid); } $output = ''; if (!cms_cache_handler::get_instance()->exists($key, 'cge_module')) { @ob_start(); parent::DoAction($name, $id, $params, $returnid); $output = @ob_get_contents(); @ob_end_clean(); if (strlen($output)) { cms_cache_handler::get_instance()->set($key, $output, 'cge_module'); } } else { $output = cms_cache_handler::get_instance()->get($key, 'cge_module'); } echo $output; return; } parent::DoAction($name, $id, $params, $returnid); }