Skip to content

Commit 7ed8509

Browse files
authored
Merge pull request #96 from mambax7/master
1.06 FINAL
2 parents 2d1700c + 1b469d2 commit 7ed8509

Some content is hidden

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

103 files changed

+2327
-2366
lines changed

admin/admin_header.php

+6-7
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@
1818
* @author The SmartFactory <www.smartfactory.ca>
1919
*/
2020

21-
2221
use XoopsModules\Publisher;
2322

24-
require_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php';
23+
require_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php';
2524
//require_once $GLOBALS['xoops']->path('www/class/xoopsformloader.php');
2625

2726
require dirname(__DIR__) . '/preloads/autoloader.php';
28-
require_once dirname(__DIR__) . '/include/common.php';
27+
require_once dirname(__DIR__) . '/include/common.php';
2928

3029
$moduleDirName = basename(dirname(__DIR__));
3130

@@ -34,8 +33,8 @@
3433
/** @var Xmf\Module\Admin $adminObject */
3534
$adminObject = \Xmf\Module\Admin::getInstance();
3635

37-
$pathIcon16 = \Xmf\Module\Admin::iconUrl('', 16);
38-
$pathIcon32 = \Xmf\Module\Admin::iconUrl('', 32);
36+
$pathIcon16 = \Xmf\Module\Admin::iconUrl('', 16);
37+
$pathIcon32 = \Xmf\Module\Admin::iconUrl('', 32);
3938
if (is_object($helper->getModule())) {
4039
$pathModIcon32 = $helper->getModule()->getInfo('modicons32');
4140
}
@@ -49,12 +48,12 @@
4948
'editimg' => "<img src='" . PUBLISHER_IMAGES_URL . "/button_edit.png' alt='" . _AM_PUBLISHER_ICO_EDIT . "' align='middle'>",
5049
'deleteimg' => "<img src='" . PUBLISHER_IMAGES_URL . "/button_delete.png' alt='" . _AM_PUBLISHER_ICO_DELETE . "' align='middle'>",
5150
'online' => "<img src='" . PUBLISHER_IMAGES_URL . "/on.png' alt='" . _AM_PUBLISHER_ICO_ONLINE . "' align='middle'>",
52-
'offline' => "<img src='" . PUBLISHER_IMAGES_URL . "/off.png' alt='" . _AM_PUBLISHER_ICO_OFFLINE . "' align='middle'>"
51+
'offline' => "<img src='" . PUBLISHER_IMAGES_URL . "/off.png' alt='" . _AM_PUBLISHER_ICO_OFFLINE . "' align='middle'>",
5352
];
5453

5554
$myts = \MyTextSanitizer::getInstance();
5655

57-
if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) {
56+
if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof \XoopsTpl)) {
5857
require_once $GLOBALS['xoops']->path('class/template.php');
5958
$GLOBALS['xoopsTpl'] = new \XoopsTpl();
6059
}

admin/blockform.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
2+
23
/**
3-
*
44
* You may not change or alter any portion of this comment or credits
55
* of supporting developers from this source code or any supporting source code
66
* which is considered copyrighted (c) material of the original comment or credit authors.
@@ -14,12 +14,10 @@
1414
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
1515
*/
1616

17-
18-
1917
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
2018

21-
$moduleDirName = basename(dirname(__DIR__));
22-
$moduleDirNameUpper = strtoupper($moduleDirName); //$capsDirName
19+
$moduleDirName = basename(dirname(__DIR__));
20+
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
2321

2422
$form = new \XoopsThemeForm($block['form_title'], 'blockform', 'blocksadmin.php', 'post', true);
2523
if (isset($block['name'])) {
@@ -50,7 +48,7 @@
5048
ksort($module_list);
5149
$mod_select->addOptionArray($module_list);
5250
$form->addElement($mod_select);
53-
$form->addElement(new \XoopsFormText(_AM_TITLE, 'btitle', 50, 255, $block['title']), false);
51+
$form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'TITLE'), 'btitle', 50, 255, $block['title']), false);
5452
if ($block['is_custom']) {
5553
$textarea = new \XoopsFormDhtmlTextArea(_AM_SYSTEM_BLOCKS_CONTENT, 'bcontent', $block['content'], 15, 70);
5654
$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>');
@@ -65,12 +63,13 @@
6563
$form->addElement($ctype_select);
6664
} else {
6765
if ('' !== $block['template']) {
66+
/** @var \XoopsTplfileHandler $tplfileHandler */
6867
$tplfileHandler = xoops_getHandler('tplfile');
69-
$btemplate =& $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']);
68+
$btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']);
7069
if (count($btemplate) > 0) {
7170
$form->addElement(new \XoopsFormLabel(_AM_SYSTEM_BLOCKS_CONTENT, '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id=' . $btemplate[0]->getVar('tpl_id') . '">' . _AM_SYSTEM_BLOCKS_EDITTPL . '</a>'));
7271
} else {
73-
$btemplate2 =& $tplfileHandler->find('default', 'block', $block['bid']);
72+
$btemplate2 = $tplfileHandler->find('default', 'block', $block['bid']);
7473
if (count($btemplate2) > 0) {
7574
$form->addElement(new \XoopsFormLabel(_AM_SYSTEM_BLOCKS_CONTENT, '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id=' . $btemplate2[0]->getVar('tpl_id') . '" target="_blank">' . _AM_SYSTEM_BLOCKS_EDITTPL . '</a>'));
7675
}
@@ -96,8 +95,9 @@
9695
]);
9796
$form->addElement($cache_select);
9897

98+
/** @var \XoopsGroupPermHandler $grouppermHandler */
9999
$grouppermHandler = xoops_getHandler('groupperm');
100-
$groups =& $grouppermHandler->getGroupIds('block_read', $block['bid']);
100+
$groups = $grouppermHandler->getGroupIds('block_read', $block['bid']);
101101

102102
$form->addElement(new \XoopsFormSelectGroup(_AM_SYSTEM_BLOCKS_GROUP, 'groups', true, $groups, 5, true));
103103

admin/blocksadmin.php

+36-30
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22
/**
3-
*
43
* You may not change or alter any portion of this comment or credits
54
* of supporting developers from this source code or any supporting source code
65
* which is considered copyrighted (c) material of the original comment or credit authors.
@@ -18,10 +17,10 @@
1817

1918
require __DIR__ . '/admin_header.php';
2019

21-
$moduleDirName = basename(dirname(__DIR__));
22-
$moduleDirNameUpper = strtoupper($moduleDirName); //$capsDirName
20+
$moduleDirName = basename(dirname(__DIR__));
21+
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
2322

24-
if (!is_object($GLOBALS['xoopsUser']) || !is_object($xoopsModule)
23+
if (!is_object($xoopsModule) || !is_object($GLOBALS['xoopsUser'])
2524
|| !$GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid())) {
2625
exit(constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR403'));
2726
}
@@ -30,7 +29,7 @@
3029
$op = 'list';
3130
if (isset($_POST)) {
3231
foreach ($_POST as $k => $v) {
33-
${$k} =$v;
32+
${$k} = $v;
3433
}
3534
}
3635
/*
@@ -49,15 +48,12 @@
4948
$bid = Request::getInt('bid', 0, 'GET');
5049
}
5150

52-
/**
53-
*
54-
*/
5551
function listBlocks()
5652
{
5753
global $xoopsModule, $pathIcon16;
5854
require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
59-
$moduleDirName = basename(dirname(__DIR__));
60-
$moduleDirNameUpper = strtoupper($moduleDirName); //$capsDirName
55+
$moduleDirName = basename(dirname(__DIR__));
56+
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
6157
$db = \XoopsDatabaseFactory::getDatabaseConnection();
6258
xoops_loadLanguage('admin', 'system');
6359
xoops_loadLanguage('admin/blocksadmin', 'system');
@@ -79,7 +75,7 @@ function listBlocks()
7975
echo "
8076
<h4 style='text-align:left;'>" . constant('CO_' . $moduleDirNameUpper . '_' . 'BADMIN') . '</h4>';
8177
$moduleHandler = xoops_getHandler('module');
82-
echo "<form action='" . $_SERVER['PHP_SELF'] . "' name='blockadmin' method='post'>";
78+
echo "<form action='" . \Xmf\Request::getString('PHP_SELF', '', 'SERVER') . "' name='blockadmin' method='post'>";
8379
echo $GLOBALS['xoopsSecurity']->getTokenHTML();
8480
echo "<table width='100%' class='outer' cellpadding='4' cellspacing='1'>
8581
<tr valign='middle'><th align='center'>"
@@ -120,7 +116,7 @@ function listBlocks()
120116
'86400' => _DAY,
121117
'259200' => sprintf(_DAYS, 3),
122118
'604800' => _WEEK,
123-
'2592000' => _MONTH
119+
'2592000' => _MONTH,
124120
];
125121
foreach ($block_arr as $i) {
126122
$groups_perms = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid'));
@@ -286,9 +282,15 @@ function listBlocks()
286282
function cloneBlock($bid)
287283
{
288284
require_once __DIR__ . '/admin_header.php';
289-
//require_once __DIR__ . '/admin_header.php';
285+
290286
xoops_cp_header();
291287

288+
/** @var \Xmf\Module\Admin $adminObject */
289+
$adminObject = \Xmf\Module\Admin::getInstance();
290+
$adminObject->displayNavigation(basename(__FILE__));
291+
$moduleDirName = basename(dirname(__DIR__));
292+
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
293+
292294
xoops_loadLanguage('admin', 'system');
293295
xoops_loadLanguage('admin/blocksadmin', 'system');
294296
xoops_loadLanguage('admin/groups', 'system');
@@ -319,26 +321,26 @@ function cloneBlock($bid)
319321
'bid' => $myblock->getVar('bid'),
320322
'edit_form' => $myblock->getOptions(),
321323
'template' => $myblock->getVar('template'),
322-
'options' => $myblock->getVar('options')
324+
'options' => $myblock->getVar('options'),
323325
];
324-
echo '<a href="blocksadmin.php">' . _AM_BADMIN . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . _AM_SYSTEM_BLOCKS_CLONEBLOCK . '<br><br>';
325-
require_once __DIR__ . '/blockform.php';
326+
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>';
327+
require_once __DIR__ . '/blockform.php';
326328
$form->display();
327329
// xoops_cp_footer();
328330
require_once __DIR__ . '/admin_footer.php';
329331
exit();
330332
}
331333

332334
/**
333-
* @param $bid
334-
* @param $bside
335-
* @param $bweight
336-
* @param $bvisible
337-
* @param $bcachetime
338-
* @param $bmodule
339-
* @param $options
335+
* @param int $bid
336+
* @param string $bside
337+
* @param int $bweight
338+
* @param bool $bvisible
339+
* @param int $bcachetime
340+
* @param array $bmodule
341+
* @param null|array|string $options
340342
*/
341-
function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options)
343+
function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options = null)
342344
{
343345
xoops_loadLanguage('admin', 'system');
344346
xoops_loadLanguage('admin/blocksadmin', 'system');
@@ -359,7 +361,7 @@ function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule,
359361
//$clone->setVar('content', $_POST['bcontent']);
360362
$clone->setVar('title', Request::getString('btitle', '', 'POST'));
361363
$clone->setVar('bcachetime', $bcachetime);
362-
if (isset($options) && (count($options) > 0)) {
364+
if (null !== $options && (count($options) > 0)) {
363365
$options = implode('|', $options);
364366
$clone->setVar('options', $options);
365367
}
@@ -426,8 +428,12 @@ function xtubeSetOrder($bid, $title, $weight, $visible, $side, $bcachetime)
426428
function xtubeEditBlock($bid)
427429
{
428430
require_once __DIR__ . '/admin_header.php';
429-
//require_once __DIR__ . '/admin_header.php';
430431
xoops_cp_header();
432+
/** @var \Xmf\Module\Admin $adminObject */
433+
$adminObject = \Xmf\Module\Admin::getInstance();
434+
$adminObject->displayNavigation(basename(__FILE__));
435+
$moduleDirName = basename(dirname(__DIR__));
436+
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
431437

432438
xoops_loadLanguage('admin', 'system');
433439
xoops_loadLanguage('admin/blocksadmin', 'system');
@@ -458,10 +464,10 @@ function xtubeEditBlock($bid)
458464
'bid' => $myblock->getVar('bid'),
459465
'edit_form' => $myblock->getOptions(),
460466
'template' => $myblock->getVar('template'),
461-
'options' => $myblock->getVar('options')
467+
'options' => $myblock->getVar('options'),
462468
];
463-
echo '<a href="blocksadmin.php">' . _AM_BADMIN . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . _AM_SYSTEM_BLOCKS_EDITBLOCK . '<br><br>';
464-
require_once __DIR__ . '/blockform.php';
469+
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>';
470+
require_once __DIR__ . '/blockform.php';
465471
$form->display();
466472
// xoops_cp_footer();
467473
require_once __DIR__ . '/admin_footer.php';
@@ -515,7 +521,7 @@ function xtubeUpdateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetim
515521

516522
if ('list' === $op) {
517523
xoops_cp_header();
518-
// mpu_adm_menu();
524+
$adminObject->displayNavigation(basename(__FILE__));
519525
listBlocks();
520526
require_once __DIR__ . '/admin_footer.php';
521527
exit();

admin/category.php

-8
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@
4040
if ($confirm) {
4141
if (!$helper->getHandler('Category')->delete($categoryObj)) {
4242
redirect_header('category.php', 1, _AM_PUBLISHER_DELETE_CAT_ERROR);
43-
// exit();
4443
}
4544
redirect_header('category.php', 1, sprintf(_AM_PUBLISHER_COLISDELETED, $name));
46-
// exit();
4745
} else {
4846
xoops_cp_header();
4947
xoops_confirm(['op' => 'del', 'categoryid' => $categoryObj->categoryid(), 'confirm' => 1, 'name' => $categoryObj->name()], 'category.php', _AM_PUBLISHER_DELETECOL . " '" . $categoryObj->name() . "'. <br> <br>" . _AM_PUBLISHER_DELETE_CAT_CONFIRM, _AM_PUBLISHER_DELETE);
@@ -85,7 +83,6 @@
8583
$allowed_mimetypes = Publisher\Utility::getAllowedImagesTypes();
8684
if (('' == $temp['tmp_name']) || !is_readable($temp['tmp_name'])) {
8785
redirect_header('javascript:history.go(-1)', 2, _AM_PUBLISHER_FILEUPLOAD_ERROR);
88-
// exit();
8986
}
9087

9188
xoops_load('XoopsMediaUploader');
@@ -94,7 +91,6 @@
9491
$categoryObj->setVar('image', $uploader->getSavedFileName());
9592
} else {
9693
redirect_header('javascript:history.go(-1)', 2, _AM_PUBLISHER_FILEUPLOAD_ERROR . $uploader->getErrors());
97-
// exit();
9894
}
9995
}
10096
} else {
@@ -131,7 +127,6 @@
131127

132128
if (!$categoryObj->store()) {
133129
redirect_header('javascript:history.go(-1)', 3, _AM_PUBLISHER_CATEGORY_SAVE_ERROR . Publisher\Utility::formatErrors($categoryObj->getErrors()));
134-
// exit;
135130
}
136131
// TODO : put this function in the category class
137132
Publisher\Utility::saveCategoryPermissions($grpread, $categoryObj->categoryid(), 'category_read');
@@ -151,7 +146,6 @@
151146

152147
if (!$categoryObj->store()) {
153148
redirect_header('javascript:history.go(-1)', 3, _AM_PUBLISHER_SUBCATEGORY_SAVE_ERROR . Publisher\Utility::formatErrors($categoryObj->getErrors()));
154-
// exit;
155149
}
156150
// TODO : put this function in the category class
157151
Publisher\Utility::saveCategoryPermissions($grpread, $categoryObj->categoryid(), 'category_read');
@@ -161,7 +155,6 @@
161155
}
162156
//end of fx2024 code
163157
redirect_header($redirect_to, 2, $redirect_msg);
164-
// exit();
165158
break;
166159

167160
//Added by fx2024
@@ -186,7 +179,6 @@
186179

187180
case 'cancel':
188181
redirect_header('category.php', 1, sprintf(_AM_PUBLISHER_BACK2IDX, ''));
189-
// exit();
190182
break;
191183
case 'default':
192184
default:

0 commit comments

Comments
 (0)