|
12 | 12 | /** |
13 | 13 | * XOOPS tag management module |
14 | 14 | * |
15 | | - * @package tag |
| 15 | + * @package tag |
16 | 16 | * @copyright {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} |
17 | 17 | * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
18 | 18 | * @author Taiwen Jiang <phppp@users.sourceforge.net> |
19 | 19 | * @since 1.00 |
20 | | - * @version $Id: admin.tag.php 12898 2014-12-08 22:05:21Z zyspec $ |
21 | 20 | */ |
22 | 21 |
|
23 | 22 | require_once __DIR__ . '/admin_header.php'; |
24 | | -require_once $GLOBALS['xoops']->path("/class/xoopsformloader.php"); |
| 23 | +require_once $GLOBALS['xoops']->path('/class/xoopsformloader.php'); |
25 | 24 | xoops_load('xoopsrequest'); |
26 | 25 |
|
27 | 26 | $indexAdmin = new ModuleAdmin(); |
28 | 27 |
|
29 | 28 | xoops_cp_header(); |
30 | 29 |
|
31 | | -include $GLOBALS['xoops']->path("/modules/tag/include/vars.php"); |
32 | | -echo $indexAdmin->addNavigation('admin.tag.php'); |
| 30 | +include $GLOBALS['xoops']->path('/modules/tag/include/vars.php'); |
| 31 | +echo $indexAdmin->addNavigation(basename(__FILE__)); |
33 | 32 |
|
34 | 33 | $limit = $GLOBALS['xoopsModuleConfig']['items_perpage']; |
35 | 34 | $modid = XoopsRequest::getInt('modid', TagConstants::DEFAULT_ID); |
36 | 35 | $start = XoopsRequest::getInt('start', TagConstants::BEGINNING); |
37 | 36 | $status = XoopsRequest::getInt('status', TagConstants::STATUS_ALL, 'GET'); |
38 | 37 |
|
39 | | -$tag_handler =& xoops_getmodulehandler('tag', $thisModuleDir); |
40 | | -$link_handler =& xoops_getmodulehandler('link', $thisModuleDir); |
| 38 | +$tag_handler = xoops_getModuleHandler('tag', $thisModuleDir); |
| 39 | +$link_handler = xoops_getModuleHandler('link', $thisModuleDir); |
41 | 40 |
|
42 | 41 | $postTags = XoopsRequest::getArray('tags', array(), 'POST'); |
43 | 42 | if (!empty($postTags)) { |
44 | | - $msgDBUpdated=''; |
| 43 | + $msgDBUpdated = ''; |
45 | 44 | foreach ($postTags as $tag => $tag_status) { |
46 | 45 | $tag_obj =& $tag_handler->get($tag); |
47 | | - if (!($tag_obj instanceof TagTag) || !$tag_obj->getVar("tag_id")) continue; |
| 46 | + if (!($tag_obj instanceof TagTag) || !$tag_obj->getVar('tag_id')) { |
| 47 | + continue; |
| 48 | + } |
48 | 49 | if ($tag_status < TagConstants::STATUS_ACTIVE) { |
49 | 50 | $tag_handler->delete($tag_obj); |
50 | | - } elseif ($tag_status != $tag_obj->getVar("tag_status")) { |
51 | | - $tag_obj->setVar("tag_status", $tag_status); |
| 51 | + } elseif ($tag_status != $tag_obj->getVar('tag_status')) { |
| 52 | + $tag_obj->setVar('tag_status', $tag_status); |
52 | 53 | $tag_handler->insert($tag_obj); |
53 | 54 | $msgDBUpdated = _AM_TAG_DB_UPDATED; |
54 | 55 | } |
55 | 56 | } |
56 | 57 | redirect_header("admin.tag.php?modid={$modid}&start={$start}&status={$status}", TagConstants::REDIRECT_DELAY_MEDIUM, $msgDBUpdated); |
57 | 58 | } |
58 | 59 |
|
59 | | -$sql = "SELECT tag_modid, COUNT(DISTINCT tag_id) AS count_tag"; |
60 | | -$sql .= " FROM " . $GLOBALS['xoopsDB']->prefix("tag_link"); |
61 | | -$sql .= " GROUP BY tag_modid"; |
| 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'; |
62 | 63 | $counts_module = array(); |
63 | | -$module_list = array(); |
64 | | -$result = $GLOBALS['xoopsDB']->query($sql); |
| 64 | +$module_list = array(); |
| 65 | +$result = $GLOBALS['xoopsDB']->query($sql); |
65 | 66 | if (false === $result) { |
66 | 67 | xoops_error($GLOBALS['xoopsDB']->error()); |
67 | 68 | } else { |
68 | 69 | while ($myrow = $GLOBALS['xoopsDB']->fetchArray($result)) { |
69 | | - $counts_module[$myrow["tag_modid"]] = $myrow["count_tag"]; |
| 70 | + $counts_module[$myrow['tag_modid']] = $myrow['count_tag']; |
70 | 71 | } |
71 | 72 | if (!empty($counts_module)) { |
72 | | - $module_handler =& xoops_gethandler("module"); |
73 | | - $module_list = $module_handler->getList(new Criteria("mid", "(" . implode(", ", array_keys($counts_module)) . ")", "IN")); |
| 73 | + $moduleHandler = xoops_getHandler('module'); |
| 74 | + $module_list = $moduleHandler->getList(new Criteria('mid', '(' . implode(', ', array_keys($counts_module)) . ')', 'IN')); |
74 | 75 | } |
75 | 76 | } |
76 | 77 |
|
77 | | -$opform = new XoopsSimpleForm('', 'moduleform', xoops_getenv("PHP_SELF"), "get"); |
78 | | -$tray = new XoopsFormElementTray(''); |
| 78 | +$opform = new XoopsSimpleForm('', 'moduleform', xoops_getenv('PHP_SELF'), 'get'); |
| 79 | +$tray = new XoopsFormElementTray(''); |
79 | 80 | $mod_select = new XoopsFormSelect(_SELECT, 'modid', $modid); |
80 | 81 | $mod_select->addOption(0, _ALL); |
81 | 82 | foreach ($module_list as $module => $module_name) { |
82 | | - $mod_select->addOption($module, $module_name." (" . $counts_module[$module] . ")"); |
| 83 | + $mod_select->addOption($module, $module_name . ' (' . $counts_module[$module] . ')'); |
83 | 84 | } |
84 | 85 | $tray->addElement($mod_select); |
85 | | -$status_select = new XoopsFormRadio("", 'status', $status); |
| 86 | +$status_select = new XoopsFormRadio('', 'status', $status); |
86 | 87 | $status_select->addOption(TagConstants::STATUS_ALL, _ALL); |
87 | 88 | $status_select->addOption(TagConstants::STATUS_ACTIVE, _AM_TAG_ACTIVE); |
88 | 89 | $status_select->addOption(TagConstants::STATUS_INACTIVE, _AM_TAG_INACTIVE); |
89 | 90 | $tray->addElement($status_select); |
90 | | -$tray->addElement(new XoopsFormButton("", "submit", _SUBMIT, "submit")); |
| 91 | +$tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
91 | 92 | $opform->addElement($tray); |
92 | 93 | $opform->display(); |
93 | 94 |
|
94 | 95 | $criteria = new CriteriaCompo(); |
95 | | -$criteria->setSort("a"); |
96 | | -$criteria->setOrder("ASC"); |
| 96 | +$criteria->setSort('a'); |
| 97 | +$criteria->setOrder('ASC'); |
97 | 98 | $criteria->setStart($start); |
98 | 99 | $criteria->setLimit($limit); |
99 | 100 | if ($status >= TagConstants::STATUS_ACTIVE) { |
100 | | - $criteria->add(new Criteria("o.tag_status", $status)); |
| 101 | + $criteria->add(new Criteria('o.tag_status', $status)); |
101 | 102 | } |
102 | 103 | if (!empty($modid)) { |
103 | | - $criteria->add(new Criteria("l.tag_modid", $modid)); |
| 104 | + $criteria->add(new Criteria('l.tag_modid', $modid)); |
104 | 105 | } |
105 | | -$tags = $tag_handler->getByLimit($criteria, false); |
| 106 | +$tags = $tag_handler->getByLimit(0, 0, $criteria, null, false); |
106 | 107 |
|
107 | | -$form_tags = "<form name='tags' method='post' action='" . xoops_getenv("PHP_SELF") . "'>\n" |
108 | | - . "<table style='border-width: 0px; margin: 1px; padding: 4px;' cellspacing='1' class='outer width100'>\n" |
109 | | - . " <thead>\n" |
110 | | - . " <tr class='txtcenter'>\n" |
111 | | - . " <th class='bg3'>" . _AM_TAG_TERM . "</th>\n" |
112 | | - . " <th class='bg3 width10'>" . _AM_TAG_INACTIVE . "</th>\n" |
113 | | - . " <th class='bg3 width10'>" . _AM_TAG_ACTIVE . "</th>\n" |
114 | | - . " <th class='bg3 width10'>" . _DELETE . "</th>\n" |
115 | | - . " </tr>\n" |
116 | | - . " </thead>\n" |
117 | | - . " <tbody>\n"; |
| 108 | +$form_tags = "<form name='tags' method='post' action='" |
| 109 | + . xoops_getenv('PHP_SELF') |
| 110 | + . "'>\n" |
| 111 | + . "<table style='border-width: 0px; margin: 1px; padding: 4px;' cellspacing='1' class='outer width100'>\n" |
| 112 | + . " <thead>\n" |
| 113 | + . " <tr class='txtcenter'>\n" |
| 114 | + . " <th class='bg3'>" |
| 115 | + . _AM_TAG_TERM |
| 116 | + . "</th>\n" |
| 117 | + . " <th class='bg3 width10'>" |
| 118 | + . _AM_TAG_INACTIVE |
| 119 | + . "</th>\n" |
| 120 | + . " <th class='bg3 width10'>" |
| 121 | + . _AM_TAG_ACTIVE |
| 122 | + . "</th>\n" |
| 123 | + . " <th class='bg3 width10'>" |
| 124 | + . _DELETE |
| 125 | + . "</th>\n" |
| 126 | + . " </tr>\n" |
| 127 | + . " </thead>\n" |
| 128 | + . " <tbody>\n"; |
118 | 129 | if (empty($tags)) { |
119 | 130 | $form_tags .= " <tr><td colspan='4'>" . _NONE . "</td></tr>\n"; |
120 | 131 | } else { |
121 | 132 | $class_tr = 'odd'; |
122 | | - $i = 0; |
| 133 | + $i = 0; |
123 | 134 | foreach (array_keys($tags) as $key) { |
124 | 135 | $form_tags .= " <tr class='{$class_tr}'>\n" |
125 | | - . " <td>" . $tags[$key]["term"] . "</td>\n" |
126 | | - . " <td class='txtcenter'><input type='radio' name='tags[{$key}]' value='" . TagConstants::STATUS_INACTIVE . "'" . ( $tags[$key]["status"] ? " checked" : " '' ") . "></td>\n" |
127 | | - . " <td class='txtcenter'><input type='radio' name='tags[{$key}]' value='" . TagConstants::STATUS_ACTIVE . "'" . ( $tags[$key]["status"] ? " '' " : " checked") . "></td>\n" |
128 | | - . " <td class='txtcenter'><input type='radio' name='tags[{$key}]' value='" . TagConstants::STATUS_DELETE . "'></td>\n" |
129 | | - . " </tr>\n"; |
130 | | - $class_tr = ('even' == $class_tr) ? 'odd' : 'even'; |
| 136 | + . ' <td>' |
| 137 | + . $tags[$key]['term'] |
| 138 | + . "</td>\n" |
| 139 | + . " <td class='txtcenter'><input type='radio' name='tags[{$key}]' value='" |
| 140 | + . TagConstants::STATUS_INACTIVE |
| 141 | + . "'" |
| 142 | + . ($tags[$key]['status'] ? ' checked' : " '' ") |
| 143 | + . "></td>\n" |
| 144 | + . " <td class='txtcenter'><input type='radio' name='tags[{$key}]' value='" |
| 145 | + . TagConstants::STATUS_ACTIVE |
| 146 | + . "'" |
| 147 | + . ($tags[$key]['status'] ? " '' " : ' checked') |
| 148 | + . "></td>\n" |
| 149 | + . " <td class='txtcenter'><input type='radio' name='tags[{$key}]' value='" |
| 150 | + . TagConstants::STATUS_DELETE |
| 151 | + . "'></td>\n" |
| 152 | + . " </tr>\n"; |
| 153 | + $class_tr = ('even' === $class_tr) ? 'odd' : 'even'; |
131 | 154 | } |
132 | 155 | if (!empty($start) || (count($tags) >= $limit)) { |
133 | 156 | $count_tag = $tag_handler->getCount($criteria); |
134 | 157 |
|
135 | | - include $GLOBALS['xoops']->path("/class/pagenav.php"); |
136 | | - $nav = new XoopsPageNav($count_tag, $limit, $start, "start", "modid={$modid}&status={$status}"); |
| 158 | + include $GLOBALS['xoops']->path('/class/pagenav.php'); |
| 159 | + $nav = new XoopsPageNav($count_tag, $limit, $start, 'start', "modid={$modid}&status={$status}"); |
137 | 160 | $form_tags .= " <tr><td colspan='4' class='txtright'>" . $nav->renderNav(4) . "</td></tr>\n"; |
138 | 161 | } |
139 | 162 | $form_tags .= " </tbody>\n" |
140 | | - . " <tfoot>\n" |
141 | | - . " <tr>\n" |
142 | | - . " <td class='txtcenter' colspan='4'>\n" |
143 | | - . " <input type='hidden' name='status' value='{$status}' /> \n" |
144 | | - . " <input type='hidden' name='start' value='{$start}' /> \n" |
145 | | - . " <input type='hidden' name='modid' value='{$modid}' /> \n" |
146 | | - . " <input type='submit' name='submit' value='" . _SUBMIT . "' /> \n" |
147 | | - . " <input type='reset' name='submit' value='" . _CANCEL . "' />\n" |
148 | | - . " </td>\n" |
149 | | - . " </tr>\n" |
150 | | - . " </tfoot>\n"; |
| 163 | + . " <tfoot>\n" |
| 164 | + . " <tr>\n" |
| 165 | + . " <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" |
| 169 | + . " <input type='submit' name='submit' value='" |
| 170 | + . _SUBMIT |
| 171 | + . "' /> \n" |
| 172 | + . " <input type='reset' name='submit' value='" |
| 173 | + . _CANCEL |
| 174 | + . "' />\n" |
| 175 | + . " </td>\n" |
| 176 | + . " </tr>\n" |
| 177 | + . " </tfoot>\n"; |
151 | 178 | } |
152 | | -$form_tags .= " </tbody>\n" |
153 | | - . "</table>\n" |
154 | | - . "</form>\n"; |
| 179 | +$form_tags .= " </tbody>\n" . "</table>\n" . "</form>\n"; |
155 | 180 |
|
156 | 181 | echo $form_tags; |
157 | 182 | include __DIR__ . '/admin_footer.php'; |
0 commit comments