[xoops-cvslog 5724] CVS update: xoops2jp/html/modules/legacy/admin/class

Back to archive index

Minahito minah****@users*****
2006年 11月 9日 (木) 16:21:07 JST


Index: xoops2jp/html/modules/legacy/admin/class/ModuleInstallUtils.class.php
diff -u xoops2jp/html/modules/legacy/admin/class/ModuleInstallUtils.class.php:1.1.2.2 xoops2jp/html/modules/legacy/admin/class/ModuleInstallUtils.class.php:1.1.2.3
--- xoops2jp/html/modules/legacy/admin/class/ModuleInstallUtils.class.php:1.1.2.2	Thu Nov  2 00:02:00 2006
+++ xoops2jp/html/modules/legacy/admin/class/ModuleInstallUtils.class.php	Thu Nov  9 16:21:07 2006
@@ -15,6 +15,76 @@
 class Legacy_ModuleInstallUtils
 {
 	/**
+	 * This is factory for the installer. The factory reads xoops_version
+	 * without modulehandler, to prevent cache in modulehandler.
+	 */
+	function &createInstaller($dirname)
+	{
+		return Legacy_ModuleInstallUtils::_createInstaller($dirname, 'installer', 'Legacy_ModuleInstaller');
+	}
+	
+	/**
+	 * This is factory for the updater. The factory reads xoops_version
+	 * without modulehandler, to prevent cache in modulehandler.
+	 */
+	function &createUpdater($dirname)
+	{
+		return Legacy_ModuleInstallUtils::_createInstaller($dirname, 'updater', 'Legacy_ModulePhasedUpgrader');
+	}
+	
+	/**
+	 * This is factory for the uninstaller. The factory reads xoops_version
+	 * without modulehandler, to prevent cache in modulehandler.
+	 */
+	function &createUninstaller($dirname)
+	{
+		return Legacy_ModuleInstallUtils::_createInstaller($dirname, 'uninstaller', 'Legacy_ModuleUninstaller');
+	}
+	
+	/**
+	 * The generic factory for installers. This function is used by other
+	 * utility functions.
+	 * @param string $dirname
+	 * @param string $mode 'installer' 'updater' or 'uninstaller'
+	 * @param string $defaultClassName
+	 */
+	function &_createInstaller($dirname, $mode, $defaultClassName)
+	{
+		$info = array();
+		
+		$filepath = XOOPS_MODULE_PATH . "/modules/${dirname}/xoops_version.php";
+		if (file_exists($filepath)) {
+			@include $filepath;
+			$info = $modversion;
+		}
+		
+		if (isset($info['legacy_installer']) && is_array($info['legacy_installer']) && isset($info['legacy_installer'][$mode])) {
+			$updateInfo = $info['legacy_installer'][$mode];
+				
+			$className = $updateInfo['class'];
+			$filePath = isset($updateInfo['filepath']) ? $updateInfo['filepath'] : XOOPS_MODULE_PATH . "/${dirname}/admin/class/${className}.class.php";
+			$namespace = isset($updateInfo['namespace']) ? $updateInfo['namespace'] : ucfirst($dirname);
+				
+			if ($namespace != null) {
+				$className = "${namespace}_${className}";
+			}
+				
+			if (!class_exists($className) && file_exists($filePath)) {
+				require_once $filePath;
+			}
+				
+			if (class_exists($className)) {
+				$installer =& new $className();
+				return $installer;
+			}
+		}
+		
+		$installer =& new $defaultClassName();
+		return $installer;
+	}
+	
+	
+	/**
 	 * Executes SQL file which xoops_version of $module specifies. This
 	 * function is usefull for installers, but it's impossible to control
 	 * for detail.
@@ -69,7 +139,7 @@
 	 * 
 	 * This function gets informations about templates from xoops_version.
 	 * 
-	 * @section Attention
+	 * @warning
 	 * 
 	 * This function depends the specific spec of Legacy_RenderSystem, but this
 	 * static function is needed by the 2nd installer of Legacy System.
@@ -93,7 +163,7 @@
 	/**
 	 * Inserts the specified template to DB.
 	 * 
-	 * @section Attention
+	 * @warning
 	 * 
 	 * This function depends the specific spec of Legacy_RenderSystem, but this
 	 * static function is needed by the 2nd installer of Legacy System.
@@ -157,7 +227,7 @@
 	 * 
 	 * This function gets informations about templates from the database.
 	 * 
-	 * @section Attention
+	 * @warning
 	 * 
 	 * This function depends the specific spec of Legacy_RenderSystem, but this
 	 * static function is needed by the 2nd installer of Legacy System.


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