UX: Ziel-Elternseite und Zielverzeichnis als Baumauswahl (1.2.3)

This commit is contained in:
2026-03-15 20:33:46 +01:00
parent 847c3aaf36
commit 71196b5c16
2 changed files with 178 additions and 12 deletions

View File

@@ -32,6 +32,7 @@ class DummyCopierModule extends BackendModule
$this->Template->newsArchiveChoices = $this->getNewsArchiveChoices($connection);
$this->Template->calendarChoices = $this->getCalendarChoices($connection);
$this->Template->directoryChoices = $this->getDirectoryChoices();
$this->Template->directoryTreeNodes = $this->getDirectoryTreeNodes();
$targetParentPageId = $this->parseSingleIdInput(Input::postRaw('targetParentPage'));
$isPost = Input::post('FORM_SUBMIT') === 'tl_dummy_copier';
@@ -340,6 +341,52 @@ class DummyCopierModule extends BackendModule
return $choices;
}
/**
* @return array<int,array<string,mixed>>
*/
private function getDirectoryTreeNodes(): array
{
$projectDir = (string) System::getContainer()->getParameter('kernel.project_dir');
$filesDir = $projectDir . '/files';
if (!is_dir($filesDir)) {
return [];
}
$build = function (string $dir) use (&$build, $projectDir): array {
$nodes = [];
$entries = @scandir($dir);
if (!$entries) {
return [];
}
foreach ($entries as $entry) {
if ($entry === '.' || $entry === '..' || str_starts_with($entry, '.')) {
continue;
}
$full = $dir . '/' . $entry;
if (!is_dir($full)) {
continue;
}
$relative = ltrim(str_replace($projectDir, '', $full), '/');
$nodes[] = [
'path' => $relative,
'label' => $entry,
'children' => $build($full),
];
}
return $nodes;
};
return $build($filesDir);
}
/**
* @return array<int,string>
*/