Skip to content

Commit e1b3593

Browse files
authored
Merge pull request #130 from mambax7/master
1.08 Alpha 1
2 parents 81fe89e + 99165a8 commit e1b3593

File tree

184 files changed

+4703
-2364
lines changed

Some content is hidden

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

184 files changed

+4703
-2364
lines changed

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
![alt XOOPS CMS](https://xoops.org/images/logoXoops4GithubRepository.png)
22
# Contributing to [XOOPS CMS](https://xoops.org)
33
[![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)
4+
[![Software License](https://img.shields.io/badge/license-GPL-brightgreen.svg?style=flat)](https://www.gnu.org/licenses/gpl-2.0.html)
55

66
Contributions are **welcome** and will be fully **credited**.
77

@@ -10,7 +10,7 @@ We accept contributions via Pull Requests on [Github](https://github.com/XoopsMo
1010
## Pull Requests
1111

1212
- **[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.
13+
- **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 kept 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.

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
![alt XOOPS CMS](https://xoops.org/images/logoXoops4GithubRepository.png)
2-
## Publisher module for [XOOPS CMS 2.5.9+](https://xoops.org)
2+
## 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)
4-
[![Software License](https://img.shields.io/badge/license-GPL-brightgreen.svg?style=flat)](http://www.gnu.org/licenses/gpl-2.0.html)
4+
[![Software License](https://img.shields.io/badge/license-GPL-brightgreen.svg?style=flat)](https://www.gnu.org/licenses/gpl-2.0.html)
55

66
[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/mambax7/publisher.svg?style=flat)](https://scrutinizer-ci.com/g/mambax7/publisher/?branch=master)
77
[![Codacy Badge](https://api.codacy.com/project/badge/grade/2d27c0023ee54f0b9ba2b5d17a68b2a5)](https://www.codacy.com/app/mambax7/publisher)
@@ -15,7 +15,7 @@
1515
[![Tutorial Available](https://xoops.org/images/tutorial-available-blue.svg)](https://xoops.gitbook.io/publisher-tutorial/) Tutorial: see [GitBook](https://xoops.gitbook.io/publisher-tutorial/).
1616
To contribute to the Tutorial, [fork it on GitHub](https://github.com/XoopsDocs/publisher-tutorial)
1717

18-
[![Translations on Transifex](https://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)
1919

2020
Please visit us on https://xoops.org
2121

admin/about.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
3+
declare(strict_types=1);
24
/**
35
* You may not change or alter any portion of this comment or credits
46
* of supporting developers from this source code or any supporting source code
@@ -13,7 +15,7 @@
1315
* Publisher
1416
*
1517
* @copyright The XOOPS Project (https://xoops.org)
16-
* @license GNU GPL (http://www.gnu.org/licenses/gpl-2.0.html/)
18+
* @license GNU GPL (https://www.gnu.org/licenses/gpl-2.0.html/)
1719
* @package Publisher
1820
* @since 1.0
1921
* @author Mage, Mamba

admin/admin_footer.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
3+
declare(strict_types=1);
24
/*
35
* You may not change or alter any portion of this comment or credits
46
* of supporting developers from this source code or any supporting source code
@@ -11,7 +13,7 @@
1113

1214
/**
1315
* @copyright XOOPS Project (https://xoops.org)
14-
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
16+
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
1517
* @package
1618
* @since
1719
* @author XOOPS Development Team

admin/admin_header.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
3+
declare(strict_types=1);
24
/**
35
* You may not change or alter any portion of this comment or credits
46
* of supporting developers from this source code or any supporting source code
@@ -20,10 +22,11 @@
2022

2123
use XoopsModules\Publisher;
2224

25+
require dirname(__DIR__) . '/preloads/autoloader.php';
26+
2327
require_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php';
2428
//require_once $GLOBALS['xoops']->path('www/class/xoopsformloader.php');
2529

26-
require dirname(__DIR__) . '/preloads/autoloader.php';
2730
require_once dirname(__DIR__) . '/include/common.php';
2831

2932
$moduleDirName = basename(dirname(__DIR__));

admin/blockform.php

+39-31
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* You may not change or alter any portion of this comment or credits
57
* of supporting developers from this source code or any supporting source code
@@ -10,8 +12,8 @@
1012
* @category Module
1113
* @author XOOPS Development Team
1214
* @copyright XOOPS Project
13-
* @link https://www.xoops.org
14-
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
15+
* @link https://xoops.org
16+
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
1517
*/
1618
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
1719

@@ -23,16 +25,18 @@
2325
$form->addElement(new \XoopsFormLabel(_AM_SYSTEM_BLOCKS_NAME, $block['name']));
2426
}
2527
$side_select = new \XoopsFormSelect(_AM_SYSTEM_BLOCKS_TYPE, 'bside', $block['side']);
26-
$side_select->addOptionArray([
27-
0 => _AM_SYSTEM_BLOCKS_SBLEFT,
28-
1 => _AM_SYSTEM_BLOCKS_SBRIGHT,
29-
3 => _AM_SYSTEM_BLOCKS_CBLEFT,
30-
4 => _AM_SYSTEM_BLOCKS_CBRIGHT,
31-
5 => _AM_SYSTEM_BLOCKS_CBCENTER,
32-
7 => _AM_SYSTEM_BLOCKS_CBBOTTOMLEFT,
33-
8 => _AM_SYSTEM_BLOCKS_CBBOTTOMRIGHT,
34-
9 => _AM_SYSTEM_BLOCKS_CBBOTTOM,
35-
]);
28+
$side_select->addOptionArray(
29+
[
30+
0 => _AM_SYSTEM_BLOCKS_SBLEFT,
31+
1 => _AM_SYSTEM_BLOCKS_SBRIGHT,
32+
3 => _AM_SYSTEM_BLOCKS_CBLEFT,
33+
4 => _AM_SYSTEM_BLOCKS_CBRIGHT,
34+
5 => _AM_SYSTEM_BLOCKS_CBCENTER,
35+
7 => _AM_SYSTEM_BLOCKS_CBBOTTOMLEFT,
36+
8 => _AM_SYSTEM_BLOCKS_CBBOTTOMRIGHT,
37+
9 => _AM_SYSTEM_BLOCKS_CBBOTTOM,
38+
]
39+
);
3640
$form->addElement($side_select);
3741
$form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'WEIGHT'), 'bweight', 2, 5, $block['weight']));
3842
$form->addElement(new \XoopsFormRadioYN(constant('CO_' . $moduleDirNameUpper . '_' . 'VISIBLE'), 'bvisible', $block['visible']));
@@ -53,12 +57,14 @@
5357
$textarea->setDescription('<span style="font-size:x-small;font-weight:bold;">' . _AM_SYSTEM_BLOCKS_USEFULTAGS . '</span><br><span style="font-size:x-small;font-weight:normal;">' . sprintf(_AM_BLOCKTAG1, '{X_SITEURL}', XOOPS_URL . '/') . '</span>');
5458
$form->addElement($textarea, true);
5559
$ctype_select = new \XoopsFormSelect(_AM_SYSTEM_BLOCKS_CTYPE, 'bctype', $block['ctype']);
56-
$ctype_select->addOptionArray([
57-
'H' => _AM_SYSTEM_BLOCKS_HTML,
58-
'P' => _AM_SYSTEM_BLOCKS_PHP,
59-
'S' => _AM_SYSTEM_BLOCKS_AFWSMILE,
60-
'T' => _AM_SYSTEM_BLOCKS_AFNOSMILE,
61-
]);
60+
$ctype_select->addOptionArray(
61+
[
62+
'H' => _AM_SYSTEM_BLOCKS_HTML,
63+
'P' => _AM_SYSTEM_BLOCKS_PHP,
64+
'S' => _AM_SYSTEM_BLOCKS_AFWSMILE,
65+
'T' => _AM_SYSTEM_BLOCKS_AFNOSMILE,
66+
]
67+
);
6268
$form->addElement($ctype_select);
6369
} else {
6470
if ('' !== $block['template']) {
@@ -79,19 +85,21 @@
7985
}
8086
}
8187
$cache_select = new \XoopsFormSelect(_AM_SYSTEM_BLOCKS_BCACHETIME, 'bcachetime', $block['bcachetime']);
82-
$cache_select->addOptionArray([
83-
'0' => _NOCACHE,
84-
'30' => sprintf(_SECONDS, 30),
85-
'60' => _MINUTE,
86-
'300' => sprintf(_MINUTES, 5),
87-
'1800' => sprintf(_MINUTES, 30),
88-
'3600' => _HOUR,
89-
'18000' => sprintf(_HOURS, 5),
90-
'86400' => _DAY,
91-
'259200' => sprintf(_DAYS, 3),
92-
'604800' => _WEEK,
93-
'2592000' => _MONTH,
94-
]);
88+
$cache_select->addOptionArray(
89+
[
90+
'0' => _NOCACHE,
91+
'30' => sprintf(_SECONDS, 30),
92+
'60' => _MINUTE,
93+
'300' => sprintf(_MINUTES, 5),
94+
'1800' => sprintf(_MINUTES, 30),
95+
'3600' => _HOUR,
96+
'18000' => sprintf(_HOURS, 5),
97+
'86400' => _DAY,
98+
'259200' => sprintf(_DAYS, 3),
99+
'604800' => _WEEK,
100+
'2592000' => _MONTH,
101+
]
102+
);
95103
$form->addElement($cache_select);
96104

97105
/** @var \XoopsGroupPermHandler $grouppermHandler */

admin/blocksadmin.php

+52-31
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
/**
36
* You may not change or alter any portion of this comment or credits
47
* of supporting developers from this source code or any supporting source code
@@ -9,8 +12,8 @@
912
* @category Module
1013
* @author XOOPS Development Team
1114
* @copyright XOOPS Project
12-
* @link https://www.xoops.org
13-
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
15+
* @link https://xoops.org
16+
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
1417
*/
1518

1619
use Xmf\Request;
@@ -51,13 +54,13 @@
5154
function listBlocks()
5255
{
5356
global $xoopsModule, $pathIcon16;
54-
// require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
57+
// require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
5558
xoops_load('xoopslist');
5659
require_once XOOPS_ROOT_PATH . '/class/xoopsblock.php';
5760
$moduleDirName = basename(dirname(__DIR__));
5861
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
5962
/** @var \XoopsDatabase $db */
60-
$db = \XoopsDatabaseFactory::getDatabaseConnection();
63+
$db = \XoopsDatabaseFactory::getDatabaseConnection();
6164
xoops_loadLanguage('admin', 'system');
6265
xoops_loadLanguage('admin/blocksadmin', 'system');
6366
xoops_loadLanguage('admin/groups', 'system');
@@ -77,8 +80,8 @@ function listBlocks()
7780
ksort($module_list);
7881
echo "
7982
<h4 style='text-align:left;'>" . constant('CO_' . $moduleDirNameUpper . '_' . 'BADMIN') . '</h4>';
80-
// $moduleHandler = xoops_getHandler('module');
81-
echo "<form action='" . \Xmf\Request::getString('PHP_SELF', '', 'SERVER') . "' name='blockadmin' method='post'>";
83+
// $moduleHandler = xoops_getHandler('module');
84+
echo "<form action='" . \Xmf\Request::getString('SCRIPT_NAME', '', 'SERVER') . "' name='blockadmin' method='post'>";
8285
echo $GLOBALS['xoopsSecurity']->getTokenHTML();
8386
echo "<table width='100%' class='outer' cellpadding='4' cellspacing='1'>
8487
<tr valign='middle'><th align='center'>"
@@ -92,10 +95,9 @@ function listBlocks()
9295
. '-'
9396
. _RIGHT
9497
. "</th><th align='center'>"
95-
. constant('CO_'
96-
. $moduleDirNameUpper
97-
. '_'
98-
. 'WEIGHT')
98+
. constant(
99+
'CO_' . $moduleDirNameUpper . '_' . 'WEIGHT'
100+
)
99101
. "</th><th align='center'>"
100102
. constant('CO_' . $moduleDirNameUpper . '_' . 'VISIBLE')
101103
. "</th><th align='center'>"
@@ -283,7 +285,7 @@ function listBlocks()
283285
}
284286

285287
/**
286-
* @param $bid
288+
* @param int $bid
287289
*/
288290
function cloneBlock($bid)
289291
{
@@ -331,6 +333,7 @@ function cloneBlock($bid)
331333
];
332334
echo '<a href="blocksadmin.php">' . constant('CO_' . $moduleDirNameUpper . '_' . 'BADMIN') . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . _AM_SYSTEM_BLOCKS_CLONEBLOCK . '<br><br>';
333335
require_once __DIR__ . '/blockform.php';
336+
/* @var XoopsThemeForm $form */
334337
$form->display();
335338
// xoops_cp_footer();
336339
require_once __DIR__ . '/admin_footer.php';
@@ -410,12 +413,12 @@ function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule,
410413
}
411414

412415
/**
413-
* @param $bid
414-
* @param $title
415-
* @param $weight
416-
* @param $visible
417-
* @param $side
418-
* @param $bcachetime
416+
* @param int $bid
417+
* @param string $title
418+
* @param int $weight
419+
* @param bool $visible
420+
* @param string $side
421+
* @param int $bcachetime
419422
*/
420423
function setOrder($bid, $title, $weight, $visible, $side, $bcachetime)
421424
{
@@ -429,7 +432,7 @@ function setOrder($bid, $title, $weight, $visible, $side, $bcachetime)
429432
}
430433

431434
/**
432-
* @param $bid
435+
* @param int $bid
433436
*/
434437
function editBlock($bid)
435438
{
@@ -474,32 +477,50 @@ function editBlock($bid)
474477
];
475478
echo '<a href="blocksadmin.php">' . constant('CO_' . $moduleDirNameUpper . '_' . 'BADMIN') . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . _AM_SYSTEM_BLOCKS_EDITBLOCK . '<br><br>';
476479
require_once __DIR__ . '/blockform.php';
480+
/* @var XoopsThemeForm $form */
477481
$form->display();
478482
// xoops_cp_footer();
479483
require_once __DIR__ . '/admin_footer.php';
480484
exit();
481485
}
482486

483487
/**
484-
* @param $bid
485-
* @param $btitle
486-
* @param $bside
487-
* @param $bweight
488-
* @param $bvisible
489-
* @param $bcachetime
490-
* @param $bmodule
491-
* @param $options
492-
* @param $groups
488+
* @param int $bid
489+
* @param string $btitle
490+
* @param string $bside
491+
* @param int $bweight
492+
* @param bool $bvisible
493+
* @param int $bcachetime
494+
* @param array $bmodule
495+
* @param null|array|string $options
496+
* @param null|array $groups
493497
*/
498+
494499
function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups)
495500
{
496-
$myblock = new \XoopsBlock($bid);
501+
$myblock = new XoopsBlock($bid);
497502
$myblock->setVar('title', $btitle);
498503
$myblock->setVar('weight', $bweight);
499504
$myblock->setVar('visible', $bvisible);
500505
$myblock->setVar('side', $bside);
501506
$myblock->setVar('bcachetime', $bcachetime);
507+
//update block options
508+
if (isset($options)) {
509+
$options_count = count($options);
510+
if ($options_count > 0) {
511+
//Convert array values to comma-separated
512+
for ($i = 0; $i < $options_count; ++$i) {
513+
if (is_array($options[$i])) {
514+
$options[$i] = implode(',', $options[$i]);
515+
}
516+
}
517+
$options = implode('|', $options);
518+
$myblock->setVar('options', $options);
519+
}
520+
}
502521
$myblock->store();
522+
$moduleDirName = basename(dirname(__DIR__));
523+
$moduleDirNameUpper = mb_strtoupper($moduleDirName);
503524

504525
if (!empty($bmodule) && count($bmodule) > 0) {
505526
$sql = sprintf('DELETE FROM `%s` WHERE block_id = %u', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid);
@@ -522,7 +543,7 @@ function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $b
522543
$GLOBALS['xoopsDB']->query($sql);
523544
}
524545
}
525-
redirect_header($_SERVER['PHP_SELF'], 1, constant('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
546+
redirect_header($_SERVER['SCRIPT_NAME'], 1, constant('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
526547
}
527548

528549
if ('list' === $op) {
@@ -535,7 +556,7 @@ function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $b
535556

536557
if ('order' === $op) {
537558
if (!$GLOBALS['xoopsSecurity']->check()) {
538-
redirect_header($_SERVER['PHP_SELF'], 3, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
559+
redirect_header($_SERVER['SCRIPT_NAME'], 3, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
539560
}
540561
foreach (array_keys($bid) as $i) {
541562
if ($oldtitle[$i] !== $title[$i] || $oldweight[$i] !== $weight[$i] || $oldvisible[$i] !== $visible[$i]
@@ -565,7 +586,7 @@ function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $b
565586
}
566587
}
567588
}
568-
redirect_header($_SERVER['PHP_SELF'], 1, constant('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
589+
redirect_header($_SERVER['SCRIPT_NAME'], 1, constant('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
569590
}
570591
if ('clone' === $op) {
571592
cloneBlock($bid);

0 commit comments

Comments
 (0)