|
| 1 | +<?php |
| 2 | +/* |
| 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 |
| 5 | + which is considered copyrighted (c) material of the original comment or credit authors. |
| 6 | + |
| 7 | + This program is distributed in the hope that it will be useful, |
| 8 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 10 | +*/ |
| 11 | + |
| 12 | +/** |
| 13 | + * XOOPS tag management module |
| 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 |
| 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 |
| 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 | + |
| 29 | +include XOOPS_ROOT_PATH . "/modules/tag/include/vars.php"; |
| 30 | +//echo function_exists("loadModuleAdminMenu") ? loadModuleAdminMenu(1) : ""; |
| 31 | + echo $indexAdmin->addNavigation('admin.tag.php'); |
| 32 | + |
| 33 | +global $xoopsModuleConfig; |
| 34 | + |
| 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']); |
| 39 | + |
| 40 | +$status = intval( (isset($_GET['status']) && $_GET['status'] >-1) ? $_GET['status'] : -1); |
| 41 | + |
| 42 | + |
| 43 | +$tag_handler =& xoops_getmodulehandler("tag", $xoopsModule->getVar("dirname")); |
| 44 | + |
| 45 | +if (!empty($_POST['tags'])) { |
| 46 | + $msgDBUpdated=''; |
| 47 | + foreach ($_POST['tags'] as $tag => $tag_status) { |
| 48 | + $tag_obj =& $tag_handler->get($tag); |
| 49 | + if (!is_object($tag_obj) || !$tag_obj->getVar("tag_id")) continue; |
| 50 | + if ($tag_status < 0) { |
| 51 | + $tag_handler->delete($tag_obj); |
| 52 | + } elseif ($tag_status != $tag_obj->getVar("tag_status")) { |
| 53 | + $tag_obj->setVar("tag_status", $tag_status); |
| 54 | + $tag_handler->insert($tag_obj); |
| 55 | + $msgDBUpdated = _AM_TAG_DB_UPDATED; |
| 56 | + } |
| 57 | + } |
| 58 | + redirect_header("admin.tag.php?modid={$modid}&start={$start}&status={$status}", 2, $msgDBUpdated); |
| 59 | + exit(); |
| 60 | +} |
| 61 | + |
| 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"; |
| 65 | +$counts_module = array(); |
| 66 | +$module_list = array(); |
| 67 | +if ( ($result = $xoopsDB->query($sql)) == false) { |
| 68 | + xoops_error($xoopsDB->error()); |
| 69 | +} else { |
| 70 | + while ($myrow = $xoopsDB->fetchArray($result)) { |
| 71 | + $counts_module[$myrow["tag_modid"]] = $myrow["count_tag"]; |
| 72 | + } |
| 73 | + if (!empty($counts_module)) { |
| 74 | + $module_handler =& xoops_gethandler("module"); |
| 75 | + $module_list = $module_handler->getList(new Criteria("mid", "(" . implode(", ", array_keys($counts_module)) . ")", "IN")); |
| 76 | + } |
| 77 | +} |
| 78 | + |
| 79 | +$opform = new XoopsSimpleForm('', 'moduleform', xoops_getenv("PHP_SELF"), "get"); |
| 80 | +$tray = new XoopsFormElementTray(''); |
| 81 | +$mod_select = new XoopsFormSelect(_SELECT, 'modid', $modid); |
| 82 | +$mod_select->addOption(0, _ALL); |
| 83 | +foreach ($module_list as $module => $module_name) { |
| 84 | + $mod_select->addOption($module, $module_name." (" . $counts_module[$module] . ")"); |
| 85 | +} |
| 86 | +$tray->addElement($mod_select); |
| 87 | +$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); |
| 91 | +$tray->addElement($status_select); |
| 92 | +$tray->addElement(new XoopsFormButton("", "submit", _SUBMIT, "submit")); |
| 93 | +$opform->addElement($tray); |
| 94 | +$opform->display(); |
| 95 | + |
| 96 | +$criteria = new CriteriaCompo(); |
| 97 | +$criteria->setSort("a"); |
| 98 | +$criteria->setOrder("ASC"); |
| 99 | +$criteria->setStart($start); |
| 100 | +$criteria->setLimit($limit); |
| 101 | +if ($status >= 0) { |
| 102 | + $criteria->add( new Criteria("o.tag_status", $status) ); |
| 103 | +} |
| 104 | +if (!empty($modid)) { |
| 105 | + $criteria->add( new Criteria("l.tag_modid", $modid) ); |
| 106 | +} |
| 107 | +$tags = $tag_handler->getByLimit($criteria, false); |
| 108 | + |
| 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>"; |
| 117 | +if (empty($tags)) { |
| 118 | + $form_tags .= "<tr><td colspan='4'>" . _NONE . "</td></tr>"; |
| 119 | +} else { |
| 120 | + $class_tr = array("odd", "even"); |
| 121 | + $i = 0; |
| 122 | + 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>"; |
| 129 | + } |
| 130 | + if ( !empty($start) || count($tags) >= $limit ) { |
| 131 | + $count_tag = $tag_handler->getCount($criteria); |
| 132 | + |
| 133 | + include XOOPS_ROOT_PATH . "/class/pagenav.php"; |
| 134 | + $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>"; |
| 136 | + } |
| 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>"; |
| 144 | +} |
| 145 | +$form_tags .= "</table>"; |
| 146 | +$form_tags .= "</form>"; |
| 147 | + |
| 148 | +echo $form_tags; |
| 149 | +include "admin_footer.php"; |
0 commit comments