29class Legacy_AdminSmarty
extends Smarty
31 public $mModulePrefix =
null;
32 public $_canUpdateFromFile =
true;
37 public $overrideMode =
true;
39 public function Legacy_AdminSmarty()
48 $this->compile_id = XOOPS_URL;
49 $this->_canUpdateFromFile =
true;
50 $this->compile_check =
true;
51 $this->compile_dir = XOOPS_COMPILE_PATH;
52 $this->left_delimiter =
'<{';
53 $this->right_delimiter =
'}>';
56 $this->plugins_dir = [SMARTY_DIR .
'plugins'];
62 $this->force_compile =
false;
65 public function setModulePrefix($prefix)
67 $this->mModulePrefix = $prefix;
70 public function _get_auto_filename($autoBase, $autoSource =
null, $auotId =
null)
72 $autoSource = $this->mModulePrefix .
'_admin_' . $autoSource;
73 return parent::_get_auto_filename($autoBase, $autoSource, $auotId);
76 public function _fetch_resource_info(&$params)
80 $root =& XCube_Root::getSingleton();
81 $theme = $root->mSiteConfig[
'Legacy'][
'Theme'];
82 $dirname = $this->mModulePrefix;
84 if (
null != $dirname) {
85 $params[
'resource_base_path'] = XOOPS_THEME_PATH .
'/' . $theme .
'/modules/' . $dirname;
86 $params[
'quiet'] =
true;
88 $_return = parent::_fetch_resource_info($params);
92 unset($params[
'resource_base_path']);
93 $params[
'quiet'] =
false;
95 $_return = parent::_fetch_resource_info($params);
118 public $_mStdoutBuffer =
null;
122 $this->mController =& $controller;
125 $this->mSmarty->register_modifier(
'theme',
'Legacy_modifier_theme');
126 $this->mSmarty->register_function(
'stylesheet',
'Legacy_function_stylesheet');
133 global $xoopsUser, $xoopsModule, $xoopsOption, $xoopsConfig;
134 $dirname = is_object( @$xoopsModule ) ? $xoopsModule->getVar(
'dirname') :
'' ;
135 $modname = is_object( @$xoopsModule ) ? $xoopsModule->getVar(
'name') :
'' ;
136 $modicon = is_object( @$xoopsModule ) ? $xoopsModule->getInfo(
'icon') :
'' ;
138 $uid = is_object( @$xoopsUser ) ? $xoopsUser->getVar(
'uid') :
'' ;
141 $moduleHandler = xoops_gethandler(
'module');
142 $legacyRender =& $moduleHandler->getByDirname(
'legacyRender');
143 $configHandler = xoops_gethandler(
'config');
144 $configs =& $configHandler->getConfigsByCat(0, $legacyRender->get(
'mid'));
146 $this->mSmarty->assign(
148 'xoops_url' => XOOPS_URL,
149 'xoops_rootpath' => XOOPS_ROOT_PATH,
150 'xoops_langcode' => _LANGCODE,
151 'xoops_charset' => _CHARSET,
152 'xoops_version' => XOOPS_VERSION,
153 'xoops_upload_url' => XOOPS_UPLOAD_URL,
154 'modulename' => $modname,
155 'moduleicon' => $modicon,
156 'dirname' => $dirname,
157 'xoops_dirname' => $dirname,
159 'module_name' => $modname,
160 'module_dir' => $dirname,
161 'logotype' => $configs[
'favicon'],
162 'favicon' => $configs[
'favicon'],
166 if (
true == $controller->mRoot->mSiteConfig[
'Legacy_AdminRenderSystem'][
'ThemeDevelopmentMode']) {
167 $this->mSmarty->force_compile =
true;
171 public function renderBlock(&$target)
173 $this->mSmarty->template_dir = XOOPS_ROOT_PATH .
'/modules/legacy/admin/templates';
175 foreach ($target->getAttributes() as $key => $value) {
176 $this->mSmarty->assign($key, $value);
179 $this->mSmarty->setModulePrefix($target->getAttribute(
'legacy_module'));
180 $result = $this->mSmarty->fetch(
'blocks/' . $target->getTemplateName());
181 $target->setResult($result);
186 foreach ($target->getAttributes() as $key => $value) {
187 $this->mSmarty->clear_assign($key);
191 public function renderTheme(&$target)
196 $smarty = $this->mSmarty;
197 $vars = [
'stdout_buffer' =>$this->_mStdoutBuffer];
198 foreach ($target->getAttributes() as $key=>$value) {
199 $vars[$key] = $value;
203 $context = $this->mController->mRoot->mContext;
204 XCube_DelegateUtils::call(
'Site.JQuery.AddFunction',
new XCube_Ref($context->mAttributes[
'headerScript']));
205 $headerScript = $context->getAttribute(
'headerScript');
206 $moduleHeader = $headerScript->createLibraryTag() . $headerScript->createOnloadFunctionTag();
207 $vars[
'xoops_module_header'] = $moduleHeader;
212 $moduleObject =& $this->mController->getVirtualCurrentModule();
213 $vars[
'currentModule'] = $moduleObject;
218 $vars[
'legacy_sitename'] = $context->getAttribute(
'legacy_sitename');
219 $vars[
'legacy_pagetitle'] = $context->getAttribute(
'legacy_pagetitle');
220 $vars[
'legacy_slogan'] = $context->getAttribute(
'legacy_slogan');
226 foreach ($context->mAttributes[
'legacy_BlockContents'][0] as $key => $result) {
228 $blocks[$result[
'name']] = $result;
230 $vars[
'xoops_lblocks'] = $blocks;
232 $smarty->assign($vars);
237 $root =& XCube_Root::getSingleton();
238 $theme = $root->mSiteConfig[
'Legacy'][
'Theme'];
240 if (file_exists(XOOPS_ROOT_PATH.
'/themes/'.$theme.
'/admin_theme.html')) {
241 $smarty->template_dir=XOOPS_THEME_PATH.
'/'.$theme;
243 $smarty->template_dir=LEGACY_ADMIN_RENDER_FALLBACK_PATH;
246 $smarty->setModulePrefix(
'');
247 $result=$smarty->fetch(
'file:admin_theme.html');
249 $target->setResult($result);
252 public function renderMain(&$target)
257 foreach ($target->getAttributes() as $key=>$value) {
258 $this->mSmarty->assign($key, $value);
263 if ($target->getTemplateName()) {
264 if (
null != $target->getAttribute(
'legacy_module')) {
265 $this->mSmarty->setModulePrefix($target->getAttribute(
'legacy_module'));
266 $this->mSmarty->template_dir = XOOPS_MODULE_PATH .
'/' . $target->getAttribute(
'legacy_module') .
'/admin/'. LEGACY_ADMIN_RENDER_TEMPLATE_DIRNAME;
269 $result=$this->mSmarty->fetch(
'file:'.$target->getTemplateName());
270 $buffer = $target->getAttribute(
'stdout_buffer');
272 $this->_mStdoutBuffer .= $buffer;
274 $result=$target->getAttribute(
'stdout_buffer');
277 $target->setResult($result);
282 foreach ($target->getAttributes() as $key=>$value) {
283 $this->mSmarty->clear_assign($key);