[xoops-cvslog 1568] CVS update: xoops2jp/html/modules/base/kernel

アーカイブの一覧に戻る

Minahito minah****@users*****
2006年 1月 5日 (木) 17:29:36 JST


Index: xoops2jp/html/modules/base/kernel/Legacy_Controller.class.php
diff -u xoops2jp/html/modules/base/kernel/Legacy_Controller.class.php:1.1.2.12 xoops2jp/html/modules/base/kernel/Legacy_Controller.class.php:1.1.2.13
--- xoops2jp/html/modules/base/kernel/Legacy_Controller.class.php:1.1.2.12	Tue Jan  3 00:05:17 2006
+++ xoops2jp/html/modules/base/kernel/Legacy_Controller.class.php	Thu Jan  5 17:29:36 2006
@@ -173,34 +173,53 @@
 		
 		$blockTarget=new XCube_RenderTarget();
 		$blockTarget->setType(XCUBE_RENDER_TARGET_TYPE_BLOCK);
+		
+		$cache =& $this->mRoot->getCacheSystem();
 
 		foreach($this->mBlockChain as $blockProcedure) {
-			$blockProcedure->execute($this,$this->getXoopsUser());
-			if($blockProcedure->hasResult()) {
+			$cache->reset();
+			$blockTarget->reset();
+
+			$cache->setResourceName("block" . $blockProcedure->getId());
+			if ($cache->isCache($blockProcedure->getCacheTime())) {
+				$this->mRenderSystem->mBlockContents[$blockProcedure->getEntryIndex()][] = array(
+						'title'   => $blockProcedure->getTitle(),
+						'content' => $cache->load(),
+						'weight'  => $blockProcedure->getWeight()
+				);
+			}
+			else {
+				$blockProcedure->execute($this,$this->getXoopsUser());
+
+				if (!$blockProcedure->hasResult()) {
+					continue;
+				}
+					
+				$blockTarget->setAttribute("mid",$blockProcedure->getId());
+
 				if ($blockProcedure->getTemplateName() == null) {
 					$this->mRenderSystem->mBlockShowFlags[$blockProcedure->getEntryIndex()] = true;
-					$blockContent = $blockProcedure->getResult();
-					$this->mRenderSystem->mBlockContents[$blockProcedure->getEntryIndex()][] = array(
-							'title'   => $blockProcedure->getTitle(),
-							'content' => $blockContent['content'],
-							'weight'  => $blockProcedure->getWeight()
-					);
+					$result = $blockProcedure->getResult();
+					
+					$blockTarget->setTemplateName('system_dummy.html');
+					$blockTarget->setAttribute('dummy_content', $result['content']);
 				}
 				else {
 					$blockTarget->setTemplateName($blockProcedure->getTemplateName());
 					$blockTarget->setAttribute("block",$blockProcedure->getResult());
-					$blockTarget->setAttribute("mid",$blockProcedure->getId());
+				}
 
-					$this->mRenderSystem->renderBlock($blockTarget);
+				$this->mRenderSystem->renderBlock($blockTarget);
 
-					$this->mRenderSystem->mBlockShowFlags[$blockProcedure->getEntryIndex()] = true;
-					$this->mRenderSystem->mBlockContents[$blockProcedure->getEntryIndex()][] = array(
-							'title'=>$blockProcedure->getTitle(),
-							'content'=>$blockTarget->getResult(),
-							'weight'=>$blockProcedure->getWeight()
-					);
-				
-					$blockTarget->reset();
+				$this->mRenderSystem->mBlockShowFlags[$blockProcedure->getEntryIndex()] = true;
+				$this->mRenderSystem->mBlockContents[$blockProcedure->getEntryIndex()][] = array(
+						'title'=>$blockProcedure->getTitle(),
+						'content'=>$blockTarget->getResult(),
+						'weight'=>$blockProcedure->getWeight()
+				);
+
+				if ($blockProcedure->getCacheTime() > 0) {
+					$cache->save($blockTarget);
 				}
 			}
 
@@ -393,12 +412,50 @@
 
 		require_once XOOPS_ROOT_PATH.'/include/old_theme_functions.php';
 		$GLOBALS['xoopsTheme']['thename'] = $GLOBALS['xoopsConfig']['theme_set'];
-		ob_start();
 
+		//
+		// cache check
+		//
+		$cacheSystem =& $this->mRoot->getCacheSystem();
+		$xoopsModule =& $this->mModuleController->getXoopsModule();
+		
 		$renderTarget=new Legacy_RenderTargetMain();
+
+		if ($this->_isModuleCache($xoopsModule)) {
+			$url = xoops_getenv('REQUEST_URI');
+			$cacheSystem->setResourceName($url);
+			
+			if ($cacheSystem->isCache($this->_getModuleCacheTime($xoopsModule))) {
+				$renderTarget =& new Legacy_RenderTargetMain();
+				$renderTarget->setResult($cacheSystem->load());
+
+				$this->_executeViewTheme($renderTarget);
+
+				exit(0);
+			}
+		}
+
+		ob_start();
+
 		$this->mRenderSystem->setRenderTarget($renderTarget);
 	}
 	
+	/**
+	 * @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')];
+	}
+	
 	function executeView()
 	{
 		//
@@ -425,12 +482,31 @@
 		$this->mRenderSystem->renderWithTarget($renderTarget);
 
 		//
+		// 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);
+		}
+		
+		$this->_executeViewTheme($renderTarget);
+	}
+	
+	/**
+	 * $resultRenderTarget object The render target of content's result.
+	 */
+	function _executeViewTheme(&$resultRenderTarget)
+	{
+		//
 		// Theme Control
 		//
 		$screenTarget=$this->mDialogMode ? new Legacy_DialogRenderTarget() : new Legacy_ThemeRenderTarget();
 		$screenTarget->setTemplateName($this->mRoot->getThemeName());
 		
-		$screenTarget->setAttribute('xoops_contents',$renderTarget->getResult());
+		$screenTarget->setAttribute('xoops_contents',$resultRenderTarget->getResult());
 
 		$this->mRenderSystem->renderWithTarget($screenTarget);
 
@@ -451,7 +527,6 @@
 			$xoopsDebugger->displayLog();
 		}
 	}
-	
 
 	function &_createEventManager()
 	{


xoops-cvslog メーリングリストの案内
アーカイブの一覧に戻る