|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* sysPass |
|
4
|
|
|
* |
|
5
|
|
|
* @author nuxsmin |
|
6
|
|
|
* @link https://syspass.org |
|
7
|
|
|
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org |
|
8
|
|
|
* |
|
9
|
|
|
* This file is part of sysPass. |
|
10
|
|
|
* |
|
11
|
|
|
* sysPass is free software: you can redistribute it and/or modify |
|
12
|
|
|
* it under the terms of the GNU General Public License as published by |
|
13
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
|
14
|
|
|
* (at your option) any later version. |
|
15
|
|
|
* |
|
16
|
|
|
* sysPass is distributed in the hope that it will be useful, |
|
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19
|
|
|
* GNU General Public License for more details. |
|
20
|
|
|
* |
|
21
|
|
|
* You should have received a copy of the GNU General Public License |
|
22
|
|
|
* along with sysPass. If not, see <http://www.gnu.org/licenses/>. |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
namespace SP\Modules\Web\Controllers; |
|
26
|
|
|
|
|
27
|
|
|
use SP\Core\Exceptions\SPException; |
|
28
|
|
|
use SP\Html\Minify; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Class ResourceController |
|
32
|
|
|
* |
|
33
|
|
|
* @package SP\Modules\Web\Controllers |
|
34
|
|
|
*/ |
|
35
|
|
|
final class ResourceController extends SimpleControllerBase |
|
36
|
|
|
{ |
|
37
|
|
|
/** |
|
38
|
|
|
* @var Minify |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $minify; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Returns CSS resources |
|
44
|
|
|
*/ |
|
45
|
|
|
public function cssAction() |
|
46
|
|
|
{ |
|
47
|
|
|
$file = $this->request->analyzeString('f'); |
|
48
|
|
|
$base = $this->request->analyzeString('b'); |
|
49
|
|
|
|
|
50
|
|
|
if ($file && $base) { |
|
51
|
|
|
$this->minify |
|
52
|
|
|
->setType(Minify::FILETYPE_CSS) |
|
53
|
|
|
->setBase(urldecode($base), true) |
|
54
|
|
|
->addFilesFromString(urldecode($file)) |
|
55
|
|
|
->getMinified(); |
|
56
|
|
|
} else { |
|
57
|
|
|
$this->minify->setType(Minify::FILETYPE_CSS) |
|
58
|
|
|
->setBase(PUBLIC_PATH . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'css') |
|
59
|
|
|
->addFiles([ |
|
60
|
|
|
'reset.min.css', |
|
61
|
|
|
'jquery-ui.min.css', |
|
62
|
|
|
'jquery-ui.structure.min.css', |
|
63
|
|
|
'material-icons.min.css', |
|
64
|
|
|
'toastr.min.css', |
|
65
|
|
|
'magnific-popup.min.css' |
|
66
|
|
|
], false) |
|
67
|
|
|
->addFile('fonts.min.css', false, PUBLIC_PATH . DIRECTORY_SEPARATOR . 'css') |
|
68
|
|
|
->getMinified(); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Returns JS resources |
|
74
|
|
|
*/ |
|
75
|
|
|
public function jsAction() |
|
76
|
|
|
{ |
|
77
|
|
|
$file = $this->request->analyzeString('f'); |
|
78
|
|
|
$base = $this->request->analyzeString('b'); |
|
79
|
|
|
|
|
80
|
|
|
if ($file && $base) { |
|
81
|
|
|
$this->minify |
|
82
|
|
|
->setType(Minify::FILETYPE_JS) |
|
83
|
|
|
->setBase(urldecode($base), true) |
|
84
|
|
|
->addFilesFromString(urldecode($file)) |
|
85
|
|
|
->getMinified(); |
|
86
|
|
|
} else { |
|
87
|
|
|
$group = $this->request->analyzeInt('g', 0); |
|
88
|
|
|
|
|
89
|
|
|
if ($group === 0) { |
|
90
|
|
|
$this->minify->setType(Minify::FILETYPE_JS) |
|
91
|
|
|
->setBase(PUBLIC_PATH . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'js'); |
|
92
|
|
|
|
|
93
|
|
|
$this->minify->addFiles([ |
|
94
|
|
|
'jquery-3.3.1.min.js', |
|
95
|
|
|
// 'jquery-migrate-3.0.0.min.js', |
|
96
|
|
|
'jquery.fileDownload.min.js', |
|
97
|
|
|
'clipboard.min.js', |
|
98
|
|
|
'selectize.min.js', |
|
99
|
|
|
'selectize-plugins.min.js', |
|
100
|
|
|
'zxcvbn-async.min.js', |
|
101
|
|
|
'jsencrypt.min.js', |
|
102
|
|
|
'spark-md5.min.js', |
|
103
|
|
|
'moment.min.js', |
|
104
|
|
|
'moment-timezone.min.js', |
|
105
|
|
|
'toastr.min.js', |
|
106
|
|
|
'jquery.magnific-popup.min.js', |
|
107
|
|
|
'eventsource.min.js'], false); |
|
108
|
|
|
} elseif ($group === 1) { |
|
109
|
|
|
$this->minify->setType(Minify::FILETYPE_JS) |
|
110
|
|
|
->setBase(PUBLIC_PATH . DIRECTORY_SEPARATOR . 'js'); |
|
111
|
|
|
|
|
112
|
|
|
// FIXME: use MIN version |
|
113
|
|
|
$this->minify->addFiles([ |
|
114
|
|
|
'app.js', |
|
115
|
|
|
'app-config.js', |
|
116
|
|
|
'app-triggers.js', |
|
117
|
|
|
'app-actions.js', |
|
118
|
|
|
'app-requests.js', |
|
119
|
|
|
'app-util.js', |
|
120
|
|
|
'app-main.js'], false); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
$this->minify->getMinified(); |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* @throws SPException |
|
129
|
|
|
*/ |
|
130
|
|
|
protected function initialize() |
|
131
|
|
|
{ |
|
132
|
|
|
$this->request->verifySignature($this->configData->getPasswordSalt()); |
|
133
|
|
|
|
|
134
|
|
|
$this->minify = $this->dic->get(Minify::class); |
|
135
|
|
|
} |
|
136
|
|
|
} |