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

Back to archive index

Minahito minah****@users*****
2006年 11月 1日 (水) 20:54:23 JST


Index: xoops2jp/html/modules/legacy/admin/class/ModuleUpdater.class.php
diff -u xoops2jp/html/modules/legacy/admin/class/ModuleUpdater.class.php:1.1.2.8 xoops2jp/html/modules/legacy/admin/class/ModuleUpdater.class.php:1.1.2.9
--- xoops2jp/html/modules/legacy/admin/class/ModuleUpdater.class.php:1.1.2.8	Wed Nov  1 00:03:39 2006
+++ xoops2jp/html/modules/legacy/admin/class/ModuleUpdater.class.php	Wed Nov  1 20:54:22 2006
@@ -1,11 +1,44 @@
 <?php
+/**
+ * @package Legacy
+ * @version $Id$
+ */
 
 if (!defined('XOOPS_ROOT_PATH')) exit();
 
-require_once XOOPS_LEGACY_PATH."/admin/class/AbstractModuleInstaller.class.php";
+require_once XOOPS_LEGACY_PATH . "/admin/class/ModuleUtils.class.php";
+require_once XOOPS_LEGACY_PATH . "/admin/class/ModuleInstallUtils.class.php";
 
 /**
- * This class is a framework for phased updating.
+ * @brief The framework for the phased update.
+ * 
+ * @section Description
+ * 
+ * You can make your own custom-update-installer for your modules with the
+ * sub-class of this class. It's easy to make by many utility functions. You
+ * can write your sub-class as well as batch files.
+ * 
+ * On Legacy System module, upgrade is called when users try to update. So you
+ * must implement your sub-class for also correct update. For example, the
+ * custom-update-install have to update module templates & block templates,
+ * because users expect that the module-update function does it.
+ * 
+ * For the custom-update-install, Legacy_ModuleInstallUtils is good for you.
+ * Plus, this class has some usefull static methods for upgrade. Such functions
+ * have notes as "The utility method for the custom-update-installer".
+ * 
+ * And, this class as the template-pattern has some methods you may override.
+ * These methods have note as "You may do custom".
+ * 
+ * @section Convention
+ * 
+ * Module Update function build the current-$xoopsModule from DB, and then sets
+ * it to this class through setCurrentXoopsModule(). Basically, you can access
+ * it by $this->_mCurrentXoopsModule. And, that function build the
+ * target-$xoopsModule from xoops_version, and then set it to this class through
+ * setTargetXoopsModule(). Also you can access it by $this->_mTargetXoopsModule.
+ * 
+ * @see Legacy_ModuleInstallUtils
  */
 class Legacy_ModulePhasedUpgrader
 {
@@ -77,7 +110,7 @@
 	 * the _mCurrentVersion as backup for the case where the value of this
 	 * object is changed for updating.
 	 * 
-	 * @access public
+	 * @public
 	 * @param XoopsModule $xoopsModule
 	 */
 	function setCurrentXoopsModule(&$xoopsModule)
@@ -254,6 +287,41 @@
 	}
 	
 	/**
+	 * Updates all of module templates.
+	 * 
+	 * @access protected
+	 * @note You may do custom
+	 */
+	function _updateModuleTemplates()
+	{
+		Legacy_ModuleInstallUtils::uninstallAllOfModuleTemplates($this->_mTargetXoopsModule, $this->mLog);
+		Legacy_ModuleInstallUtils::installAllModuleTemplates($this->_mTargetXoopsModule, $this->mLog);
+	}
+	
+	/**
+	 * Updates all of blocks.
+	 * 
+	 * @access protected
+	 * @note You may do custom
+	 */
+	function _updateBlocks()
+	{
+		Legacy_ModuleInstallUtils::uninstallAllOfBlocks($this->_mTargetXoopsModule, $this->mLog);
+		Legacy_ModuleInstallUtils::installAllOfBlocks($this->_mTargetXoopsModule, $this->mLog);
+	}
+	
+	/**
+	 * Updates all of preferences & notifications.
+	 * 
+	 * @access protected
+	 * @note You may do custom
+	 */
+	function _updatePreferences()
+	{
+		$this->_upgradePreference();
+	}
+	
+	/**
 	 * This method executes upgrading automatically by the diff of
 	 * xoops_version.
 	 * 
@@ -267,18 +335,9 @@
 		$this->mLog->addReport(_AD_LEGACY_MESSAGE_UPDATE_STARTED);
 		
 		//
-		// Uninstall all of existed module templates
-		//
-		Legacy_ModuleUtils::uninstallAllModuleTemplates($this->_mTargetXoopsModule, $this->mLog);
-		if (!$this->_mForceMode && $this->mLog->hasError()) {
-			$this->_processReport();
-			return false;
-		}
-		
-		//
-		// Install all of module templates.
+		// Updates all of module templates
 		//
-		Legacy_ModuleUtils::installAllModuleTemplates($this->_mTargetXoopsModule, $this->mLog);
+		$this->_updateTemplates();
 		if (!$this->_mForceMode && $this->mLog->hasError()) {
 			$this->_processReport();
 			return false;
@@ -287,8 +346,7 @@
 		//
 		// Update blocks.
 		//
-		Legacy_ModuleUtils::uninstallAllBlocks($this->_mTargetXoopsModule, $this->mLog);
-		Legacy_ModuleUtils::installAllBlocks($this->_mTargetXoopsModule, $this->mLog);
+		$this->_updateBlocks();
 		if (!$this->_mForceMode && $this->mLog->hasError()) {
 			$this->_processReport();
 			return false;
@@ -297,7 +355,7 @@
 		//
 		// Update preferences & notifications.
 		//
-		$this->_upgradePreference();
+		$this->_updatePreferences();
 		if (!$this->_mForceMode && $this->mLog->hasError()) {
 			$this->_processReport();
 			return false;
@@ -322,7 +380,14 @@
 		return true;
 	}
 
-	function _upgradePreference()
+	/**
+	 * Tries to smart update all of preferences & notifications.
+	 * 
+	 * @todo This method is perhaps uncompleted. If you have written more smart
+	 *       function, please contribute it to us.
+	 * @note The utility method for the custom-update-installer.
+	 */
+	function _upgradePreferences()
 	{
 		$configHandler =& xoops_gethandler('config');
 		


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