From a650c3218e9a7349d36f6882f7ec2bbce3e809f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9stor=20de=20Dios=20Fern=C3=A1ndez?= Date: Wed, 24 Aug 2022 10:48:15 +0200 Subject: [PATCH 1/7] Rename variables --- src/Controller/Backend/Async/FileListingController.php | 4 ++-- src/Utils/FilesIndex.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Controller/Backend/Async/FileListingController.php b/src/Controller/Backend/Async/FileListingController.php index c9242d438..6d7adc820 100644 --- a/src/Controller/Backend/Async/FileListingController.php +++ b/src/Controller/Backend/Async/FileListingController.php @@ -61,10 +61,10 @@ public function index(): JsonResponse // Do not allow any path outside of the public directory. $path = PathCanonicalize::canonicalize($this->publicPath, $relativeLocation); - $basePath = PathCanonicalize::canonicalize($this->publicPath, $relativeTopLocation); + $baseFilePath = PathCanonicalize::canonicalize($this->publicPath, $relativeTopLocation); $relativePath = Path::makeRelative($path, $this->publicPath); - $files = $this->filesIndex->get($relativePath, $type, $basePath); + $files = $this->filesIndex->get($relativePath, $type, $baseFilePath); return new JsonResponse($files); } diff --git a/src/Utils/FilesIndex.php b/src/Utils/FilesIndex.php index 65b8f257b..025243805 100644 --- a/src/Utils/FilesIndex.php +++ b/src/Utils/FilesIndex.php @@ -17,7 +17,7 @@ public function __construct(Config $config) $this->config = $config; } - public function get(string $path, string $type, string $basePath): Collection + public function get(string $path, string $type, string $baseFilePath): Collection { if ($type === 'images') { $glob = sprintf('*.{%s}', $this->config->getMediaTypes()->implode(',')); @@ -37,7 +37,7 @@ public function get(string $path, string $type, string $basePath): Collection foreach (self::findFiles($path, $glob) as $file) { $files[] = [ - 'group' => basename($basePath), + 'group' => basename($baseFilePath), 'value' => $path . '/' . $file->getRelativePathname(), 'text' => $file->getFilename(), ]; From cbd5c354c2ba9892cc4de592c34d845cd0e2f3e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9stor=20de=20Dios=20Fern=C3=A1ndez?= Date: Wed, 24 Aug 2022 10:52:02 +0200 Subject: [PATCH 2/7] Add new $baseUrlPath to support dinamic routes in async images/files --- src/Controller/Backend/Async/FileListingController.php | 3 ++- src/Utils/FilesIndex.php | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Controller/Backend/Async/FileListingController.php b/src/Controller/Backend/Async/FileListingController.php index 6d7adc820..1e88f9885 100644 --- a/src/Controller/Backend/Async/FileListingController.php +++ b/src/Controller/Backend/Async/FileListingController.php @@ -62,9 +62,10 @@ public function index(): JsonResponse // Do not allow any path outside of the public directory. $path = PathCanonicalize::canonicalize($this->publicPath, $relativeLocation); $baseFilePath = PathCanonicalize::canonicalize($this->publicPath, $relativeTopLocation); + $baseUrlPath = $this->request->server->get('PATH_INFO'); $relativePath = Path::makeRelative($path, $this->publicPath); - $files = $this->filesIndex->get($relativePath, $type, $baseFilePath); + $files = $this->filesIndex->get($relativePath, $type, $baseUrlPath, $baseFilePath); return new JsonResponse($files); } diff --git a/src/Utils/FilesIndex.php b/src/Utils/FilesIndex.php index 025243805..8a8a96612 100644 --- a/src/Utils/FilesIndex.php +++ b/src/Utils/FilesIndex.php @@ -17,7 +17,7 @@ public function __construct(Config $config) $this->config = $config; } - public function get(string $path, string $type, string $baseFilePath): Collection + public function get(string $path, string $type, string $baseUrlPath, string $baseFilePath): Collection { if ($type === 'images') { $glob = sprintf('*.{%s}', $this->config->getMediaTypes()->implode(',')); @@ -32,6 +32,7 @@ public function get(string $path, string $type, string $baseFilePath): Collectio 'group' => 'directories', 'value' => $dir->getPathname(), 'text' => $dir->getFilename(), + 'base_url_path' => $baseUrlPath ]; } @@ -40,6 +41,7 @@ public function get(string $path, string $type, string $baseFilePath): Collectio 'group' => basename($baseFilePath), 'value' => $path . '/' . $file->getRelativePathname(), 'text' => $file->getFilename(), + 'base_url_path' => $baseUrlPath ]; } From f78b2d506244b038000c8e87f1d6d5f9795764c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9stor=20de=20Dios=20Fern=C3=A1ndez?= Date: Wed, 24 Aug 2022 11:08:53 +0200 Subject: [PATCH 3/7] Update FilesIndexCacher with $baseFilePath and $baseUrlPath --- src/Cache/FilesIndexCacher.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cache/FilesIndexCacher.php b/src/Cache/FilesIndexCacher.php index 65e9978a0..699726ff0 100644 --- a/src/Cache/FilesIndexCacher.php +++ b/src/Cache/FilesIndexCacher.php @@ -11,11 +11,11 @@ class FilesIndexCacher extends FilesIndex implements CachingInterface public const CACHE_CONFIG_KEY = 'files_index'; - public function get(string $path, string $type, string $basePath): Collection + public function get(string $path, string $type, string $baseUrlPath, string $baseFilePath): Collection { $this->setCacheTags(['fileslisting']); $this->setCacheKey([$path, $type]); - return $this->execute([parent::class, __FUNCTION__], [$path, $type, $basePath]); + return $this->execute([parent::class, __FUNCTION__], [$path, $type, $baseUrlPath, $baseFilePath]); } -} \ No newline at end of file +} From 52646eadd3fb54c1c999709abf12ab43fbaa64ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9stor=20de=20Dios=20Fern=C3=A1ndez?= Date: Wed, 24 Aug 2022 11:42:30 +0200 Subject: [PATCH 4/7] Set dinamic base async path --- assets/js/app/editor/Components/Image.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/js/app/editor/Components/Image.vue b/assets/js/app/editor/Components/Image.vue index 8d715c1cd..abe5cac66 100644 --- a/assets/js/app/editor/Components/Image.vue +++ b/assets/js/app/editor/Components/Image.vue @@ -280,8 +280,8 @@ export default { }, generateModalContent(inputOptions) { let filePath = ''; - let baseAsyncUrl = `/bolt/async/list_files?location=${filePath}&type=images`; let folderPath = inputOptions[0].value; + let baseAsyncPath = inputOptions[0].base_url_path; let modalContent = '
'; // If we are deep in the directory, add an arrow to navigate back to previous folder if (folderPath.includes('/')) { @@ -289,7 +289,7 @@ export default { pathChunks.pop(); pathChunks.pop(); filePath = pathChunks.join('/'); - baseAsyncUrl = `/bolt/async/list_files?location=${filePath}&type=images`; + let baseAsyncUrl = `${baseAsyncPath}?location=${filePath}&type=images`; if (filePath != '') { modalContent += ` @@ -312,7 +312,7 @@ export default { inputOptions.forEach((element, key) => { if (element.group == 'directories') { filePath = element.value; - baseAsyncUrl = `/bolt/async/list_files?location=${filePath}&type=images`; + let baseAsyncUrl = `${baseAsyncPath}?location=${filePath}&type=images`; // let directoryPath = '/bolt/async/list_files?location=files/' + element.value + '&type=images'; modalContent += `
From f08e23c822f497b1d13e5fad4c5a3c53827f6001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9stor=20de=20Dios=20Fern=C3=A1ndez?= Date: Wed, 24 Aug 2022 11:52:52 +0200 Subject: [PATCH 5/7] Set dinamic base async path for images --- assets/js/app/editor/Components/File.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/js/app/editor/Components/File.vue b/assets/js/app/editor/Components/File.vue index 10ac5c19d..384de5273 100644 --- a/assets/js/app/editor/Components/File.vue +++ b/assets/js/app/editor/Components/File.vue @@ -217,8 +217,8 @@ export default { }, generateModalContent(inputOptions) { let filePath = ''; - let baseAsyncUrl = `/bolt/async/list_files?location=files/${filePath}&type=files`; let folderPath = inputOptions[0].value; + let baseAsyncPath = inputOptions[0].base_url_path; let fileIcons = { jpg: 'fa-file-image', jpeg: 'fa-file-image', @@ -251,7 +251,7 @@ export default { pathChunks.pop(); pathChunks.pop(); filePath = pathChunks.join('/'); - baseAsyncUrl = `/bolt/async/list_files?location=${filePath}&type=files`; + let baseAsyncUrl = `${baseAsyncPath}?location=${filePath}&type=files`; if (filePath != '') { modalContent += `
@@ -277,7 +277,7 @@ export default { .toLowerCase(); if (element.group == 'directories') { filePath = element.value; - baseAsyncUrl = `/bolt/async/list_files?location=${filePath}&type=files`; + let baseAsyncUrl = `${baseAsyncPath}?location=${filePath}&type=files`; modalContent += `
From 75d468fbc297504f99b36902df4811713d735a1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9stor=20de=20Dios=20Fern=C3=A1ndez?= Date: Wed, 24 Aug 2022 13:46:18 +0200 Subject: [PATCH 6/7] Add Dutch collection.confirm_delete translation --- translations/messages.nl.xlf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translations/messages.nl.xlf b/translations/messages.nl.xlf index 5f06d0995..f01597790 100644 --- a/translations/messages.nl.xlf +++ b/translations/messages.nl.xlf @@ -2115,7 +2115,7 @@ collection.confirm_delete - collection.confirm_delete + Weet u zeker dat je dit collectie item wilt verwijderen? From 7c0bbbf3cf07ff23d49b19d156b62c1bbf9efe8d Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Wed, 24 Aug 2022 14:31:17 +0200 Subject: [PATCH 7/7] Update translations/messages.nl.xlf --- translations/messages.nl.xlf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translations/messages.nl.xlf b/translations/messages.nl.xlf index f01597790..e9a135ea2 100644 --- a/translations/messages.nl.xlf +++ b/translations/messages.nl.xlf @@ -2115,7 +2115,7 @@ collection.confirm_delete - Weet u zeker dat je dit collectie item wilt verwijderen? + Weet je zeker dat je dit collectie item wilt verwijderen?