|
25 | 25 | use function Vvveb\__;
|
26 | 26 | use Vvveb\Controller\Base;
|
27 | 27 | use function Vvveb\sanitizeFileName;
|
28 |
| -use Vvveb\System\Core\View; |
29 | 28 |
|
30 | 29 | class Code extends Base {
|
31 | 30 | function dirForType($type) {
|
@@ -53,16 +52,15 @@ function dirForType($type) {
|
53 | 52 | }
|
54 | 53 |
|
55 | 54 | function index() {
|
56 |
| - $type = $this->request->get['type']; |
57 |
| - $admin_path = \Vvveb\adminPath(); |
58 |
| - $controllerPath = $admin_path . 'index.php?module=editor/code'; |
| 55 | + $type = $this->request->get['type']; |
| 56 | + $admin_path = \Vvveb\adminPath(); |
| 57 | + $controllerPath = $admin_path . 'index.php?module=editor/code'; |
59 | 58 |
|
60 |
| - $this->view->scanUrl = "$controllerPath&action=scan&type=$type"; |
61 |
| - $this->view->uploadUrl = "$controllerPath&action=upload&type=$type"; |
62 |
| - $this->view->saveUrl = "$controllerPath&action=save&type=$type"; |
63 |
| - $this->view->loadFileUrl = "$controllerPath&action=loadFile&type=$type"; |
64 |
| - $this->view->saveUrl = "$controllerPath&action=save&type=$type"; |
65 |
| - $this->view->type = $type; |
| 59 | + $this->view->scanUrl = "$controllerPath&action=scan&type=$type"; |
| 60 | + $this->view->uploadUrl = "$controllerPath&action=upload&type=$type"; |
| 61 | + $this->view->loadFileUrl = "$controllerPath&action=loadFile&type=$type"; |
| 62 | + $this->view->saveUrl = "$controllerPath&action=save&type=$type"; |
| 63 | + $this->view->type = $type; |
66 | 64 |
|
67 | 65 | if ($type) {
|
68 | 66 | $this->view->mediaPath = str_replace('/media', "/$type", $this->view->mediaPath);
|
@@ -161,10 +159,10 @@ function scan() {
|
161 | 159 | // Is there actually such a folder/file?
|
162 | 160 |
|
163 | 161 | if (file_exists($dir)) {
|
164 |
| - $files = @scandir($dir); |
| 162 | + $listdir = @scandir($dir); |
165 | 163 |
|
166 |
| - if ($files) { |
167 |
| - foreach ($files as $f) { |
| 164 | + if ($listdir) { |
| 165 | + foreach ($listdir as $f) { |
168 | 166 | if (! $f || $f[0] == '.' || $f == 'node_modules' || $f == 'vendor') {
|
169 | 167 | continue; // Ignore hidden files
|
170 | 168 | }
|
@@ -198,20 +196,12 @@ function scan() {
|
198 | 196 | $response = $scan($scandir);
|
199 | 197 |
|
200 | 198 | // Output the directory listing as JSON
|
201 |
| - $view = View::getInstance(); |
202 |
| - $view->noJson = true; |
203 |
| - |
204 |
| - header('Content-type: application/json'); |
205 |
| - |
206 |
| - echo json_encode([ |
| 199 | + $this->response->setType('json'); |
| 200 | + $this->response->output([ |
207 | 201 | 'name' => '',
|
208 | 202 | 'type' => 'folder',
|
209 | 203 | 'path' => '',
|
210 | 204 | 'items' => $response,
|
211 | 205 | ]);
|
212 |
| - |
213 |
| - die(); |
214 |
| - |
215 |
| - return false; |
216 | 206 | }
|
217 | 207 | }
|
0 commit comments