1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11: if (!defined('XOOPS_ROOT_PATH')) exit();
12:
13: require_once XOOPS_LEGACY_PATH . "/admin/forms/ModuleListFilterForm.class.php";
14: require_once XOOPS_LEGACY_PATH . "/admin/forms/ModuleListForm.class.php";
15:
16: class Legacy_ModuleListAction extends Legacy_Action
17: {
18: var $mModuleObjects = array();
19: var $mFilter = null;
20:
21: var $mActionForm = null;
22:
23: function prepare(&$controller, &$xoopsUser)
24: {
25: $this->mActionForm =new Legacy_ModuleListForm();
26: $this->mActionForm->prepare();
27: }
28:
29:
30: function getDefaultView(&$controller, &$xoopsUser)
31: {
32: $this->mFilter =new Legacy_ModuleListFilterForm();
33: $this->mFilter->fetch();
34:
35: $moduleHandler =& xoops_gethandler('module');
36: $this->mModuleObjects =& $moduleHandler->getObjects($this->mFilter->getCriteria());
37:
38: return LEGACY_FRAME_VIEW_INDEX;
39: }
40:
41: function execute(&$controller, &$xoopsUser)
42: {
43: $form_cancel = $controller->mRoot->mContext->mRequest->getRequest('_form_control_cancel');
44: if ($form_cancel != null) {
45: return LEGACY_FRAME_VIEW_CANCEL;
46: }
47:
48: $this->mActionForm->fetch();
49: $this->mActionForm->validate();
50:
51: if ($this->mActionForm->hasError()) {
52: return $this->_processConfirm($controller, $xoopsUser);
53: }
54: else {
55: return $this->_processSave($controller, $xoopsUser);
56: }
57: }
58:
59: function _processConfirm(&$controller,&$xoopsUser)
60: {
61: $moduleHandler =& xoops_gethandler('module');
62: $t_objectArr =& $moduleHandler->getObjects();
63:
64:
65:
66:
67: foreach ($t_objectArr as $module) {
68: $this->mModuleObjects[$module->get('mid')] =& $module;
69: unset($module);
70: }
71:
72: return LEGACY_FRAME_VIEW_INPUT;
73: }
74:
75: function _processSave(&$controller, &$xoopsUser)
76: {
77: $moduleHandler =& xoops_gethandler('module');
78: $blockHandler =& xoops_gethandler('block');
79: $t_objectArr =& $moduleHandler->getObjects();
80:
81: $successFlag = true;
82: foreach($t_objectArr as $module) {
83: $mid = $module->get('mid');
84: $olddata['name'] = $module->get('name');
85: $olddata['weight'] = $module->get('weight');
86: $olddata['isactive'] = $module->get('isactive');
87: $newdata['name'] = $this->mActionForm->get('name', $mid);
88: $newdata['weight'] = $this->mActionForm->get('weight', $mid);
89: $newdata['isactive'] = $this->mActionForm->get('isactive', $mid);
90: if (count(array_diff_assoc($olddata, $newdata)) > 0 ) {
91: $module->set('name', $this->mActionForm->get('name', $mid));
92: $module->set('weight', $this->mActionForm->get('weight', $mid));
93: $module->set('isactive', $this->mActionForm->get('isactive', $mid));
94:
95:
96:
97:
98: if ($moduleHandler->insert($module)) {
99: $successFlag &= true;
100: $blockHandler->syncIsActive($module->get('mid'), $module->get('isactive'));
101: }
102: else {
103: $successFlag = false;
104: }
105: }
106: }
107:
108: return $successFlag ? LEGACY_FRAME_VIEW_SUCCESS : LEGACY_FRAME_VIEW_ERROR;
109: }
110:
111: 112: 113:
114: function executeViewInput(&$controller, &$xoopsUser, &$render)
115: {
116: $render->setTemplateName("module_list_confirm.html");
117: $render->setAttribute('moduleObjects', $this->mModuleObjects);
118: $render->setAttribute('actionForm', $this->mActionForm);
119:
120:
121:
122:
123:
124: $t_arr = $this->mActionForm->get('name');
125: $render->setAttribute('mids', array_keys($t_arr));
126: }
127:
128: function executeViewIndex(&$controller, &$xoopsUser, &$render)
129: {
130: $render->setTemplateName("module_list.html");
131: $render->setAttribute('actionForm', $this->mActionForm);
132:
133:
134:
135:
136: foreach(array_keys($this->mModuleObjects) as $key) {
137: $this->mModuleObjects[$key]->loadAdminMenu();
138: $this->mModuleObjects[$key]->loadInfo($this->mModuleObjects[$key]->get('dirname'));
139: }
140:
141: $render->setAttribute('moduleObjects', $this->mModuleObjects);
142:
143: $moduleHandler =& xoops_gethandler('module');
144: $module_total = $moduleHandler->getCount();
145: $active_module_total = $moduleHandler->getCount(new Criteria('isactive', 1));
146: $render->setAttribute('ModuleTotal', $module_total);
147: $render->setAttribute('activeModuleTotal', $active_module_total );
148: $render->setAttribute('inactiveModuleTotal', $module_total - $active_module_total);
149: }
150:
151: function executeViewSuccess(&$controller,&$xoopsUser,&$renderer)
152: {
153: $controller->executeForward('./index.php?action=ModuleList');
154: }
155:
156: function executeViewError(&$controller, &$xoopsUser, &$renderer)
157: {
158: $controller->executeRedirect('./index.php?action=ModuleList', 1, _MD_LEGACY_ERROR_DBUPDATE_FAILED);
159: }
160:
161: function executeViewCancel(&$controller,&$xoopsUser,&$renderer)
162: {
163: $controller->executeForward('./index.php?action=ModuleList');
164: }
165: }
166:
167: ?>
168: