Minahito
minah****@users*****
2006年 8月 21日 (月) 18:59:02 JST
Index: xoops2jp/html/modules/base/admin/class/ModuleUtils.class.php diff -u xoops2jp/html/modules/base/admin/class/ModuleUtils.class.php:1.1.2.21 xoops2jp/html/modules/base/admin/class/ModuleUtils.class.php:1.1.2.22 --- xoops2jp/html/modules/base/admin/class/ModuleUtils.class.php:1.1.2.21 Mon Aug 14 10:59:26 2006 +++ xoops2jp/html/modules/base/admin/class/ModuleUtils.class.php Mon Aug 21 18:59:02 2006 @@ -160,8 +160,9 @@ $filePath = XOOPS_MODULE_PATH . "/" . $dirname . "/templates/" . $fileName; } - if (!file_exists($filePath) && is_file($filePath)) + if (!file_exists($filePath)) { return false; + } $lines = file($filePath); if ($lines == false) { Index: xoops2jp/html/modules/base/admin/class/ModuleUninstaller.class.php diff -u xoops2jp/html/modules/base/admin/class/ModuleUninstaller.class.php:1.1.2.11 xoops2jp/html/modules/base/admin/class/ModuleUninstaller.class.php:1.1.2.12 --- xoops2jp/html/modules/base/admin/class/ModuleUninstaller.class.php:1.1.2.11 Thu Aug 10 12:56:11 2006 +++ xoops2jp/html/modules/base/admin/class/ModuleUninstaller.class.php Mon Aug 21 18:59:02 2006 @@ -6,17 +6,18 @@ class Legacy_ModuleUninstaller extends Legacy_AbstractModuleInstaller { - /** - * @var XCube_Delegate - */ - var $mProcessScript = null; - function Legacy_ModuleUninstaller($dirname) { parent::Legacy_AbstractModuleInstaller($dirname); - $this->mProcessScript =& new XCube_Delegate(); $this->mProcessScript->register('Legacy_ModuleUninstaller.ProcessScript'); + $this->mProcessScript->add('Legacy_ModuleUninstaller::_processScript'); + + $this->mInstallTable->register('Legacy_ModuleInstaller.InstallTable'); + $this->mInstallTable->add('Legacy_ModuleUninstaller::_uninstallTable'); + + $this->mInstallTemplate->register('Legacy_ModuleUninstaller.InstallTemplate'); + $this->mInstallTemplate->add('Legacy_ModuleUninstaller::_uninstallTemplate'); } /** @@ -63,23 +64,23 @@ /** * Drop table because this class is uninstaller. */ - function _installTable() + function _uninstallTable(&$module, &$log) { $root =& XCube_Root::getSingleton(); $db =& $root->mController->getDB(); - $tables = $this->mModule->getInfo('tables'); + $tables = $module->getInfo('tables'); if ($tables != false && is_array($tables)) { foreach($tables as $table) { - + // // TODO Do we need to check reserved core tables? - + // $sql = "DROP TABLE " . $db->prefix($table); if ($db->query($sql)) { - $this->mLog->addReport(XCube_Utils::formatMessage(_AD_BASE_MESSAGE_DROP_TABLE, $db->prefix($table))); + $log->addReport(XCube_Utils::formatMessage(_AD_BASE_MESSAGE_DROP_TABLE, $db->prefix($table))); } else { - $this->mLog->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_DROP_TABLE, $db->prefix($table))); + $log->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_DROP_TABLE, $db->prefix($table))); } } } @@ -88,15 +89,15 @@ /** * Delete template because this class is uninstaller. */ - function _installTemplate() + function _uninstallTemplate(&$module, &$log) { $tplHandler =& xoops_gethandler('tplfile'); - $deleteTemplates =& $tplHandler->find(null, 'module', $this->mModule->getVar('mid')); + $deleteTemplates =& $tplHandler->find(null, 'module', $module->getVar('mid')); foreach($deleteTemplates as $tpl) { if (!$tplHandler->delete($tpl)) { - $this->mLog->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_TEMPLATE_UNINSTALLED, $tpl->getVar('tpl_file'))); + $log->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_TEMPLATE_UNINSTALLED, $tpl->getVar('tpl_file'))); } } } @@ -138,20 +139,18 @@ Legacy_ModuleUtils::deleteAllConfigs($this->mModule, $this->mLog); } - function _processScript() + function _processScript(&$module, &$log) { - $installScript = trim($this->mModule->getInfo('onUninstall')); + $installScript = trim($module->getInfo('onUninstall')); if ($installScript != false) { - require_once XOOPS_MODULE_PATH . "/" . $this->mModule->getVar('dirname') . "/" . $installScript; - $funcName = 'xoops_module_uninstall_' . $this->mModule->getVar('dirname'); + require_once XOOPS_MODULE_PATH . "/" . $module->getVar('dirname') . "/" . $installScript; + $funcName = 'xoops_module_uninstall_' . $module->getVar('dirname'); if (function_exists($funcName)) { - if (!call_user_func($funcName, $this->mModule)) { - $this->mLog->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_FAILED_TO_EXECUTE_CALLBACK, $funcName)); + if (!call_user_func($funcName, $module)) { + $log->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_FAILED_TO_EXECUTE_CALLBACK, $funcName)); } } } - - $this->mProcessScript->call(new XCube_Ref($this->mModule), new XCube_Ref($this->mLog)); } function _processReport() Index: xoops2jp/html/modules/base/admin/class/ModuleUpdater.class.php diff -u xoops2jp/html/modules/base/admin/class/ModuleUpdater.class.php:1.1.2.10 xoops2jp/html/modules/base/admin/class/ModuleUpdater.class.php:1.1.2.11 --- xoops2jp/html/modules/base/admin/class/ModuleUpdater.class.php:1.1.2.10 Thu Aug 10 12:56:11 2006 +++ xoops2jp/html/modules/base/admin/class/ModuleUpdater.class.php Mon Aug 21 18:59:02 2006 @@ -8,17 +8,17 @@ { var $mPreVersion = 0; - /** - * @var XCube_Delegate - */ - var $mProcessScript = null; - function Legacy_ModuleUpdater($dirname) { parent::Legacy_AbstractModuleInstaller($dirname); - $this->mProcessScript =& new XCube_Delegate(); $this->mProcessScript->register('Legacy_ModuleUpdater.ProcessScript'); + $this->mProcessScript->add(array(&$this, '_processScript')); + + $this->mInstallTable->register('Legacy_ModuleUpdater.InstallTable'); + + $this->mInstallTemplate->register('Legacy_ModuleUpdater.InstallTemplate'); + $this->mInstallTemplate->add('Legacy_ModuleUpdater::_uninstallTemplate'); } /** @@ -56,9 +56,9 @@ } /** - * Remove all of installed templates and re-install all of defined templates. + * @static */ - function _installTemplate() + function _uninstallTemplate(&$module, &$log) { $tplHandler =& xoops_gethandler('tplfile'); @@ -66,17 +66,17 @@ // The following processing depends on the structure of Legacy_RenderSystem. // $tplHandler =& xoops_gethandler('tplfile'); - $delTemplates =& $tplHandler->find('default', 'module', $this->mModule->getVar('mid')); + $delTemplates =& $tplHandler->find('default', 'module', $module->getVar('mid')); if(is_array($delTemplates) && count($delTemplates) > 0) { // // clear cache // $xoopsTpl=new XoopsTpl(); - $xoopsTpl->clear_cache(null, "mod_" . $this->mModule->getVar('dirname')); + $xoopsTpl->clear_cache(null, "mod_" . $module->getVar('dirname')); foreach ($delTemplates as $tpl) { if (!$tplHandler->delete($tpl)) { - $this->mLog->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_TEMPLATE_UNINSTALLED, $tpl->getVar('tpl_file'))); + $log->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_TEMPLATE_UNINSTALLED, $tpl->getVar('tpl_file'))); } } } @@ -84,10 +84,10 @@ // // install Template All // - $templates = $this->mModule->getInfo('templates'); + $templates = $module->getInfo('templates'); if ($templates != false) { foreach ($templates as $template) { - Legacy_ModuleUtils::installTemplate($this->mModule, $template, $this->mLog); + Legacy_ModuleUtils::installTemplate($module, $template, $log); } } } @@ -181,20 +181,18 @@ Legacy_ModuleUtils::insertAllConfigs($this->mModule, $this->mLog); } - function _processScript() + function _processScript(&$module, &$log) { - $installScript = trim($this->mModule->getInfo('onUpdate')); + $installScript = trim($module->getInfo('onUpdate')); if ($installScript != false) { - require_once XOOPS_MODULE_PATH . "/" . $this->mModule->getVar('dirname') . "/" . $installScript; - $funcName = 'xoops_module_update_' . $this->mModule->getVar('dirname'); + require_once XOOPS_MODULE_PATH . "/" . $module->getVar('dirname') . "/" . $installScript; + $funcName = 'xoops_module_update_' . $module->getVar('dirname'); if (function_exists($funcName)) { - if (!call_user_func($funcName, $this->mModule, $this->mPreVersion)) { - $this->mLog->addError("Failed to execute " . $funcName); + if (!call_user_func($funcName, $module, $this->mPreVersion)) { + $log->addError("Failed to execute " . $funcName); } } } - - $this->mProcessScript->call(new XCube_Ref($this->mModule), new XCube_Ref($this->mLog)); } function _processReport() Index: xoops2jp/html/modules/base/admin/class/ModuleInstaller.class.php diff -u xoops2jp/html/modules/base/admin/class/ModuleInstaller.class.php:1.1.2.17 xoops2jp/html/modules/base/admin/class/ModuleInstaller.class.php:1.1.2.18 --- xoops2jp/html/modules/base/admin/class/ModuleInstaller.class.php:1.1.2.17 Thu Aug 17 16:42:35 2006 +++ xoops2jp/html/modules/base/admin/class/ModuleInstaller.class.php Mon Aug 21 18:59:02 2006 @@ -12,17 +12,18 @@ { var $mAgree = false; - /** - * @var XCube_Delegate - */ - var $mProcessScript = null; - function Legacy_ModuleInstaller($dirname) { parent::Legacy_AbstractModuleInstaller($dirname); - $this->mProcessScript =& new XCube_Delegate(); $this->mProcessScript->register('Legacy_ModuleInstaller.ProcessScript'); + $this->mProcessScript->add('Legacy_ModuleInstaller::_processScript'); + + $this->mInstallTable->register('Legacy_ModuleInstaller.InstallTable'); + $this->mInstallTable->add('Legacy_ModuleUtils::installTable'); + + $this->mInstallTemplate->register('Legacy_ModuleInstaller.InstallTemplate'); + $this->mInstallTemplate->add('Legacy_ModuleInstaller::_installTemplate'); } /** @@ -156,20 +157,18 @@ return $perm; } - function _installTable() - { - Legacy_ModuleUtils::installTable($this->mModule, $this->mLog); - } - - function _installTemplate() - { - $templates = $this->mModule->getInfo('templates'); + /** + * @static + */ + function _installTemplate(&$module, &$log) + { + $templates = $module->getInfo('templates'); if ($templates != false) { foreach ($templates as $template) { - Legacy_ModuleUtils::installTemplate($this->mModule, $template, $this->mLog); + Legacy_ModuleUtils::installTemplate($module, $template, $log); } } - } + } function _installBlock() { @@ -198,20 +197,18 @@ Legacy_ModuleUtils::insertAllConfigs($this->mModule, $this->mLog); } - function _processScript() + function _processScript(&$module, &$log) { - $installScript = trim($this->mModule->getInfo('onInstall')); + $installScript = trim($module->getInfo('onInstall')); if ($installScript != false) { - require_once XOOPS_MODULE_PATH . "/" . $this->mModule->getVar('dirname') . "/" . $installScript; - $funcName = 'xoops_module_install_' . $this->mModule->getVar('dirname'); + require_once XOOPS_MODULE_PATH . "/" . $module->getVar('dirname') . "/" . $installScript; + $funcName = 'xoops_module_install_' . $module->getVar('dirname'); if (function_exists($funcName)) { - if (!call_user_func($funcName, $this->mModule)) { - $this->mLog->addError(XCUbe_Utils::formatMessage(_AD_BASE_ERROR_FAILED_TO_EXECUTE_CALLBACK, $funcName)); + if (!call_user_func($funcName, $module)) { + $log->addError(XCUbe_Utils::formatMessage(_AD_BASE_ERROR_FAILED_TO_EXECUTE_CALLBACK, $funcName)); } } } - - $this->mProcessScript->call(new XCube_Ref($this->mModule), new XCube_Ref($this->mLog)); } function _processReport()