|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
/* |
|
3
|
|
|
You may not change or alter any portion of this comment or credits |
|
4
|
|
|
of supporting developers from this source code or any supporting source code |
|
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
6
|
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
|
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
14
|
|
|
* @license https://www.fsf.org/copyleft/gpl.html GNU public license |
|
15
|
|
|
* @since 1.0 |
|
16
|
|
|
* @author trabis <[email protected]> |
|
17
|
|
|
* @author The SmartFactory <www.smartfactory.ca> |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
use Xmf\Request; |
|
|
|
|
|
|
21
|
|
|
use XoopsModules\Publisher\BlockForm; |
|
22
|
|
|
use XoopsModules\Publisher\CategoryHandler; |
|
23
|
|
|
use XoopsModules\Publisher\Helper; |
|
24
|
|
|
use XoopsModules\Publisher\Utility; |
|
25
|
|
|
|
|
26
|
|
|
require_once \dirname(__DIR__) . '/include/common.php'; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @param $options |
|
30
|
|
|
* |
|
31
|
|
|
* @return array |
|
32
|
|
|
*/ |
|
33
|
|
|
function publisher_items_menu_show($options) |
|
|
|
|
|
|
34
|
|
|
{ |
|
35
|
|
|
$block = []; |
|
36
|
|
|
|
|
37
|
|
|
$helper = Helper::getInstance(); |
|
38
|
|
|
|
|
39
|
|
|
// Getting all top cats |
|
40
|
|
|
/** @var CategoryHandler $categoryHandler */ |
|
41
|
|
|
$categoryHandler = $helper->getHandler('Category'); |
|
42
|
|
|
$blockCategoriesObj = $categoryHandler->getCategories(0, 0, 0); |
|
43
|
|
|
|
|
44
|
|
|
if (0 == count($blockCategoriesObj)) { |
|
45
|
|
|
return $block; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
// Are we in Publisher ? |
|
49
|
|
|
$block['inModule'] = (isset($GLOBALS['xoopsModule']) && $GLOBALS['xoopsModule']->getVar('dirname') == $helper->getDirname()); |
|
50
|
|
|
|
|
51
|
|
|
$catLinkClass = 'menuMain'; |
|
52
|
|
|
|
|
53
|
|
|
$categoryid = 0; |
|
54
|
|
|
|
|
55
|
|
|
if ($block['inModule']) { |
|
56
|
|
|
// Are we in a category and if yes, in which one ? |
|
57
|
|
|
$categoryid = Request::getInt('categoryid', 0, 'GET'); |
|
58
|
|
|
|
|
59
|
|
|
if (0 != $categoryid) { |
|
60
|
|
|
// if we are in a category, then the $categoryObj is already defined in publisher/category.php |
|
61
|
|
|
global $categoryObj; |
|
62
|
|
|
$block['currentcat'] = $categoryObj->getCategoryLink('menuTop'); |
|
63
|
|
|
$catLinkClass = 'menuSub'; |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
foreach ($blockCategoriesObj as $catId => $blockCategoryObj) { |
|
68
|
|
|
if ($catId != $categoryid) { |
|
69
|
|
|
$block['categories'][$catId]['categoryLink'] = $blockCategoryObj->getCategoryLink($catLinkClass); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
return $block; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @param $options |
|
78
|
|
|
* |
|
79
|
|
|
* @return string |
|
80
|
|
|
*/ |
|
81
|
|
|
function publisher_items_menu_edit($options) |
|
82
|
|
|
{ |
|
83
|
|
|
// require_once PUBLISHER_ROOT_PATH . '/class/blockform.php'; |
|
84
|
|
|
xoops_load('XoopsFormLoader'); |
|
85
|
|
|
|
|
86
|
|
|
$form = new BlockForm(); |
|
87
|
|
|
|
|
88
|
|
|
$catEle = new \XoopsFormLabel(_MB_PUBLISHER_SELECTCAT, Utility::createCategorySelect($options[0], 0, true, 'options[0]')); |
|
89
|
|
|
$orderEle = new \XoopsFormSelect(_MB_PUBLISHER_ORDER, 'options[1]', $options[1]); |
|
90
|
|
|
$orderEle->addOptionArray( |
|
91
|
|
|
[ |
|
92
|
|
|
'datesub' => _MB_PUBLISHER_DATE, |
|
93
|
|
|
'counter' => _MB_PUBLISHER_HITS, |
|
94
|
|
|
'weight' => _MB_PUBLISHER_WEIGHT, |
|
95
|
|
|
] |
|
96
|
|
|
); |
|
97
|
|
|
$dispEle = new \XoopsFormText(_MB_PUBLISHER_DISP, 'options[2]', 10, 255, $options[2]); |
|
98
|
|
|
|
|
99
|
|
|
$form->addElement($catEle); |
|
100
|
|
|
$form->addElement($orderEle); |
|
101
|
|
|
$form->addElement($dispEle); |
|
102
|
|
|
|
|
103
|
|
|
return $form->render(); |
|
104
|
|
|
} |
|
105
|
|
|
|
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: