|
1 | 1 | <?php |
2 | 2 | /* |
3 | 3 | You may not change or alter any portion of this comment or credits |
4 | | - of supporting developers from this source code or any supporting source code |
| 4 | + of supporting developers from this source code or any supporting source code |
5 | 5 | which is considered copyrighted (c) material of the original comment or credit authors. |
6 | | - |
| 6 | +
|
7 | 7 | This program is distributed in the hope that it will be useful, |
8 | 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 | 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
12 | 12 | /** |
13 | 13 | * XOOPS tag management module |
14 | 14 | * |
15 | | - * @copyright The XOOPS project http://sourceforge.net/projects/xoops/ |
16 | | - * @license http://www.fsf.org/copyleft/gpl.html GNU public license |
17 | | - * @since 1.0.0 |
| 15 | + * @package tag |
| 16 | + * @copyright {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} |
| 17 | + * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
18 | 18 | * @author Taiwen Jiang <phppp@users.sourceforge.net> |
19 | | - * @version $Id: admin.tag.php 11906 2013-08-14 05:54:12Z beckmi $ |
20 | | - * @package tag |
| 19 | + * @since 1.00 |
| 20 | + * @version $Id: admin.tag.php 12898 2014-12-08 22:05:21Z zyspec $ |
21 | 21 | */ |
22 | | - |
23 | | -include_once 'admin_header.php'; |
24 | | -require_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; |
25 | | -$indexAdmin = new ModuleAdmin(); |
26 | | - |
27 | | -xoops_cp_header(); |
28 | 22 |
|
29 | | -include XOOPS_ROOT_PATH . "/modules/tag/include/vars.php"; |
30 | | -//echo function_exists("loadModuleAdminMenu") ? loadModuleAdminMenu(1) : ""; |
31 | | - echo $indexAdmin->addNavigation('admin.tag.php'); |
| 23 | +require_once __DIR__ . '/admin_header.php'; |
| 24 | +require_once $GLOBALS['xoops']->path("/class/xoopsformloader.php"); |
| 25 | +xoops_load('xoopsrequest'); |
32 | 26 |
|
33 | | -global $xoopsModuleConfig; |
| 27 | +$indexAdmin = new ModuleAdmin(); |
34 | 28 |
|
35 | | -$limit = $xoopsModuleConfig['items_perpage']; |
36 | | -$modid = intval( empty($_GET['modid']) ? @$_POST['modid'] : $_GET['modid'] ); |
37 | | -$start = intval( empty($_GET['start']) ? @$_POST['start'] : $_GET['start'] ); |
38 | | -//$status = intval( empty($_GET['status']) ? @$_POST['status'] : $_GET['status']); |
| 29 | +xoops_cp_header(); |
39 | 30 |
|
40 | | -$status = intval( (isset($_GET['status']) && $_GET['status'] >-1) ? $_GET['status'] : -1); |
| 31 | +include $GLOBALS['xoops']->path("/modules/tag/include/vars.php"); |
| 32 | +echo $indexAdmin->addNavigation('admin.tag.php'); |
41 | 33 |
|
| 34 | +$limit = $GLOBALS['xoopsModuleConfig']['items_perpage']; |
| 35 | +$modid = XoopsRequest::getInt('modid', TagConstants::DEFAULT_ID); |
| 36 | +$start = XoopsRequest::getInt('start', TagConstants::BEGINNING); |
| 37 | +$status = XoopsRequest::getInt('status', TagConstants::STATUS_ALL, 'GET'); |
42 | 38 |
|
43 | | -$tag_handler =& xoops_getmodulehandler("tag", $xoopsModule->getVar("dirname")); |
| 39 | +$tag_handler =& xoops_getmodulehandler('tag', $thisModuleDir); |
| 40 | +$link_handler =& xoops_getmodulehandler('link', $thisModuleDir); |
44 | 41 |
|
45 | | -if (!empty($_POST['tags'])) { |
| 42 | +$postTags = XoopsRequest::getArray('tags', array(), 'POST'); |
| 43 | +if (!empty($postTags)) { |
46 | 44 | $msgDBUpdated=''; |
47 | | - foreach ($_POST['tags'] as $tag => $tag_status) { |
| 45 | + foreach ($postTags as $tag => $tag_status) { |
48 | 46 | $tag_obj =& $tag_handler->get($tag); |
49 | | - if (!is_object($tag_obj) || !$tag_obj->getVar("tag_id")) continue; |
50 | | - if ($tag_status < 0) { |
| 47 | + if (!($tag_obj instanceof TagTag) || !$tag_obj->getVar("tag_id")) continue; |
| 48 | + if ($tag_status < TagConstants::STATUS_ACTIVE) { |
51 | 49 | $tag_handler->delete($tag_obj); |
52 | 50 | } elseif ($tag_status != $tag_obj->getVar("tag_status")) { |
53 | 51 | $tag_obj->setVar("tag_status", $tag_status); |
54 | 52 | $tag_handler->insert($tag_obj); |
55 | 53 | $msgDBUpdated = _AM_TAG_DB_UPDATED; |
56 | 54 | } |
57 | 55 | } |
58 | | - redirect_header("admin.tag.php?modid={$modid}&start={$start}&status={$status}", 2, $msgDBUpdated); |
59 | | - exit(); |
| 56 | + redirect_header("admin.tag.php?modid={$modid}&start={$start}&status={$status}", TagConstants::REDIRECT_DELAY_MEDIUM, $msgDBUpdated); |
60 | 57 | } |
61 | 58 |
|
62 | | -$sql = " SELECT tag_modid, COUNT(DISTINCT tag_id) AS count_tag"; |
63 | | -$sql .= " FROM " . $xoopsDB->prefix("tag_link"); |
64 | | -$sql .= " GROUP BY tag_modid"; |
| 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"; |
65 | 62 | $counts_module = array(); |
66 | 63 | $module_list = array(); |
67 | | -if ( ($result = $xoopsDB->query($sql)) == false) { |
68 | | - xoops_error($xoopsDB->error()); |
| 64 | +$result = $GLOBALS['xoopsDB']->query($sql); |
| 65 | +if (false === $result) { |
| 66 | + xoops_error($GLOBALS['xoopsDB']->error()); |
69 | 67 | } else { |
70 | | - while ($myrow = $xoopsDB->fetchArray($result)) { |
| 68 | + while ($myrow = $GLOBALS['xoopsDB']->fetchArray($result)) { |
71 | 69 | $counts_module[$myrow["tag_modid"]] = $myrow["count_tag"]; |
72 | 70 | } |
73 | 71 | if (!empty($counts_module)) { |
|
85 | 83 | } |
86 | 84 | $tray->addElement($mod_select); |
87 | 85 | $status_select = new XoopsFormRadio("", 'status', $status); |
88 | | -$status_select->addOption(-1, _ALL); |
89 | | -$status_select->addOption(1, TAG_AM_ACTIVE); |
90 | | -$status_select->addOption(0, TAG_AM_INACTIVE); |
| 86 | +$status_select->addOption(TagConstants::STATUS_ALL, _ALL); |
| 87 | +$status_select->addOption(TagConstants::STATUS_ACTIVE, _AM_TAG_ACTIVE); |
| 88 | +$status_select->addOption(TagConstants::STATUS_INACTIVE, _AM_TAG_INACTIVE); |
91 | 89 | $tray->addElement($status_select); |
92 | 90 | $tray->addElement(new XoopsFormButton("", "submit", _SUBMIT, "submit")); |
93 | 91 | $opform->addElement($tray); |
|
98 | 96 | $criteria->setOrder("ASC"); |
99 | 97 | $criteria->setStart($start); |
100 | 98 | $criteria->setLimit($limit); |
101 | | -if ($status >= 0) { |
102 | | - $criteria->add( new Criteria("o.tag_status", $status) ); |
| 99 | +if ($status >= TagConstants::STATUS_ACTIVE) { |
| 100 | + $criteria->add(new Criteria("o.tag_status", $status)); |
103 | 101 | } |
104 | 102 | if (!empty($modid)) { |
105 | | - $criteria->add( new Criteria("l.tag_modid", $modid) ); |
| 103 | + $criteria->add(new Criteria("l.tag_modid", $modid)); |
106 | 104 | } |
107 | 105 | $tags = $tag_handler->getByLimit($criteria, false); |
108 | 106 |
|
109 | | -$form_tags = "<form name='tags' method='post' action='" . xoops_getenv("PHP_SELF") . "'>"; |
110 | | -$form_tags .= "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>"; |
111 | | -$form_tags .= "<tr align='center'>"; |
112 | | -$form_tags .= "<th class='bg3'>" . TAG_AM_TERM . "</td>"; |
113 | | -$form_tags .= "<th class='bg3' width='10%'>" . TAG_AM_ACTIVE . "</td>"; |
114 | | -$form_tags .= "<th class='bg3' width='10%'>" . TAG_AM_INACTIVE . "</td>"; |
115 | | -$form_tags .= "<th class='bg3' width='10%'>" . _DELETE . "</td>"; |
116 | | -$form_tags .= "</tr>"; |
| 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"; |
117 | 118 | if (empty($tags)) { |
118 | | - $form_tags .= "<tr><td colspan='4'>" . _NONE . "</td></tr>"; |
| 119 | + $form_tags .= " <tr><td colspan='4'>" . _NONE . "</td></tr>\n"; |
119 | 120 | } else { |
120 | | - $class_tr = array("odd", "even"); |
| 121 | + $class_tr = 'odd'; |
121 | 122 | $i = 0; |
122 | 123 | foreach (array_keys($tags) as $key) { |
123 | | - $form_tags .= "<tr class='" . $class_tr[(++$i) % 2] . "'>"; |
124 | | - $form_tags .= "<td>" . $tags[$key]["term"] . "</td>"; |
125 | | - $form_tags .= "<td align='center'><input type='radio' name='tags[{$key}]' value='1' " . ( $tags[$key]["status"] ? "checked" : " '' ") . "></td>"; |
126 | | - $form_tags .= "<td align='center'><input type='radio' name='tags[{$key}]' value='0' " . ( $tags[$key]["status"] ? " '' " : "checked") . "></td>"; |
127 | | - $form_tags .= "<td align='center'><input type='radio' name='tags[{$key}]' value='-1'></td>"; |
128 | | - $form_tags .= "</tr>"; |
| 124 | + $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'; |
129 | 131 | } |
130 | | - if ( !empty($start) || count($tags) >= $limit ) { |
| 132 | + if (!empty($start) || (count($tags) >= $limit)) { |
131 | 133 | $count_tag = $tag_handler->getCount($criteria); |
132 | | - |
133 | | - include XOOPS_ROOT_PATH . "/class/pagenav.php"; |
| 134 | + |
| 135 | + include $GLOBALS['xoops']->path("/class/pagenav.php"); |
134 | 136 | $nav = new XoopsPageNav($count_tag, $limit, $start, "start", "modid={$modid}&status={$status}"); |
135 | | - $form_tags .= "<tr><td colspan='4' align='right'>" . $nav->renderNav(4) . "</td></tr>"; |
| 137 | + $form_tags .= " <tr><td colspan='4' class='txtright'>" . $nav->renderNav(4) . "</td></tr>\n"; |
136 | 138 | } |
137 | | - $form_tags .= "<tr><td colspan='4' align='center'>"; |
138 | | - $form_tags .= "<input type='hidden' name='status' value='{$status}'> "; |
139 | | - $form_tags .= "<input type='hidden' name='start' value='{$start}'> "; |
140 | | - $form_tags .= "<input type='hidden' name='modid' value='{$modid}'> "; |
141 | | - $form_tags .= "<input type='submit' name='submit' value='" . _SUBMIT . "'> "; |
142 | | - $form_tags .= "<input type='reset' name='submit' value='" . _CANCEL . "'>"; |
143 | | - $form_tags .= "</td></tr>"; |
| 139 | + $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"; |
144 | 151 | } |
145 | | -$form_tags .= "</table>"; |
146 | | -$form_tags .= "</form>"; |
| 152 | +$form_tags .= " </tbody>\n" |
| 153 | + . "</table>\n" |
| 154 | + . "</form>\n"; |
147 | 155 |
|
148 | 156 | echo $form_tags; |
149 | | -include "admin_footer.php"; |
| 157 | +include __DIR__ . '/admin_footer.php'; |
0 commit comments