72 public $mInstallSuccess =
null;
77 public $mInstallFail =
null;
83 public $mXoopsModule =
null;
89 public $mInstaller =
null;
95 public $mActionForm =
null;
97 public function __construct($flag)
99 parent::__construct($flag);
102 $this->mInstallSuccess->register(
'Legacy_ModuleInstallAction.InstallSuccess');
105 $this->mInstallFail->register(
'Legacy_ModuleInstallAction.InstallFail');
108 public function prepare(&$controller, &$xoopsUser)
110 $dirname = $controller->mRoot->mContext->mRequest->getRequest(
'dirname');
112 $handler =& xoops_gethandler(
'module');
113 $this->mXoopsModule =& $handler->getByDirname($dirname);
115 if (is_object($this->mXoopsModule)) {
119 $this->mXoopsModule =& $handler->create();
121 $this->mXoopsModule->set(
'weight', 1);
122 $this->mXoopsModule->loadInfoAsVar($dirname);
124 if (
null == $this->mXoopsModule->get(
'dirname')) {
128 if (
'system' == $this->mXoopsModule->get(
'dirname')) {
129 $this->mXoopsModule->set(
'mid', 1);
132 $this->_setupActionForm();
134 $this->mInstaller =& $this->_getInstaller();
139 $this->mInstaller->setCurrentXoopsModule($this->mXoopsModule);
144 public function &_getInstaller()
146 $dirname = $this->mXoopsModule->get(
'dirname');
151 public function _setupActionForm()
154 $this->mActionForm->prepare();
157 public function getDefaultView(&$controller, &$xoopsUser)
159 $this->mActionForm->load($this->mXoopsModule);
161 return LEGACY_FRAME_VIEW_INPUT;
164 public function execute(&$controller, &$xoopsUser)
166 if (isset($_REQUEST[
'_form_control_cancel'])) {
167 return LEGACY_FRAME_VIEW_CANCEL;
170 $this->mActionForm->fetch();
171 $this->mActionForm->validate();
173 if ($this->mActionForm->hasError()) {
174 return $this->getDefaultView($controller, $xoopsUser);
177 $this->mInstaller->setForceMode($this->mActionForm->get(
'force'));
178 if (!$this->mInstaller->executeInstall()) {
179 $this->mInstaller->mLog->addReport(
'Force Uninstallation is started.');
180 $dirname = $this->mXoopsModule->get(
'dirname');
183 $uninstaller->setForceMode(
true);
184 $uninstaller->setCurrentXoopsModule($this->mXoopsModule);
186 $uninstaller->executeUninstall();
189 return LEGACY_FRAME_VIEW_SUCCESS;
200 if (!$this->mInstaller->mLog->hasError()) {
201 $this->mInstallSuccess->call(
new XCube_Ref($this->mXoopsModule),
new XCube_Ref($this->mInstaller->mLog));
202 XCube_DelegateUtils::call(
'Legacy.Admin.Event.ModuleInstall.' . ucfirst($this->mXoopsModule->get(
'dirname') .
'.Success'),
new XCube_Ref($this->mXoopsModule),
new XCube_Ref($this->mInstaller->mLog));
203 XCube_DelegateUtils::call(
'Legacy.Admin.Event.ModuleInstall.Success',
new XCube_Ref($this->mXoopsModule),
new XCube_Ref($this->mInstaller->mLog));
205 $this->mInstallFail->call(
new XCube_Ref($this->mXoopsModule),
new XCube_Ref($this->mInstaller->mLog));
206 XCube_DelegateUtils::call(
'Legacy.Admin.Event.ModuleInstall.' . ucfirst($this->mXoopsModule->get(
'dirname') .
'.Fail'),
new XCube_Ref($this->mXoopsModule),
new XCube_Ref($this->mInstaller->mLog));
207 XCube_DelegateUtils::call(
'Legacy.Admin.Event.ModuleInstall.Fail',
new XCube_Ref($this->mXoopsModule),
new XCube_Ref($this->mInstaller->mLog));
210 $renderer->setTemplateName(
'module_install_success.html');
211 $renderer->setAttribute(
'module', $this->mXoopsModule);
212 $renderer->setAttribute(
'log', $this->mInstaller->mLog->mMessages);
223 $renderer->setTemplateName(
'module_install.html');
224 $renderer->setAttribute(
'module', $this->mXoopsModule);
225 $renderer->setAttribute(
'actionForm', $this->mActionForm);
226 $renderer->setAttribute(
'currentVersion', round($this->mXoopsModule->get(
'version') / 100, 2));
229 public function executeViewCancel(&$controller, &$xoopsUser, &$render)
231 $controller->executeForward(
'./index.php?action=InstallList');