[xoops-cvslog 5545] CVS update: xoops2jp/html/modules/legacy/admin/actions

Zurück zum Archiv-Index

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


Index: xoops2jp/html/modules/legacy/admin/actions/ModuleUpdateAction.class.php
diff -u xoops2jp/html/modules/legacy/admin/actions/ModuleUpdateAction.class.php:1.1.2.5 xoops2jp/html/modules/legacy/admin/actions/ModuleUpdateAction.class.php:1.1.2.6
--- xoops2jp/html/modules/legacy/admin/actions/ModuleUpdateAction.class.php:1.1.2.5	Mon Oct 30 18:52:32 2006
+++ xoops2jp/html/modules/legacy/admin/actions/ModuleUpdateAction.class.php	Wed Nov  1 20:55:09 2006
@@ -10,6 +10,56 @@
 require_once XOOPS_LEGACY_PATH . "/admin/class/ModuleUpdater.class.php";
 require_once XOOPS_LEGACY_PATH . "/admin/forms/ModuleUpdateForm.class.php";
 
+/**
+ * @brief Module Update function having possibility to extend by module developers.
+ * 
+ * The precondition is that the specified module has been installed.
+ * 
+ * @section cupdate The custom-update-installer
+ * 
+ * Module developers can use their own custom-update-installer in this action.
+ * This function uses Legacy_ModulePhasedUpgrader to update moudles. But, this
+ * class can't smart update modules correctly & automatically, because the
+ * module updat function bases on XOOPS2 JP spec. We have no rules to declare
+ * modules strictly.
+ * 
+ * To solve it, module developers should use the custom-update-installer,
+ * because module developers know detail changelog of their module.
+ * 
+ * @subsection convention Convention
+ * 
+ * See Legacy_ModuleUpdateAction::_getInstaller().
+ * 
+ * \li $modversion['legacy_installer']['updater']['class'] = {classname};
+ * \li $modversion['legacy_installer']['updater']['namespace'] = {namespace}; (Optional)
+ * \li $modversion['legacy_installer']['updater']['filepath'] = {filepath}; (Optional)
+ * 
+ * You must declare your sub-class of Legacy_ModulePhasedUpgrader as
+ * {namespace}_{classname} in {filepath}. You must specify classname. Others
+ * are decided by the naming convention without your descriptions. Namespace
+ * is ucfirst(dirname). Filepath is "admin/class/{classname}.class.php".
+ * 
+ * For example, "news" module.
+ * 
+ * $modversion['legacy_installer']['updater']['class'] = "Updater";
+ * 
+ * You must declare News_Updater in XOOPS_ROOT_PATH . "/modules/news/admin/class/Updater.class.php".
+ * 
+ * In the case where you specify the filepath, take care you describe the
+ * filepath with absolute path.
+ * 
+ * @subsection process Install Process
+ * 
+ * \li Gets a instance of the update installer class through Legacy_ModuleUpdateAction::_getInstaller().
+ * \li Sets the current XoopsModule to the instance.
+ * \li Builds the target XoopsModule from xoops_version, and sets it to the instance.
+ * \li Sets a value indicating whether an administrator hopes the force-mode, to the instance.
+ * \li Calls executeUpgrade().
+ * 
+ * @see Legacy_ModuleUpdateAction::_getInstaller()
+ * @see Legacy_ModulePhasedUpgrader
+ * @see Legacy_ModuleInstallUtils
+ */
 class Legacy_ModuleUpdateAction extends Legacy_Action
 {
 	/**
Index: xoops2jp/html/modules/legacy/admin/actions/ModuleUninstallAction.class.php
diff -u xoops2jp/html/modules/legacy/admin/actions/ModuleUninstallAction.class.php:1.1.2.2 xoops2jp/html/modules/legacy/admin/actions/ModuleUninstallAction.class.php:1.1.2.3
--- xoops2jp/html/modules/legacy/admin/actions/ModuleUninstallAction.class.php:1.1.2.2	Sun Oct 15 00:55:35 2006
+++ xoops2jp/html/modules/legacy/admin/actions/ModuleUninstallAction.class.php	Wed Nov  1 20:55:09 2006
@@ -10,24 +10,83 @@
 require_once XOOPS_LEGACY_PATH . "/admin/class/ModuleUninstaller.class.php";
 require_once XOOPS_LEGACY_PATH . "/admin/forms/ModuleUninstallForm.class.php";
 
+
 /**
- * Uninstall module
+ * @brief Module Uninstall function having possibility to extend by module developers.
+ * 
+ * The precondition is that the specified module has been installed && none-actived.
+ * 
+ * @section cuninstall The custom-uninstaller
+ * 
+ * Module developers can use their own custom-uninstaller in this action.
+ * Unlike the module update function, the standard uninstaller in this action
+ * is perhaps no problems. But, duplicatable modules or some modules with the
+ * special framework may need the custom-uninstaller.
+ * 
+ * @subsection convention Convention
+ * 
+ * See Legacy_ModuleUninstallAction::_getInstaller().
+ * 
+ * \li $modversion['legacy_installer']['uninstaller']['class'] = {classname};
+ * \li $modversion['legacy_installer']['uninstaller']['namespace'] = {namespace}; (Optional)
+ * \li $modversion['legacy_installer']['uninstaller']['filepath'] = {filepath}; (Optional)
+ * 
+ * You must declare your sub-class of Legacy_ModuleUninstaller as
+ * {namespace}_{classname} in {filepath}. You must specify classname. Others
+ * are decided by the naming convention without your descriptions. Namespace
+ * is ucfirst(dirname). Filepath is "admin/class/{classname}.class.php".
+ * 
+ * For example, "news" module.
+ * 
+ * $modversion['legacy_installer']['uninstaller']['class'] = "Uninstaller";
+ * 
+ * You must declare News_Uninstaller in XOOPS_ROOT_PATH . "/modules/news/admin/class/Uninstallerr.class.php".
+ * 
+ * In the case where you specify the filepath, take care you describe the
+ * filepath with absolute path.
+ * 
+ * @subsection process Uninstall Process
+ * 
+ * \li Gets a instance of the uninstaller class through Legacy_ModuleUninstallAction::_getInstaller().
+ * \li Sets the current XoopsModule to the instance.
+ * \li Sets a value indicating whether an administrator hopes the force-mode, to the instance.
+ * \li Calls executeUninstall().
+ * 
+ * @see Legacy_ModuleUpdateAction::_getInstaller()
+ * @see Legacy_ModuleUninstaller
+ * @see Legacy_ModuleInstallUtils
+ * 
+ * @todo These classes are good to abstract again.
  */
-class Legacy_ModuleUninstallAction extends Legacy_AbstractModuleInstallAction
+class Legacy_ModuleUninstallAction extends Legacy_Action
 {
 	/**
+	 * @private
 	 * @var XCube_Delegate
 	 */
 	var $mUninstallSuccess = null;
 	
 	/**
+	 * @private
 	 * @var XCube_Delegate
 	 */
 	var $mUninstallFail = null;
 	
+	/**
+	 * @private
+	 * @var XoopsModule
+	 */
+	var $mXoopsModule = null;
+	
+	/**
+	 * @private
+	 * @var Legacy_ModuleUinstaller
+	 */
+	var $mInstaller = null;
+	
 	function Legacy_ModuleUninstallAction($flag)
 	{
-		parent::Legacy_AbstractModuleInstallAction($flag);
+		parent::Legacy_Action($flag);
 		
 		$this->mUninstallSuccess =& new XCube_Delegate();
 		$this->mUninstallSuccess->register('Legacy_ModuleUninstallAction.UninstallSuccess');
@@ -36,9 +95,58 @@
 		$this->mUninstallFail->register('Legacy_ModuleUninstallAction.UninstallFail');
 	}
 
-	function &_getInstaller($dirname)
+	function prepare(&$controller, &$xoopsUser)
 	{
-		$installer =& new Legacy_ModuleUninstaller($dirname);
+		$dirname = $controller->mRoot->mContext->mRequest->getRequest('dirname');
+		
+		$handler =& xoops_gethandler('module');
+		$this->mXoopsModule =& $handler->getByDirname($dirname);
+		
+		if (!(is_object($this->mXoopsModule) && $this->mXoopsModule->get('isactive') == 0)) {
+			return false;
+		}
+		
+		$this->_setupActionForm();
+		
+		$this->mInstaller =& $this->_getInstaller();
+		
+		//
+		// Set the current object.
+		//
+		$this->mInstaller->setCurrentXoopsModule($this->mXoopsModule);
+		
+		return true;
+	}
+	
+	function &_getInstaller()
+	{
+		$dirname = $this->mXoopsModule->get('dirname');
+		$this->mXoopsModule->loadInfo($dirname, false);
+
+		$info = $this->mXoopsModule->modinfo;
+			
+		if (isset($info['legacy_installer']) && is_array($info['legacy_installer']) && isset($info['legacy_installer']['uninstaller'])) {
+			$updateInfo = $info['legacy_installer']['uninstaller'];
+				
+			$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 Legacy_ModuleUninstaller();
 		return $installer;
 	}
 	
@@ -48,32 +156,54 @@
 		$this->mActionForm->prepare();
 	}
 
+	function getDefaultView(&$controller, &$xoopsUser)
+	{
+		$this->mActionForm->load($this->mXoopsModule);
+		
+		return LEGACY_FRAME_VIEW_INPUT;
+	}
+
+	function execute(&$controller, &$xoopsUser)
+	{
+		if (isset($_REQUEST['_form_control_cancel'])) {
+			return LEGACY_FRAME_VIEW_CANCEL;
+		}
+		
+		$this->mActionForm->fetch();
+		$this->mActionForm->validate();
+		
+		if ($this->mActionForm->hasError()) {
+			return $this->getDefaultView($controller, $xoopsUser);
+		}
+		
+		$this->mInstaller->setForceMode($this->mActionForm->get('force'));
+		$this->mInstaller->executeUninstall();
+
+		return LEGACY_FRAME_VIEW_SUCCESS;
+	}
+	
 	function executeViewSuccess(&$controller, &$xoopsUser, &$renderer)
 	{
-		if (!$this->mLog->hasError()) {
-			$this->mUninstallSuccess->call(new XCube_Ref($this->mModuleObject), new XCube_Ref($this->mLog));
-			XCube_DelegateUtils::call('Legacy.Admin.Event.ModuleUninstall.' . ucfirst($this->mModuleObject->get('dirname') . '.Success'), new XCube_Ref($this->mModuleObject), new XCube_Ref($this->mLog));
+		if (!$this->mInstaller->mLog->hasError()) {
+			$this->mUninstallSuccess->call(new XCube_Ref($this->mXoopsModule), new XCube_Ref($this->mInstaller->mLog));
+			XCube_DelegateUtils::call('Legacy.Admin.Event.ModuleUninstall.' . ucfirst($this->mXoopsModule->get('dirname') . '.Success'), new XCube_Ref($this->mXoopsModule), new XCube_Ref($this->mInstaller->mLog));
 		}
 		else {
-			$this->mUninstallFail->call(new XCube_Ref($this->mModuleObject), new XCube_Ref($this->mLog));
-			XCube_DelegateUtils::call('Legacy.Admin.Event.ModuleUninstall.' . ucfirst($this->mModuleObject->get('dirname') . '.Fail'), new XCube_Ref($this->mModuleObject), new XCube_Ref($this->mLog));
+			$this->mUninstallFail->call(new XCube_Ref($this->mXoopsModule), new XCube_Ref($this->mInstaller->mLog));
+			XCube_DelegateUtils::call('Legacy.Admin.Event.ModuleUninstall.' . ucfirst($this->mXoopsModule->get('dirname') . '.Fail'), new XCube_Ref($this->mXoopsModule), new XCube_Ref($this->mInstaller->mLog));
 		}
 
 		$renderer->setTemplateName("module_uninstall_success.html");
-		$renderer->setAttribute('module',$this->mModuleObject);
-		$renderer->setAttribute('log', $this->mLog->mMessages);
+		$renderer->setAttribute('module',$this->mXoopsModule);
+		$renderer->setAttribute('log', $this->mInstaller->mLog->mMessages);
 	}
 
-	function executeViewIndex(&$controller, &$xoopsUser, &$renderer)
+	function executeViewInput(&$controller, &$xoopsUser, &$renderer)
 	{
 		$renderer->setTemplateName("module_uninstall.html");
 		$renderer->setAttribute('actionForm', $this->mActionForm);
-		$renderer->setAttribute('module', $this->mModuleObject);
-	}
-
-	function executeViewInput(&$controller, &$xoopsUser, &$renderer)
-	{
-		$this->executeViewIndex(&$controller, &$xoopsUser, &$renderer);
+		$renderer->setAttribute('module', $this->mXoopsModule);
+		$renderer->setAttribute('currentVersion', round($this->mXoopsModule->get('version') / 100, 2));
 	}
 
 	function executeViewCancel(&$controller, &$xoopsUser, &$renderer)


xoops-cvslog メーリングリストの案内
Zurück zum Archiv-Index