22 public $mBlockObjects = [];
23 public $mActionForm =
null;
24 public $mpageArr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100, 0];
26 public function prepare(&$controller, &$xoopsUser)
29 $this->mActionForm->prepare();
32 public function &_getHandler()
34 $handler =& xoops_getmodulehandler(
'newblocks');
38 public function &_getFilterForm()
44 public function &_getPageNavi()
46 $navi =
new XCube_PageNavigator($this->_getBaseUrl(), XCUBE_PAGENAVI_START | XCUBE_PAGENAVI_PERPAGE);
48 $root =& XCube_Root::getSingleton();
49 $perpage = $root->mContext->mRequest->getRequest($navi->mPrefix.
'perpage');
51 if (isset($perpage) && 0 == (
int)$perpage) {
56 $selectedMid = (int)$root->mContext->mRequest->getRequest(
'selmid') ;
57 if (0 !== $selectedMid) {
58 $navi->addExtra(
'selmid', $selectedMid);
60 $selectedGid = (int)$root->mContext->mRequest->getRequest(
'selgid') ;
61 if (0 !== $selectedGid) {
62 $navi->addExtra(
'selgid', $selectedGid);
67 public function _getBaseUrl()
69 return './index.php?action=BlockList';
72 public function executeViewIndex(&$controller, &$xoopsUser, &$render)
74 $render->setTemplateName(
'block_list.html');
75 foreach (array_keys($this->mObjects) as $key) {
76 $this->mObjects[$key]->loadModule();
77 $this->mObjects[$key]->loadColumn();
78 $this->mObjects[$key]->loadCachetime();
81 $render->setAttribute(
'objects', $this->mObjects);
82 $render->setAttribute(
'pageNavi', $this->mFilter->mNavi);
84 $render->setAttribute(
'modules', $controller->mActiveModules);
85 $render->setAttribute(
'filterForm', $this->mFilter);
86 $render->setAttribute(
'pageArr', $this->mpageArr);
89 $root =& XCube_Root::getSingleton();
90 $render->setAttribute(
'selectedMid', $root->mContext->mRequest->getRequest(
'selmid'));
91 $handler =& xoops_gethandler(
'module');
93 $criteria->add(
new Criteria(
'isactive', 1));
94 $criteria->add(
new Criteria(
'weight', 0,
'>'));
95 $view_modules = $handler->getObjects($criteria);
96 $render->setAttribute(
'view_modules', $view_modules);
99 $handler =& xoops_gethandler(
'group');
100 $groupArr =& $handler->getObjects();
101 $render->setAttribute(
'groupArr', $groupArr);
102 $render->setAttribute(
'selectedGid', $root->mContext->mRequest->getRequest(
'selgid'));
107 $handler =& xoops_gethandler(
'cachetime');
108 $cachetimeArr =& $handler->getObjects();
109 $render->setAttribute(
'cachetimeArr', $cachetimeArr);
110 $render->setAttribute(
'actionForm', $this->mActionForm);
112 $handler =& xoops_getmodulehandler(
'columnside');
113 $columnSideArr =& $handler->getObjects();
114 $render->setAttribute(
'columnSideArr', $columnSideArr);
116 $block_handler =& $this->_getHandler();
117 $block_total = $block_handler->getCount();
118 $inactive_block_total = $block_handler->getCount(
new Criteria(
'isactive', 0));
119 $active_block_total = $block_total-$inactive_block_total;
120 $render->setAttribute(
'BlockTotal', $block_total);
121 $render->setAttribute(
'ActiveBlockTotal', $active_block_total);
122 $render->setAttribute(
'InactiveBlockTotal', $inactive_block_total);
125 $active_installed_criteria->add(
new Criteria(
'isactive', 1));
126 $active_installed_block_total = $block_handler->getCount($active_installed_criteria);
127 $render->setAttribute(
'ActiveInstalledBlockTotal', $active_installed_block_total);
128 $render->setAttribute(
'ActiveUninstalledBlockTotal', $active_block_total - $active_installed_block_total);
131 $inactive_installed_criteria->add(
new Criteria(
'isactive', 0));
132 $inactive_installed_block_total = $block_handler->getCount($inactive_installed_criteria);
133 $render->setAttribute(
'InactiveInstalledBlockTotal', $inactive_installed_block_total);
134 $render->setAttribute(
'InactiveUninstalledBlockTotal', $inactive_block_total - $inactive_installed_block_total);
138 public function execute(&$controller, &$xoopsUser)
140 $form_cancel = $controller->mRoot->mContext->mRequest->getRequest(
'_form_control_cancel');
141 if (
null !== $form_cancel) {
142 return LEGACY_FRAME_VIEW_CANCEL;
145 $this->mActionForm->fetch();
146 $this->mActionForm->validate();
148 if ($this->mActionForm->hasError()) {
149 return $this->_processConfirm($controller, $xoopsUser);
152 return $this->_processSave($controller, $xoopsUser);
155 public function _processConfirm(&$controller, &$xoopsUser)
157 $titleArr = $this->mActionForm->get(
'title');
158 $blockHandler =& xoops_getmodulehandler(
'newblocks');
162 foreach (array_keys($titleArr) as $bid) {
163 $block =& $blockHandler->get($bid);
164 if (is_object($block) && 1 == $block->get(
'isactive') && 1 == $block->get(
'visible')) {
165 $this->mBlockObjects[$bid] =& $block;
166 $this->mBlockObjects[$bid]->loadColumn();
167 $this->mBlockObjects[$bid]->loadCachetime();
172 return LEGACY_FRAME_VIEW_INPUT;
175 public function _processSave(&$controller, &$xoopsUser)
177 $titleArr = $this->mActionForm->get(
'title');
178 $blockHandler =& xoops_getmodulehandler(
'newblocks');
180 foreach (array_keys($titleArr) as $bid) {
181 $block =& $blockHandler->get($bid);
182 if (is_object($block) && 1 == $block->get(
'isactive') && 1 == $block->get(
'visible')) {
183 $olddata[
'title'] = $block->get(
'title');
184 $olddata[
'weight'] = $block->get(
'weight');
185 $olddata[
'side'] = $block->get(
'side');
186 $olddata[
'bcachetime'] = $block->get(
'bcachetime');
187 $newdata[
'title'] = $this->mActionForm->get(
'title', $bid);
188 $newdata[
'weight'] = $this->mActionForm->get(
'weight', $bid);
189 $newdata[
'side'] = $this->mActionForm->get(
'side', $bid);
190 $newdata[
'bcachetime'] = $this->mActionForm->get(
'bcachetime', $bid);
191 if (count(array_diff_assoc($olddata, $newdata)) > 0) {
192 $block->set(
'title', $this->mActionForm->get(
'title', $bid));
193 $block->set(
'weight', $this->mActionForm->get(
'weight', $bid));
194 $block->set(
'side', $this->mActionForm->get(
'side', $bid));
195 $block->set(
'bcachetime', $this->mActionForm->get(
'bcachetime', $bid));
196 $block->set(
'last_modified', time());
197 if (!$blockHandler->insert($block)) {
198 return LEGACY_FRAME_VIEW_ERROR;
205 foreach (array_keys($titleArr) as $bid) {
206 if (1 == $this->mActionForm->get(
'uninstall', $bid)) {
207 $block =& $blockHandler->get($bid);
208 if (is_object($block) && 1 == $block->get(
'isactive') && 1 == $block->get(
'visible')) {
209 $block->set(
'visible', 0);
210 if (!$blockHandler->insert($block)) {
211 return LEGACY_FRAME_VIEW_ERROR;
217 return LEGACY_FRAME_VIEW_SUCCESS;
221 public function executeViewInput(&$controller, &$xoopsUser, &$render)
223 $render->setTemplateName(
'block_list_confirm.html');
224 $render->setAttribute(
'blockObjects', $this->mBlockObjects);
225 $render->setAttribute(
'actionForm', $this->mActionForm);
227 $t_arr = $this->mActionForm->get(
'title');
228 $render->setAttribute(
'bids', array_keys($t_arr));
230 $handler =& xoops_getmodulehandler(
'columnside');
231 $columnSideArr =& $handler->getObjects($criteria =
null, $id_as_key =
true);
232 $render->setAttribute(
'columnSideArr', $columnSideArr);
233 $handler =& xoops_gethandler(
'cachetime');
234 $cachetimeArr =& $handler->getObjects($criteria =
null, $id_as_key =
true);
235 $render->setAttribute(
'cachetimeArr', $cachetimeArr);
238 public function executeViewSuccess(&$controller, &$xoopsUser, &$render)
240 $controller->executeForward(
'./index.php?action=BlockList');
243 public function executeViewError(&$controller, &$xoopsUser, &$render)
245 $controller->executeRedirect(
'./index.php?action=BlockInstallList', 1, _MD_LEGACY_ERROR_DBUPDATE_FAILED);
248 public function executeViewCancel(&$controller, &$xoopsUser, &$renderer)
250 $controller->executeForward(
'./index.php?action=BlockList');