|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by Gorlum 05.03.2018 12:57 |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace Pages\Deprecated; |
|
7
|
|
|
|
|
8
|
|
|
use Modules\sn_module; |
|
9
|
|
|
use SN; |
|
10
|
|
|
|
|
11
|
|
|
class PageAdminModules extends PageDeprecated { |
|
12
|
|
|
const SORT_BY_PACKAGE = 0; |
|
13
|
|
|
const SORT_BY_ACTIVITY = 1; |
|
14
|
|
|
|
|
15
|
|
|
private static $sorting = [ |
|
16
|
|
|
self::SORT_BY_PACKAGE => ['PACKAGE', 'NAME', '!ACTIVE', '!INSTALLED',], |
|
17
|
|
|
self::SORT_BY_ACTIVITY => ['!ACTIVE', '!INSTALLED', 'PACKAGE', 'NAME',], |
|
18
|
|
|
]; |
|
19
|
|
|
|
|
20
|
|
|
private static $sortFields = []; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @param sn_module $a |
|
24
|
|
|
* @param sn_module $b |
|
25
|
|
|
*/ |
|
26
|
|
|
private static function sortBy($a, $b) { |
|
27
|
|
|
$result = 0; |
|
28
|
|
|
foreach (static::$sortFields as $fieldName) { |
|
|
|
|
|
|
29
|
|
|
if (strpos($fieldName, '!') !== false) { |
|
30
|
|
|
$fieldName = substr($fieldName, 1); |
|
31
|
|
|
$c = $a; |
|
32
|
|
|
$a = $b; |
|
33
|
|
|
$b = $c; |
|
34
|
|
|
} |
|
35
|
|
|
if ($result = $a[$fieldName] > $b[$fieldName] ? 1 : ($a[$fieldName] < $b[$fieldName] ? -1 : 0)) { |
|
36
|
|
|
break; |
|
37
|
|
|
} |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
return $result; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public static function viewStatic($template = null) { |
|
|
|
|
|
|
44
|
|
|
define('IN_ADMIN', true); |
|
45
|
|
|
|
|
46
|
|
|
lng_include('admin'); |
|
47
|
|
|
|
|
48
|
|
|
$modules = SN::$gc->modules->getModulesInGroup([], false); |
|
49
|
|
|
|
|
50
|
|
|
$render = []; |
|
51
|
|
|
foreach ($modules as $module) { |
|
52
|
|
|
$render[] = [ |
|
53
|
|
|
'PACKAGE' => $module->manifest['package'], |
|
54
|
|
|
'NAME' => $module->manifest['name'], |
|
55
|
|
|
'VERSION' => $module->manifest['version'], |
|
56
|
|
|
'ACTIVE' => $module->isActive(), |
|
57
|
|
|
'INSTALLED' => $module->isInstalled(), |
|
58
|
|
|
]; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
$sortBy = sys_get_param_int('SORT_BY', self::SORT_BY_ACTIVITY); |
|
62
|
|
|
array_key_exists($sortBy, static::$sorting) ?: ($sortBy = self::SORT_BY_ACTIVITY); |
|
|
|
|
|
|
63
|
|
|
static::$sortFields = static::$sorting[$sortBy]; |
|
|
|
|
|
|
64
|
|
|
usort($render, [static::class, 'sortBy']); |
|
65
|
|
|
|
|
66
|
|
|
$template = gettemplate('admin/admin_modules'); |
|
67
|
|
|
$template->assign_recursive([ |
|
68
|
|
|
'.' => ['modules' => $render], |
|
69
|
|
|
'SORT_BY' => $sortBy, |
|
70
|
|
|
'PAGE_NAME' => SN::$lang['menu_admin_modules'], |
|
71
|
|
|
]); |
|
72
|
|
|
|
|
73
|
|
|
display($template, SN::$lang['menu_admin_modules']); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
|