• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

XOOPS Cube Legacy base repository


Commit MetaInfo

修订版213207f96d78cda799990c178b24ee9388e0932b (tree)
时间2011-11-16 22:07:51
作者nbuy <nbuy@704c...>
Commiternbuy

Log Message

template variables assign at once by array for speedup

git-svn-id: https://xoopscube.svn.sourceforge.net/svnroot/xoopscube/Package_Legacy/trunk@1052 704cf05f-ae62-4b0e-a484-234ee0250e75

更改概述

差异

--- a/html/modules/legacyRender/kernel/Legacy_RenderSystem.class.php
+++ b/html/modules/legacyRender/kernel/Legacy_RenderSystem.class.php
@@ -37,9 +37,15 @@ class Legacy_XoopsTpl extends XoopsTpl
3737 function assign($tpl_var, $value = null)
3838 {
3939 if (is_array($tpl_var)){
40+ $root =& XCube_Root::getSingleton();
41+ $context = $root->mContext;
42+ $reverse = &$this->_mContextReserve;
4043 foreach ($tpl_var as $key => $val) {
4144 if ($key != '') {
42- $this->assign($key, $val);
45+ if (isset($reserve[$key])) {
46+ $context->setAttribute($reserve[$key], htmlspecialchars_decode($val));
47+ }
48+ $this->_tpl_vars[$key] = $val;
4349 }
4450 }
4551 }
@@ -202,8 +208,8 @@ class Legacy_RenderSystem extends XCube_RenderSystem
202208 if (is_object($context->mXoopsUser)) {
203209 $arr = array(
204210 'xoops_isuser' => true,
205- 'xoops_userid' => $context->mXoopsUser->getShow('uid'),
206- 'xoops_uname' => $context->mXoopsUser->getShow('uname')
211+ 'xoops_userid' => $context->mXoopsUser->getVar('uid', 'n'),
212+ 'xoops_uname' => $context->mXoopsUser->getVar('uname')
207213 );
208214 }
209215 else {
@@ -236,27 +242,26 @@ class Legacy_RenderSystem extends XCube_RenderSystem
236242 $textFilter =& $root->getTextFilter();
237243
238244 $themeName = $context->getThemeName();
239- $mTpl = $this->mXoopsTpl;
240- $mTpl->assign('xoops_theme', $themeName);
241- $mTpl->assign('xoops_imageurl', XOOPS_THEME_URL . "/${themeName}/");
242- $mTpl->assign('xoops_themecss', xoops_getcss($themeName));
243-
244- $mTpl->assign('xoops_sitename', $textFilter->toShow($context->getAttribute('legacy_sitename')));
245- $mTpl->assign('xoops_pagetitle', $textFilter->toShow($context->getAttribute('legacy_pagetitle')));
246- $mTpl->assign('xoops_slogan', $textFilter->toShow($context->getAttribute('legacy_slogan')));
245+ $vars = array('xoops_theme'=>$themeName,
246+ 'xoops_imageurl'=>XOOPS_THEME_URL . "/${themeName}/",
247+ 'xoops_themecss'=>xoops_getcss($themeName),
248+ 'xoops_sitename'=>$textFilter->toShow($context->getAttribute('legacy_sitename')),
249+ 'xoops_pagetitle'=>$textFilter->toShow($context->getAttribute('legacy_pagetitle')),
250+ 'xoops_slogan', $textFilter->toShow($context->getAttribute('legacy_slogan')));
247251
248252 //
249253 // Assign module informations.
250254 //
251255 if($context->mModule != null) { // The process of module
252256 $xoopsModule =& $context->mXoopsModule;
253- $mTpl->assign(array('xoops_modulename' => $xoopsModule->getShow('name'),
254- 'xoops_dirname' => $xoopsModule->getShow('dirname')));
257+ $vars['xoops_modulename'] = $xoopsModule->getVar('name');
258+ $vars['xoops_dirname'] = $xoopsModule->getVar('dirname');
255259 }
256260
257261 if (isset($GLOBALS['xoopsUserIsAdmin'])) {
258- $mTpl->assign('xoops_isadmin', $GLOBALS['xoopsUserIsAdmin']);
262+ $vars['xoops_isadmin']=$GLOBALS['xoopsUserIsAdmin'];
259263 }
264+ $this->mXoopsTpl->assign($vars);
260265 }
261266
262267 function renderBlock(&$target)
@@ -269,9 +274,8 @@ class Legacy_RenderSystem extends XCube_RenderSystem
269274 $mTpl = $this->mXoopsTpl;
270275 $mTpl->xoops_setCaching(0);
271276
272- foreach($target->getAttributes() as $key=>$value) {
273- $mTpl->assign($key,$value);
274- }
277+ $vars = $target->getAttributes();
278+ $mTpl->assign($vars);
275279
276280 $this->mBeginRender->call(new XCube_Ref($mTpl));
277281 $result=&$mTpl->fetchBlock($target->getTemplateName(),$target->getAttribute("bid"));
@@ -280,9 +284,7 @@ class Legacy_RenderSystem extends XCube_RenderSystem
280284 //
281285 // Reset
282286 //
283- foreach($target->getAttributes() as $key=>$value) {
284- $mTpl->clear_assign($key);
285- }
287+ $mTpl->clear_assign(array_keys($vars));
286288 }
287289
288290 function _render(&$target)
@@ -364,43 +366,38 @@ class Legacy_RenderSystem extends XCube_RenderSystem
364366 $mTpl = $this->mXoopsTpl;
365367 $moduleHeader = $mTpl->get_template_vars('xoops_module_header');
366368 $moduleHeader = $headerScript->createLibraryTag() . $moduleHeader . $headerScript->createOnloadFunctionTag();
367- $mTpl->assign('xoops_module_header', $moduleHeader);
369+
370+ //
371+ // Assign from attributes of the render-target.
372+ //
373+ $vars = $target->getAttributes();
374+ $vars['xoops_module_header'] = $moduleHeader;
368375
369376 $moduleHandler =& xoops_gethandler('module');
370377 $legacyRender =& $moduleHandler->getByDirname('legacyRender');
371378 $configHandler =& xoops_gethandler('config');
372379 $configs =& $configHandler->getConfigsByCat(0, $legacyRender->get('mid'));
373380
374- $textFilter =& $this->mController->mRoot->getTextFilter();
375- $headerScript = $this->mController->mRoot->mContext->getAttribute('headerScript');//echo $headerScript->getMeta('author');die();
376- $headerScript->getMeta('keywords') ? $this->mXoopsTpl->assign('xoops_meta_keywords', $textFilter->toShow($headerScript->getMeta('keywords'))) : $this->mXoopsTpl->assign('xoops_meta_keywords', $textFilter->toShow($configs['meta_keywords']));
377- $headerScript->getMeta('description') ? $this->mXoopsTpl->assign('xoops_meta_description', $headerScript->getMeta('description')) : $this->mXoopsTpl->assign('xoops_meta_description', $textFilter->toShow($configs['meta_description']));
378- $headerScript->getMeta('robots') ? $this->mXoopsTpl->assign('xoops_meta_robots', $textFilter->toShow($headerScript->getMeta('robots'))) : $this->mXoopsTpl->assign('xoops_meta_robots', $textFilter->toShow($configs['meta_robots']));
379- $headerScript->getMeta('rating') ? $this->mXoopsTpl->assign('xoops_meta_rating', $textFilter->toShow($headerScript->getMeta('rating'))) : $this->mXoopsTpl->assign('xoops_meta_rating', $textFilter->toShow($configs['meta_rating']));
380- $headerScript->getMeta('author') ? $this->mXoopsTpl->assign('xoops_meta_author', $textFilter->toShow($headerScript->getMeta('author'))) : $this->mXoopsTpl->assign('xoops_meta_author', $textFilter->toShow($configs['meta_author']));
381- $headerScript->getMeta('copyright') ? $this->mXoopsTpl->assign('xoops_meta_copyright', $textFilter->toShow($headerScript->getMeta('copyright'))) : $this->mXoopsTpl->assign('xoops_meta_copyright', $textFilter->toShow($configs['meta_copyright']));
382- $this->mXoopsTpl->assign('xoops_footer', $configs['footer']); // footer may be raw HTML text.
381+ $textFilter =& $mRoot->getTextFilter();
382+ $headerScript = $mContext->getAttribute('headerScript');
383+ $vars['xoops_meta_keywords'] = $textFilter->toShow($headerScript->getMeta('keywords') ? $headerScript->getMeta('keywords') : $configs['meta_keywords']);
384+ $vars['xoops_meta_description'] = $textFilter->toShow($headerScript->getMeta('description') ? $headerScript->getMeta('description') : $configs['meta_description']);
385+ $vars['xoops_meta_robots'] = $textFilter->toShow($headerScript->getMeta('robots') ? $headerScript->getMeta('robots') : $configs['meta_robots']);
386+ $vars['xoops_meta_rating'] = $textFilter->toShow($headerScript->getMeta('rating') ? $headerScript->getMeta('rating') : $configs['meta_rating']);
387+ $vars['xoops_meta_author'] = $textFilter->toShow($headerScript->getMeta('author') ? $headerScript->getMeta('author') : $configs['meta_author']);
388+ $vars['xoops_meta_copyright'] = $textFilter->toShow($headerScript->getMeta('copyright') ? $headerScript->getMeta('copyright') : $configs['meta_copyright']);
389+ $vars['xoops_footer'] = $configs['footer']; // footer may be raw HTML text.
383390
384391 //
385392 // If this site has the setting of banner.
386393 // TODO this process depends on XOOPS 2.0.x.
387394 //
388395 if (LEGACY_RENDERSYSTEM_BANNERSETUP_BEFORE == false) {
389- if ($this->_mIsActiveBanner == 1) {
390- $mTpl->assign('xoops_banner',xoops_getbanner());
391- }
392- else {
393- $mTpl->assign('xoops_banner','&nbsp;');
394- }
396+ $vars['xoops_banner'] = ($this->_mIsActiveBanner == 1)?xoops_getbanner():'&nbsp;';
395397 }
396398
397- //
398- // Assign from attributes of the render-target.
399- //
400- foreach($target->getAttributes() as $key => $value) {
401- $mTpl->assign($key, $value);
402- }
403-
399+ $mTpl->assign($vars);
400+
404401 //
405402 // [TODO]
406403 // We must implement with a render-target.