-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathicons.php
105 lines (85 loc) · 3.93 KB
/
icons.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/**
* Common Utilities Framework for Xoops
*
* Copyright © 2015 Eduardo Cortés http://www.eduardocortes.mx
* -------------------------------------------------------------
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
* -------------------------------------------------------------
* @copyright Eduardo Cortés (http://www.redmexico.com.mx)
* @license GNU GPL 2
* @package rmcommon
* @author Eduardo Cortés (AKA bitcero) <i.bitcero@gmail.com>
* @url http://www.eduardocortes.mx
*/
require dirname(dirname(__DIR__)) . '/include/cp_header.php';
$common->location = 'icons';
// Add scripts
$common->template()->add_script('icons.min.js', 'rmcommon', ['footer' => 1, 'id' => 'icons-js']);
// Load providers
$providers = \RMEvents::get()->trigger('rmcommon.register.icon.provider', []);
$action = $common->httpRequest()->request('action', 'string', '');
switch ($action) {
case 'load-icons':
$common->ajax()->prepare();
$common->checkToken(true);
$provider = $common->httpRequest()->get('provider', 'string', '');
$size = $common->httpRequest()->get('size', 'integer', 32);
$tempProviders = [];
foreach ($providers as $item) {
$tempProviders[$item['id']] = $item;
}
unset($item);
$providers = $tempProviders;
unset($tempProviders);
if (!array_key_exists($provider, $providers) && 'rmcommon' != $provider) {
$common->ajax()->notifyError(__('Icons provider does not exists!', 'rmcommon'));
}
$selected = $providers[$provider];
$name = isset($providers[$provider]['name']) ? $providers[$provider]['name'] : $providers[$provider]['id'];
$icons = $cuIcons->getIconsList([$provider]);
$common->template()->assign('icons', $icons);
$common->template()->assign('selectedProvider', ['id' => 'rmcommon', 'name' => $name]);
$common->template()->assign('providerPrefix', 'svg-' . $selected['id'] . '-');
$common->template()->assign('size', $size);
$common->ajax()->response(
sprintf(__('Icons from %s', 'rmcommon'), $name),
0,
1,
[
'content' => $common->template()->render('ajax/ajax-icons.php', 'module', 'rmcommon'),
]
);
break;
default:
// SHOW ICONS
$common->template()->append('providers', ['id' => 'rmcommon', 'name' => 'Common Utilities']);
foreach ($providers as $provider) {
if (!is_dir($provider['directory'])) {
continue;
}
$common->template()->append('providers', ['id' => $provider['id'], 'name' => isset($provider['name']) ? $provider['name'] : $provider['id']]);
}
$common->template()->assign('selectedProvider', ['id' => 'rmcommon', 'name' => 'Common Utilities']);
$common->template()->assign('providerPrefix', 'svg-rmcommon-');
$icons = $cuIcons->getIconsList(['rmcommon']);
$common->template()->assign('icons', $icons);
$common->template()->add_attribute('body', ['class' => 'rmcommon-icons']);
$common->template()->header();
$common->template()->display('rmc-icons.php', 'module', 'rmcommon');
$common->template()->footer();
break;
}