|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Modulebuilder\Files\Admin; |
|
4
|
|
|
|
|
5
|
|
|
use XoopsModules\Modulebuilder; |
|
6
|
|
|
use XoopsModules\Modulebuilder\Files; |
|
7
|
|
|
|
|
8
|
|
|
/* |
|
9
|
|
|
You may not change or alter any portion of this comment or credits |
|
10
|
|
|
of supporting developers from this source code or any supporting source code |
|
11
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
12
|
|
|
|
|
13
|
|
|
This program is distributed in the hope that it will be useful, |
|
14
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
16
|
|
|
*/ |
|
17
|
|
|
/** |
|
18
|
|
|
* modulebuilder module. |
|
19
|
|
|
* |
|
20
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
21
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
22
|
|
|
* |
|
23
|
|
|
* @since 2.5.0 |
|
24
|
|
|
* |
|
25
|
|
|
* @author Txmod Xoops http://www.txmodxoops.org |
|
26
|
|
|
* |
|
27
|
|
|
*/ |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Class AdminMenu. |
|
31
|
|
|
*/ |
|
32
|
|
|
class AdminMenu extends Files\CreateFile |
|
33
|
|
|
{ |
|
34
|
|
|
/** |
|
35
|
|
|
* @var string |
|
36
|
|
|
*/ |
|
37
|
|
|
private $xc = null; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @public function constructor |
|
41
|
|
|
* @param null |
|
42
|
|
|
*/ |
|
43
|
|
|
public function __construct() |
|
44
|
|
|
{ |
|
45
|
|
|
parent::__construct(); |
|
46
|
|
|
$this->xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); |
|
|
|
|
|
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @static function getInstance |
|
51
|
|
|
* @param null |
|
52
|
|
|
* @return AdminMenu |
|
53
|
|
|
*/ |
|
54
|
|
|
public static function getInstance() |
|
55
|
|
|
{ |
|
56
|
|
|
static $instance = false; |
|
57
|
|
|
if (!$instance) { |
|
58
|
|
|
$instance = new self(); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
return $instance; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @public function write |
|
66
|
|
|
* @param string $module |
|
67
|
|
|
* @param string $filename |
|
68
|
|
|
*/ |
|
69
|
|
|
public function write($module, $filename) |
|
70
|
|
|
{ |
|
71
|
|
|
$this->setModule($module); |
|
72
|
|
|
$this->setFileName($filename); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @private function getAdminMenuArray |
|
77
|
|
|
* @param array $param |
|
78
|
|
|
* @param bool $adminObject |
|
79
|
|
|
* @return string |
|
80
|
|
|
*/ |
|
81
|
|
|
private function getAdminMenuArray($param = [], $adminObject = false) |
|
82
|
|
|
{ |
|
83
|
|
|
$ret = ''; |
|
84
|
|
|
if ($adminObject) { |
|
85
|
|
|
$ret .= $this->getSimpleString("\$adminmenu[] = ["); |
|
86
|
|
|
foreach ($param as $key => $value) { |
|
87
|
|
|
$ret .= $this->getSimpleString("\t'{$key}' => {$value},"); |
|
88
|
|
|
} |
|
89
|
|
|
$ret .= $this->getSimpleString("];"); |
|
90
|
|
|
} else { |
|
91
|
|
|
foreach ($param as $key => $value) { |
|
92
|
|
|
$ret .= $this->xc->getXcEqualsOperator((string)$key, (string)$value); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
return $ret; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @private function getAdminMenuHeader |
|
101
|
|
|
* @param null |
|
102
|
|
|
* @return string |
|
103
|
|
|
*/ |
|
104
|
|
|
private function getAdminMenuHeader() |
|
105
|
|
|
{ |
|
106
|
|
|
$ret = $this->getSimpleString(''); |
|
107
|
|
|
$mod = [ |
|
108
|
|
|
'$dirname ' => 'basename(dirname(__DIR__))', |
|
109
|
|
|
'$moduleHandler' => "xoops_getHandler('module')", |
|
110
|
|
|
'$xoopsModule ' => 'XoopsModule::getByDirname($dirname)', |
|
111
|
|
|
'$moduleInfo ' => "\$moduleHandler->get(\$xoopsModule->getVar('mid'))", |
|
112
|
|
|
'$sysPathIcon32' => "\$moduleInfo->getInfo('sysicons32')", |
|
113
|
|
|
]; |
|
114
|
|
|
$ret .= $this->getAdminMenuArray($mod); |
|
115
|
|
|
$ret .= $this->getSimpleString(''); |
|
116
|
|
|
|
|
117
|
|
|
return $ret; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* @private function getAdminMenuDashboard |
|
122
|
|
|
* @param string $language |
|
123
|
|
|
* @param int $menu |
|
124
|
|
|
* |
|
125
|
|
|
* @return string |
|
126
|
|
|
*/ |
|
127
|
|
|
private function getAdminMenuDashboard($language, $menu) |
|
128
|
|
|
{ |
|
129
|
|
|
$param = ['title' => "{$language}{$menu}", 'link' => "'admin/index.php'", 'icon' => "\$sysPathIcon32.'/dashboard.png'"]; |
|
130
|
|
|
$ret = $this->getAdminMenuArray($param, true); |
|
131
|
|
|
|
|
132
|
|
|
return $ret; |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* @private function getAdminMenuList |
|
137
|
|
|
* @param string $module |
|
138
|
|
|
* @param string $language |
|
139
|
|
|
* @param string $langAbout |
|
140
|
|
|
* @param int $menu |
|
141
|
|
|
* |
|
142
|
|
|
* @return string |
|
143
|
|
|
*/ |
|
144
|
|
|
private function getAdminMenuList($module, $language, $langAbout, $menu) |
|
145
|
|
|
{ |
|
146
|
|
|
$ret = ''; |
|
147
|
|
|
$tables = $this->getTableTables($module->getVar('mod_id'), 'table_order'); |
|
148
|
|
|
$tablePermissions = []; |
|
149
|
|
|
$tableBroken = []; |
|
150
|
|
|
foreach (array_keys($tables) as $t) { |
|
151
|
|
|
$tablePermissions[] = $tables[$t]->getVar('table_permissions'); |
|
152
|
|
|
$tableBroken[] = $tables[$t]->getVar('table_broken'); |
|
153
|
|
|
if (1 == $tables[$t]->getVar('table_admin')) { |
|
154
|
|
|
++$menu; |
|
155
|
|
|
$param1 = ['title' => "{$language}{$menu}", 'link' => "'admin/{$tables[$t]->getVar('table_name')}.php'", 'icon' => "'assets/icons/32/{$tables[$t]->getVar('table_image')}'"]; |
|
156
|
|
|
$ret .= $this->getAdminMenuArray($param1, true); |
|
157
|
|
|
} |
|
158
|
|
|
} |
|
159
|
|
|
if (in_array(1, $tableBroken)) { |
|
160
|
|
|
++$menu; |
|
161
|
|
|
$param2 = ['title' => "{$language}{$menu}", 'link' => "'admin/broken.php'", 'icon' => "\$sysPathIcon32.'/brokenlink.png'"]; |
|
162
|
|
|
$ret .= $this->getAdminMenuArray($param2, true); |
|
163
|
|
|
} |
|
164
|
|
|
if (in_array(1, $tablePermissions)) { |
|
165
|
|
|
++$menu; |
|
166
|
|
|
$param2 = ['title' => "{$language}{$menu}", 'link' => "'admin/permissions.php'", 'icon' => "\$sysPathIcon32.'/permissions.png'"]; |
|
167
|
|
|
$ret .= $this->getAdminMenuArray($param2, true); |
|
168
|
|
|
} |
|
169
|
|
|
++$menu; |
|
170
|
|
|
$param3 = ['title' => "{$language}{$menu}", 'link' => "'admin/feedback.php'", 'icon' => "\$sysPathIcon32.'/mail_foward.png'"]; |
|
171
|
|
|
$ret .= $this->getAdminMenuArray($param3, true); |
|
172
|
|
|
unset($menu); |
|
173
|
|
|
$param3 = ['title' => (string)$langAbout, 'link' => "'admin/about.php'", 'icon' => "\$sysPathIcon32.'/about.png'"]; |
|
174
|
|
|
$ret .= $this->getAdminMenuArray($param3, true); |
|
175
|
|
|
|
|
176
|
|
|
return $ret; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
/** |
|
180
|
|
|
* @public function render |
|
181
|
|
|
* @param null |
|
182
|
|
|
* @return bool|string |
|
183
|
|
|
*/ |
|
184
|
|
|
public function render() |
|
185
|
|
|
{ |
|
186
|
|
|
$module = $this->getModule(); |
|
187
|
|
|
$filename = $this->getFileName(); |
|
188
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
|
189
|
|
|
$language = $this->getLanguage($moduleDirname, 'MI', 'ADMENU'); |
|
190
|
|
|
$langAbout = $this->getLanguage($moduleDirname, 'MI', 'ABOUT'); |
|
191
|
|
|
$menu = 1; |
|
192
|
|
|
$content = $this->getHeaderFilesComments($module); |
|
193
|
|
|
$content .= $this->getAdminMenuHeader(); |
|
194
|
|
|
$content .= $this->getAdminMenuDashboard($language, $menu); |
|
195
|
|
|
$content .= $this->getAdminMenuList($module, $language, $langAbout, $menu); |
|
196
|
|
|
|
|
197
|
|
|
$this->create($moduleDirname, 'admin', $filename, $content, _AM_MODULEBUILDER_FILE_CREATED, _AM_MODULEBUILDER_FILE_NOTCREATED); |
|
198
|
|
|
|
|
199
|
|
|
return $this->renderFile(); |
|
200
|
|
|
} |
|
201
|
|
|
} |
|
202
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..