Skip to content

Commit 8c1d2ac

Browse files
authored
Merge pull request #6 from mambax7/master
starting 2.61 beta cycle
2 parents e3833b8 + 2cdfaba commit 8c1d2ac

Some content is hidden

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

63 files changed

+638
-544
lines changed

.github/FUNDING.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: [mambax7]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
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

33
# Contributing to [XOOPS CMS](https://xoops.org)
44

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

1212
## Pull Requests
1313

14-
- **[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).
14+
- **[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).
1515
- **Add tests!** - We encourage providing tests for your contributions.
1616
- **Document any change in behavior** - Make sure the `/docs/changelog.txt` and any other relevant documentation are up-to-date.
1717
- **Consider our release cycle** - We try to follow [Semantic Versioning v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.

README.md

Lines changed: 1 addition & 1 deletion
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

33
## Marquee module for [XOOPS CMS 2.5.9+](https://xoops.org)
44

admin/about.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use Xmf\Module\Admin;
2020

2121
/** @var Admin $adminObject */
22-
require __DIR__ . '/admin_header.php';
22+
require_once __DIR__ . '/admin_header.php';
2323
xoops_cp_header();
2424
$adminObject->displayNavigation(basename(__FILE__));
2525
$adminObject::setPaypal('[email protected]');

admin/admin_header.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222

2323
/** @var Admin $adminObject */
2424
/** @var Helper $helper */
25-
require_once dirname(__DIR__, 3) . '/include/cp_header.php';
26-
//require_once dirname(dirname(dirname(__DIR__))) . '/class/xoopsformloader.php';
27-
// require_once dirname(__DIR__) . '/class/Utility.php';
28-
require_once dirname(__DIR__) . '/include/common.php';
29-
$moduleDirName = basename(dirname(__DIR__));
25+
require \dirname(__DIR__, 3) . '/include/cp_header.php';
26+
//require_once \dirname(__DIR__, 3) . '/class/xoopsformloader.php';
27+
// require_once \dirname(__DIR__) . '/class/Utility.php';
28+
require_once \dirname(__DIR__) . '/include/common.php';
29+
$moduleDirName = \basename(\dirname(__DIR__));
3030
$moduleDirNameUpper = mb_strtoupper($moduleDirName);
3131
//if functions.php file exist
32-
//require_once dirname(__DIR__) . '/include/functions.php';
32+
//require_once \dirname(__DIR__) . '/include/functions.php';
3333
$helper = Helper::getInstance();
3434
$adminObject = Admin::getInstance();
3535
//$pathIcon16 = \Xmf\Module\Admin::iconUrl('', 16);

admin/blockform.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* of supporting developers from this source code or any supporting source code
55
* which is considered copyrighted (c) material of the original comment or credit authors.
66
*
7-
* PHP version 5
87
*
98
* @category Module
109
* @author XOOPS Development Team
@@ -19,11 +18,11 @@
1918

2019
/** @var Admin $adminObject */
2120
/** @var Helper $helper */
22-
require __DIR__ . '/admin_header.php';
21+
2322
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
24-
$moduleDirName = basename(dirname(__DIR__));
25-
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
26-
$helper->loadLanguage('blocksadmin');
23+
$moduleDirName = \basename(\dirname(__DIR__));
24+
$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
25+
2726
$form = new \XoopsThemeForm($block['form_title'], 'blockform', 'blocksadmin.php', 'post', true);
2827
if (isset($block['name'])) {
2928
$form->addElement(new \XoopsFormLabel(_AM_SYSTEM_BLOCKS_NAME, $block['name']));
@@ -92,17 +91,17 @@
9291
$cache_select = new \XoopsFormSelect(_AM_SYSTEM_BLOCKS_BCACHETIME, 'bcachetime', $block['bcachetime']);
9392
$cache_select->addOptionArray(
9493
[
95-
'0' => _NOCACHE,
96-
'30' => sprintf(_SECONDS, 30),
97-
'60' => _MINUTE,
98-
'300' => sprintf(_MINUTES, 5),
99-
'1800' => sprintf(_MINUTES, 30),
100-
'3600' => _HOUR,
101-
'18000' => sprintf(_HOURS, 5),
102-
'86400' => _DAY,
103-
'259200' => sprintf(_DAYS, 3),
104-
'604800' => _WEEK,
105-
'2592000' => _MONTH,
94+
0 => _NOCACHE,
95+
30 => sprintf(_SECONDS, 30),
96+
60 => _MINUTE,
97+
300 => sprintf(_MINUTES, 5),
98+
1800 => sprintf(_MINUTES, 30),
99+
3600 => _HOUR,
100+
18000 => sprintf(_HOURS, 5),
101+
86400 => _DAY,
102+
259200 => sprintf(_DAYS, 3),
103+
604800 => _WEEK,
104+
2592000 => _MONTH,
106105
]
107106
);
108107
$form->addElement($cache_select);

admin/blocksadmin.php

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* of supporting developers from this source code or any supporting source code
55
* which is considered copyrighted (c) material of the original comment or credit authors.
66
*
7-
* PHP version 5
87
*
98
* @category Module
109
* @author XOOPS Development Team
@@ -21,15 +20,15 @@
2120
/** @var Admin $adminObject */
2221
/** @var Helper $helper */
2322
require __DIR__ . '/admin_header.php';
24-
$moduleDirName = basename(dirname(__DIR__));
25-
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
23+
$moduleDirName = \basename(\dirname(__DIR__));
24+
$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
2625
$helper->loadLanguage('blocksadmin');
2726
if (!is_object($GLOBALS['xoopsUser']) || !is_object($xoopsModule)
2827
|| !$GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid())) {
2928
exit(constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR403'));
3029
}
3130
if ($GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid())) {
32-
require_once XOOPS_ROOT_PATH . '/class/xoopsblock.php';
31+
require_once XOOPS_ROOT_PATH . '/kernel/block.php';
3332
$op = 'list';
3433
if (isset($_POST)) {
3534
foreach ($_POST as $k => $v) {
@@ -52,10 +51,10 @@ function listBlocks()
5251
{
5352
global $xoopsModule, $pathIcon16;
5453
require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
55-
$moduleDirName = basename(dirname(__DIR__));
56-
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
54+
$moduleDirName = \basename(\dirname(__DIR__));
55+
$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
5756
$db = \XoopsDatabaseFactory::getDatabaseConnection();
58-
$adminObject = Admin::getInstance();
57+
$adminObject = Admin::getInstance();
5958
$adminObject->displayNavigation(basename(__FILE__));
6059
xoops_loadLanguage('admin', 'system');
6160
xoops_loadLanguage('admin/blocksadmin', 'system');
@@ -79,7 +78,7 @@ function listBlocks()
7978
echo $GLOBALS['xoopsSecurity']->getTokenHTML();
8079
echo "<table width='100%' class='outer' cellpadding='4' cellspacing='1'>
8180
<tr valign='middle'><th align='center'>"
82-
. constant('CO_' . $moduleDirNameUpper . '_' . 'TITLE')
81+
. _AM_SYSTEM_BLOCKS_TITLE
8382
. "</th><th align='center' nowrap='nowrap'>"
8483
. constant('CO_' . $moduleDirNameUpper . '_' . 'SIDE')
8584
. '<br>'
@@ -108,17 +107,17 @@ function listBlocks()
108107
$blockCount = count($blockArray);
109108
$class = 'even';
110109
$cachetimes = [
111-
'0' => _NOCACHE,
112-
'30' => sprintf(_SECONDS, 30),
113-
'60' => _MINUTE,
114-
'300' => sprintf(_MINUTES, 5),
115-
'1800' => sprintf(_MINUTES, 30),
116-
'3600' => _HOUR,
117-
'18000' => sprintf(_HOURS, 5),
118-
'86400' => _DAY,
119-
'259200' => sprintf(_DAYS, 3),
120-
'604800' => _WEEK,
121-
'2592000' => _MONTH,
110+
0 => _NOCACHE,
111+
30 => sprintf(_SECONDS, 30),
112+
60 => _MINUTE,
113+
300 => sprintf(_MINUTES, 5),
114+
1800 => sprintf(_MINUTES, 30),
115+
3600 => _HOUR,
116+
18000 => sprintf(_HOURS, 5),
117+
86400 => _DAY,
118+
259200 => sprintf(_DAYS, 3),
119+
604800 => _WEEK,
120+
2592000 => _MONTH,
122121
];
123122
foreach ($blockArray as $i) {
124123
$groupsPerms = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid'));
@@ -276,12 +275,11 @@ function listBlocks()
276275
*/
277276
function cloneBlock($bid)
278277
{
279-
require_once __DIR__ . '/admin_header.php';
280278
xoops_cp_header();
281279
$adminObject = Admin::getInstance();
282280
$adminObject->displayNavigation(basename(__FILE__));
283-
$moduleDirName = basename(dirname(__DIR__));
284-
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
281+
$moduleDirName = \basename(\dirname(__DIR__));
282+
$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
285283
xoops_loadLanguage('admin', 'system');
286284
xoops_loadLanguage('admin/blocksadmin', 'system');
287285
xoops_loadLanguage('admin/groups', 'system');
@@ -389,7 +387,7 @@ function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule,
389387
$sql = 'INSERT INTO ' . $db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $groups[$i] . ', ' . $newid . ", 1, 'block_read')";
390388
$db->query($sql);
391389
}
392-
redirect_header('blocksadmin.php?op=listar', 1, _AM_DBUPDATED);
390+
redirect_header('blocksadmin.php?op=listar', 1, _AM_SYSTEM_BLOCKS_DBUPDATED);
393391
}
394392

395393
/**
@@ -399,30 +397,32 @@ function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule,
399397
* @param bool $visible
400398
* @param string $side
401399
* @param int $bcachetime
402-
* @param int $bmodule
400+
* @param null|int $bmodule
403401
*/
404-
function setOrder($bid, $title, $weight, $visible, $side, $bcachetime, $bmodule)
402+
function setOrder($bid, $title, $weight, $visible, $side, $bcachetime, $bmodule = null)
405403
{
406404
$myblock = new \XoopsBlock($bid);
407405
$myblock->setVar('title', $title);
408406
$myblock->setVar('weight', $weight);
409407
$myblock->setVar('visible', $visible);
410408
$myblock->setVar('side', $side);
411409
$myblock->setVar('bcachetime', $bcachetime);
412-
$myblock->store();
410+
// $myblock->store();
411+
/** @var \XoopsBlockHandler $blkhandler */
412+
$blkhandler = xoops_getHandler('block');
413+
return $blkhandler->insert($myblock);
413414
}
414415

415416
/**
416417
* @param int $bid
417418
*/
418419
function editBlock($bid)
419420
{
420-
require_once __DIR__ . '/admin_header.php';
421421
xoops_cp_header();
422422
$adminObject = Admin::getInstance();
423423
$adminObject->displayNavigation(basename(__FILE__));
424-
$moduleDirName = basename(dirname(__DIR__));
425-
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
424+
$moduleDirName = \basename(\dirname(__DIR__));
425+
$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
426426
xoops_loadLanguage('admin', 'system');
427427
xoops_loadLanguage('admin/blocksadmin', 'system');
428428
xoops_loadLanguage('admin/groups', 'system');
@@ -498,10 +498,13 @@ function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $b
498498
$myblock->setVar('options', $options);
499499
}
500500
}
501-
$myblock->store();
501+
// $myblock->store();
502+
/** @var \XoopsBlockHandler $blkhandler */
503+
$blkhandler = xoops_getHandler('block');
504+
return $blkhandler->insert($myblock);
502505
global $xoopsDB;
503-
$moduleDirName = basename(dirname(__DIR__));
504-
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
506+
$moduleDirName = \basename(\dirname(__DIR__));
507+
$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
505508
if (!empty($bmodule) && count($bmodule) > 0) {
506509
$sql = sprintf('DELETE FROM `%s` WHERE block_id = %u', $xoopsDB->prefix('block_module_link'), $bid);
507510
$xoopsDB->query($sql);
@@ -523,7 +526,7 @@ function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $b
523526
$xoopsDB->query($sql);
524527
}
525528
}
526-
redirect_header($_SERVER['PHP_SELF'], 1, constant('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
529+
redirect_header($_SERVER['SCRIPT_NAME'], 1, constant('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
527530
}
528531

529532
if ('list' === $op) {
@@ -535,7 +538,7 @@ function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $b
535538
}
536539
if ('order' === $op) {
537540
if (!$GLOBALS['xoopsSecurity']->check()) {
538-
redirect_header($_SERVER['PHP_SELF'], 3, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
541+
redirect_header($_SERVER['SCRIPT_NAME'], 3, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
539542
}
540543
foreach (array_keys($bid) as $i) {
541544
if ($oldtitle[$i] != $title[$i] || $oldweight[$i] != $weight[$i] || $oldvisible[$i] != $visible[$i]
@@ -565,7 +568,7 @@ function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $b
565568
}
566569
}
567570
}
568-
redirect_header($_SERVER['PHP_SELF'], 1, constant('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
571+
redirect_header($_SERVER['SCRIPT_NAME'], 1, constant('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
569572
}
570573
if ('clone' === $op) {
571574
cloneBlock($bid);

admin/index.html

Lines changed: 0 additions & 1 deletion
This file was deleted.

admin/index.php

Lines changed: 15 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@
2424
use Xmf\Request;
2525
use Xmf\Yaml;
2626
use XoopsModules\Marquee\{Common,
27+
Common\TestdataButtons,
2728
Helper,
2829
Utility
2930
};
3031

3132
/** @var Admin $adminObject */
3233
/** @var Helper $helper */
3334
/** @var Utility $utility */
35+
3436
require_once __DIR__ . '/admin_header.php';
3537
// Display Admin header
3638
xoops_cp_header();
@@ -40,64 +42,27 @@
4042
//if (!empty($newRelease)) {
4143
// $adminObject->addItemButton($newRelease[0], $newRelease[1], 'download', 'style="color : Red"');
4244
//}
43-
//------------- Test Data ----------------------------
45+
46+
//------------- Test Data Buttons ----------------------------
4447
if ($helper->getConfig('displaySampleButton')) {
45-
$yamlFile = dirname(__DIR__) . '/config/admin.yml';
46-
$config = loadAdminConfig($yamlFile);
47-
$displaySampleButton = $config['displaySampleButton'];
48-
if (1 == $displaySampleButton) {
49-
xoops_loadLanguage('admin/modulesadmin', 'system');
50-
require_once dirname(__DIR__) . '/testdata/index.php';
51-
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=load', 'add');
52-
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=save', 'add');
53-
// $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), '__DIR__ . /../../testdata/index.php?op=exportschema', 'add');
54-
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete');
55-
} else {
56-
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add');
57-
$displaySampleButton = $config['displaySampleButton'];
58-
}
48+
TestdataButtons::loadButtonConfig($adminObject);
5949
$adminObject->displayButton('left', '');
6050
}
61-
//------------- End Test Data ----------------------------
62-
$adminObject->displayIndex();
63-
/**
64-
* @param $yamlFile
65-
* @return array|bool
66-
*/
67-
function loadAdminConfig($yamlFile)
68-
{
69-
$config = Yaml::readWrapped($yamlFile); // work with phpmyadmin YAML dumps
70-
return $config;
71-
}
72-
73-
/**
74-
* @param $yamlFile
75-
*/
76-
function hideButtons($yamlFile)
77-
{
78-
$app['displaySampleButton'] = 0;
79-
Yaml::save($app, $yamlFile);
80-
redirect_header('index.php', 0, '');
81-
}
82-
83-
/**
84-
* @param $yamlFile
85-
*/
86-
function showButtons($yamlFile)
87-
{
88-
$app['displaySampleButton'] = 1;
89-
Yaml::save($app, $yamlFile);
90-
redirect_header('index.php', 0, '');
91-
}
92-
9351
$op = Request::getString('op', 0, 'GET');
9452
switch ($op) {
9553
case 'hide_buttons':
96-
hideButtons($yamlFile);
54+
TestdataButtons::hideButtons();
9755
break;
9856
case 'show_buttons':
99-
showButtons($yamlFile);
57+
TestdataButtons::showButtons();
10058
break;
10159
}
60+
//------------- End Test Data Buttons ----------------------------
61+
62+
63+
$adminObject->displayIndex();
10264
echo $utility::getServerStats();
103-
require __DIR__ . '/admin_footer.php';
65+
66+
//codeDump(__FILE__);
67+
require_once __DIR__ . '/admin_footer.php';
68+

0 commit comments

Comments
 (0)