1
1
<?php
2
+
3
+ declare (strict_types=1 );
4
+
2
5
/**
3
6
* You may not change or alter any portion of this comment or credits
4
7
* of supporting developers from this source code or any supporting source code
9
12
* @category Module
10
13
* @author XOOPS Development Team
11
14
* @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)
14
17
*/
15
18
16
19
use Xmf \Request ;
51
54
function listBlocks ()
52
55
{
53
56
global $ xoopsModule , $ pathIcon16 ;
54
- // require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
57
+ // require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
55
58
xoops_load ('xoopslist ' );
56
59
require_once XOOPS_ROOT_PATH . '/class/xoopsblock.php ' ;
57
60
$ moduleDirName = basename (dirname (__DIR__ ));
58
61
$ moduleDirNameUpper = mb_strtoupper ($ moduleDirName ); //$capsDirName
59
62
/** @var \XoopsDatabase $db */
60
- $ db = \XoopsDatabaseFactory::getDatabaseConnection ();
63
+ $ db = \XoopsDatabaseFactory::getDatabaseConnection ();
61
64
xoops_loadLanguage ('admin ' , 'system ' );
62
65
xoops_loadLanguage ('admin/blocksadmin ' , 'system ' );
63
66
xoops_loadLanguage ('admin/groups ' , 'system ' );
@@ -77,8 +80,8 @@ function listBlocks()
77
80
ksort ($ module_list );
78
81
echo "
79
82
<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'> " ;
82
85
echo $ GLOBALS ['xoopsSecurity ' ]->getTokenHTML ();
83
86
echo "<table width='100%' class='outer' cellpadding='4' cellspacing='1'>
84
87
<tr valign='middle'><th align='center'> "
@@ -92,10 +95,9 @@ function listBlocks()
92
95
. '- '
93
96
. _RIGHT
94
97
. "</th><th align='center'> "
95
- . constant ('CO_ '
96
- . $ moduleDirNameUpper
97
- . '_ '
98
- . 'WEIGHT ' )
98
+ . constant (
99
+ 'CO_ ' . $ moduleDirNameUpper . '_ ' . 'WEIGHT '
100
+ )
99
101
. "</th><th align='center'> "
100
102
. constant ('CO_ ' . $ moduleDirNameUpper . '_ ' . 'VISIBLE ' )
101
103
. "</th><th align='center'> "
@@ -283,7 +285,7 @@ function listBlocks()
283
285
}
284
286
285
287
/**
286
- * @param $bid
288
+ * @param int $bid
287
289
*/
288
290
function cloneBlock ($ bid )
289
291
{
@@ -331,6 +333,7 @@ function cloneBlock($bid)
331
333
];
332
334
echo '<a href="blocksadmin.php"> ' . constant ('CO_ ' . $ moduleDirNameUpper . '_ ' . 'BADMIN ' ) . '</a> <span style="font-weight:bold;">»»</span> ' . _AM_SYSTEM_BLOCKS_CLONEBLOCK . '<br><br> ' ;
333
335
require_once __DIR__ . '/blockform.php ' ;
336
+ /* @var XoopsThemeForm $form */
334
337
$ form ->display ();
335
338
// xoops_cp_footer();
336
339
require_once __DIR__ . '/admin_footer.php ' ;
@@ -410,12 +413,12 @@ function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule,
410
413
}
411
414
412
415
/**
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
419
422
*/
420
423
function setOrder ($ bid , $ title , $ weight , $ visible , $ side , $ bcachetime )
421
424
{
@@ -429,7 +432,7 @@ function setOrder($bid, $title, $weight, $visible, $side, $bcachetime)
429
432
}
430
433
431
434
/**
432
- * @param $bid
435
+ * @param int $bid
433
436
*/
434
437
function editBlock ($ bid )
435
438
{
@@ -474,32 +477,50 @@ function editBlock($bid)
474
477
];
475
478
echo '<a href="blocksadmin.php"> ' . constant ('CO_ ' . $ moduleDirNameUpper . '_ ' . 'BADMIN ' ) . '</a> <span style="font-weight:bold;">»»</span> ' . _AM_SYSTEM_BLOCKS_EDITBLOCK . '<br><br> ' ;
476
479
require_once __DIR__ . '/blockform.php ' ;
480
+ /* @var XoopsThemeForm $form */
477
481
$ form ->display ();
478
482
// xoops_cp_footer();
479
483
require_once __DIR__ . '/admin_footer.php ' ;
480
484
exit ();
481
485
}
482
486
483
487
/**
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
493
497
*/
498
+
494
499
function updateBlock ($ bid , $ btitle , $ bside , $ bweight , $ bvisible , $ bcachetime , $ bmodule , $ options , $ groups )
495
500
{
496
- $ myblock = new \ XoopsBlock ($ bid );
501
+ $ myblock = new XoopsBlock ($ bid );
497
502
$ myblock ->setVar ('title ' , $ btitle );
498
503
$ myblock ->setVar ('weight ' , $ bweight );
499
504
$ myblock ->setVar ('visible ' , $ bvisible );
500
505
$ myblock ->setVar ('side ' , $ bside );
501
506
$ 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
+ }
502
521
$ myblock ->store ();
522
+ $ moduleDirName = basename (dirname (__DIR__ ));
523
+ $ moduleDirNameUpper = mb_strtoupper ($ moduleDirName );
503
524
504
525
if (!empty ($ bmodule ) && count ($ bmodule ) > 0 ) {
505
526
$ 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
522
543
$ GLOBALS ['xoopsDB ' ]->query ($ sql );
523
544
}
524
545
}
525
- redirect_header ($ _SERVER ['PHP_SELF ' ], 1 , constant ('CO_ ' . $ moduleDirNameUpper . '_ ' . 'UPDATE_SUCCESS ' ));
546
+ redirect_header ($ _SERVER ['SCRIPT_NAME ' ], 1 , constant ('CO_ ' . $ moduleDirNameUpper . '_ ' . 'UPDATE_SUCCESS ' ));
526
547
}
527
548
528
549
if ('list ' === $ op ) {
@@ -535,7 +556,7 @@ function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $b
535
556
536
557
if ('order ' === $ op ) {
537
558
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 ()));
539
560
}
540
561
foreach (array_keys ($ bid ) as $ i ) {
541
562
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
565
586
}
566
587
}
567
588
}
568
- redirect_header ($ _SERVER ['PHP_SELF ' ], 1 , constant ('CO_ ' . $ moduleDirNameUpper . '_ ' . 'UPDATE_SUCCESS ' ));
589
+ redirect_header ($ _SERVER ['SCRIPT_NAME ' ], 1 , constant ('CO_ ' . $ moduleDirNameUpper . '_ ' . 'UPDATE_SUCCESS ' ));
569
590
}
570
591
if ('clone ' === $ op ) {
571
592
cloneBlock ($ bid );
0 commit comments