Skip to content

Commit 090462c

Browse files
authored
Merge pull request #18 from mambax7/master
updates
2 parents 756ad9d + 7a9f4f4 commit 090462c

99 files changed

Lines changed: 3479 additions & 1892 deletions

Some content is hidden

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

.scrutinizer.yml

Lines changed: 19 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,19 @@
1-
checks:
2-
php:
3-
code_rating: true
4-
variable_existence: true
5-
useless_calls: true
6-
use_statement_alias_conflict: true
7-
unused_variables: true
8-
unused_properties: true
9-
unused_parameters: true
10-
unused_methods: true
11-
unreachable_code: true
12-
sql_injection_vulnerabilities: true
13-
security_vulnerabilities: true
14-
precedence_mistakes: true
15-
precedence_in_conditions: true
16-
parameter_non_unique: true
17-
no_property_on_interface: true
18-
no_non_implemented_abstract_methods: true
19-
deprecated_code_usage: true
20-
closure_use_not_conflicting: true
21-
closure_use_modifiable: true
22-
avoid_useless_overridden_methods: true
23-
avoid_conflicting_incrementers: true
24-
assignment_of_null_return: true
25-
verify_property_names: true
26-
verify_argument_usable_as_reference: true
27-
verify_access_scope_valid: true
28-
use_self_instead_of_fqcn: true
29-
too_many_arguments: true
30-
single_namespace_per_use: true
31-
return_doc_comment_if_not_inferrable: true
32-
return_doc_comments: true
33-
require_scope_for_methods: true
34-
require_scope_for_properties: true
35-
require_php_tag_first: true
36-
require_braces_around_control_structures: true
37-
psr2_control_structure_declaration: true
38-
psr2_switch_declaration: true
39-
psr2_class_declaration: true
40-
no_eval: true
41-
no_else_if_statements: true
42-
avoid_corrupting_byteorder_marks: true
43-
argument_type_checks: true
44-
php5_style_constructor: true
45-
parameter_doc_comments: true
46-
no_duplicate_arguments: true
47-
missing_arguments: true
48-
instanceof_class_exists: true
49-
foreach_traversable: true
50-
no_unnecessary_function_call_in_for_loop: true
1+
# language: php
2+
build:
3+
nodes:
4+
tests: true
5+
analysis:
6+
dependencies:
7+
after:
8+
# The following installs the most recent XOOPS CMS version, you might want
9+
# to install a specific release tag or branch instead.
10+
- git clone --depth=1 https://github.com/XOOPS/XoopsCore25
11+
- git clone --depth=1 https://github.com/mambax7/tag
12+
project_setup:
13+
override: true
14+
tests:
15+
override:
16+
- php-scrutinizer-run --enable-security-analysis
17+
filter:
18+
dependency_paths:
19+
- XoopsCore25/*

CONTRIBUTING.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
![alt XOOPS CMS](https://xoops.org/images/logoXoops4GithubRepository.png)
2+
# Contributing to [XOOPS CMS](https://xoops.org)
3+
[![XOOPS CMS Module](https://img.shields.io/badge/XOOPS%20CMS-Module-blue.svg)](https://xoops.org)
4+
[![Software License](https://img.shields.io/badge/license-GPL-brightgreen.svg?style=flat)](http://www.gnu.org/licenses/gpl-2.0.html)
5+
6+
Contributions are **welcome** and will be fully **credited**.
7+
8+
We accept contributions via Pull Requests on [Github](https://github.com/XoopsModules25x/xoopseditors).
9+
10+
## Pull Requests
11+
12+
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
13+
- **Add tests!** - We encourage to provide tests for your contributions.
14+
- **Document any change in behavior** - Make sure the `/docs/changelog.txt` and any other relevant documentation are kept up-to-date.
15+
- **Consider our release cycle** - We try to follow [Semantic Versioning v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
16+
- **Create feature branches** - Don't ask us to pull from your master branch.
17+
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
18+
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.
19+
20+
**Happy coding, and _May the Source be with You_!**

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
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)
1+
![alt XOOPS CMS](https://xoops.org/images/logoXoops4GithubRepository.png)
2+
## Tag module for [XOOPS CMS 2.5.9+](https://xoops.org)
3+
[![XOOPS CMS Module](https://img.shields.io/badge/XOOPS%20CMS-Module-blue.svg)](https://xoops.org)
4+
[![Software License](https://img.shields.io/badge/license-GPL-brightgreen.svg?style=flat)](http://www.gnu.org/licenses/gpl-2.0.html)
5+
46
[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/XoopsModules25x/tag.svg?style=flat)](https://scrutinizer-ci.com/g/XoopsModules25x/tag/?branch=master)
57
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/0fdcfa1725a14753865921b99bb3611e)](https://www.codacy.com/app/mambax7/tag_2)
68
[![Code Climate](https://img.shields.io/codeclimate/github/XoopsModules25x/tag.svg?style=flat)](https://codeclimate.com/github/XoopsModules25x/tag)
79
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/0ffc2915-82a8-446a-978e-df50e2e58858/mini.png)](https://insight.sensiolabs.com/projects/0ffc2915-82a8-446a-978e-df50e2e58858)
810
[![Latest Pre-Release](https://img.shields.io/github/tag/XoopsModules25x/tag.svg?style=flat)](https://github.com/XoopsModules25x/tag/tags/)
911
[![Latest Version](https://img.shields.io/github/release/XoopsModules25x/tag.svg?style=flat)](https://github.com/XoopsModules25x/tag/releases/)
1012

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.
13+
**Tag module** for [XOOPS CMS](https://xoops.org) is designed for site-wide tag management, handling tag input, display and stats for each module that enables tag plugin.
1214

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/).
15+
[![Tutorial Available](https://xoops.org/images/tutorial-available-blue.svg)](https://xoops.gitbook.io/tag-tutorial/) Tutorial: see [GitBook](https://xoops.gitbook.io/tag-tutorial/).
1416
To contribute to the Tutorial, [fork it on GitHub](https://github.com/XoopsDocs/tag-tutorial)
1517

16-
[![Translations on Transifex](http://xoops.org/images/translations-transifex-blue.svg)](https://www.transifex.com/xoops)
18+
[![Translations on Transifex](https://xoops.org/images/translations-transifex-blue.svg)](https://www.transifex.com/xoops)
1719

18-
Please visit us on http://xoops.org
20+
Please visit us on https://xoops.org
1921

20-
The upcoming "next generation" version of XOOPS CMS is being crafted on GitHub at: https://github.com/XOOPS
22+
Current and upcoming "next generation" versions of XOOPS CMS are being crafted on GitHub at: https://github.com/XOOPS

admin/about.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@
1919
* @author Mamba
2020
* @since 2.31
2121
*/
22-
23-
include_once __DIR__ . '/admin_header.php';
24-
22+
require_once __DIR__ . '/admin_header.php';
2523
xoops_cp_header();
2624

27-
$aboutAdmin = new ModuleAdmin();
28-
29-
echo $aboutAdmin->addNavigation(basename(__FILE__));
30-
echo $aboutAdmin->renderAbout('xoopsfoundation@gmail.com', false);
25+
$adminObject->displayNavigation(basename(__FILE__));
26+
$adminObject::setPaypal('xoopsfoundation@gmail.com');
27+
$adminObject->displayAbout(false);
3128

32-
include __DIR__ . '/admin_footer.php';
29+
require_once __DIR__ . '/admin_footer.php';

admin/admin.tag.php

Lines changed: 58 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -19,91 +19,100 @@
1919
* @since 1.00
2020
*/
2121

22+
use Xmf\Request;
23+
use XoopsModules\Tag;
24+
use XoopsModules\Tag\Constants;
25+
2226
require_once __DIR__ . '/admin_header.php';
2327
require_once $GLOBALS['xoops']->path('/class/xoopsformloader.php');
24-
xoops_load('xoopsrequest');
2528

26-
$indexAdmin = new ModuleAdmin();
29+
$adminObject = \Xmf\Module\Admin::getInstance();
2730

2831
xoops_cp_header();
2932

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

3336
$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);
3743

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');
4048

41-
$postTags = XoopsRequest::getArray('tags', array(), 'POST');
49+
$postTags = Request::getArray('tags', [], 'POST');
4250
if (!empty($postTags)) {
4351
$msgDBUpdated = '';
4452
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')) {
4755
continue;
4856
}
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);
5159
} elseif ($tag_status != $tag_obj->getVar('tag_status')) {
5260
$tag_obj->setVar('tag_status', $tag_status);
53-
$tag_handler->insert($tag_obj);
61+
$tagHandler->insert($tag_obj);
5462
$msgDBUpdated = _AM_TAG_DB_UPDATED;
5563
}
5664
}
57-
redirect_header("admin.tag.php?modid={$modid}&amp;start={$start}&amp;status={$status}", TagConstants::REDIRECT_DELAY_MEDIUM, $msgDBUpdated);
65+
redirect_header("admin.tag.php?modid={$modid}&amp;start={$start}&amp;status={$status}", Constants::REDIRECT_DELAY_MEDIUM, $msgDBUpdated);
5866
}
5967

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 = [];
6573
$result = $GLOBALS['xoopsDB']->query($sql);
6674
if (false === $result) {
6775
xoops_error($GLOBALS['xoopsDB']->error());
6876
} else {
69-
while ($myrow = $GLOBALS['xoopsDB']->fetchArray($result)) {
77+
while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) {
7078
$counts_module[$myrow['tag_modid']] = $myrow['count_tag'];
7179
}
7280
if (!empty($counts_module)) {
81+
/** @var \XoopsModuleHandler $moduleHandler */
7382
$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'));
7584
}
7685
}
7786

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);
8190
$mod_select->addOption(0, _ALL);
8291
foreach ($module_list as $module => $module_name) {
8392
$mod_select->addOption($module, $module_name . ' (' . $counts_module[$module] . ')');
8493
}
8594
$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);
9099
$tray->addElement($status_select);
91-
$tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
100+
$tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
92101
$opform->addElement($tray);
93102
$opform->display();
94103

95-
$criteria = new CriteriaCompo();
104+
$criteria = new \CriteriaCompo();
96105
$criteria->setSort('a');
97106
$criteria->setOrder('ASC');
98107
$criteria->setStart($start);
99108
$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));
102111
}
103112
if (!empty($modid)) {
104-
$criteria->add(new Criteria('l.tag_modid', $modid));
113+
$criteria->add(new \Criteria('l.tag_modid', $modid));
105114
}
106-
$tags = $tag_handler->getByLimit(0, 0, $criteria, null, false);
115+
$tags = &$tagHandler->getByLimit(0, 0, $criteria, null, false);
107116

108117
$form_tags = "<form name='tags' method='post' action='"
109118
. xoops_getenv('PHP_SELF')
@@ -137,46 +146,46 @@
137146
. $tags[$key]['term']
138147
. "</td>\n"
139148
. " <td class='txtcenter'><input type='radio' name='tags[{$key}]' value='"
140-
. TagConstants::STATUS_INACTIVE
149+
. Constants::STATUS_INACTIVE
141150
. "'"
142151
. ($tags[$key]['status'] ? ' checked' : " '' ")
143152
. "></td>\n"
144153
. " <td class='txtcenter'><input type='radio' name='tags[{$key}]' value='"
145-
. TagConstants::STATUS_ACTIVE
154+
. Constants::STATUS_ACTIVE
146155
. "'"
147156
. ($tags[$key]['status'] ? " '' " : ' checked')
148157
. "></td>\n"
149158
. " <td class='txtcenter'><input type='radio' name='tags[{$key}]' value='"
150-
. TagConstants::STATUS_DELETE
159+
. Constants::STATUS_DELETE
151160
. "'></td>\n"
152161
. " </tr>\n";
153-
$class_tr = ('even' === $class_tr) ? 'odd' : 'even';
162+
$class_tr = ('even' === $class_tr) ? 'odd' : 'even';
154163
}
155164
if (!empty($start) || (count($tags) >= $limit)) {
156-
$count_tag = $tag_handler->getCount($criteria);
165+
$count_tag = $tagHandler->getCount($criteria);
157166

158-
include $GLOBALS['xoops']->path('/class/pagenav.php');
159-
$nav = new XoopsPageNav($count_tag, $limit, $start, 'start', "modid={$modid}&amp;status={$status}");
167+
require_once $GLOBALS['xoops']->path('/class/pagenav.php');
168+
$nav = new \XoopsPageNav($count_tag, $limit, $start, 'start', "modid={$modid}&amp;status={$status}");
160169
$form_tags .= " <tr><td colspan='4' class='txtright'>" . $nav->renderNav(4) . "</td></tr>\n";
161170
}
162171
$form_tags .= " </tbody>\n"
163172
. " <tfoot>\n"
164173
. " <tr>\n"
165174
. " <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"
169178
. " <input type='submit' name='submit' value='"
170179
. _SUBMIT
171-
. "' /> \n"
180+
. "'> \n"
172181
. " <input type='reset' name='submit' value='"
173182
. _CANCEL
174-
. "' />\n"
183+
. "'>\n"
175184
. " </td>\n"
176185
. " </tr>\n"
177186
. " </tfoot>\n";
178187
}
179188
$form_tags .= " </tbody>\n" . "</table>\n" . "</form>\n";
180189

181190
echo $form_tags;
182-
include __DIR__ . '/admin_footer.php';
191+
require_once __DIR__ . '/admin_footer.php';

admin/admin_footer.php

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,11 @@
1515
* @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}
18-
* @author Mamba {@link http://www.xoops.org}
18+
* @author Mamba {@link https://xoops.org}
1919
* @since 2.31
2020
*/
21-
/*
22-
echo "<div class='adminfooter'>\n"
23-
." <div class='txtcenter'>\n"
24-
." <a href='http://www.xoops.org' rel='external'><img src='{$pathIcon32}/xoopsmicrobutton.gif' alt='XOOPS' title='XOOPS'></a>\n"
25-
." </div>\n"
26-
." " . _AM_TAG_FOOTER . "\n"
27-
."</div>";
28-
*/
29-
echo "<div class='adminfooter'>\n"
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>';
21+
$pathIcon32 = Xmf\Module\Admin::iconUrl('', 32);
22+
23+
echo "<div class='adminfooter'>\n" . " <div style='text-align: center;'>\n" . " <a href='https://xoops.org' rel='external'><img src='{$pathIcon32}/xoopsmicrobutton.gif' alt='XOOPS' title='XOOPS'></a>\n" . " </div>\n" . ' ' . _AM_MODULEADMIN_ADMIN_FOOTER . "\n" . '</div>';
5224

5325
xoops_cp_footer();

0 commit comments

Comments
 (0)