[xoops-cvslog 1733] CVS update: xoops2jp/html/modules/legacyRender/class

Back to archive index

Minahito minah****@users*****
2006年 1月 14日 (土) 14:29:38 JST


Index: xoops2jp/html/modules/legacyRender/class/theme.php
diff -u xoops2jp/html/modules/legacyRender/class/theme.php:1.1.2.2 xoops2jp/html/modules/legacyRender/class/theme.php:1.1.2.3
--- xoops2jp/html/modules/legacyRender/class/theme.php:1.1.2.2	Fri Jan 13 01:22:56 2006
+++ xoops2jp/html/modules/legacyRender/class/theme.php	Sat Jan 14 14:29:38 2006
@@ -54,6 +54,84 @@
 			return $obj;
 		}
 	}
+
+	/**
+	 * Search themes that Legacy_RenderSystem can render in file system, then register by handler.
+	 */	
+	function searchThemes()
+	{
+		$themeList = array();
+		
+		if($handler=opendir(XOOPS_THEME_PATH)) {
+			while(($dir=readdir($handler))!==false) {
+				if($dir=="." || $dir=="..") {
+					continue;
+				}
+
+				$themeDir=XOOPS_THEME_PATH."/".$dir;
+				if(is_dir($themeDir)) {
+					$mnfFile=$themeDir."/package.ini.php";
+					if(file_exists($mnfFile)) {
+						$manifesto=parse_ini_file($mnfFile,true);
+						
+						//
+						// If this system can use this theme, add this to list.
+						//
+						if(isset($manifesto['Manifesto']) && isset($manifesto['Manifesto']['Depends']) && $manifesto['Manifesto']['Depends'] == "Legacy_RenderSystem") {
+							$themeList[]=$dir;
+						}
+					}
+					else {
+						$file=$themeDir."/theme.html";
+						if(file_exists($file)) {
+							$themeList[]=$dir;
+						}
+					}
+				}
+			}
+			closedir($handler);
+		}
+		
+		return $themeList;
+	}
+	
+	function updateThemeList()
+	{
+		$diskThemeNames = $this->searchThemes();
+		$DBthemes =& $this->getObjects();
+
+		//
+		// At first, check new theme.
+		//		
+		foreach ($diskThemeNames as $name) {
+			$findFlag = false;
+			foreach ($DBthemes as $theme) {
+				if ($theme->get('name') == $name) {
+					$findFlag = true;
+					break;
+				}
+			}
+			
+			//
+			// If $findFlag is false, $name is new theme that is not registered to DB, yet.
+			//
+			if (!$findFlag) {
+				$obj =& $this->create();
+				$obj->set('name', $name);
+				$this->insert($obj, true);
+			}
+		}
+		
+		//
+		//  Next, check themes that we got from DB. If it had removed from disk system,
+		// We also have to remove from DB.
+		//
+		foreach ($DBthemes as $theme) {
+			if (!in_array($theme->get('name'), $diskThemeNames)) {
+				$this->delete($theme, true);
+			}
+		}
+	}
 }
 
 ?>


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