20 public $mModuleObjects = [];
21 public $mFilter =
null;
23 public $mActionForm =
null;
25 public function prepare(&$controller, &$xoopsUser)
28 $this->mActionForm->prepare();
32 public function getDefaultView(&$controller, &$xoopsUser)
35 $this->mFilter->fetch();
37 $moduleHandler =& xoops_gethandler(
'module');
38 $this->mModuleObjects =& $moduleHandler->getObjects($this->mFilter->getCriteria());
40 return LEGACY_FRAME_VIEW_INDEX;
43 public function execute(&$controller, &$xoopsUser)
45 $form_cancel = $controller->mRoot->mContext->mRequest->getRequest(
'_form_control_cancel');
46 if (
null !== $form_cancel) {
47 return LEGACY_FRAME_VIEW_CANCEL;
50 $this->mActionForm->fetch();
51 $this->mActionForm->validate();
53 if ($this->mActionForm->hasError()) {
54 return $this->_processConfirm($controller, $xoopsUser);
56 $result = $this->_processSave($controller, $xoopsUser);
57 if (LEGACY_FRAME_VIEW_SUCCESS === $result) {
58 XCube_DelegateUtils::call(
'Legacy.Admin.Event.ModuleListSave.Success',
new XCube_Ref($this->mActionForm));
60 XCube_DelegateUtils::call(
'Legacy.Admin.Event.ModuleListSave.Fail',
new XCube_Ref($this->mActionForm));
66 public function _processConfirm(&$controller, &$xoopsUser)
68 $moduleHandler =& xoops_gethandler(
'module');
69 $t_objectArr =& $moduleHandler->getObjects();
74 foreach ($t_objectArr as $module) {
75 $this->mModuleObjects[$module->get(
'mid')] =& $module;
79 return LEGACY_FRAME_VIEW_INPUT;
82 public function _processSave(&$controller, &$xoopsUser)
84 $moduleHandler =& xoops_gethandler(
'module');
85 $blockHandler =& xoops_gethandler(
'block');
86 $t_objectArr =& $moduleHandler->getObjects();
89 foreach ($t_objectArr as $module) {
90 $mid = $module->get(
'mid');
91 $olddata[
'name'] = $module->get(
'name');
92 $olddata[
'weight'] = $module->get(
'weight');
93 $olddata[
'isactive'] = $module->get(
'isactive');
94 $newdata[
'name'] = $this->mActionForm->get(
'name', $mid);
95 $newdata[
'weight'] = $this->mActionForm->get(
'weight', $mid);
96 $newdata[
'isactive'] = $this->mActionForm->get(
'isactive', $mid);
97 if (count(array_diff_assoc($olddata, $newdata)) > 0) {
98 $module->set(
'name', $this->mActionForm->get(
'name', $mid));
99 $module->set(
'weight', $this->mActionForm->get(
'weight', $mid));
100 $module->set(
'isactive', $this->mActionForm->get(
'isactive', $mid));
105 if ($moduleHandler->insert($module)) {
106 $successFlag &=
true;
107 $blockHandler->syncIsActive($module->get(
'mid'), $module->get(
'isactive'));
109 $successFlag =
false;
114 return $successFlag ? LEGACY_FRAME_VIEW_SUCCESS : LEGACY_FRAME_VIEW_ERROR;
125 $render->setTemplateName(
'module_list_confirm.html');
126 $render->setAttribute(
'moduleObjects', $this->mModuleObjects);
127 $render->setAttribute(
'actionForm', $this->mActionForm);
133 $t_arr = $this->mActionForm->get(
'name');
134 $render->setAttribute(
'mids', array_keys($t_arr));
137 public function executeViewIndex(&$controller, &$xoopsUser, &$render)
139 $render->setTemplateName(
'module_list.html');
140 $render->setAttribute(
'actionForm', $this->mActionForm);
145 foreach (array_keys($this->mModuleObjects) as $key) {
146 $this->mModuleObjects[$key]->loadInfo($this->mModuleObjects[$key]->
get(
'dirname'));
149 $render->setAttribute(
'moduleObjects', $this->mModuleObjects);
151 $moduleHandler =& xoops_gethandler(
'module');
152 $module_total = $moduleHandler->getCount();
153 $active_module_total = $moduleHandler->getCount(
new Criteria(
'isactive', 1));
154 $render->setAttribute(
'ModuleTotal', $module_total);
155 $render->setAttribute(
'activeModuleTotal', $active_module_total);
156 $render->setAttribute(
'inactiveModuleTotal', $module_total - $active_module_total);
159 public function executeViewSuccess(&$controller, &$xoopsUser, &$renderer)
161 $controller->executeForward(
'./index.php?action=ModuleList');
164 public function executeViewError(&$controller, &$xoopsUser, &$renderer)
166 $controller->executeRedirect(
'./index.php?action=ModuleList', 1, _MD_LEGACY_ERROR_DBUPDATE_FAILED);
169 public function executeViewCancel(&$controller, &$xoopsUser, &$renderer)
171 $controller->executeForward(
'./index.php?action=ModuleList');