XOOPS Cube Legacy base repository
修订版 | 213207f96d78cda799990c178b24ee9388e0932b (tree) |
---|---|
时间 | 2011-11-16 22:07:51 |
作者 | nbuy <nbuy@704c...> |
Commiter | nbuy |
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
@@ -37,9 +37,15 @@ class Legacy_XoopsTpl extends XoopsTpl | ||
37 | 37 | function assign($tpl_var, $value = null) |
38 | 38 | { |
39 | 39 | if (is_array($tpl_var)){ |
40 | + $root =& XCube_Root::getSingleton(); | |
41 | + $context = $root->mContext; | |
42 | + $reverse = &$this->_mContextReserve; | |
40 | 43 | foreach ($tpl_var as $key => $val) { |
41 | 44 | 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; | |
43 | 49 | } |
44 | 50 | } |
45 | 51 | } |
@@ -202,8 +208,8 @@ class Legacy_RenderSystem extends XCube_RenderSystem | ||
202 | 208 | if (is_object($context->mXoopsUser)) { |
203 | 209 | $arr = array( |
204 | 210 | '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') | |
207 | 213 | ); |
208 | 214 | } |
209 | 215 | else { |
@@ -236,27 +242,26 @@ class Legacy_RenderSystem extends XCube_RenderSystem | ||
236 | 242 | $textFilter =& $root->getTextFilter(); |
237 | 243 | |
238 | 244 | $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'))); | |
247 | 251 | |
248 | 252 | // |
249 | 253 | // Assign module informations. |
250 | 254 | // |
251 | 255 | if($context->mModule != null) { // The process of module |
252 | 256 | $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'); | |
255 | 259 | } |
256 | 260 | |
257 | 261 | if (isset($GLOBALS['xoopsUserIsAdmin'])) { |
258 | - $mTpl->assign('xoops_isadmin', $GLOBALS['xoopsUserIsAdmin']); | |
262 | + $vars['xoops_isadmin']=$GLOBALS['xoopsUserIsAdmin']; | |
259 | 263 | } |
264 | + $this->mXoopsTpl->assign($vars); | |
260 | 265 | } |
261 | 266 | |
262 | 267 | function renderBlock(&$target) |
@@ -269,9 +274,8 @@ class Legacy_RenderSystem extends XCube_RenderSystem | ||
269 | 274 | $mTpl = $this->mXoopsTpl; |
270 | 275 | $mTpl->xoops_setCaching(0); |
271 | 276 | |
272 | - foreach($target->getAttributes() as $key=>$value) { | |
273 | - $mTpl->assign($key,$value); | |
274 | - } | |
277 | + $vars = $target->getAttributes(); | |
278 | + $mTpl->assign($vars); | |
275 | 279 | |
276 | 280 | $this->mBeginRender->call(new XCube_Ref($mTpl)); |
277 | 281 | $result=&$mTpl->fetchBlock($target->getTemplateName(),$target->getAttribute("bid")); |
@@ -280,9 +284,7 @@ class Legacy_RenderSystem extends XCube_RenderSystem | ||
280 | 284 | // |
281 | 285 | // Reset |
282 | 286 | // |
283 | - foreach($target->getAttributes() as $key=>$value) { | |
284 | - $mTpl->clear_assign($key); | |
285 | - } | |
287 | + $mTpl->clear_assign(array_keys($vars)); | |
286 | 288 | } |
287 | 289 | |
288 | 290 | function _render(&$target) |
@@ -364,43 +366,38 @@ class Legacy_RenderSystem extends XCube_RenderSystem | ||
364 | 366 | $mTpl = $this->mXoopsTpl; |
365 | 367 | $moduleHeader = $mTpl->get_template_vars('xoops_module_header'); |
366 | 368 | $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; | |
368 | 375 | |
369 | 376 | $moduleHandler =& xoops_gethandler('module'); |
370 | 377 | $legacyRender =& $moduleHandler->getByDirname('legacyRender'); |
371 | 378 | $configHandler =& xoops_gethandler('config'); |
372 | 379 | $configs =& $configHandler->getConfigsByCat(0, $legacyRender->get('mid')); |
373 | 380 | |
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. | |
383 | 390 | |
384 | 391 | // |
385 | 392 | // If this site has the setting of banner. |
386 | 393 | // TODO this process depends on XOOPS 2.0.x. |
387 | 394 | // |
388 | 395 | 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',' '); | |
394 | - } | |
396 | + $vars['xoops_banner'] = ($this->_mIsActiveBanner == 1)?xoops_getbanner():' '; | |
395 | 397 | } |
396 | 398 | |
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 | + | |
404 | 401 | // |
405 | 402 | // [TODO] |
406 | 403 | // We must implement with a render-target. |