[xoops-cvslog 5645] CVS update: xoops2jp/html/modules/stdCache/blocks

アーカイブの一覧に戻る

Minahito minah****@users*****
2006年 11月 7日 (火) 16:31:46 JST


Index: xoops2jp/html/modules/stdCache/blocks/cacheclear.php
diff -u xoops2jp/html/modules/stdCache/blocks/cacheclear.php:1.1.2.1.2.3 xoops2jp/html/modules/stdCache/blocks/cacheclear.php:1.1.2.1.2.4
--- xoops2jp/html/modules/stdCache/blocks/cacheclear.php:1.1.2.1.2.3	Tue Nov  7 15:36:19 2006
+++ xoops2jp/html/modules/stdCache/blocks/cacheclear.php	Tue Nov  7 16:31:46 2006
@@ -4,6 +4,14 @@
 
 class Stdcache_CacheclearBlock extends Legacy_BlockProcedure
 {
+	var $_mFilePath = null;
+	
+	function prepare()
+	{
+		$this->_mFilePath = XOOPS_CACHE_PATH . "/" . md5(XOOPS_SALT) . ".cache.html";
+		return parent::prepare();
+	}
+	
 	function execute()
 	{
 		$root =& XCube_Root::getSingleton();
@@ -12,20 +20,57 @@
 			return false;
 		}
 		
-		if($handler = opendir(XOOPS_CACHE_PATH)) {
-			while(($file = readdir($handler)) !== false) {
-				if(preg_match("/\w+\.cache\.html$/", $file, $matches)) {
-					@unlink(XOOPS_CACHE_PATH . "/" . $matches[0]);
+		//
+		// Check timer
+		//
+		$options = explode('|', $this->_mBlock->get('options'));
+		if (!file_exists($this->_mFilePath)) {
+			$this->updateTimer();
+		}
+		
+		if (filemtime($this->_mFilePath) < time() - intval($options[0]) * 60) {
+			if($handler = opendir(XOOPS_CACHE_PATH)) {
+				while(($file = readdir($handler)) !== false) {
+					if(preg_match("/\w+\.cache\.html$/", $file, $matches)) {
+						@unlink(XOOPS_CACHE_PATH . "/" . $matches[0]);
+					}
 				}
+				closedir($handler);
 			}
-			closedir($handler);
+			
+			$this->updateTimer();
 		}
 	}
 	
+	function updateTimer()
+	{
+		$fp = fopen($this->_mFilePath, "wb");
+		fclose ($fp);
+	}
+	
 	function isDisplay()
 	{
 		return false;
 	}
+
+	function getOptionForm()
+	{
+		$options = explode('|', $this->_mBlock->get('options'));
+		
+		$root =& XCube_Root::getSingleton();
+		$renderSystem =& $root->getRenderSystem('Legacy_AdminRenderSystem');
+		$renderTarget =& $renderSystem->createRenderTarget();
+		
+		$renderTarget->setAttribute('legacy_module', 'stdCache');
+		$renderTarget->setTemplateName('block_cacheclear_option.html');
+		$renderTarget->setAttribute('timer', $options[0]);
+
+		//
+		// renderWithTarget() will be renamed to render() in the near future.
+		//		
+		$renderSystem->renderWithTarget($renderTarget);
+		return $renderTarget->getResult();
+	}
 }
 
 ?>
\ No newline at end of file


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