13 public $mRanksObjects = [];
14 public $mActionForm =
null;
15 public $mpageArr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100, 0];
17 public function prepare(&$controller, &$xoopsUser, $moduleConfig)
20 $this->mActionForm->prepare();
23 public function &_getHandler()
25 $handler =& xoops_getmodulehandler(
'ranks');
29 public function &_getPageNavi()
31 $navi =
new XCube_PageNavigator($this->_getBaseUrl(), XCUBE_PAGENAVI_START | XCUBE_PAGENAVI_PERPAGE);
33 $root =& XCube_Root::getSingleton();
34 $perpage = $root->mContext->mRequest->getRequest($navi->mPrefix.
'perpage');
36 if (isset($perpage) && 0 == (
int)$perpage) {
42 public function &_getFilterForm()
48 public function _getBaseUrl()
50 return './index.php?action=RanksList';
53 public function executeViewIndex(&$controller, &$xoopsUser, &$render)
55 $render->setTemplateName(
'ranks_list.html');
56 $render->setAttribute(
'objects', $this->mObjects);
57 $render->setAttribute(
'pageNavi', $this->mFilter->mNavi);
58 $render->setAttribute(
'actionForm', $this->mActionForm);
59 $render->setAttribute(
'pageArr', $this->mpageArr);
60 $render->setAttribute(
'filterForm', $this->mFilter);
61 $rank_handler =& $this->_getHandler();
62 $rank_total = $rank_handler->getCount();
63 $rank_s_total = $rank_handler->getCount(
new Criteria(
'rank_special', 1));
64 $render->setAttribute(
'rankTotal_S', $rank_s_total);
65 $render->setAttribute(
'rankTotal', $rank_total);
68 public function execute(&$controller, &$xoopsUser)
70 $form_cancel = $controller->mRoot->mContext->mRequest->getRequest(
'_form_control_cancel');
71 if (
null != $form_cancel) {
72 return USER_FRAME_VIEW_CANCEL;
75 $this->mActionForm->fetch();
76 $this->mActionForm->validate();
78 if ($this->mActionForm->hasError()) {
79 return $this->_processConfirm($controller, $xoopsUser);
81 return $this->_processSave($controller, $xoopsUser);
85 public function _processConfirm(&$controller, &$xoopsUser)
87 $titleArr = $this->mActionForm->get(
'title');
88 $ranksHandler =& xoops_getmodulehandler(
'ranks');
92 foreach (array_keys($titleArr) as $rid) {
93 $ranks =& $ranksHandler->get($rid);
94 if (is_object($ranks)) {
95 $this->mRanksObjects[$rid] =& $ranks;
100 return USER_FRAME_VIEW_INPUT;
103 public function _processSave(&$controller, &$xoopsUser)
105 $titleArr = $this->mActionForm->get(
'title');
106 $ranksHandler =& xoops_getmodulehandler(
'ranks');
108 foreach (array_keys($titleArr) as $rid) {
109 $ranks =& $ranksHandler->get($rid);
110 if (is_object($ranks)) {
111 $olddata[
'title'] = $ranks->get(
'rank_title');
112 $olddata[
'min'] = $ranks->get(
'rank_min');
113 $olddata[
'max'] = $ranks->get(
'rank_max');
114 $newdata[
'title'] = $this->mActionForm->get(
'title', $rid);
115 $newdata[
'min'] = $this->mActionForm->get(
'min', $rid);
116 $newdata[
'max'] = $this->mActionForm->get(
'max', $rid);
117 if (count(array_diff_assoc($olddata, $newdata)) > 0) {
118 $ranks->set(
'rank_title', $this->mActionForm->get(
'title', $rid));
119 $ranks->set(
'rank_min', $this->mActionForm->get(
'min', $rid));
120 $ranks->set(
'rank_max', $this->mActionForm->get(
'max', $rid));
121 if (!$ranksHandler->insert($ranks)) {
122 return USER_FRAME_VIEW_ERROR;
128 foreach (array_keys($titleArr) as $rid) {
129 if (1 == $this->mActionForm->get(
'delete', $rid)) {
130 $ranks =& $ranksHandler->get($rid);
131 if (is_object($ranks)) {
132 if (!$ranksHandler->delete($ranks)) {
133 return USER_FRAME_VIEW_ERROR;
138 return USER_FRAME_VIEW_SUCCESS;
149 $render->setTemplateName(
'ranks_list_confirm.html');
150 $render->setAttribute(
'ranksObjects', $this->mRanksObjects);
151 $render->setAttribute(
'actionForm', $this->mActionForm);
157 $t_arr = $this->mActionForm->get(
'title');
158 $render->setAttribute(
'rids', array_keys($t_arr));
162 public function executeViewSuccess(&$controller, &$xoopsUser, &$renderer)
164 $controller->executeForward(
'./index.php?action=RanksList');
167 public function executeViewError(&$controller, &$xoopsUser, &$renderer)
169 $controller->executeRedirect(
'./index.php?action=RanksList', 1, _MD_USER_ERROR_DBUPDATE_FAILED);
172 public function executeViewCancel(&$controller, &$xoopsUser, &$renderer)
174 $controller->executeForward(
'./index.php?action=RanksList');