Completed
Pull Request — master (#446)
by Richard
12:11
created

ModuleAdmin   C

Complexity

Total Complexity 73

Size/Duplication

Total Lines 588
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 588
rs 5.5447
c 0
b 0
f 0
wmc 73
lcom 2
cbo 1

16 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A getInfo() 0 12 3
A getVersion() 0 10 1
A getReleaseDate() 0 10 1
A getClassMethods() 0 6 1
A loadLanguage() 0 12 3
A addItemButton() 0 11 1
A addInfoBox() 0 8 1
C renderMenuIndex() 0 29 7
B renderButton() 0 31 6
C addConfigBoxLine() 0 44 7
A addInfoBoxLine() 0 20 3
F renderIndex() 0 106 18
A renderInfoBox() 0 19 4
F renderAbout() 0 95 12
B addNavigation() 0 22 4

How to fix   Complexity   

Complex Class

Complex classes like ModuleAdmin often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use ModuleAdmin, and based on these observations, apply Extract Interface, too.

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 (http://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, $xoTheme;
36
        global $xoopsModule;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
37
        $this->_obj =& $xoopsModule;
38
        echo "<style type=\"text/css\" media=\"screen\">@import \"" . XOOPS_URL . "/Frameworks/moduleclasses/moduleadmin/css/admin.css\";</style>";
39
        //$xoTheme->addStylesheet("Frameworks/moduleclasses/moduleadmin/css/admin.css");
40
        $this->loadLanguage();
41
    }
42
43
    /**
44
     * @return array
45
     */
46
    public function getInfo()
47
    {
48
        $infoArray = array();
49
        if (!isset($infoArray) || empty($infoArray)) {
50
            $infoArray                = array();
51
            $infoArray['version']     = $this->getVersion();
52
            $infoArray['releasedate'] = $this->getReleaseDate();
53
            $infoArray['methods']     = $this->getClassMethods();
54
        }
55
56
        return $infoArray;
57
    }
58
59
    /**
60
     * Return the Module Admin class version number
61
     * return string version
62
     **/
63
    public function getVersion()
64
    {
65
        /**
66
         * version is rev of this class
67
         */
68
        include_once 'xoops_version.php';
69
        $version = XOOPS_FRAMEWORKS_MODULEADMIN_VERSION;
70
71
        return $version;
72
    }
73
74
    /**
75
     * Return the Module Admin class release date
76
     * return string version
77
     **/
78
    public function getReleaseDate()
79
    {
80
        /**
81
         * version is rev of this class
82
         */
83
        include_once 'xoops_version.php';
84
        $releasedate = XOOPS_FRAMEWORKS_MODULEADMIN_RELEASEDATE;
85
86
        return $releasedate;
87
    }
88
89
    /**
90
     * Return the available methods for the class
91
     *
92
     * @return array methods supported by this class
93
     */
94
    public function getClassMethods()
95
    {
96
        $myMethods = get_class_methods(__CLASS__);
97
98
        return $myMethods;
99
    }
100
101
    //******************************************************************************************************************
102
    // loadLanguage
103
    //******************************************************************************************************************
104
    // Loaf the language file.
105
    //******************************************************************************************************************
106
    /**
107
     * @return bool|mixed
108
     */
109
    public function loadLanguage()
110
    {
111
        $language = $GLOBALS['xoopsConfig']['language'];
112
        if (!file_exists($fileinc = XOOPS_ROOT_PATH . "/Frameworks/moduleclasses/moduleadmin/language/{$language}/main.php")) {
113
            if (!file_exists($fileinc = XOOPS_ROOT_PATH . '/Frameworks/moduleclasses/moduleadmin/language/english/main.php')) {
114
                return false;
115
            }
116
        }
117
        $ret = include_once $fileinc;
118
119
        return $ret;
120
    }
121
    //******************************************************************************************************************
122
    // renderMenuIndex
123
    //******************************************************************************************************************
124
    // Creating a menu icon in the index
125
    //******************************************************************************************************************
126
    /**
127
     * @return string
128
     */
129
    public function renderMenuIndex()
130
    {
131
        $path       = XOOPS_URL . '/modules/' . $this->_obj->getVar('dirname') . '/';
132
        $pathsystem = XOOPS_URL . '/modules/system/';
133
        $this->_obj->loadAdminMenu();
134
        $ret = "<div class=\"rmmenuicon\">\n";
135
        foreach (array_keys($this->_obj->adminmenu) as $i) {
136
            if ($this->_obj->adminmenu[$i]['link'] !== 'admin/index.php') {
137
                $ret .= "<a href=\"../" . $this->_obj->adminmenu[$i]['link'] . "\" title=\"" . (isset($this->_obj->adminmenu[$i]['desc']) ? $this->_obj->adminmenu[$i]['desc'] : '') . "\">";
138
                //$ret .= "<img src=\"" . $path . $this->_obj->adminmenu[$i]['icon']. "\" alt=\"" . $this->_obj->adminmenu[$i]['title'] . "\" />";
139
                //mb for direct URL access to icons in modules Admin
140
                $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'] . "\" />";
141
142
                $ret .= '<span>' . $this->_obj->adminmenu[$i]['title'] . '</span>';
143
                $ret .= '</a>';
144
            }
145
        }
146
        if ($this->_obj->getInfo('help')) {
147
            if (substr(XOOPS_VERSION, 0, 9) >= 'XOOPS 2.5') {
148
                $ret .= "<a href=\"" . $pathsystem . 'help.php?mid=' . $this->_obj->getVar('mid', 's') . '&amp;' . $this->_obj->getInfo('help') . "\" title=\"" . _AM_SYSTEM_HELP . "\">";
149
                $ret .= "<img width=\"32px\" src=\"" . XOOPS_URL . "/Frameworks/moduleclasses/icons/32/help.png\" alt=\"" . _AM_SYSTEM_HELP . "\" /> ";
150
                $ret .= '<span>' . _AM_SYSTEM_HELP . '</span>';
151
                $ret .= '</a>';
152
            }
153
        }
154
        $ret .= "</div>\n<div style=\"clear: both;\"></div>\n";
155
156
        return $ret;
157
    }
158
    //******************************************************************************************************************
159
    // renderButton
160
    //******************************************************************************************************************
161
    // Creating button
162
    //******************************************************************************************************************
163
    /**
164
     * @param string $position
165
     * @param string $delimeter
166
     *
167
     * @return string
168
     */
169
    public function renderButton($position = 'right', $delimeter = '&nbsp;')
170
    {
171
        $path = XOOPS_URL . '/Frameworks/moduleclasses/icons/32/';
172
        switch ($position) {
173
            default:
174
            case 'right':
175
                $ret = "<div class=\"floatright\">\n";
176
                break;
177
178
            case 'left':
179
                $ret = "<div class=\"floatleft\">\n";
180
                break;
181
182
            case 'center':
183
                $ret = "<div class=\"aligncenter\">\n";
184
        }
185
        $ret .= "<div class=\"xo-buttons\">\n";
186
        foreach (array_keys($this->_itemButton) as $i) {
187
            $ret .= "<a class='ui-corner-all tooltip' href='" . $this->_itemButton[$i]['link'] . "' title='" . $this->_itemButton[$i]['title'] . "' " . $this->_itemButton[$i]['extra'] . '>';
188
            $ret .= "<img src='"
189
                    //. $path . $this -> _itemButton[$i]['icon']
190
                    //mb for direct URL access to icons in modules Admin
191
                    . (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'];
192
            $ret .= "</a>\n";
193
            $ret .= $delimeter;
194
        }
195
        $ret .= "</div>\n</div>\n";
196
        $ret .= '<br>&nbsp;<br><br>';
197
198
        return $ret;
199
    }
200
201
    /**
202
     * @param        $title
203
     * @param        $link
204
     * @param string $icon
205
     * @param string $extra
206
     *
207
     * @return bool
208
     */
209
    public function addItemButton($title, $link, $icon = 'add', $extra = '')
210
    {
211
        $ret = array();
212
        $ret['title']        = $title;
213
        $ret['link']         = $link;
214
        $ret['icon']         = $icon . '.png';
215
        $ret['extra']        = $extra;
216
        $this->_itemButton[] = $ret;
217
218
        return true;
219
    }
220
    //******************************************************************************************************************
221
    // addConfigBoxLine
222
    //******************************************************************************************************************
223
    // $value: value
224
    // $type: type of config:   1- "default": Just a line with value.
225
    //                          2- "folder": check if this is an folder.
226
    //                          3- "chmod": check if this is the good chmod.
227
    //                                      For this type ("chmod"), the value is an array: array(path, chmod)
228
    //******************************************************************************************************************
229
    /**
230
     * @param string $value
231
     * @param string $type
232
     *
233
     * @return bool
234
     */
235
    public function addConfigBoxLine($value = '', $type = 'default')
236
    {
237
        $line = '';
238
        $path = XOOPS_URL . '/Frameworks/moduleclasses/icons/16/';
239
        switch ($type) {
240
            default:
241
            case 'default':
242
                $line .= '<span>' . $value . '</span>';
243
                break;
244
245
            case 'folder':
246
                if (!is_dir($value)) {
247
                    $line .= "<span style='color : red; font-weight : bold;'>";
248
                    $line .= "<img src='" . $path . "0.png' >";
249
                    $line .= sprintf(_AM_MODULEADMIN_CONFIG_FOLDERKO, $value);
250
                    $line .= "</span>\n";
251
                } else {
252
                    $line .= "<span style='color : green;'>";
253
                    $line .= "<img src='" . $path . "1.png' >";
254
                    $line .= sprintf(_AM_MODULEADMIN_CONFIG_FOLDEROK, $value);
255
                    $line .= "</span>\n";
256
                }
257
                break;
258
259
            case 'chmod':
260
                if (is_dir($value[0])) {
261
                    if (substr(decoct(fileperms($value[0])), 2) != $value[1]) {
262
                        $line .= "<span style='color : red; font-weight : bold;'>";
263
                        $line .= "<img src='" . $path . "0.png' >";
264
                        $line .= sprintf(_AM_MODULEADMIN_CONFIG_CHMOD, $value[0], $value[1], substr(decoct(fileperms($value[0])), 2));
265
                        $line .= "</span>\n";
266
                    } else {
267
                        $line .= "<span style='color : green;'>";
268
                        $line .= "<img src='" . $path . "1.png' >";
269
                        $line .= sprintf(_AM_MODULEADMIN_CONFIG_CHMOD, $value[0], $value[1], substr(decoct(fileperms($value[0])), 2));
270
                        $line .= "</span>\n";
271
                    }
272
                }
273
                break;
274
        }
275
        $this->_itemConfigBoxLine[] = $line;
276
277
        return true;
278
    }
279
    //******************************************************************************************************************
280
    // renderIndex
281
    //******************************************************************************************************************
282
    // Creating an index
283
    //******************************************************************************************************************
284
    /**
285
     * @return string
286
     */
287
    public function renderIndex()
288
    {
289
        $ret = "<table id='xo-modadmin-index'>\n<tr>\n";
290
        $ret .= "<td width=\"40%\">\n";
291
        $ret .= $this->renderMenuIndex();
292
        $ret .= "</td>\n";
293
        $ret .= "<td width=\"60%\">\n";
294
        $ret .= $this->renderInfoBox();
295
        $ret .= "</td>\n";
296
        $ret .= "</tr>\n";
297
        // If you use a config label
298
        if ($this->_obj->getInfo('min_php') || $this->_obj->getInfo('min_xoops') || !empty($this->_itemConfigBoxLine)) {
299
            $ret .= "<tr>\n";
300
            $ret .= "<td colspan=\"2\">\n";
301
            $ret .= "<fieldset><legend class=\"label\">";
302
            $ret .= _AM_MODULEADMIN_CONFIG;
303
            $ret .= "</legend>\n";
304
305
            // php version
306
            $path = XOOPS_URL . '/Frameworks/moduleclasses/icons/16/';
307
            if ($this->_obj->getInfo('min_php')) {
308
                if (version_compare(phpversion(), $this->_obj->getInfo('min_php'), '<')) {
309
                    $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";
310
                } else {
311
                    $ret .= "<span style='color : green;'><img src='" . $path . "1.png' >" . sprintf(_AM_MODULEADMIN_CONFIG_PHP, $this->_obj->getInfo('min_php'), phpversion()) . "</span>\n";
312
                }
313
                $ret .= '<br>';
314
            }
315
316
            // Database version
317
            $path    = XOOPS_URL . '/Frameworks/moduleclasses/icons/16/';
318
            $dbarray = $this->_obj->getInfo('min_db');
319
320
            if ($dbarray[XOOPS_DB_TYPE]) {
321
                // changes from redheadedrod to use connector specific version info
322
                switch (XOOPS_DB_TYPE) {
323
                    // server should be the same in both cases
324
                    case 'mysql':
325
                    case 'mysqli':
326
                        global $xoopsDB;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
327
                        $dbCurrentVersion = $xoopsDB->getServerVersion();
328
                        break;
329
                    //case "pdo":
330
                    //    global $xoopsDB;
331
                    //    $dbCurrentVersion = $xoopsDB->getAttribute(PDO::ATTR_SERVER_VERSION);
332
                    //    break;
333
                    default: // don't really support anything other than mysql
334
                        $dbCurrentVersion = '0';
335
                        break;
336
                }
337
                $currentVerParts   = explode('.', (string)$dbCurrentVersion);
338
                $iCurrentVerParts  = array_map('intval', $currentVerParts);
339
                $dbRequiredVersion = $dbarray[XOOPS_DB_TYPE];
340
                $reqVerParts       = explode('.', (string)$dbRequiredVersion);
341
                $iReqVerParts      = array_map('intval', $reqVerParts);
342
                $icount            = $j = count($iReqVerParts);
343
                $reqVer            = $curVer = 0;
344
                for ($i = 0; $i < $icount; ++$i) {
345
                    $j--;
346
                    $reqVer += $iReqVerParts[$i] * pow(10, $j);
347
                    if (isset($iCurrentVerParts[$i])) {
348
                        $curVer += $iCurrentVerParts[$i] * pow(10, $j);
349
                    } else {
350
                        $curVer *= pow(10, $j);
351
                    }
352
                }
353
                if ($reqVer > $curVer) {
354
                    $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";
355
                } else {
356
                    $ret .= "<span style='color : green;'><img src='" . $path . "1.png' >" . sprintf(strtoupper(XOOPS_DB_TYPE) . ' ' . _AM_MODULEADMIN_CONFIG_DB, $dbRequiredVersion, $dbCurrentVersion) . "</span><br>\n";
357
                }
358
            }
359
360
            // xoops version
361
            if ($this->_obj->getInfo('min_xoops')) {
362
                if (substr(XOOPS_VERSION, 6, strlen(XOOPS_VERSION) - 6) < $this->_obj->getInfo('min_xoops')) {
363
                    $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";
364
                } else {
365
                    $ret .= "<span style='color : green;'><img src='" . $path . "1.png' >" . sprintf(_AM_MODULEADMIN_CONFIG_XOOPS, $this->_obj->getInfo('min_xoops'), substr(XOOPS_VERSION, 6, strlen(XOOPS_VERSION) - 6)) . "</span>\n";
366
                }
367
                $ret .= '<br>';
368
            }
369
370
            // ModuleAdmin version
371
            if ($this->_obj->getInfo('min_admin')) {
372
                if ($this->getVersion() < $this->_obj->getInfo('min_admin')) {
373
                    $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";
374
                } else {
375
                    $ret .= "<span style='color : green;'><img src='" . $path . "1.png' >" . sprintf(_AM_MODULEADMIN_CONFIG_ADMIN, $this->_obj->getInfo('min_admin'), $this->getVersion()) . "</span>\n";
376
                }
377
                $ret .= '<br>';
378
            }
379
            if (!empty($this->_itemConfigBoxLine)) {
380
                foreach (array_keys($this->_itemConfigBoxLine) as $i) {
381
                    $ret .= $this->_itemConfigBoxLine[$i];
382
                    $ret .= '<br>';
383
                }
384
            }
385
            $ret .= "</fieldset>\n";
386
            $ret .= "</td>\n";
387
            $ret .= "</tr>\n";
388
        }
389
        $ret .= "</table>\n";
390
391
        return $ret;
392
    }
393
    //******************************************************************************************************************
394
    // addInfoBox
395
    //******************************************************************************************************************
396
    // $title: title of an InfoBox
397
    //******************************************************************************************************************
398
    /**
399
     * @param $title
400
     *
401
     * @return bool
402
     */
403
    public function addInfoBox($title)
404
    {
405
        $ret = array();
406
        $ret['title']         = $title;
407
        $this->_itemInfoBox[] = $ret;
408
409
        return true;
410
    }
411
    //******************************************************************************************************************
412
    // addInfoBoxLine
413
    //******************************************************************************************************************
414
    // $label: title of InfoBox Line
415
    // $text:
416
    // $type: type of config:   1- "default": Just a line with value.
417
    //                          2- "information": check if this is an folder.
418
    //                          3- "chmod": check if this is the good chmod.
419
    //                                      For this type ("chmod"), the value is an array: array(path, chmod)
420
    //******************************************************************************************************************
421
    /**
422
     * @param        $label
423
     * @param        $text
424
     * @param string $value
425
     * @param string $color
426
     * @param string $type
427
     *
428
     * @return bool
429
     */
430
    public function addInfoBoxLine($label, $text, $value = '', $color = 'inherit', $type = 'default')
431
    {
432
        $ret = array();
433
        $ret['label'] = $label;
434
        $line         = '';
435
        switch ($type) {
436
            default:
437
            case 'default':
438
                $line .= sprintf($text, "<span style='color : " . $color . "; font-weight : bold;'>" . $value . '</span>');
439
                break;
440
441
            case 'information':
442
                $line .= $text;
443
                break;
444
        }
445
        $ret['line']              = $line;
446
        $this->_itemInfoBoxLine[] = $ret;
447
448
        return true;
449
    }
450
451
    /**
452
     * @return string
453
     */
454
    public function renderInfoBox()
455
    {
456
        $ret = '';
457
        foreach (array_keys($this->_itemInfoBox) as $i) {
458
            $ret .= "<fieldset><legend class=\"label\">";
459
            $ret .= $this->_itemInfoBox[$i]['title'];
460
            $ret .= "</legend>\n";
461
            foreach (array_keys($this->_itemInfoBoxLine) as $k) {
462
                if ($this->_itemInfoBoxLine[$k]['label'] == $this->_itemInfoBox[$i]['title']) {
463
                    $ret .= $this->_itemInfoBoxLine[$k]['line'];
464
                    $ret .= '<br>';
465
                }
466
            }
467
            $ret .= "</fieldset>\n";
468
            $ret .= "<br>\n";
469
        }
470
471
        return $ret;
472
    }
473
474
    /**
475
     * Create HTML text to display on Admin About page
476
     *
477
     * @param string $business the PAYPAL business email or Merchant Account ID
478
     * @param bool   $logo_xoops true to display XOOPS logo and link on page
479
     *
480
     * @return string HTML to display
481
     */
482
    public function renderAbout($business = '', $logo_xoops = true)
483
    {
484
        $path         = XOOPS_URL . '/Frameworks/moduleclasses/icons/32/';
485
        $date         = preg_replace('/-\\\/', '/', $this->_obj->getInfo('release_date')); // make format a little more forgiving
486
        $date         = explode('/', $date);
487
        $author       = explode(',', $this->_obj->getInfo('author'));
488
        $nickname     = explode(',', $this->_obj->getInfo('nickname'));
489
        $release_date = formatTimestamp(mktime(0, 0, 0, $date[1], $date[2], $date[0]), 's');
490
        $module_dir   = $this->_obj->getVar('dirname');
491
        $module_info  = "<div id=\"about\"><label class=\"label_after\">" . _AM_MODULEADMIN_ABOUT_DESCRIPTION . "</label>\n"
492
                      . "<text>" . $this->_obj->getInfo('description') . "</text><br>\n"
493
                      . "<label class=\"label_after\">" . _AM_MODULEADMIN_ABOUT_UPDATEDATE . "</label>\n"
494
                      . "<text class=\"bold\">" . formatTimestamp($this->_obj->getVar('last_update'), 'm') . "</text><br>\n"
495
                      . "<label class=\"label_after\">" . _AM_MODULEADMIN_ABOUT_MODULESTATUS . "</label>\n"
496
                      . "<text>" . $this->_obj->getInfo('module_status') . "</text><br>\n"
497
                      . "<label class=\"label_after\">" . _AM_MODULEADMIN_ABOUT_WEBSITE . "</label>\n"
498
                      . "<text><a class=\"tooltip\" href=\"http://" . $this->_obj->getInfo('module_website_url') . "\" rel=\"external\" title=\""
499
                      . $this->_obj->getInfo('module_website_name') . " - " . $this->_obj->getInfo('module_website_url') . "\">"
500
                      . $this->_obj->getInfo('module_website_name') . "</a></text>\n"
501
                      . "</div>\n";
502
        $authorArray  = array();
503
        foreach ( $author as $k => $aName ) {
504
            $authorArray[$k] = ( isset( $nickname[$k] ) && ( '' != $nickname[$k] ) ) ? "{$aName} ({$nickname[$k]})" : "{$aName}";
505
        }
506
        $ret = "<table>\n<tr>\n"
507
             . "<td width=\"50%\">\n"
508
             . "<table>\n<tr>\n<td style=\"width: 100px;\">\n"
509
             . "<img src=\"" . XOOPS_URL . '/modules/' . $module_dir . '/' . $this->_obj->getInfo('image') . "\" alt=\"" . $module_dir . "\" style=\"float: left; margin-right: 10px;\">\n"
510
             . "</td><td>\n"
511
             . "<div style=\"margin-top: 1px; margin-bottom: 4px; font-size: 18px; line-height: 18px; color: #2F5376; font-weight: bold;\">\n"
512
             . $this->_obj->getInfo('name') . ' ' . $this->_obj->getInfo('version') . ' ' . $this->_obj->getInfo('module_status') . " ({$release_date})\n"
513
             . "<br>\n"
514
             . "</div>\n"
515
             . "<div style=\"line-height: 16px; font-weight: bold;\">\n"
516
             . _AM_MODULEADMIN_ABOUT_BY . implode(', ', $authorArray) . "\n"
517
             . "</div>\n"
518
             . "<div style=\"line-height: 16px;\">\n"
519
             . "<a href=\"http://" . $this->_obj->getInfo('license_url') . "\" target=\"_blank\" rel=\"external\">" . $this->_obj->getInfo('license') . "</a>\n"
520
             . "<br>\n"
521
             . "<a href=\"http://" . $this->_obj->getInfo('website') . "\" target=\"_blank\">" . $this->_obj->getInfo('website') . "</a>\n"
522
             . "<br>\n"
523
             . "<br>\n"
524
             . "</div>\n"
525
             . "</td></tr>\n";
526
        if ((1 !== preg_match('/[^a-zA-Z0-9]/', $business)) || (false !== checkEmail($business))) {
527
            $ret .= "<td colspan=\"2\">"
528
                  . "<div id=\"about_donate\"><fieldset><legend class=\"label\">Donation</legend><br>\n"
529
                  . "<div style=\"clear: both; height: 1em;\"></div>\n"
530
                  . "<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\" target=\"_blank\" rel=\external\">\n"
531
                  . "<input name=\"cmd\" type=\"hidden\" value=\"_donations\">\n"
532
                  . "<input name=\"business\" type=\"hidden\" value=\"{$business}\">\n"
533
                  . "<input name=\"currency_code\" type=\"hidden\" value=\"" . _AM_MODULEADMIN_ABOUT_AMOUNT_CURRENCY . "\">\n"
534
                  . "<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"
535
                  . "<br>\n"
536
                  . "<text><input type=\"image\" name=\"submit\" class=\"donate_button\" src=\"https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif\" alt=\"" . _AM_MODULEADMIN_ABOUT_DONATE_IMG_ALT . "\"></text>\n"
537
                  . "<img alt=\"\" height=\"1\" src=\"https://www.paypalobjects.com/en_US/i/scr/pixel.gif\" style=\"border-width: 0px;\" width=\"1\">\n"
538
                  . "</form>\n"
539
                  . "<br>\n"
540
                  . "</fieldset>\n"
541
                  . "</div>\n"
542
                  . "</td>\n</tr>\n";
543
        }
544
        $ret .= "</table>\n";
545
        $this->addInfoBox( _AM_MODULEADMIN_ABOUT_MODULEINFO );
546
        $this->addInfoBoxLine( _AM_MODULEADMIN_ABOUT_MODULEINFO, $module_info, '', '', 'information' );
547
        $ret .= $this->renderInfoBox()
548
              . "</td>\n"
549
              . "<td width=\"50%\">\n"
550
              . "<fieldset><legend class=\"label\">" . _AM_MODULEADMIN_ABOUT_CHANGELOG . "</legend><br>\n"
551
              . "<div class=\"txtchangelog\">\n";
552
        $language = empty( $GLOBALS['xoopsConfig']['language'] ) ? 'english' : $GLOBALS['xoopsConfig']['language'];
553
        $file     = XOOPS_ROOT_PATH . "/modules/{$module_dir}/language/{$language}/changelog.txt";
554
        if ( !is_file( $file ) && ( 'english' !== $language ) ) {
555
            $file = XOOPS_ROOT_PATH . "/modules/{$module_dir}/language/english/changelog.txt";
556
        }
557
        if ( is_readable( $file ) ) {
558
            $ret .= ( implode( '<br>', file( $file ) ) ) . "\n";
559
        } else {
560
            $file = XOOPS_ROOT_PATH . "/modules/{$module_dir}/docs/changelog.txt";
561
            if ( is_readable( $file ) ) {
562
                $ret .= implode( '<br>', file( $file ) ) . "\n";
563
            }
564
        }
565
        $ret .= "</div>\n"
566
              . "</fieldset>\n"
567
              . "</td>\n"
568
              . "</tr>\n"
569
              . "</table>\n";
570
        if ( true === $logo_xoops ) {
571
            $ret .= "<div class=\"center\">"
572
                  . "<a href=\"http://www.xoops.org\" target=\"_blank\"><img src=\"{$path}xoopsmicrobutton.gif\" alt=\"XOOPS\" title=\"XOOPS\"></a>"
573
                  . "</div>";
574
        }
575
        return $ret;
576
    }
577
578
    /**
579
     * @param string $menu
580
     *
581
     * @return string
582
     */
583
    public function addNavigation($menu = '')
584
    {
585
        $ret        = '';
586
        $navigation = '';
587
        $path       = XOOPS_URL . '/modules/' . $this->_obj->getVar('dirname') . '/';
588
        $this->_obj->loadAdminMenu();
589
        foreach (array_keys($this->_obj->adminmenu) as $i) {
590
            if ($this->_obj->adminmenu[$i]['link'] == 'admin/' . $menu) {
591
                $navigation .= $this->_obj->adminmenu[$i]['title'] . ' | ';
592
                $ret = "<div class=\"CPbigTitle\" style=\"background-image: url(" . $path . $this->_obj->adminmenu[$i]['icon'] . "); background-repeat: no-repeat; background-position: left; padding-left: 50px;\">
593
        <strong>" . $this->_obj->adminmenu[$i]['title'] . '</strong></div><br>';
594
            } else {
595
                $navigation .= "<a href = '../" . $this->_obj->adminmenu[$i]['link'] . "'>" . $this->_obj->adminmenu[$i]['title'] . '</a> | ';
596
            }
597
        }
598
        if (substr(XOOPS_VERSION, 0, 9) < 'XOOPS 2.5') {
599
            $navigation .= "<a href = '../../system/admin.php?fct=preferences&op=showmod&mod=" . $this->_obj->getVar('mid') . "'>" . _MI_SYSTEM_ADMENU6 . '</a>';
600
            $ret = $navigation . '<br><br>' . $ret;
601
        }
602
603
        return $ret;
604
    }
605
}
606