protected static function &get_instance() { if (!self::$_instance) { self::$_instance = new cms_module_smarty_plugin_manager(); } return self::$_instance; }
/** * defaultPluginHandler * NOTE: Registered in constructor * * @param string $name * @param string $type * @param string $template * @param string $callback * @param string $script * @return boolean true on success, false on failure */ public function defaultPluginHandler($name, $type, $template, &$callback, &$script, &$cachable) { debug_buffer('', "Start Load Smarty Plugin {$name}/{$type}"); $cachable = TRUE; $config = cmsms()->GetConfig(); $fn = cms_join_path($config['root_path'], 'plugins', $type . '.' . $name . '.php'); if (file_exists($fn)) { // plugins with the smarty_cms_function require_once $fn; $func = 'smarty_cms_' . $type . '_' . $name; $script = $fn; if (function_exists($func)) { $callback = $func; $cachable = FALSE; debug_buffer('', "End Load Smarty Plugin {$name}/{$type}"); return TRUE; } $func = 'smarty_' . $type . '_' . $name; $script = $fn; if (function_exists($func)) { $callback = $func; $cachable = TRUE; debug_buffer('', "End Load Smarty Plugin {$name}/{$type}"); return TRUE; } } if (cmsms()->is_frontend_request()) { $row = cms_module_smarty_plugin_manager::load_plugin($name, $type); if (is_array($row) && is_array($row['callback']) && count($row['callback']) == 2 && is_string($row['callback'][0]) && is_string($row['callback'][1])) { $cachable = $row['cachable']; $callback = $row['callback'][0] . '::' . $row['callback'][1]; return TRUE; } } return FALSE; }
/** * Register a plugin to smarty with the * name of the module. This method should be called * from the module constructor, or from the InitializeFrontend() * method. * * Note: * @final * @return void * @see SetParameters * @see can_cache_output * @param boolean Indicate wether this registration should be forced to be entered in the database. Default value is false (for compatibility) * @param mixed Indicate wether this plugins output should be cachable. If null, use the site preferences, and the can_cache_output method. Otherwise a boolean is expected. * @deprecated */ public final function RegisterModulePlugin($forcedb = FALSE, $cachable = null) { global $CMS_ADMIN_PAGE; global $CMS_INSTALL_PAGE; if (is_null($cachable)) { $do_cache = get_site_preference('smarty_cachemodules', 'never'); $cachable = false; if ($do_cache == 'always') { $cachable = true; } else { if ($do_cache == 'moduledecides') { $cachable = $this->can_cache_output(); } } } // frontend request. $admin_req = isset($CMS_ADMIN_PAGE) && !$this->LazyLoadAdmin() ? 1 : 0; $fe_req = !isset($CMS_ADMIN_PAGE) && !$this->LazyLoadFrontend() ? 1 : 0; if (($fe_req || $admin_req) && !$forcedb) { // no lazy loading. $gCms = cmsms(); $smarty = $gCms->GetSmarty(); $smarty->register_function($this->GetName(), array($this->GetName(), 'function_plugin'), $cachable); return TRUE; } else { return cms_module_smarty_plugin_manager::addStatic($this->GetName(), $this->GetName(), 'function', 'function_plugin', $cachable); } }