| @@ -15,9 +15,9 @@ | ||
| 15 | 15 | use WPIDE\App\Services\Auth\AuthInterface; |
| 16 | 16 | use WPIDE\App\Services\Transient\Transient; |
| 17 | 17 | use WPIDE\App\Services\Storage\Filesystem; |
| 18 | 18 | use WPIDE\App\Services\Storage\LocalFileSystem; |
| 19 | -use const WPIDE\Constants\CONTENT_DIR; | |
| 19 | +use const WPIDE\Constants\WP_PATH; | |
| 20 | 20 | |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * |
| @@ -98,12 +98,17 @@ | ||
| 98 | 98 | public function getDirectory(Request $request, Response $response) |
| 99 | 99 | { |
| 100 | 100 | $path = $request->input('dir', $this->transient->get(self::SESSION_CWD, $this->separator)); |
| 101 | 101 | $root = $request->input('root', false); |
| 102 | + $filter = $request->enumInput('filter', ['image']); | |
| 102 | 103 | |
| 103 | - $storage = $root ? LocalFileSystem::load(CONTENT_DIR) : $this->storage; | |
| 104 | + if($root) { | |
| 105 | + $storage = LocalFileSystem::load(WP_PATH); | |
| 106 | + }else{ | |
| 107 | + $storage = $this->storage; | |
| 108 | + } | |
| 104 | 109 | |
| 105 | - $content = $storage->getDirectoryCollection($path); | |
| 110 | + $content = $storage->getDirectoryCollection($path, false, $filter); | |
| 106 | 111 | |
| 107 | 112 | return $response->json($content); |
| 108 | 113 | } |
| 109 | 114 | |
| @@ -279,9 +284,10 @@ | ||
| 279 | 284 | |
| 280 | 285 | if ($item->ext === 'php') { |
| 281 | 286 | try { |
| 282 | 287 | PhpValidator::validate($content); |
| 283 | - } catch (Error $error) { | |
| 288 | + } catch (Error | Exception $error) { | |
| 289 | + | |
| 284 | 290 | $message = "Parse error: {$error->getMessage()}\n"; |
| 285 | 291 | return $response->json($message, 422); |
| 286 | 292 | } |
| 287 | 293 | } |
| @@ -305,7 +311,9 @@ | ||
| 305 | 311 | |
| 306 | 312 | return $response->json(__('Failed saving file!', 'wpide'), 422); |
| 307 | 313 | } |
| 308 | 314 | |
| 309 | - return $response->json(true); | |
| 315 | + return $response->json([ | |
| 316 | + 'success' => true | |
| 317 | + ]); | |
| 310 | 318 | } |
| 311 | 319 | } |