|
19 | 19 | * @since 1.00 |
20 | 20 | */ |
21 | 21 |
|
| 22 | +use Xmf\Request; |
| 23 | +use XoopsModules\Tag; |
| 24 | +use XoopsModules\Tag\Constants; |
| 25 | + |
22 | 26 | require_once __DIR__ . '/admin_header.php'; |
23 | 27 | require_once $GLOBALS['xoops']->path('/class/xoopsformloader.php'); |
24 | | -xoops_load('xoopsrequest'); |
25 | 28 |
|
26 | | -$indexAdmin = new ModuleAdmin(); |
| 29 | +$adminObject = \Xmf\Module\Admin::getInstance(); |
27 | 30 |
|
28 | 31 | xoops_cp_header(); |
29 | 32 |
|
30 | | -include $GLOBALS['xoops']->path('/modules/tag/include/vars.php'); |
31 | | -echo $indexAdmin->addNavigation(basename(__FILE__)); |
| 33 | +require_once $GLOBALS['xoops']->path('/modules/tag/include/vars.php'); |
| 34 | +$adminObject->displayNavigation(basename(__FILE__)); |
32 | 35 |
|
33 | 36 | $limit = $GLOBALS['xoopsModuleConfig']['items_perpage']; |
34 | | -$modid = XoopsRequest::getInt('modid', TagConstants::DEFAULT_ID); |
35 | | -$start = XoopsRequest::getInt('start', TagConstants::BEGINNING); |
36 | | -$status = XoopsRequest::getInt('status', TagConstants::STATUS_ALL, 'GET'); |
| 37 | +$modid = Request::getInt('modid', Constants::DEFAULT_ID); |
| 38 | +$start = Request::getInt('start', Constants::BEGINNING); |
| 39 | +$status = Request::getInt('status', Constants::STATUS_ALL, 'GET'); |
| 40 | +///** @var \XoopsModules\Tag\TagHandler $tagHandler */ |
| 41 | +//$tagHandler = xoops_getModuleHandler('tag', $moduleDirName); |
| 42 | +//$linkHandler = xoops_getModuleHandler('link', $moduleDirName); |
37 | 43 |
|
38 | | -$tag_handler = xoops_getModuleHandler('tag', $thisModuleDir); |
39 | | -$link_handler = xoops_getModuleHandler('link', $thisModuleDir); |
| 44 | +/** @var Tag\TagHandler $tagHandler */ |
| 45 | +/** @var Tag\LinkHandler $linkHandler */ |
| 46 | +$tagHandler = Tag\Helper::getInstance()->getHandler('Tag'); |
| 47 | +$linkHandler = Tag\Helper::getInstance()->getHandler('Link'); |
40 | 48 |
|
41 | | -$postTags = XoopsRequest::getArray('tags', array(), 'POST'); |
| 49 | +$postTags = Request::getArray('tags', [], 'POST'); |
42 | 50 | if (!empty($postTags)) { |
43 | 51 | $msgDBUpdated = ''; |
44 | 52 | foreach ($postTags as $tag => $tag_status) { |
45 | | - $tag_obj =& $tag_handler->get($tag); |
46 | | - if (!($tag_obj instanceof TagTag) || !$tag_obj->getVar('tag_id')) { |
| 53 | + $tag_obj = $tagHandler->get($tag); |
| 54 | + if (!($tag_obj instanceof Tag) || !$tag_obj->getVar('tag_id')) { |
47 | 55 | continue; |
48 | 56 | } |
49 | | - if ($tag_status < TagConstants::STATUS_ACTIVE) { |
50 | | - $tag_handler->delete($tag_obj); |
| 57 | + if ($tag_status < Constants::STATUS_ACTIVE) { |
| 58 | + $tagHandler->delete($tag_obj); |
51 | 59 | } elseif ($tag_status != $tag_obj->getVar('tag_status')) { |
52 | 60 | $tag_obj->setVar('tag_status', $tag_status); |
53 | | - $tag_handler->insert($tag_obj); |
| 61 | + $tagHandler->insert($tag_obj); |
54 | 62 | $msgDBUpdated = _AM_TAG_DB_UPDATED; |
55 | 63 | } |
56 | 64 | } |
57 | | - redirect_header("admin.tag.php?modid={$modid}&start={$start}&status={$status}", TagConstants::REDIRECT_DELAY_MEDIUM, $msgDBUpdated); |
| 65 | + redirect_header("admin.tag.php?modid={$modid}&start={$start}&status={$status}", Constants::REDIRECT_DELAY_MEDIUM, $msgDBUpdated); |
58 | 66 | } |
59 | 67 |
|
60 | | -$sql = 'SELECT tag_modid, COUNT(DISTINCT tag_id) AS count_tag'; |
61 | | -$sql .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('tag_link'); |
62 | | -$sql .= ' GROUP BY tag_modid'; |
63 | | -$counts_module = array(); |
64 | | -$module_list = array(); |
| 68 | +$sql = 'SELECT tag_modid, COUNT(DISTINCT tag_id) AS count_tag'; |
| 69 | +$sql .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('tag_link'); |
| 70 | +$sql .= ' GROUP BY tag_modid'; |
| 71 | +$counts_module = []; |
| 72 | +$module_list = []; |
65 | 73 | $result = $GLOBALS['xoopsDB']->query($sql); |
66 | 74 | if (false === $result) { |
67 | 75 | xoops_error($GLOBALS['xoopsDB']->error()); |
68 | 76 | } else { |
69 | | - while ($myrow = $GLOBALS['xoopsDB']->fetchArray($result)) { |
| 77 | + while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) { |
70 | 78 | $counts_module[$myrow['tag_modid']] = $myrow['count_tag']; |
71 | 79 | } |
72 | 80 | if (!empty($counts_module)) { |
| 81 | + /** @var \XoopsModuleHandler $moduleHandler */ |
73 | 82 | $moduleHandler = xoops_getHandler('module'); |
74 | | - $module_list = $moduleHandler->getList(new Criteria('mid', '(' . implode(', ', array_keys($counts_module)) . ')', 'IN')); |
| 83 | + $module_list = $moduleHandler->getList(new \Criteria('mid', '(' . implode(', ', array_keys($counts_module)) . ')', 'IN')); |
75 | 84 | } |
76 | 85 | } |
77 | 86 |
|
78 | | -$opform = new XoopsSimpleForm('', 'moduleform', xoops_getenv('PHP_SELF'), 'get'); |
79 | | -$tray = new XoopsFormElementTray(''); |
80 | | -$mod_select = new XoopsFormSelect(_SELECT, 'modid', $modid); |
| 87 | +$opform = new \XoopsSimpleForm('', 'moduleform', xoops_getenv('PHP_SELF'), 'get', true); |
| 88 | +$tray = new \XoopsFormElementTray(''); |
| 89 | +$mod_select = new \XoopsFormSelect(_SELECT, 'modid', $modid); |
81 | 90 | $mod_select->addOption(0, _ALL); |
82 | 91 | foreach ($module_list as $module => $module_name) { |
83 | 92 | $mod_select->addOption($module, $module_name . ' (' . $counts_module[$module] . ')'); |
84 | 93 | } |
85 | 94 | $tray->addElement($mod_select); |
86 | | -$status_select = new XoopsFormRadio('', 'status', $status); |
87 | | -$status_select->addOption(TagConstants::STATUS_ALL, _ALL); |
88 | | -$status_select->addOption(TagConstants::STATUS_ACTIVE, _AM_TAG_ACTIVE); |
89 | | -$status_select->addOption(TagConstants::STATUS_INACTIVE, _AM_TAG_INACTIVE); |
| 95 | +$status_select = new \XoopsFormRadio('', 'status', $status); |
| 96 | +$status_select->addOption(Constants::STATUS_ALL, _ALL); |
| 97 | +$status_select->addOption(Constants::STATUS_ACTIVE, _AM_TAG_ACTIVE); |
| 98 | +$status_select->addOption(Constants::STATUS_INACTIVE, _AM_TAG_INACTIVE); |
90 | 99 | $tray->addElement($status_select); |
91 | | -$tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
| 100 | +$tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
92 | 101 | $opform->addElement($tray); |
93 | 102 | $opform->display(); |
94 | 103 |
|
95 | | -$criteria = new CriteriaCompo(); |
| 104 | +$criteria = new \CriteriaCompo(); |
96 | 105 | $criteria->setSort('a'); |
97 | 106 | $criteria->setOrder('ASC'); |
98 | 107 | $criteria->setStart($start); |
99 | 108 | $criteria->setLimit($limit); |
100 | | -if ($status >= TagConstants::STATUS_ACTIVE) { |
101 | | - $criteria->add(new Criteria('o.tag_status', $status)); |
| 109 | +if ($status >= Constants::STATUS_ACTIVE) { |
| 110 | + $criteria->add(new \Criteria('o.tag_status', $status)); |
102 | 111 | } |
103 | 112 | if (!empty($modid)) { |
104 | | - $criteria->add(new Criteria('l.tag_modid', $modid)); |
| 113 | + $criteria->add(new \Criteria('l.tag_modid', $modid)); |
105 | 114 | } |
106 | | -$tags = $tag_handler->getByLimit(0, 0, $criteria, null, false); |
| 115 | +$tags = &$tagHandler->getByLimit(0, 0, $criteria, null, false); |
107 | 116 |
|
108 | 117 | $form_tags = "<form name='tags' method='post' action='" |
109 | 118 | . xoops_getenv('PHP_SELF') |
|
137 | 146 | . $tags[$key]['term'] |
138 | 147 | . "</td>\n" |
139 | 148 | . " <td class='txtcenter'><input type='radio' name='tags[{$key}]' value='" |
140 | | - . TagConstants::STATUS_INACTIVE |
| 149 | + . Constants::STATUS_INACTIVE |
141 | 150 | . "'" |
142 | 151 | . ($tags[$key]['status'] ? ' checked' : " '' ") |
143 | 152 | . "></td>\n" |
144 | 153 | . " <td class='txtcenter'><input type='radio' name='tags[{$key}]' value='" |
145 | | - . TagConstants::STATUS_ACTIVE |
| 154 | + . Constants::STATUS_ACTIVE |
146 | 155 | . "'" |
147 | 156 | . ($tags[$key]['status'] ? " '' " : ' checked') |
148 | 157 | . "></td>\n" |
149 | 158 | . " <td class='txtcenter'><input type='radio' name='tags[{$key}]' value='" |
150 | | - . TagConstants::STATUS_DELETE |
| 159 | + . Constants::STATUS_DELETE |
151 | 160 | . "'></td>\n" |
152 | 161 | . " </tr>\n"; |
153 | | - $class_tr = ('even' === $class_tr) ? 'odd' : 'even'; |
| 162 | + $class_tr = ('even' === $class_tr) ? 'odd' : 'even'; |
154 | 163 | } |
155 | 164 | if (!empty($start) || (count($tags) >= $limit)) { |
156 | | - $count_tag = $tag_handler->getCount($criteria); |
| 165 | + $count_tag = $tagHandler->getCount($criteria); |
157 | 166 |
|
158 | | - include $GLOBALS['xoops']->path('/class/pagenav.php'); |
159 | | - $nav = new XoopsPageNav($count_tag, $limit, $start, 'start', "modid={$modid}&status={$status}"); |
| 167 | + require_once $GLOBALS['xoops']->path('/class/pagenav.php'); |
| 168 | + $nav = new \XoopsPageNav($count_tag, $limit, $start, 'start', "modid={$modid}&status={$status}"); |
160 | 169 | $form_tags .= " <tr><td colspan='4' class='txtright'>" . $nav->renderNav(4) . "</td></tr>\n"; |
161 | 170 | } |
162 | 171 | $form_tags .= " </tbody>\n" |
163 | 172 | . " <tfoot>\n" |
164 | 173 | . " <tr>\n" |
165 | 174 | . " <td class='txtcenter' colspan='4'>\n" |
166 | | - . " <input type='hidden' name='status' value='{$status}' /> \n" |
167 | | - . " <input type='hidden' name='start' value='{$start}' /> \n" |
168 | | - . " <input type='hidden' name='modid' value='{$modid}' /> \n" |
| 175 | + . " <input type='hidden' name='status' value='{$status}'> \n" |
| 176 | + . " <input type='hidden' name='start' value='{$start}'> \n" |
| 177 | + . " <input type='hidden' name='modid' value='{$modid}'> \n" |
169 | 178 | . " <input type='submit' name='submit' value='" |
170 | 179 | . _SUBMIT |
171 | | - . "' /> \n" |
| 180 | + . "'> \n" |
172 | 181 | . " <input type='reset' name='submit' value='" |
173 | 182 | . _CANCEL |
174 | | - . "' />\n" |
| 183 | + . "'>\n" |
175 | 184 | . " </td>\n" |
176 | 185 | . " </tr>\n" |
177 | 186 | . " </tfoot>\n"; |
178 | 187 | } |
179 | 188 | $form_tags .= " </tbody>\n" . "</table>\n" . "</form>\n"; |
180 | 189 |
|
181 | 190 | echo $form_tags; |
182 | | -include __DIR__ . '/admin_footer.php'; |
| 191 | +require_once __DIR__ . '/admin_footer.php'; |
0 commit comments