[xoops-cvslog 1578] CVS update: xoops2jp/html/modules/stdCache/kernel

Back to archive index

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


Index: xoops2jp/html/modules/stdCache/kernel/StdRenderCache.class.php
diff -u /dev/null xoops2jp/html/modules/stdCache/kernel/StdRenderCache.class.php:1.1.2.1
--- /dev/null	Thu Jan  5 17:52:33 2006
+++ xoops2jp/html/modules/stdCache/kernel/StdRenderCache.class.php	Thu Jan  5 17:52:33 2006
@@ -0,0 +1,81 @@
+<?php
+// $Id: StdRenderCache.class.php,v 1.1.2.1 2006/01/05 08:52:33 minahito Exp $
+
+require_once XOOPS_ROOT_PATH . "/kernel/XCube_RenderCache.class.php";
+
+/**
+ * This is standard render cache class. It makes cash by a group of a user.
+ * Therefore cash does not collide, but a cache file is made a lot.
+ *
+ * The processing should be limited so that this class gives standard.
+ * For example, this makes cash only for a guest with registered user.
+ */
+class StdRenderCache extends XCube_RenderCache
+{
+	var $mGroupIds = array();
+	
+	function StdRenderCache()
+	{
+		parent::XCube_RenderCache();
+		
+		$root =& XCube_Root::getSingleton();
+
+		$user =& $root->mController->mXoopsUser;
+
+		$groups = is_object($user) ? $user->getGroups() : XOOPS_GROUP_ANONYMOUS;
+		$this->_setGroupIds($groups);
+	}
+
+	/**
+	 * @return bool
+	 */
+	function isCache($cachetime = null)
+	{
+		if ($cachetime === 0) {
+			return false;
+		}
+		
+		$filename = XOOPS_CACHE_PATH . "/" . $this->getCacheId() . ".cache.html";
+		if (!file_exists($filename)) {
+			return false;
+		}
+		
+		if($cachetime === null) {
+			return true;
+		}
+
+		//
+		// Check expire
+		//
+		$time = time() - filemtime($filename);
+		if ($time > $cachetime) {
+			return false;
+		}
+
+		return true;
+	}
+	
+	function _setGroupIds($ids)
+	{
+		if (is_array($ids)) {
+			sort($ids);
+			$this->mGroupIds = $ids;
+		}
+		else {
+			$this->mGroupIds = array();
+			$this->mGroupIds[] = $ids;
+		}
+	}
+
+	function getCacheId()
+	{
+		return md5($this->mResourceName . implode("_", $this->mGroupIds));
+	}
+
+	function _getFileName()
+	{
+		return XOOPS_CACHE_PATH . "/" . $this->getCacheId() . ".cache.html";
+	}
+}
+
+?>
\ No newline at end of file


xoops-cvslog メーリングリストの案内
Back to archive index