Minahito
minah****@users*****
2006年 9月 24日 (日) 23:05:34 JST
Index: xoops2jp/html/modules/base/kernel/Legacy_ModuleController.class.php diff -u xoops2jp/html/modules/base/kernel/Legacy_ModuleController.class.php:1.1.2.10 xoops2jp/html/modules/base/kernel/Legacy_ModuleController.class.php:1.1.2.11 --- xoops2jp/html/modules/base/kernel/Legacy_ModuleController.class.php:1.1.2.10 Fri Aug 18 18:11:17 2006 +++ xoops2jp/html/modules/base/kernel/Legacy_ModuleController.class.php Sun Sep 24 23:05:34 2006 @@ -1,11 +1,13 @@ <?php /** * @package legacy - * @version $Id: Legacy_ModuleController.class.php,v 1.1.2.10 2006/08/18 09:11:17 minahito Exp $ + * @version $Id: Legacy_ModuleController.class.php,v 1.1.2.11 2006/09/24 14:05:34 minahito Exp $ */ if (!defined('XOOPS_ROOT_PATH')) exit(); +require_once XOOPS_ROOT_PATH . "/modules/base/kernel/Legacy_CacheInformation.class.php"; + define("LEGACY_XOOPS_MODULE_MANIFESTO_FILENAME", "./xoops_version.php"); /** @@ -31,9 +33,24 @@ */ var $mRenderTarget = null; + /** + * The cache information for the current module. + * @var Legacy_CacheInformation + */ + var $mCacheInformation = null; + + /** + * @var XCube_Delegate + */ + var $_mSetupCacheInformation = null; + function Legacy_ModuleController(&$controller) { $this->mController =& $controller; + $this->mCacheInformation =& new Legacy_ModuleCacheInformation(); + + $this->_mSetupCacheInformation =& new XCube_Delegate(); + $this->_mSetupCacheInformation->register('Legacy_ModuleController.SetupCacheInformation'); } function getConfig($key = null) @@ -237,5 +254,30 @@ { return "Legacy_RenderSystem"; } + + /** + * Initialize the cache information object. + */ + function setupCacheInformation() + { + $this->mCacheInformation->mURL = xoops_getenv('REQUEST_URI'); + $this->mCacheInformation->setModule($xoopsModule); + + $this->_mSetupCacheInformation->call(new XCube_Ref($this->mCacheInformation)); + } + + /** + * Gets a value indicating whether the current module has a option of + * configurations to use the cache system. + * @return bool + */ + function hasModuleCacheConfig() + { + if (xoops_getenv('REQUEST_METHOD') == 'POST') { + return false; + } + + return is_object($this->mModuleObject) && !empty($this->mController->mConfig['module_cache'][$this->mModuleObject->get('mid')]); + } } ?> \ No newline at end of file Index: xoops2jp/html/modules/base/kernel/Legacy_Controller.class.php diff -u xoops2jp/html/modules/base/kernel/Legacy_Controller.class.php:1.1.2.76 xoops2jp/html/modules/base/kernel/Legacy_Controller.class.php:1.1.2.77 --- xoops2jp/html/modules/base/kernel/Legacy_Controller.class.php:1.1.2.76 Fri Sep 22 19:37:49 2006 +++ xoops2jp/html/modules/base/kernel/Legacy_Controller.class.php Sun Sep 24 23:05:34 2006 @@ -1,7 +1,7 @@ <?php /** * @package Legacy - * @version $Id: Legacy_Controller.class.php,v 1.1.2.76 2006/09/22 10:37:49 minahito Exp $ + * @version $Id: Legacy_Controller.class.php,v 1.1.2.77 2006/09/24 14:05:34 minahito Exp $ */ if (!defined('XOOPS_ROOT_PATH')) exit(); @@ -70,6 +70,16 @@ /** * @var XCube_Delegate */ + var $mCheckEnableBlockCache = null; + + /** + * @var XCube_Delegate + */ + var $mCheckEnableModuleCache = null; + + /** + * @var XCube_Delegate + */ var $mGetLanguageName = null; var $mBlockShowFlags = array(); @@ -102,7 +112,10 @@ $this->mGetLanguageName =& new XCube_Delegate(); $this->mGetLanguageName->register("Legacy_Controller.GetLanguageName"); - + + $this->mCheckEnableBlockCache =& new XCube_Delegate(); + $this->mCheckEnableModuleCache =& new XCube_Delegate(); + set_magic_quotes_runtime(0); // ^^; // @@ -247,15 +260,21 @@ $renderTarget =& new XCube_RenderTarget(); $renderTarget->setType(XCUBE_RENDER_TARGET_TYPE_BLOCK); - $cache =& $this->mRoot->getCacheSystem(); + $blockCache =& new Legacy_BlockCacheInformation(); foreach ($this->mBlockChain as $blockProcedure) { - $cache->reset(); $renderTarget->reset(); + $blockCache->reset(); + + $blockCache->setBlock($blockProcedure->mAdapteeBlockObject); //< FIXME + + // + // Checks whether the controller should do cache. + // + $this->mCheckEnableBlockCache->call(new XCube_Ref($blockCache)); - $cache->setResourceName("block" . $blockProcedure->getId()); - if ($cache->isCache($blockProcedure->getCacheTime())) { - $content = $cache->load(); + if ($blockCache->isEnableCache() && $blockCache->isExpireCache($blockProcedure->getCacheTime())) { + $content = $blockCache->load(); if ($content) { $this->mBlockShowFlags[$blockProcedure->getEntryIndex()] = true; $this->mBlockContents[$blockProcedure->getEntryIndex()][] = array( @@ -285,8 +304,8 @@ 'weight'=>$blockProcedure->getWeight() ); - if ($blockProcedure->getCacheTime() > 0) { - $cache->save($renderTarget); + if ($blockProcedure->getCacheTime() > 0 && $blockCache->isEnableCache()) { + $blockCache->save($renderTarget); } } @@ -319,7 +338,7 @@ } if (!$this->mModuleController->hasPermission()) { - $this->executeRedirect(XOOPS_URL,1,_NOPERM); // TODO Depens on const message catalog. + $this->executeRedirect(XOOPS_URL . '/',1,_NOPERM); // TODO Depens on const message catalog. } $this->mModuleController->setupLanguage(); @@ -618,21 +637,30 @@ // // cache check // - $cacheSystem =& $this->mRoot->getCacheSystem(); - $xoopsModule =& $this->mModuleController->getXoopsModule(); + $this->mModuleController->setupCacheInformation(); + $moduleCache =& $this->mModuleController->mCacheInformation; - if ($this->_isModuleCache($xoopsModule)) { - $url = xoops_getenv('REQUEST_URI'); - $cacheSystem->setResourceName($url); + $this->mCheckEnableModuleCache->call(new XCube_Ref($moduleCache)); + + if ($this->mModuleController->hasModuleCacheConfig()) { + // + // Checks whether the cache file exists. + // + $xoopsModule =& $this->mModuleController->getXoopsModule(); + $cachetime = $this->mConfig['module_cache'][$xoopsModule->get('mid')]; - if ($cacheSystem->isCache($this->_getModuleCacheTime($xoopsModule))) { + // + // Checks whether the active cache file exists. If it's OK, load + // cache and do display. + // + if ($moduleCache->isEnableCache() && $moduleCache->isExpireCache($cachetime)) { $renderSystem =& $this->mRoot->getRenderSystem($this->mModuleController->getDependRenderSystem()); $renderTarget =& $renderSystem->createRenderTarget(XCUBE_RENDER_TARGET_TYPE_MAIN); - $renderTarget->setResult($cacheSystem->load()); - + $renderTarget->setResult($moduleCache->load()); + $this->_executeViewTheme($renderTarget); - - exit(0); + + exit('CACHE'); } } @@ -640,22 +668,6 @@ } /** - * @return bool - */ - function _isModuleCache($xoopsModule) - { - return (xoops_getenv('REQUEST_METHOD') != 'POST' && is_object($xoopsModule) && !empty($this->mConfig['module_cache'][$xoopsModule->getVar('mid')])); - } - - /** - * @return int - */ - function _getModuleCacheTime($xoopsModule) - { - return $this->mConfig['module_cache'][$xoopsModule->getVar('mid')]; - } - - /** * @var string $theme */ function setMainTheme($theme) @@ -698,12 +710,10 @@ // // Cache Control // - $xoopsModule =& $this->mModuleController->getXoopsModule(); - if ($this->_isModuleCache($xoopsModule)) { - $url = xoops_getenv('REQUEST_URI'); - $cacheSystem =& $this->mRoot->getCacheSystem(); - $cacheSystem->setResourceName($url); - $cacheSystem->save($renderTarget); + if ($this->mModuleController->hasModuleCacheConfig()) { + if ($this->mModuleController->mCacheInformation->isEnableCache()) { + $this->mModuleController->mCacheInformation->save($renderTarget); + } } } @@ -858,7 +868,7 @@ $this->mLogout->call(new XCube_Ref($successFlag), $xoopsUser); if ($successFlag) { XCube_DelegateUtils::call("Site.Logout.Success", $xoopsUser); - $this->executeRedirect(XOOPS_URL, 1, array(_MD_BASE_MESSAGE_LOGGEDOUT, _MD_BASE_MESSAGE_THANKYOUFORVISIT)); + $this->executeRedirect(XOOPS_URL . '/', 1, array(_MD_BASE_MESSAGE_LOGGEDOUT, _MD_BASE_MESSAGE_THANKYOUFORVISIT)); } else { XCube_DelegateUtils::call("Site.Logout.Fail", $xoopsUser); @@ -1054,6 +1064,11 @@ exit(); } + + function isEnableCacheFeature() + { + return $this->mStrategy->isEnableCacheFeature(); + } } /** @@ -1187,6 +1202,11 @@ return $theme; } + + function isEnableCacheFeature() + { + return true; + } } class Legacy_AdminControllerStrategy extends Legacy_AbstractControllerStrategy @@ -1300,6 +1320,11 @@ return $theme; } + + function isEnableCacheFeature() + { + return true; + } } ?> \ No newline at end of file