1 | <?php |
||
2 | |||
3 | /** |
||
4 | * Frameworks Module Admin |
||
5 | * |
||
6 | * You may not change or alter any portion of this comment or credits |
||
7 | * of supporting developers from this source code or any supporting source code |
||
8 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
9 | * This program is distributed in the hope that it will be useful, |
||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
12 | * |
||
13 | * @copyright Grégory Mage (Aka Mage) |
||
14 | * @copyright (c) 2000-2016 XOOPS Project (www.xoops.org) |
||
15 | * @license GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html) |
||
16 | * @author Grégory Mage (Aka Mage) |
||
17 | */ |
||
18 | class ModuleAdmin |
||
19 | { |
||
20 | private $_itemButton = array(); |
||
21 | private $_itemInfoBox = array(); |
||
22 | private $_itemInfoBoxLine = array(); |
||
23 | private $_itemConfigBoxLine = array(); |
||
24 | |||
25 | /** |
||
26 | * @var XoopsModule |
||
27 | */ |
||
28 | private $_obj; |
||
29 | |||
30 | /** |
||
31 | * Constructor |
||
32 | */ |
||
33 | public function __construct() |
||
34 | { |
||
35 | global $xoopsModule; |
||
36 | $this->_obj =& $xoopsModule; |
||
37 | $this->loadLanguage(); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * addAssets - add assets to theme, if it is established |
||
42 | * |
||
43 | * @return void |
||
44 | */ |
||
45 | private function addAssets() |
||
46 | { |
||
47 | static $added; |
||
48 | |||
49 | if (empty($added) && !empty($GLOBALS['xoTheme'])) { |
||
50 | $added = true; |
||
51 | $GLOBALS['xoTheme']->addStylesheet("Frameworks/moduleclasses/moduleadmin/css/admin.css"); |
||
52 | } |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @return array |
||
57 | */ |
||
58 | public function getInfo() |
||
59 | { |
||
60 | $infoArray = array(); |
||
61 | if (!isset($infoArray) || empty($infoArray)) { |
||
62 | $infoArray = array(); |
||
63 | $infoArray['version'] = $this->getVersion(); |
||
64 | $infoArray['releasedate'] = $this->getReleaseDate(); |
||
65 | $infoArray['methods'] = $this->getClassMethods(); |
||
66 | } |
||
67 | |||
68 | return $infoArray; |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * Return the Module Admin class version number |
||
73 | * return string version |
||
74 | **/ |
||
75 | public function getVersion() |
||
76 | { |
||
77 | /** |
||
78 | * version is rev of this class |
||
79 | */ |
||
80 | include_once __DIR__ . '/xoops_version.php'; |
||
81 | $version = XOOPS_FRAMEWORKS_MODULEADMIN_VERSION; |
||
82 | |||
83 | return $version; |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * Return the Module Admin class release date |
||
88 | * return string version |
||
89 | **/ |
||
90 | public function getReleaseDate() |
||
91 | { |
||
92 | /** |
||
93 | * version is rev of this class |
||
94 | */ |
||
95 | include_once __DIR__ . '/xoops_version.php'; |
||
96 | $releasedate = XOOPS_FRAMEWORKS_MODULEADMIN_RELEASEDATE; |
||
97 | |||
98 | return $releasedate; |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * Return the available methods for the class |
||
103 | * |
||
104 | * @return array methods supported by this class |
||
105 | */ |
||
106 | public function getClassMethods() |
||
107 | { |
||
108 | $myMethods = get_class_methods(__CLASS__); |
||
109 | |||
110 | return $myMethods; |
||
111 | } |
||
112 | |||
113 | //****************************************************************************************************************** |
||
114 | // loadLanguage |
||
115 | //****************************************************************************************************************** |
||
116 | // Loaf the language file. |
||
117 | //****************************************************************************************************************** |
||
118 | /** |
||
119 | * @return bool|mixed |
||
120 | */ |
||
121 | public function loadLanguage() |
||
122 | { |
||
123 | $language = $GLOBALS['xoopsConfig']['language']; |
||
124 | if (!file_exists($fileinc = XOOPS_ROOT_PATH . "/Frameworks/moduleclasses/moduleadmin/language/{$language}/main.php")) { |
||
125 | if (!file_exists($fileinc = XOOPS_ROOT_PATH . '/Frameworks/moduleclasses/moduleadmin/language/english/main.php')) { |
||
126 | return false; |
||
127 | } |
||
128 | } |
||
129 | $ret = include_once $fileinc; |
||
130 | |||
131 | return $ret; |
||
132 | } |
||
133 | //****************************************************************************************************************** |
||
134 | // renderMenuIndex |
||
135 | //****************************************************************************************************************** |
||
136 | // Creating a menu icon in the index |
||
137 | //****************************************************************************************************************** |
||
138 | /** |
||
139 | * @return string |
||
140 | */ |
||
141 | public function renderMenuIndex() |
||
142 | { |
||
143 | $this->addAssets(); |
||
144 | $path = XOOPS_URL . '/modules/' . $this->_obj->getVar('dirname') . '/'; |
||
145 | $pathsystem = XOOPS_URL . '/modules/system/'; |
||
146 | $this->_obj->loadAdminMenu(); |
||
147 | $ret = "<div class=\"rmmenuicon\">\n"; |
||
148 | foreach (array_keys($this->_obj->adminmenu) as $i) { |
||
149 | if ($this->_obj->adminmenu[$i]['link'] !== 'admin/index.php') { |
||
150 | $ret .= "<a href=\"../" . $this->_obj->adminmenu[$i]['link'] . "\" title=\"" . (isset($this->_obj->adminmenu[$i]['desc']) ? $this->_obj->adminmenu[$i]['desc'] : '') . "\">"; |
||
151 | //$ret .= "<img src=\"" . $path . $this->_obj->adminmenu[$i]['icon']. "\" alt=\"" . $this->_obj->adminmenu[$i]['title'] . "\" />"; |
||
152 | //mb for direct URL access to icons in modules Admin |
||
153 | $ret .= "<img src=\"" . (filter_var($this->_obj->adminmenu[$i]['icon'], FILTER_VALIDATE_URL) ? $this->_obj->adminmenu[$i]['icon'] : $path . $this->_obj->adminmenu[$i]['icon']) . "\" alt=\"" . $this->_obj->adminmenu[$i]['title'] . "\" />"; |
||
154 | |||
155 | $ret .= '<span>' . $this->_obj->adminmenu[$i]['title'] . '</span>'; |
||
156 | $ret .= '</a>'; |
||
157 | } |
||
158 | } |
||
159 | if ($this->_obj->getInfo('help')) { |
||
160 | if (substr(XOOPS_VERSION, 0, 9) >= 'XOOPS 2.5') { |
||
161 | $ret .= "<a href=\"" . $pathsystem . 'help.php?mid=' . $this->_obj->getVar('mid', 's') . '&' . $this->_obj->getInfo('help') . "\" title=\"" . _AM_SYSTEM_HELP . "\">"; |
||
162 | $ret .= "<img width=\"32px\" src=\"" . XOOPS_URL . "/Frameworks/moduleclasses/icons/32/help.png\" alt=\"" . _AM_SYSTEM_HELP . "\" /> "; |
||
163 | $ret .= '<span>' . _AM_SYSTEM_HELP . '</span>'; |
||
164 | $ret .= '</a>'; |
||
165 | } |
||
166 | } |
||
167 | $ret .= "</div>\n<div style=\"clear: both;\"></div>\n"; |
||
168 | |||
169 | return $ret; |
||
170 | } |
||
171 | //****************************************************************************************************************** |
||
172 | // renderButton |
||
173 | //****************************************************************************************************************** |
||
174 | // Creating button |
||
175 | //****************************************************************************************************************** |
||
176 | /** |
||
177 | * @param string $position |
||
178 | * @param string $delimeter |
||
179 | * |
||
180 | * @return string |
||
181 | */ |
||
182 | public function renderButton($position = 'right', $delimeter = ' ') |
||
183 | { |
||
184 | $this->addAssets(); |
||
185 | $path = XOOPS_URL . '/Frameworks/moduleclasses/icons/32/'; |
||
186 | switch ($position) { |
||
187 | default: |
||
188 | case 'right': |
||
189 | $ret = "<div class=\"floatright\">\n"; |
||
190 | break; |
||
191 | |||
192 | case 'left': |
||
193 | $ret = "<div class=\"floatleft\">\n"; |
||
194 | break; |
||
195 | |||
196 | case 'center': |
||
197 | $ret = "<div class=\"aligncenter\">\n"; |
||
198 | } |
||
199 | $ret .= "<div class=\"xo-buttons\">\n"; |
||
200 | foreach (array_keys($this->_itemButton) as $i) { |
||
201 | $ret .= "<a class='ui-corner-all tooltip' href='" . $this->_itemButton[$i]['link'] . "' title='" . $this->_itemButton[$i]['title'] . "' " . $this->_itemButton[$i]['extra'] . '>'; |
||
202 | $ret .= "<img src='" |
||
203 | //. $path . $this -> _itemButton[$i]['icon'] |
||
204 | //mb for direct URL access to icons in modules Admin |
||
205 | . (filter_var($this->_itemButton[$i]['icon'], FILTER_VALIDATE_URL) ? $this->_itemButton[$i]['icon'] : $path . $this->_itemButton[$i]['icon']) . "' title='" . $this->_itemButton[$i]['title'] . "' alt='" . $this->_itemButton[$i]['title'] . "' />" . $this->_itemButton[$i]['title']; |
||
206 | $ret .= "</a>\n"; |
||
207 | $ret .= $delimeter; |
||
208 | } |
||
209 | $ret .= "</div>\n</div>\n"; |
||
210 | $ret .= '<br> <br><br>'; |
||
211 | |||
212 | return $ret; |
||
213 | } |
||
214 | |||
215 | /** |
||
216 | * @param $title |
||
217 | * @param $link |
||
218 | * @param string $icon |
||
219 | * @param string $extra |
||
220 | * |
||
221 | * @return bool |
||
222 | */ |
||
223 | public function addItemButton($title, $link, $icon = 'add', $extra = '') |
||
224 | { |
||
225 | $ret = array(); |
||
226 | $ret['title'] = $title; |
||
227 | $ret['link'] = $link; |
||
228 | $ret['icon'] = $icon . '.png'; |
||
229 | $ret['extra'] = $extra; |
||
230 | $this->_itemButton[] = $ret; |
||
231 | |||
232 | return true; |
||
233 | } |
||
234 | //****************************************************************************************************************** |
||
235 | // addConfigBoxLine |
||
236 | //****************************************************************************************************************** |
||
237 | // $value: value |
||
238 | // $type: type of config: 1- "default": Just a line with value. |
||
239 | // 2- "folder": check if this is an folder. |
||
240 | // 3- "chmod": check if this is the good chmod. |
||
241 | // For this type ("chmod"), the value is an array: array(path, chmod) |
||
242 | //****************************************************************************************************************** |
||
243 | /** |
||
244 | * @param string $value |
||
245 | * @param string $type |
||
246 | * |
||
247 | * @return bool |
||
248 | */ |
||
249 | public function addConfigBoxLine($value = '', $type = 'default') |
||
250 | { |
||
251 | $line = ''; |
||
252 | $path = XOOPS_URL . '/Frameworks/moduleclasses/icons/16/'; |
||
253 | switch ($type) { |
||
254 | default: |
||
255 | case 'default': |
||
256 | $line .= '<span>' . $value . '</span>'; |
||
257 | break; |
||
258 | |||
259 | case 'folder': |
||
260 | if (!is_dir($value)) { |
||
261 | $line .= "<span style='color : red; font-weight : bold;'>"; |
||
262 | $line .= "<img src='" . $path . "0.png' >"; |
||
263 | $line .= sprintf(_AM_MODULEADMIN_CONFIG_FOLDERKO, $value); |
||
264 | $line .= "</span>\n"; |
||
265 | } else { |
||
266 | $line .= "<span style='color : green;'>"; |
||
267 | $line .= "<img src='" . $path . "1.png' >"; |
||
268 | $line .= sprintf(_AM_MODULEADMIN_CONFIG_FOLDEROK, $value); |
||
269 | $line .= "</span>\n"; |
||
270 | } |
||
271 | break; |
||
272 | |||
273 | case 'chmod': |
||
274 | if (is_dir($value[0])) { |
||
275 | if (substr(decoct(fileperms($value[0])), 2) != $value[1]) { |
||
276 | $line .= "<span style='color : red; font-weight : bold;'>"; |
||
277 | $line .= "<img src='" . $path . "0.png' >"; |
||
278 | $line .= sprintf(_AM_MODULEADMIN_CONFIG_CHMOD, $value[0], $value[1], substr(decoct(fileperms($value[0])), 2)); |
||
279 | $line .= "</span>\n"; |
||
280 | } else { |
||
281 | $line .= "<span style='color : green;'>"; |
||
282 | $line .= "<img src='" . $path . "1.png' >"; |
||
283 | $line .= sprintf(_AM_MODULEADMIN_CONFIG_CHMOD, $value[0], $value[1], substr(decoct(fileperms($value[0])), 2)); |
||
284 | $line .= "</span>\n"; |
||
285 | } |
||
286 | } |
||
287 | break; |
||
288 | } |
||
289 | $this->_itemConfigBoxLine[] = $line; |
||
290 | |||
291 | return true; |
||
292 | } |
||
293 | //****************************************************************************************************************** |
||
294 | // renderIndex |
||
295 | //****************************************************************************************************************** |
||
296 | // Creating an index |
||
297 | //****************************************************************************************************************** |
||
298 | /** |
||
299 | * @return string |
||
300 | */ |
||
301 | public function renderIndex() |
||
302 | { |
||
303 | $this->addAssets(); |
||
304 | $ret = "<table id='xo-modadmin-index'>\n<tr>\n"; |
||
305 | $ret .= "<td width=\"40%\">\n"; |
||
306 | $ret .= $this->renderMenuIndex(); |
||
307 | $ret .= "</td>\n"; |
||
308 | $ret .= "<td width=\"60%\">\n"; |
||
309 | $ret .= $this->renderInfoBox(); |
||
310 | $ret .= "</td>\n"; |
||
311 | $ret .= "</tr>\n"; |
||
312 | // If you use a config label |
||
313 | if ($this->_obj->getInfo('min_php') || $this->_obj->getInfo('min_xoops') || !empty($this->_itemConfigBoxLine)) { |
||
314 | $ret .= "<tr>\n"; |
||
315 | $ret .= "<td colspan=\"2\">\n"; |
||
316 | $ret .= "<fieldset><legend class=\"label\">"; |
||
317 | $ret .= _AM_MODULEADMIN_CONFIG; |
||
318 | $ret .= "</legend>\n"; |
||
319 | |||
320 | // php version |
||
321 | $path = XOOPS_URL . '/Frameworks/moduleclasses/icons/16/'; |
||
322 | if ($this->_obj->getInfo('min_php')) { |
||
323 | if (version_compare(phpversion(), strtolower($this->_obj->getInfo('min_php')), '<')) { |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
324 | $ret .= "<span style='color : red; font-weight : bold;'><img src='" . $path . "0.png' >" . sprintf(_AM_MODULEADMIN_CONFIG_PHP, $this->_obj->getInfo('min_php'), phpversion()) . "</span>\n"; |
||
325 | } else { |
||
326 | $ret .= "<span style='color : green;'><img src='" . $path . "1.png' >" . sprintf(_AM_MODULEADMIN_CONFIG_PHP, $this->_obj->getInfo('min_php'), phpversion()) . "</span>\n"; |
||
327 | } |
||
328 | $ret .= '<br>'; |
||
329 | } |
||
330 | |||
331 | // Database version |
||
332 | $path = XOOPS_URL . '/Frameworks/moduleclasses/icons/16/'; |
||
333 | $dbarray = $this->_obj->getInfo('min_db'); |
||
334 | if ($dbarray!=false) { |
||
335 | // changes from redheadedrod to use connector specific version info |
||
336 | switch (XOOPS_DB_TYPE) { |
||
337 | // server should be the same in both cases |
||
338 | case 'mysql': |
||
339 | case 'mysqli': |
||
340 | global $xoopsDB; |
||
341 | $dbCurrentVersion = $xoopsDB->getServerVersion(); |
||
342 | break; |
||
343 | //case "pdo": |
||
344 | // global $xoopsDB; |
||
345 | // $dbCurrentVersion = $xoopsDB->getAttribute(PDO::ATTR_SERVER_VERSION); |
||
346 | // break; |
||
347 | default: // don't really support anything other than mysql |
||
348 | $dbCurrentVersion = '0'; |
||
349 | break; |
||
350 | } |
||
351 | $currentVerParts = explode('.', (string)$dbCurrentVersion); |
||
352 | $iCurrentVerParts = array_map('intval', $currentVerParts); |
||
353 | $dbRequiredVersion = $dbarray[XOOPS_DB_TYPE]; |
||
354 | $reqVerParts = explode('.', (string)$dbRequiredVersion); |
||
355 | $iReqVerParts = array_map('intval', $reqVerParts); |
||
356 | $icount = $j = count($iReqVerParts); |
||
357 | $reqVer = $curVer = 0; |
||
358 | for ($i = 0; $i < $icount; ++$i) { |
||
359 | $j--; |
||
360 | $reqVer += $iReqVerParts[$i] * pow(10, $j); |
||
361 | if (isset($iCurrentVerParts[$i])) { |
||
362 | $curVer += $iCurrentVerParts[$i] * pow(10, $j); |
||
363 | } else { |
||
364 | $curVer *= pow(10, $j); |
||
365 | } |
||
366 | } |
||
367 | if ($reqVer > $curVer) { |
||
368 | $ret .= "<span style='color : red; font-weight : bold;'><img src='" . $path . "0.png' >" . sprintf(XOOPS_DB_TYPE . ' ' . _AM_MODULEADMIN_CONFIG_DB, $dbRequiredVersion, $dbCurrentVersion) . "</span><br>\n"; |
||
369 | } else { |
||
370 | $ret .= "<span style='color : green;'><img src='" . $path . "1.png' >" . sprintf(strtoupper(XOOPS_DB_TYPE) . ' ' . _AM_MODULEADMIN_CONFIG_DB, $dbRequiredVersion, $dbCurrentVersion) . "</span><br>\n"; |
||
371 | } |
||
372 | } |
||
373 | |||
374 | // xoops version |
||
375 | if ($this->_obj->getInfo('min_xoops')) { |
||
376 | $currentXoopsVersion = strtolower(str_replace('XOOPS ', '', XOOPS_VERSION)); |
||
377 | if ($this->_obj->versionCompare($currentXoopsVersion, strtolower($this->_obj->getInfo('min_xoops')), '<')) { |
||
378 | $ret .= "<span style='color : red; font-weight : bold;'><img src='" . $path . "0.png' >" . sprintf(_AM_MODULEADMIN_CONFIG_XOOPS, $this->_obj->getInfo('min_xoops'), substr(XOOPS_VERSION, 6, strlen(XOOPS_VERSION) - 6)) . "</span>\n"; |
||
379 | } else { |
||
380 | $ret .= "<span style='color : green;'><img src='" . $path . "1.png' >" . sprintf(_AM_MODULEADMIN_CONFIG_XOOPS, $this->_obj->getInfo('min_xoops'), substr(XOOPS_VERSION, 6)) . "</span>\n"; |
||
381 | } |
||
382 | $ret .= '<br>'; |
||
383 | } |
||
384 | |||
385 | // ModuleAdmin version |
||
386 | if ($this->_obj->getInfo('min_admin')) { |
||
387 | if ($this->getVersion() < $this->_obj->getInfo('min_admin')) { |
||
388 | $ret .= "<span style='color : red; font-weight : bold;'><img src='" . $path . "0.png' >" . sprintf(_AM_MODULEADMIN_CONFIG_ADMIN, $this->_obj->getInfo('min_admin'), $this->getVersion()) . "</span>\n"; |
||
389 | } else { |
||
390 | $ret .= "<span style='color : green;'><img src='" . $path . "1.png' >" . sprintf(_AM_MODULEADMIN_CONFIG_ADMIN, $this->_obj->getInfo('min_admin'), $this->getVersion()) . "</span>\n"; |
||
391 | } |
||
392 | $ret .= '<br>'; |
||
393 | } |
||
394 | if (!empty($this->_itemConfigBoxLine)) { |
||
395 | foreach (array_keys($this->_itemConfigBoxLine) as $i) { |
||
396 | $ret .= $this->_itemConfigBoxLine[$i]; |
||
397 | $ret .= '<br>'; |
||
398 | } |
||
399 | } |
||
400 | $ret .= "</fieldset>\n"; |
||
401 | $ret .= "</td>\n"; |
||
402 | $ret .= "</tr>\n"; |
||
403 | } |
||
404 | $ret .= "</table>\n"; |
||
405 | |||
406 | return $ret; |
||
407 | } |
||
408 | //****************************************************************************************************************** |
||
409 | // addInfoBox |
||
410 | //****************************************************************************************************************** |
||
411 | // $title: title of an InfoBox |
||
412 | //****************************************************************************************************************** |
||
413 | /** |
||
414 | * @param $title |
||
415 | * |
||
416 | * @return bool |
||
417 | */ |
||
418 | public function addInfoBox($title) |
||
419 | { |
||
420 | $ret = array(); |
||
421 | $ret['title'] = $title; |
||
422 | $this->_itemInfoBox[] = $ret; |
||
423 | |||
424 | return true; |
||
425 | } |
||
426 | //****************************************************************************************************************** |
||
427 | // addInfoBoxLine |
||
428 | //****************************************************************************************************************** |
||
429 | // $label: title of InfoBox Line |
||
430 | // $text: |
||
431 | // $type: type of config: 1- "default": Just a line with value. |
||
432 | // 2- "information": check if this is an folder. |
||
433 | // 3- "chmod": check if this is the good chmod. |
||
434 | // For this type ("chmod"), the value is an array: array(path, chmod) |
||
435 | //****************************************************************************************************************** |
||
436 | /** |
||
437 | * @param $label |
||
438 | * @param $text |
||
439 | * @param string $value |
||
440 | * @param string $color |
||
441 | * @param string $type |
||
442 | * |
||
443 | * @return bool |
||
444 | */ |
||
445 | public function addInfoBoxLine($label, $text, $value = '', $color = 'inherit', $type = 'default') |
||
446 | { |
||
447 | $ret = array(); |
||
448 | $ret['label'] = $label; |
||
449 | $line = ''; |
||
450 | switch ($type) { |
||
451 | default: |
||
452 | case 'default': |
||
453 | $line .= sprintf($text, "<span style='color : " . $color . "; font-weight : bold;'>" . $value . '</span>'); |
||
454 | break; |
||
455 | |||
456 | case 'information': |
||
457 | $line .= $text; |
||
458 | break; |
||
459 | } |
||
460 | $ret['line'] = $line; |
||
461 | $this->_itemInfoBoxLine[] = $ret; |
||
462 | |||
463 | return true; |
||
464 | } |
||
465 | |||
466 | /** |
||
467 | * @return string |
||
468 | */ |
||
469 | public function renderInfoBox() |
||
470 | { |
||
471 | $this->addAssets(); |
||
472 | $ret = ''; |
||
473 | foreach (array_keys($this->_itemInfoBox) as $i) { |
||
474 | $ret .= "<fieldset><legend class=\"label\">"; |
||
475 | $ret .= $this->_itemInfoBox[$i]['title']; |
||
476 | $ret .= "</legend>\n"; |
||
477 | foreach (array_keys($this->_itemInfoBoxLine) as $k) { |
||
478 | if ($this->_itemInfoBoxLine[$k]['label'] == $this->_itemInfoBox[$i]['title']) { |
||
479 | $ret .= $this->_itemInfoBoxLine[$k]['line']; |
||
480 | $ret .= '<br>'; |
||
481 | } |
||
482 | } |
||
483 | $ret .= "</fieldset>\n"; |
||
484 | $ret .= "<br>\n"; |
||
485 | } |
||
486 | |||
487 | return $ret; |
||
488 | } |
||
489 | |||
490 | /** |
||
491 | * Create HTML text to display on Admin About page |
||
492 | * |
||
493 | * @param string $business the PAYPAL business email or Merchant Account ID |
||
494 | * @param bool $logo_xoops true to display XOOPS logo and link on page |
||
495 | * |
||
496 | * @return string HTML to display |
||
497 | */ |
||
498 | public function renderAbout($business = '', $logo_xoops = true) |
||
499 | { |
||
500 | $this->addAssets(); |
||
501 | $path = XOOPS_URL . '/Frameworks/moduleclasses/icons/32/'; |
||
502 | $date = preg_replace('/-\\\/', '/', $this->_obj->getInfo('release_date')); // make format a little more forgiving |
||
503 | $date = explode('/', $date); |
||
504 | $author = explode(',', $this->_obj->getInfo('author')); |
||
505 | $nickname = explode(',', $this->_obj->getInfo('nickname')); |
||
506 | $release_date = formatTimestamp(mktime(0, 0, 0, $date[1], $date[2], $date[0]), 's'); |
||
507 | $module_dir = $this->_obj->getVar('dirname'); |
||
508 | $module_info = "<div id=\"about\"><label class=\"label_after\">" . _AM_MODULEADMIN_ABOUT_DESCRIPTION . "</label>\n" |
||
509 | . "<text>" . $this->_obj->getInfo('description') . "</text><br>\n" |
||
510 | . "<label class=\"label_after\">" . _AM_MODULEADMIN_ABOUT_UPDATEDATE . "</label>\n" |
||
511 | . "<text class=\"bold\">" . formatTimestamp($this->_obj->getVar('last_update'), 'm') . "</text><br>\n" |
||
512 | . "<label class=\"label_after\">" . _AM_MODULEADMIN_ABOUT_MODULESTATUS . "</label>\n" |
||
513 | . "<text>" . $this->_obj->getStatus() . "</text><br>\n" |
||
514 | . "<label class=\"label_after\">" . _AM_MODULEADMIN_ABOUT_WEBSITE . "</label>\n" |
||
515 | . "<text><a class=\"tooltip\" href=\"http://" . $this->_obj->getInfo('module_website_url') . "\" rel=\"external\" title=\"" |
||
516 | . $this->_obj->getInfo('module_website_name') . " - " . $this->_obj->getInfo('module_website_url') . "\">" |
||
517 | . $this->_obj->getInfo('module_website_name') . "</a></text>\n" |
||
518 | . "</div>\n"; |
||
519 | $authorArray = array(); |
||
520 | foreach ( $author as $k => $aName ) { |
||
521 | $authorArray[$k] = ( isset( $nickname[$k] ) && ( '' != $nickname[$k] ) ) ? "{$aName} ({$nickname[$k]})" : "{$aName}"; |
||
522 | } |
||
523 | $license_url = $this->_obj->getInfo('license_url'); |
||
524 | $license_url = preg_match('%^(https?:)?//%', $license_url) ? $license_url : 'http://' . $license_url; |
||
525 | $website = $this->_obj->getInfo('website'); |
||
526 | $website = preg_match('%^(https?:)?//%', $website) ? $website : 'http://' . $website; |
||
527 | |||
528 | $ret = "<table>\n<tr>\n" |
||
529 | . "<td width=\"50%\">\n" |
||
530 | . "<table>\n<tr>\n<td style=\"width: 100px;\">\n" |
||
531 | . "<img src=\"" . XOOPS_URL . '/modules/' . $module_dir . '/' . $this->_obj->getInfo('image') . "\" alt=\"" . $module_dir . "\" style=\"float: left; margin-right: 10px;\">\n" |
||
532 | . "</td><td>\n" |
||
533 | . "<div style=\"margin-top: 1px; margin-bottom: 4px; font-size: 18px; line-height: 18px; color: #2F5376; font-weight: bold;\">\n" |
||
534 | . $this->_obj->getInfo('name') . ' ' . $this->_obj->getVar('version') . ' ' . " ({$release_date})\n" |
||
535 | . "<br>\n" |
||
536 | . "</div>\n" |
||
537 | . "<div style=\"line-height: 16px; font-weight: bold;\">\n" |
||
538 | . _AM_MODULEADMIN_ABOUT_BY . implode(', ', $authorArray) . "\n" |
||
539 | . "</div>\n" |
||
540 | . "<div style=\"line-height: 16px;\">\n" |
||
541 | . "<a href=\"$license_url\" target=\"_blank\" rel=\"external\">" . $this->_obj->getInfo('license') . "</a>\n" |
||
542 | . "<br>\n" |
||
543 | . "<a href=\"$website\" target=\"_blank\">" . $this->_obj->getInfo('website') . "</a>\n" |
||
544 | . "<br>\n" |
||
545 | . "<br>\n" |
||
546 | . "</div>\n" |
||
547 | . "</td></tr>\n"; |
||
548 | if ((1 !== preg_match('/[^a-zA-Z0-9]/', $business)) || (false !== checkEmail($business))) { |
||
549 | $ret .= "<td colspan=\"2\">" |
||
550 | . "<div id=\"about_donate\"><fieldset><legend class=\"label\">Donation</legend><br>\n" |
||
551 | . "<div style=\"clear: both; height: 1em;\"></div>\n" |
||
552 | . "<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\" target=\"_blank\" rel=\external\">\n" |
||
553 | . "<input name=\"cmd\" type=\"hidden\" value=\"_donations\">\n" |
||
554 | . "<input name=\"business\" type=\"hidden\" value=\"{$business}\">\n" |
||
555 | . "<input name=\"currency_code\" type=\"hidden\" value=\"" . _AM_MODULEADMIN_ABOUT_AMOUNT_CURRENCY . "\">\n" |
||
556 | . "<label class=\"label_after\" for=\"amount\">" . _AM_MODULEADMIN_ABOUT_AMOUNT . "</label><text><input class=\"donate_amount\" type=\"text\" name=\"amount\" value=\"" . _AM_MODULEADMIN_ABOUT_AMOUNT_SUGGESTED . "\" title=\"" . _AM_MODULEADMIN_ABOUT_AMOUNT_TTL . "\" pattern=\"" . _AM_MODULEADMIN_ABOUT_AMOUNT_PATTERN . "\"></text>\n" |
||
557 | . "<br>\n" |
||
558 | . "<text><input type=\"image\" name=\"submit\" class=\"donate_button\" src=\"" . XOOPS_URL . "/images/btn_donate_LG.png\" alt=\"" . _AM_MODULEADMIN_ABOUT_DONATE_IMG_ALT . "\"></text>\n" |
||
559 | . "</form>\n" |
||
560 | . "<br>\n" |
||
561 | . "</fieldset>\n" |
||
562 | . "</div>\n" |
||
563 | . "</td>\n</tr>\n"; |
||
564 | } |
||
565 | $ret .= "</table>\n"; |
||
566 | $this->addInfoBox( _AM_MODULEADMIN_ABOUT_MODULEINFO ); |
||
567 | $this->addInfoBoxLine( _AM_MODULEADMIN_ABOUT_MODULEINFO, $module_info, '', '', 'information' ); |
||
568 | $ret .= $this->renderInfoBox() |
||
569 | . "</td>\n" |
||
570 | . "<td width=\"50%\">\n" |
||
571 | . "<fieldset><legend class=\"label\">" . _AM_MODULEADMIN_ABOUT_CHANGELOG . "</legend><br>\n" |
||
572 | . "<div class=\"txtchangelog\">\n"; |
||
573 | $language = empty( $GLOBALS['xoopsConfig']['language'] ) ? 'english' : $GLOBALS['xoopsConfig']['language']; |
||
574 | $file = XOOPS_ROOT_PATH . "/modules/{$module_dir}/language/{$language}/changelog.txt"; |
||
575 | if ( !is_file( $file ) && ( 'english' !== $language ) ) { |
||
576 | $file = XOOPS_ROOT_PATH . "/modules/{$module_dir}/language/english/changelog.txt"; |
||
577 | } |
||
578 | if ( is_readable( $file ) ) { |
||
579 | $ret .= ( implode( '<br>', file( $file ) ) ) . "\n"; |
||
580 | } else { |
||
581 | $file = XOOPS_ROOT_PATH . "/modules/{$module_dir}/docs/changelog.txt"; |
||
582 | if ( is_readable( $file ) ) { |
||
583 | $ret .= implode( '<br>', file( $file ) ) . "\n"; |
||
584 | } |
||
585 | } |
||
586 | $ret .= "</div>\n" |
||
587 | . "</fieldset>\n" |
||
588 | . "</td>\n" |
||
589 | . "</tr>\n" |
||
590 | . "</table>\n"; |
||
591 | if ( true === $logo_xoops ) { |
||
592 | $ret .= "<div class=\"center\">" |
||
593 | . "<a href=\"https://xoops.org\" target=\"_blank\"><img src=\"{$path}xoopsmicrobutton.gif\" alt=\"XOOPS\" title=\"XOOPS\"></a>" |
||
594 | . "</div>"; |
||
595 | } |
||
596 | return $ret; |
||
597 | } |
||
598 | |||
599 | /** |
||
600 | * @param string $menu |
||
601 | * |
||
602 | * @return string |
||
603 | */ |
||
604 | public function addNavigation($menu = '') |
||
605 | { |
||
606 | $this->addAssets(); |
||
607 | $ret = ''; |
||
608 | $navigation = ''; |
||
609 | $path = XOOPS_URL . '/modules/' . $this->_obj->getVar('dirname') . '/'; |
||
610 | $this->_obj->loadAdminMenu(); |
||
611 | foreach (array_keys((array) $this->_obj->adminmenu) as $i) { |
||
612 | if ($this->_obj->adminmenu[$i]['link'] == 'admin/' . $menu) { |
||
613 | $navigation .= $this->_obj->adminmenu[$i]['title'] . ' | '; |
||
614 | $ret = "<div class=\"CPbigTitle\" style=\"background-image: url(" . $path . $this->_obj->adminmenu[$i]['icon'] . "); background-repeat: no-repeat; background-position: left; padding-left: 50px;\"> |
||
615 | <strong>" . $this->_obj->adminmenu[$i]['title'] . '</strong></div><br>'; |
||
616 | } else { |
||
617 | $navigation .= "<a href = '../" . $this->_obj->adminmenu[$i]['link'] . "'>" . $this->_obj->adminmenu[$i]['title'] . '</a> | '; |
||
618 | } |
||
619 | } |
||
620 | if (substr(XOOPS_VERSION, 0, 9) < 'XOOPS 2.5') { |
||
621 | $navigation .= "<a href = '../../system/admin.php?fct=preferences&op=showmod&mod=" . $this->_obj->getVar('mid') . "'>" . _MI_SYSTEM_ADMENU6 . '</a>'; |
||
622 | $ret = $navigation . '<br><br>' . $ret; |
||
623 | } |
||
624 | |||
625 | return $ret; |
||
626 | } |
||
627 | } |
||
628 |