Skip to content

Commit 70e25ba

Browse files
authored
Merge pull request #154 from mambax7/master
1.08 Alpha 3
2 parents c65278a + edaa71f commit 70e25ba

File tree

188 files changed

+4912
-1794
lines changed

Some content is hidden

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

188 files changed

+4912
-1794
lines changed

.scrutinizer.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ build:
1313
override: true
1414
tests:
1515
override:
16-
- php-scrutinizer-run --enable-security-analysis
16+
- php-scrutinizer-run --enable-security-analysis
17+
environment:
18+
php:
19+
version: "7.2"
1720
filter:
1821
dependency_paths:
19-
- XoopsCore25/*
20-
- tag/*
22+
- XoopsCore25/*
23+
- tag/*

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ We accept contributions via Pull Requests on [Github](https://github.com/XoopsMo
99

1010
## Pull Requests
1111

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).
12+
- **[PSR-12 Coding Standard](https://www.php-fig.org/psr/psr-12/)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
1313
- **Add tests!** - We encourage providing tests for your contributions.
1414
- **Document any change in behavior** - Make sure the `/docs/changelog.txt` and any other relevant documentation are up-to-date.
1515
- **Consider our release cycle** - We try to follow [Semantic Versioning v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
1616
- **Create feature branches** - Don't ask us to pull from your master branch.
1717
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
1818
- **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.
1919

20-
**Happy coding, and _May the Source be with You_!**
20+
Happy coding, and **_May the Source be with You_**!

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![alt XOOPS CMS](https://xoops.org/images/logoXoops4GithubRepository.png)
1+
![alt XOOPS CMS](https://xoops.org/images/logoXoopsPhp8.png)
22
## Publisher module for [XOOPS CMS 2.5.10+](https://xoops.org)
33
[![XOOPS CMS Module](https://img.shields.io/badge/XOOPS%20CMS-Module-blue.svg)](https://xoops.org)
44
[![Software License](https://img.shields.io/badge/license-GPL-brightgreen.svg?style=flat)](https://www.gnu.org/licenses/gpl-2.0.html)

admin/about.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@
1919
* @since 1.0
2020
* @author Mage, Mamba
2121
*/
22-
require_once __DIR__ . '/admin_header.php';
22+
23+
use Xmf\Module\Admin;
24+
25+
/** @var Admin $adminObject */
26+
27+
require __DIR__ . '/admin_header.php';
2328
xoops_cp_header();
2429

2530
$adminObject->displayNavigation(basename(__FILE__));

admin/admin_footer.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
* @since
1818
* @author XOOPS Development Team
1919
*/
20-
$pathIcon32 = \Xmf\Module\Admin::iconUrl('', 32);
20+
21+
use Xmf\Module\Admin;
22+
23+
$pathIcon32 = Admin::iconUrl('', 32);
2124

2225
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>';
2326

admin/admin_header.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
use Xmf\Module\Admin;
2323
use XoopsModules\Publisher\Helper;
24+
use XoopsModules\Publisher\Common\Configurator;
2425

2526
require dirname(__DIR__) . '/preloads/autoloader.php';
2627

@@ -46,12 +47,8 @@
4647
$helper->loadLanguage('modinfo');
4748
$helper->loadLanguage('main');
4849

49-
$imagearray = [
50-
'editimg' => "<img src='" . PUBLISHER_IMAGES_URL . "/button_edit.png' alt='" . _AM_PUBLISHER_ICO_EDIT . "' align='middle'>",
51-
'deleteimg' => "<img src='" . PUBLISHER_IMAGES_URL . "/button_delete.png' alt='" . _AM_PUBLISHER_ICO_DELETE . "' align='middle'>",
52-
'online' => "<img src='" . PUBLISHER_IMAGES_URL . "/on.png' alt='" . _AM_PUBLISHER_ICO_ONLINE . "' align='middle'>",
53-
'offline' => "<img src='" . PUBLISHER_IMAGES_URL . "/off.png' alt='" . _AM_PUBLISHER_ICO_OFFLINE . "' align='middle'>",
54-
];
50+
$configurator = new Configurator();
51+
$icons = $configurator->icons;
5552

5653
$myts = \MyTextSanitizer::getInstance();
5754

admin/blockform.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
}
120120

121121
//Submit buttons
122-
$buttonTray = new \XoopsFormElementTray('', '');
122+
$buttonTray = new \XoopsFormElementTray('', '');
123123
$submitButton = new \XoopsFormButton('', 'submitblock', _SUBMIT, 'submit');
124124
$buttonTray->addElement($submitButton);
125125

admin/blocksadmin.php

+33-26
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@
1818

1919
use Xmf\Module\Admin;
2020
use Xmf\Request;
21+
use XoopsModules\Publisher\{
22+
Common\Configurator,
23+
Helper
24+
};
2125

2226
require __DIR__ . '/admin_header.php';
27+
include_once $GLOBALS['xoops']->path('class/xoopsblock.php');
2328

2429
$moduleDirName = basename(dirname(__DIR__));
2530
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
@@ -66,6 +71,9 @@ function listBlocks()
6671
xoops_loadLanguage('admin/blocksadmin', 'system');
6772
xoops_loadLanguage('admin/groups', 'system');
6873

74+
$configurator = new Configurator();
75+
$icons = $configurator->icons;
76+
6977
/** @var \XoopsModuleHandler $moduleHandler */
7078
$moduleHandler = xoops_getHandler('module');
7179
/** @var \XoopsMemberHandler $memberHandler */
@@ -81,8 +89,7 @@ function listBlocks()
8189
ksort($moduleList);
8290
echo "
8391
<h4 style='text-align:left;'>" . constant('CO_' . $moduleDirNameUpper . '_' . 'BADMIN') . '</h4>';
84-
// $moduleHandler = xoops_getHandler('module');
85-
echo "<form action='" . \Xmf\Request::getString('SCRIPT_NAME', '', 'SERVER') . "' name='blockadmin' method='post'>";
92+
echo "<form action='" . Request::getString('SCRIPT_NAME', '', 'SERVER') . "' name='blockadmin' method='post'>";
8693
echo $GLOBALS['xoopsSecurity']->getTokenHTML();
8794
echo "<table width='100%' class='outer' cellpadding='4' cellspacing='1'>
8895
<tr valign='middle'><th align='center'>"
@@ -111,10 +118,10 @@ function listBlocks()
111118
. constant('CO_' . $moduleDirNameUpper . '_' . 'ACTION')
112119
. '</th></tr>
113120
';
114-
$blockArray = \XoopsBlock::getByModule($xoopsModule->mid());
121+
$blockArray = \XoopsBlock::getByModule($xoopsModule->mid());
115122
$blockCount = count($blockArray);
116-
$class = 'even';
117-
$cachetimes = [
123+
$class = 'even';
124+
$cachetimes = [
118125
'0' => _NOCACHE,
119126
'30' => sprintf(_SECONDS, 30),
120127
'60' => _MINUTE,
@@ -129,9 +136,9 @@ function listBlocks()
129136
];
130137
foreach ($blockArray as $i) {
131138
$groupsPerms = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid'));
132-
$sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid');
133-
$result = $db->query($sql);
134-
$modules = [];
139+
$sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid');
140+
$result = $db->query($sql);
141+
$modules = [];
135142
while (false !== ($row = $db->fetchArray($result))) {
136143
$modules[] = (int)$row['module_id'];
137144
}
@@ -257,12 +264,10 @@ function listBlocks()
257264

258265
// Actions
259266

260-
echo "<td class='$class' align='center'><a href='blocksadmin.php?op=edit&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/edit.png' . " alt='" . _EDIT . "' title='" . _EDIT . "'>
261-
</a> <a href='blocksadmin.php?op=clone&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/editcopy.png' . " alt='" . _CLONE . "' title='" . _CLONE . "'>
267+
echo "<td class='$class' align='center'><a href='blocksadmin.php?op=edit&amp;bid=" . $i->getVar('bid') . "'>" . $icons->edit . "</a> <a href='blocksadmin.php?op=clone&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/editcopy.png' . " alt='" . _CLONE . "' title='" . _CLONE . "'>
262268
</a>";
263-
if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) {
264-
echo "&nbsp;<a href='" . XOOPS_URL . '/modules/system/admin.php?fct=blocksadmin&amp;op=delete&amp;bid=' . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/delete.png' . " alt='" . _DELETE . "' title='" . _DELETE . "'>
265-
</a>";
269+
if (!in_array($i->getVar('block_type'), ['S', 'M'])) {
270+
echo "&nbsp;<a href='" . XOOPS_URL . '/modules/system/admin.php?fct=blocksadmin&amp;op=delete&amp;bid=' . $i->getVar('bid') . "'>" . $icons->delete . '</a>';
266271
}
267272
echo "
268273
<input type='hidden' name='oldtitle[" . $i->getVar('bid') . "]' value='" . $i->getVar('title') . "'>
@@ -313,8 +318,8 @@ function cloneBlock($bid)
313318
while (false !== ($row = $db->fetchArray($result))) {
314319
$modules[] = (int)$row['module_id'];
315320
}
316-
$isCustom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type'));
317-
$block = [
321+
$isCustom = (in_array($myblock->getVar('block_type'), ['C', 'E']));
322+
$block = [
318323
'title' => $myblock->getVar('title') . ' Clone',
319324
'form_title' => constant('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK'),
320325
'name' => $myblock->getVar('name'),
@@ -375,7 +380,7 @@ function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule,
375380
$clone->setVar('options', $options);
376381
}
377382
$clone->setVar('bid', 0);
378-
if ('C' === $block->getVar('block_type') || 'E' === $block->getVar('block_type')) {
383+
if (in_array($block->getVar('block_type'), ['C', 'E'])) {
379384
$clone->setVar('block_type', 'E');
380385
} else {
381386
$clone->setVar('block_type', 'D');
@@ -404,9 +409,8 @@ function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule,
404409
$db->query($sql);
405410
}
406411
$groups = &$GLOBALS['xoopsUser']->getGroups();
407-
$count = count($groups);
408-
for ($i = 0; $i < $count; ++$i) {
409-
$sql = 'INSERT INTO ' . $db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $groups[$i] . ', ' . $newid . ", 1, 'block_read')";
412+
foreach ($groups as $iValue) {
413+
$sql = 'INSERT INTO ' . $db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $iValue . ', ' . $newid . ", 1, 'block_read')";
410414
$db->query($sql);
411415
}
412416
redirect_header('blocksadmin.php?op=listar', 1, _AM_DBUPDATED);
@@ -419,8 +423,9 @@ function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule,
419423
* @param bool $visible
420424
* @param string $side
421425
* @param int $bcachetime
426+
* @param null $bmodule
422427
*/
423-
function setOrder($bid, $title, $weight, $visible, $side, $bcachetime)
428+
function setOrder($bid, $title, $weight, $visible, $side, $bcachetime, $bmodule = null)
424429
{
425430
$myblock = new \XoopsBlock($bid);
426431
$myblock->setVar('title', $title);
@@ -456,8 +461,8 @@ function editBlock($bid)
456461
while (false !== ($row = $db->fetchArray($result))) {
457462
$modules[] = (int)$row['module_id'];
458463
}
459-
$isCustom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type'));
460-
$block = [
464+
$isCustom = (in_array($myblock->getVar('block_type'), ['C', 'E']));
465+
$block = [
461466
'title' => $myblock->getVar('title'),
462467
'form_title' => constant('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_EDITBLOCK'),
463468
// 'name' => $myblock->getVar('name'),
@@ -504,14 +509,16 @@ function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $b
504509
$myblock->setVar('visible', $bvisible);
505510
$myblock->setVar('side', $bside);
506511
$myblock->setVar('bcachetime', $bcachetime);
512+
$helper = Helper::getInstance();
513+
$helper->loadLanguage('common');
507514
//update block options
508515
if (isset($options)) {
509516
$optionsCount = count($options);
510517
if ($optionsCount > 0) {
511518
//Convert array values to comma-separated
512-
for ($i = 0; $i < $optionsCount; ++$i) {
513-
if (is_array($options[$i])) {
514-
$options[$i] = implode(',', $options[$i]);
519+
foreach ($options as $i => $iValue) {
520+
if (is_array($iValue)) {
521+
$options[$i] = implode(',', $iValue);
515522
}
516523
}
517524
$options = implode('|', $options);
@@ -562,7 +569,7 @@ function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $b
562569
if ($oldtitle[$i] !== $title[$i] || $oldweight[$i] !== $weight[$i] || $oldvisible[$i] !== $visible[$i]
563570
|| $oldside[$i] !== $side[$i]
564571
|| $oldbcachetime[$i] !== $bcachetime[$i]) {
565-
setOrder($bid[$i], $title[$i], $weight[$i], $visible[$i], $side[$i], $bcachetime[$i], $bmodule[$i]=null);
572+
setOrder($bid[$i], $title[$i], $weight[$i], $visible[$i], $side[$i], $bcachetime[$i], $bmodule[$i]);
566573
}
567574
if (!empty($bmodule[$i]) && count($bmodule[$i]) > 0) {
568575
$sql = sprintf('DELETE FROM `%s` WHERE block_id = %u', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid[$i]);

admin/category.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@
2020
*/
2121

2222
use Xmf\Request;
23-
use XoopsModules\Publisher\{
23+
use XoopsModules\Publisher\{Helper,
2424
Utility
2525
};
2626

27+
/** @var Helper $helper */
28+
2729
require_once __DIR__ . '/admin_header.php';
2830

2931
$op = Request::getCmd('op', Request::getCmd('op', '', 'POST'), 'GET');
@@ -72,7 +74,7 @@
7274

7375
// Uploading the image, if any
7476
// Retreive the filename to be uploaded
75-
$temp = Request::getArray('image_file', '', 'FILES');
77+
$temp = Request::getArray('image_file', '', 'FILES');
7678
$imageFile = $temp['name'];
7779
if ($imageFile) {
7880
// $filename = Request::getArray('xoops_upload_file', array(), 'POST')[0];
@@ -81,8 +83,8 @@
8183
if ($filename) {
8284
// TODO : implement publisher mimetype management
8385
$maxSize = $helper->getConfig('maximum_filesize');
84-
$maxImageWidth = $helper->getConfig('maximum_image_width');
85-
$maxImageHeight = $helper->getConfig('maximum_image_height');
86+
$maxImageWidth = $helper->getConfig('maximum_image_width');
87+
$maxImageHeight = $helper->getConfig('maximum_image_height');
8688
$allowedMimetypes = Utility::getAllowedImagesTypes();
8789
if (('' == $temp['tmp_name']) || !is_readable($temp['tmp_name'])) {
8890
redirect_header('<script>javascript:history.go(-1)</script>', 2, _AM_PUBLISHER_FILEUPLOAD_ERROR);
@@ -162,7 +164,7 @@
162164
//Added by fx2024
163165

164166
case 'addsubcats':
165-
$categoryId = 0;
167+
$categoryId = 0;
166168
$numberSubcats = Request::getInt('nb_subcats', 0, 'POST') + Request::getInt('nb_sub_yet', 0, 'POST');
167169

168170
$categoryObj = $helper->getHandler('Category')->create();

admin/clone.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
*/
2020

2121
use Xmf\Request;
22-
use XoopsModules\Publisher\{
23-
Cloner,
22+
use XoopsModules\Publisher\{Cloner,
2423
Utility
2524
};
2625

admin/feedback.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@
2121
* @author Fernando Santos (topet05) <fernando@mastop.com.br>
2222
*/
2323

24+
use Xmf\Module\Admin;
2425
use Xmf\Request;
2526
use \XoopsModules\Publisher\Common\ModuleFeedback;
2627

2728
require __DIR__ . '/admin_header.php';
2829

29-
$adminObject = \Xmf\Module\Admin::getInstance();
30+
$adminObject = Admin::getInstance();
3031

3132
$feedback = new ModuleFeedback();
3233

@@ -45,7 +46,7 @@
4546
$feedback->name = $GLOBALS['xoopsUser']->getVar('name');
4647
$feedback->email = $GLOBALS['xoopsUser']->getVar('email');
4748
$feedback->site = XOOPS_URL;
48-
$form = $feedback->getFormFeedback();
49+
$form = $feedback->getFormFeedback();
4950
echo $form->display();
5051
break;
5152
case 'send':
@@ -58,7 +59,7 @@
5859

5960
$your_name = Request::getString('your_name', '');
6061
$your_site = Request::getString('your_site', '');
61-
$yourMail = Request::getString('your_mail', '');
62+
$yourMail = Request::getString('your_mail', '');
6263
$fb_type = Request::getString('fb_type', '');
6364
$fb_content = Request::getText('fb_content', '');
6465
$fb_content = str_replace(["\r\n", "\n", "\r"], '<br>', $fb_content); //clean line break from dhtmltextarea

0 commit comments

Comments
 (0)