Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions assets/js/app/editor/Components/File.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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 += `
<div class="col">
Expand All @@ -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 += `
<div class="col">
<div class="card h-100">
Expand Down
6 changes: 3 additions & 3 deletions assets/js/app/editor/Components/Image.vue
Original file line number Diff line number Diff line change
Expand Up @@ -280,16 +280,16 @@ 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 = '<div class="row row-cols-1 row-cols-sm-2 row-cols-lg-4 g-2">';
// If we are deep in the directory, add an arrow to navigate back to previous folder
if (folderPath.includes('/')) {
let pathChunks = inputOptions[0].value.split('/');
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 += `
Expand All @@ -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 += `
<div class="col">
Expand Down
6 changes: 3 additions & 3 deletions src/Cache/FilesIndexCacher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
}
5 changes: 3 additions & 2 deletions src/Controller/Backend/Async/FileListingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ 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);
$baseUrlPath = $this->request->server->get('PATH_INFO');
$relativePath = Path::makeRelative($path, $this->publicPath);

$files = $this->filesIndex->get($relativePath, $type, $basePath);
$files = $this->filesIndex->get($relativePath, $type, $baseUrlPath, $baseFilePath);

return new JsonResponse($files);
}
Expand Down
6 changes: 4 additions & 2 deletions src/Utils/FilesIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 $baseUrlPath, string $baseFilePath): Collection
{
if ($type === 'images') {
$glob = sprintf('*.{%s}', $this->config->getMediaTypes()->implode(','));
Expand All @@ -32,14 +32,16 @@ public function get(string $path, string $type, string $basePath): Collection
'group' => 'directories',
'value' => $dir->getPathname(),
'text' => $dir->getFilename(),
'base_url_path' => $baseUrlPath
];
}

foreach (self::findFiles($path, $glob) as $file) {
$files[] = [
'group' => basename($basePath),
'group' => basename($baseFilePath),
'value' => $path . '/' . $file->getRelativePathname(),
'text' => $file->getFilename(),
'base_url_path' => $baseUrlPath
];
}

Expand Down
2 changes: 1 addition & 1 deletion translations/messages.nl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2115,7 +2115,7 @@
<unit id="JpJFIFq" name="collection.confirm_delete">
<segment>
<source>collection.confirm_delete</source>
<target>collection.confirm_delete</target>
<target>Weet je zeker dat je dit collectie item wilt verwijderen?</target>
</segment>
</unit>
</file>
Expand Down