Skip to content

Commit 463166a

Browse files
committed
Merge pull request #5 from mambax7/master
2.33 RC 1
2 parents e6990fe + 62c7c45 commit 463166a

66 files changed

Lines changed: 2508 additions & 1986 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.codeclimate.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
engines:
2+
eslint:
3+
enabled: true
4+
csslint:
5+
enabled: true
6+
duplication:
7+
enabled: true
8+
config:
9+
languages:
10+
- javascript
11+
- php
12+
fixme:
13+
enabled: true
14+
phpmd:
15+
enabled: true
16+
config:
17+
file_extensions:
18+
- php
19+
- inc
20+
phpcodesniffer:
21+
enabled: true
22+
config:
23+
file_extensions: "php,inc,lib"
24+
standard: "PSR1,PSR2"
25+
ratings:
26+
paths:
27+
- "**.inc"
28+
- "**.js"
29+
- "**.lib"
30+
- "**.php"
31+
exclude_paths: []

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
#Tag
2-
[![Software License](https://img.shields.io/badge/license-GPL-brightgreen.svg?style=flat)](LICENSE)
1+
![alt XOOPS CMS](http://xoops.org/images/logoXoops4GithubRepository.png)
2+
## Tag module for [XOOPS CMS 2.5.8+](https://xoops.org)
3+
[![Software License](https://img.shields.io/badge/license-GPL-brightgreen.svg?style=flat)](LICENSE)
4+
[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/XoopsModules25x/tag.svg?style=flat)](https://scrutinizer-ci.com/g/XoopsModules25x/tag/?branch=master)
5+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/0fdcfa1725a14753865921b99bb3611e)](https://www.codacy.com/app/mambax7/tag_2)
6+
[![Code Climate](https://img.shields.io/codeclimate/github/XoopsModules25x/tag.svg?style=flat)](https://codeclimate.com/github/XoopsModules25x/tag)
7+
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/0ffc2915-82a8-446a-978e-df50e2e58858/mini.png)](https://insight.sensiolabs.com/projects/0ffc2915-82a8-446a-978e-df50e2e58858)
8+
[![Latest Pre-Resease](https://img.shields.io/github/tag/XoopsModules25x/tag.svg?style=flat)](https://github.com/XoopsModules25x/tag/tags/)
9+
[![Latest Version](https://img.shields.io/github/release/XoopsModules25x/tag.svg?style=flat)](https://github.com/XoopsModules25x/tag/releases/)
310

4-
The Tag module is designed for site-wide tag management, handling tag input, display and stats for each module that enables tag plugin.
11+
Tag module for [XOOPS CMS](http://xoops.org) is designed for site-wide tag management, handling tag input, display and stats for each module that enables tag plugin.
12+
13+
[![Tutorial Available](http://xoops.org/images/tutorial-available-blue.svg)](https://www.gitbook.com/book/xoops/tag-tutorial/) Tutorial: see [GitBook](https://www.gitbook.com/book/xoops/tag-tutorial/).
14+
To contribute to the Tutorial, [fork it on GitHub](https://github.com/XoopsDocs/tag-tutorial)
15+
16+
[![Translations on Transifex](http://xoops.org/images/translations-transifex-blue.svg)](https://www.transifex.com/xoops)
17+
18+
Please visit us on http://xoops.org
19+
20+
The upcoming "next generation" version of XOOPS CMS is being crafted on GitHub at: https://github.com/XOOPS
21+
22+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/0fdcfa1725a14753865921b99bb3611e)](https://www.codacy.com/app/mambax7/tag_2?utm_source=github.com&utm_medium=referral&utm_content=XoopsModules25x/tag&utm_campaign=Badge_Grade)

admin/about.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@
1212
/**
1313
* XOOPS tag management module
1414
*
15-
* @package tag
15+
* @package tag
1616
* @copyright {@link http://sourceforge.net/projects/xoops/ The XOOPS Project}
1717
* @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
1818
* @author Mage
1919
* @author Mamba
2020
* @since 2.31
21-
* @version $Id: about.php 12898 2014-12-08 22:05:21Z zyspec $
2221
*/
2322

2423
include_once __DIR__ . '/admin_header.php';
@@ -27,7 +26,7 @@
2726

2827
$aboutAdmin = new ModuleAdmin();
2928

30-
echo $aboutAdmin->addNavigation('about.php');
29+
echo $aboutAdmin->addNavigation(basename(__FILE__));
3130
echo $aboutAdmin->renderAbout('6KJ7RW5DR3VTJ', false);
3231

3332
include __DIR__ . '/admin_footer.php';

admin/admin.tag.php

Lines changed: 88 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -12,146 +12,171 @@
1212
/**
1313
* XOOPS tag management module
1414
*
15-
* @package tag
15+
* @package tag
1616
* @copyright {@link http://sourceforge.net/projects/xoops/ The XOOPS Project}
1717
* @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
1818
* @author Taiwen Jiang <phppp@users.sourceforge.net>
1919
* @since 1.00
20-
* @version $Id: admin.tag.php 12898 2014-12-08 22:05:21Z zyspec $
2120
*/
2221

2322
require_once __DIR__ . '/admin_header.php';
24-
require_once $GLOBALS['xoops']->path("/class/xoopsformloader.php");
23+
require_once $GLOBALS['xoops']->path('/class/xoopsformloader.php');
2524
xoops_load('xoopsrequest');
2625

2726
$indexAdmin = new ModuleAdmin();
2827

2928
xoops_cp_header();
3029

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__));
3332

3433
$limit = $GLOBALS['xoopsModuleConfig']['items_perpage'];
3534
$modid = XoopsRequest::getInt('modid', TagConstants::DEFAULT_ID);
3635
$start = XoopsRequest::getInt('start', TagConstants::BEGINNING);
3736
$status = XoopsRequest::getInt('status', TagConstants::STATUS_ALL, 'GET');
3837

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);
4140

4241
$postTags = XoopsRequest::getArray('tags', array(), 'POST');
4342
if (!empty($postTags)) {
44-
$msgDBUpdated='';
43+
$msgDBUpdated = '';
4544
foreach ($postTags as $tag => $tag_status) {
4645
$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+
}
4849
if ($tag_status < TagConstants::STATUS_ACTIVE) {
4950
$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);
5253
$tag_handler->insert($tag_obj);
5354
$msgDBUpdated = _AM_TAG_DB_UPDATED;
5455
}
5556
}
5657
redirect_header("admin.tag.php?modid={$modid}&amp;start={$start}&amp;status={$status}", TagConstants::REDIRECT_DELAY_MEDIUM, $msgDBUpdated);
5758
}
5859

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';
6263
$counts_module = array();
63-
$module_list = array();
64-
$result = $GLOBALS['xoopsDB']->query($sql);
64+
$module_list = array();
65+
$result = $GLOBALS['xoopsDB']->query($sql);
6566
if (false === $result) {
6667
xoops_error($GLOBALS['xoopsDB']->error());
6768
} else {
6869
while ($myrow = $GLOBALS['xoopsDB']->fetchArray($result)) {
69-
$counts_module[$myrow["tag_modid"]] = $myrow["count_tag"];
70+
$counts_module[$myrow['tag_modid']] = $myrow['count_tag'];
7071
}
7172
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'));
7475
}
7576
}
7677

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('');
7980
$mod_select = new XoopsFormSelect(_SELECT, 'modid', $modid);
8081
$mod_select->addOption(0, _ALL);
8182
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] . ')');
8384
}
8485
$tray->addElement($mod_select);
85-
$status_select = new XoopsFormRadio("", 'status', $status);
86+
$status_select = new XoopsFormRadio('', 'status', $status);
8687
$status_select->addOption(TagConstants::STATUS_ALL, _ALL);
8788
$status_select->addOption(TagConstants::STATUS_ACTIVE, _AM_TAG_ACTIVE);
8889
$status_select->addOption(TagConstants::STATUS_INACTIVE, _AM_TAG_INACTIVE);
8990
$tray->addElement($status_select);
90-
$tray->addElement(new XoopsFormButton("", "submit", _SUBMIT, "submit"));
91+
$tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
9192
$opform->addElement($tray);
9293
$opform->display();
9394

9495
$criteria = new CriteriaCompo();
95-
$criteria->setSort("a");
96-
$criteria->setOrder("ASC");
96+
$criteria->setSort('a');
97+
$criteria->setOrder('ASC');
9798
$criteria->setStart($start);
9899
$criteria->setLimit($limit);
99100
if ($status >= TagConstants::STATUS_ACTIVE) {
100-
$criteria->add(new Criteria("o.tag_status", $status));
101+
$criteria->add(new Criteria('o.tag_status', $status));
101102
}
102103
if (!empty($modid)) {
103-
$criteria->add(new Criteria("l.tag_modid", $modid));
104+
$criteria->add(new Criteria('l.tag_modid', $modid));
104105
}
105-
$tags = $tag_handler->getByLimit($criteria, false);
106+
$tags = $tag_handler->getByLimit(0, 0, $criteria, null, false);
106107

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";
118129
if (empty($tags)) {
119130
$form_tags .= " <tr><td colspan='4'>" . _NONE . "</td></tr>\n";
120131
} else {
121132
$class_tr = 'odd';
122-
$i = 0;
133+
$i = 0;
123134
foreach (array_keys($tags) as $key) {
124135
$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';
131154
}
132155
if (!empty($start) || (count($tags) >= $limit)) {
133156
$count_tag = $tag_handler->getCount($criteria);
134157

135-
include $GLOBALS['xoops']->path("/class/pagenav.php");
136-
$nav = new XoopsPageNav($count_tag, $limit, $start, "start", "modid={$modid}&amp;status={$status}");
158+
include $GLOBALS['xoops']->path('/class/pagenav.php');
159+
$nav = new XoopsPageNav($count_tag, $limit, $start, 'start', "modid={$modid}&amp;status={$status}");
137160
$form_tags .= " <tr><td colspan='4' class='txtright'>" . $nav->renderNav(4) . "</td></tr>\n";
138161
}
139162
$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";
151178
}
152-
$form_tags .= " </tbody>\n"
153-
. "</table>\n"
154-
. "</form>\n";
179+
$form_tags .= " </tbody>\n" . "</table>\n" . "</form>\n";
155180

156181
echo $form_tags;
157182
include __DIR__ . '/admin_footer.php';

admin/admin_footer.php

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
/**
1313
* XOOPS tag management module
1414
*
15-
* @package tag
15+
* @package tag
1616
* @copyright {@link http://sourceforge.net/projects/xoops/ The XOOPS Project}
1717
* @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
1818
* @author Mamba {@link http://www.xoops.org}
1919
* @since 2.31
20-
* @version $Id: admin_footer.php 12898 2014-12-08 22:05:21Z zyspec $
2120
*/
2221
/*
2322
echo "<div class='adminfooter'>\n"
@@ -28,14 +27,27 @@
2827
."</div>";
2928
*/
3029
echo "<div class='adminfooter'>\n"
31-
. " <div class='center'>\n"
32-
. " <a href='" . $GLOBALS['xoopsModule']->getInfo('author_website_url') . "' target='_blank'><img src='{$pathIcon32}/xoopsmicrobutton.gif' alt='" . $GLOBALS['xoopsModule']->getInfo('author_website_name') . "' title='" . $GLOBALS['xoopsModule']->getInfo('author_website_name') . "' /></a>\n"
33-
. " </div>\n"
34-
. " <div class='center smallsmall italic pad5'>\n"
35-
. " " . _AM_TAG_MAINTAINED_BY
36-
. " <a class='tooltip' rel='external' href='http://" . $GLOBALS['xoopsModule']->getInfo('module_website_url') . "' "
37-
. "title='" . _AM_TAG_MAINTAINED_TITLE . "'>" . _AM_TAG_MAINTAINED_TEXT . "</a>\n"
38-
. " </div>\n"
39-
. "</div>";
30+
. " <div class='center'>\n"
31+
. " <a href='"
32+
. $GLOBALS['xoopsModule']->getInfo('author_website_url')
33+
. "' target='_blank'><img src='{$pathIcon32}/xoopsmicrobutton.gif' alt='"
34+
. $GLOBALS['xoopsModule']->getInfo('author_website_name')
35+
. "' title='"
36+
. $GLOBALS['xoopsModule']->getInfo('author_website_name')
37+
. "' /></a>\n"
38+
. " </div>\n"
39+
. " <div class='center smallsmall italic pad5'>\n"
40+
. ' '
41+
. _AM_TAG_MAINTAINED_BY
42+
. " <a class='tooltip' rel='external' href='http://"
43+
. $GLOBALS['xoopsModule']->getInfo('module_website_url')
44+
. "' "
45+
. "title='"
46+
. _AM_TAG_MAINTAINED_TITLE
47+
. "'>"
48+
. _AM_TAG_MAINTAINED_TEXT
49+
. "</a>\n"
50+
. " </div>\n"
51+
. '</div>';
4052

4153
xoops_cp_footer();

admin/admin_header.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
/**
1313
* XOOPS tag management module
1414
*
15-
* @copyright The XOOPS project http://sourceforge.net/projects/xoops/
15+
* @copyright XOOPS Project (http://xoops.org)
1616
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
1717
* @since 1.00
1818
* @author Taiwen Jiang <phppp@users.sourceforge.net>
19-
* @version $Id: admin_header.php 12898 2014-12-08 22:05:21Z zyspec $
2019
* */
2120

2221
$path = dirname(dirname(dirname(__DIR__)));
@@ -32,14 +31,10 @@
3231
xoops_loadLanguage('modinfo', $thisModuleDir);
3332
xoops_loadLanguage('main', $thisModuleDir);
3433

35-
$pathIcon16 = $GLOBALS['xoops']->url('www/' . $GLOBALS['xoopsModule']->getInfo('icons16'));
36-
$pathIcon32 = $GLOBALS['xoops']->url('www/' . $GLOBALS['xoopsModule']->getInfo('icons32'));
34+
$pathIcon16 = $GLOBALS['xoops']->url('www/' . $GLOBALS['xoopsModule']->getInfo('icons16'));
35+
$pathIcon32 = $GLOBALS['xoops']->url('www/' . $GLOBALS['xoopsModule']->getInfo('icons32'));
3736
$pathModuleAdmin = $GLOBALS['xoops']->path('www/' . $GLOBALS['xoopsModule']->getInfo('dirmoduleadmin'));
3837

39-
if ( file_exists("{$pathModuleAdmin}/moduleadmin/moduleadmin.php")) {
40-
include_once "{$pathModuleAdmin}/moduleadmin/moduleadmin.php";
41-
} else {
42-
redirect_header("{$path}/admin.php", TagConstants::REDIRECT_DELAY_LONG, _AM_MODULEADMIN_MISSING, false);
43-
}
38+
include_once "{$pathModuleAdmin}/moduleadmin/moduleadmin.php";
4439

45-
include_once $GLOBALS['xoops']->path("/Frameworks/art/functions.admin.php");
40+
include_once $GLOBALS['xoops']->path('/Frameworks/art/functions.admin.php');

0 commit comments

Comments
 (0)