Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 71196b5c16 | |||
| 847c3aaf36 | |||
| 16627b0433 | |||
| 147b163fd5 | |||
| 976d33cd1b |
42
CHANGELOG.md
Normal file
42
CHANGELOG.md
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
Alle nennenswerten Aenderungen an `webfarben/contao-dummy-copier` werden in dieser Datei dokumentiert.
|
||||||
|
|
||||||
|
## [1.1.5] - 2026-03-15
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Kompatibilitaet fuer Contao 4.13 und 5.x verbessert: Array-Serialisierung nutzt jetzt natives PHP `serialize()` statt `StringUtil::serialize()`.
|
||||||
|
|
||||||
|
## [1.1.4] - 2026-03-15
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- SQL-Fehler in Umgebungen ohne `sorting`-Spalte in `tl_news` bzw. `tl_calendar_events` behoben.
|
||||||
|
- Sortierung fuer News/Events auf robuste ORDER-BY-Klauseln ohne `sorting` angepasst.
|
||||||
|
|
||||||
|
## [1.1.3] - 2026-03-15
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Backend-Modul-Icon (`public/icon.svg`) hinzugefuegt/aktualisiert.
|
||||||
|
- README auf aktuellen Funktionsumfang und Installationsweg ueber Packagist gebracht.
|
||||||
|
|
||||||
|
## [1.1.2] - 2026-03-12
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Paket-Metadaten (`homepage`, `support.source`, `support.issues`) auf GitHub als kanonische Quelle umgestellt.
|
||||||
|
|
||||||
|
## [1.1.1] - 2026-03-12
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Rewiring fuer interne News-Referenzen (`related`) in kopierten News verbessert.
|
||||||
|
- Reader-Modul-Referenzen in kopierten Modulen korrigiert (`news_readerModule`, `cal_readerModule`).
|
||||||
|
|
||||||
|
## [1.1.0] - 2026-03-12
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Kopieren von Newsarchiven und Newsbeitraegen (`tl_news_archive`, `tl_news`).
|
||||||
|
- Kopieren von Kalendern und Events (`tl_calendar`, `tl_calendar_events`).
|
||||||
|
- Auswahlfelder fuer Newsarchive/Kalender im Backend-Modul.
|
||||||
|
- Ergebnisdaten um Zaehler und Mapping fuer News/Kalender erweitert.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Referenz-Umschreibung fuer kopierte Module um Archivzuordnungen erweitert (`news_archives`, `cal_calendar`).
|
||||||
@@ -50,3 +50,7 @@ Das Backend-Modul `Dummy Copier` erscheint anschliessend unter `System`.
|
|||||||
|
|
||||||
- Nach Dateikopien ggf. `php vendor/bin/console contao:filesync` ausfuehren, damit die DBAFS-Daten synchronisiert werden.
|
- Nach Dateikopien ggf. `php vendor/bin/console contao:filesync` ausfuehren, damit die DBAFS-Daten synchronisiert werden.
|
||||||
- Das Bundle ist fuer pragmatische Redaktions- und Setup-Workflows gedacht. Projektspezifische Sonderfelder oder Referenzen koennen bei Bedarf erweitert werden.
|
- Das Bundle ist fuer pragmatische Redaktions- und Setup-Workflows gedacht. Projektspezifische Sonderfelder oder Referenzen koennen bei Bedarf erweitert werden.
|
||||||
|
|
||||||
|
## Changelog
|
||||||
|
|
||||||
|
- Siehe `CHANGELOG.md` fuer die dokumentierten Aenderungen ab `1.1.0`.
|
||||||
|
|||||||
@@ -11,6 +11,16 @@
|
|||||||
.dc-section { border: 1px solid #ccc; padding: 1rem; margin-bottom: 1.5rem; border-radius: 4px; }
|
.dc-section { border: 1px solid #ccc; padding: 1rem; margin-bottom: 1.5rem; border-radius: 4px; }
|
||||||
.dc-section h3 { margin: 0 0 0.75rem; font-size: 1rem; font-weight: bold; }
|
.dc-section h3 { margin: 0 0 0.75rem; font-size: 1rem; font-weight: bold; }
|
||||||
.dc-hint { color: #666; font-size: 0.85rem; margin: 0.25rem 0 0.75rem; }
|
.dc-hint { color: #666; font-size: 0.85rem; margin: 0.25rem 0 0.75rem; }
|
||||||
|
.dc-page-tree { border: 1px solid #ddd; border-radius: 4px; background: #fff; max-height: 360px; overflow: auto; padding: 0.5rem; }
|
||||||
|
.dc-page-tree ul { list-style: none; margin: 0.1rem 0 0.1rem 1.1rem; padding: 0; }
|
||||||
|
.dc-page-tree > ul { margin-left: 0; }
|
||||||
|
.dc-page-tree li { margin: 0.1rem 0; }
|
||||||
|
.dc-page-item { display: flex; align-items: center; gap: 0.45rem; }
|
||||||
|
.dc-page-id { color: #777; font-size: 0.8rem; }
|
||||||
|
.dc-tree-option { padding: 0.2rem 0 0.4rem; border-bottom: 1px solid #eee; margin-bottom: 0.3rem; }
|
||||||
|
.dc-dir-item { cursor: pointer; border-radius: 3px; }
|
||||||
|
.dc-dir-item:hover { background: #f0f4f8; }
|
||||||
|
.dc-dir-selected { font-weight: bold; color: #0a5a8c; background: #e8f0fe; }
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- Abschnitt 1: Quell-Seiten -->
|
<!-- Abschnitt 1: Quell-Seiten -->
|
||||||
@@ -19,16 +29,48 @@
|
|||||||
<p class="dc-hint">Alle Artikel und Inhaltselemente der gewaehlten Seiten werden automatisch mitkopiert (sofern Option "inkl. Content" aktiv ist).</p>
|
<p class="dc-hint">Alle Artikel und Inhaltselemente der gewaehlten Seiten werden automatisch mitkopiert (sofern Option "inkl. Content" aktiv ist).</p>
|
||||||
<p>
|
<p>
|
||||||
<label>Quell-Seiten (Mehrfachauswahl):<br>
|
<label>Quell-Seiten (Mehrfachauswahl):<br>
|
||||||
<input class="dc-filter" type="text" data-filter-for="sourcePages" placeholder="Seiten filtern...">
|
<input class="dc-filter" type="text" data-filter-for-tree="sourcePages" placeholder="Seiten im Baum filtern...">
|
||||||
<span class="dc-tools">
|
<span class="dc-tools">
|
||||||
<button class="dc-button" type="button" data-select-all="sourcePages">Alle</button>
|
<button class="dc-button" type="button" data-check-all="sourcePages">Alle</button>
|
||||||
<button class="dc-button" type="button" data-select-none="sourcePages">Keine</button>
|
<button class="dc-button" type="button" data-check-none="sourcePages">Keine</button>
|
||||||
</span>
|
</span>
|
||||||
<select id="sourcePages" name="sourcePages[]" multiple size="12" style="width:100%;">
|
<div class="dc-page-tree" id="sourcePages">
|
||||||
<?php foreach (($this->pageChoices ?? []) as $id => $label): ?>
|
<?php
|
||||||
<option value="<?= (int) $id; ?>" <?= in_array((int) $id, ($this->selected['sourcePages'] ?? []), true) ? 'selected' : ''; ?>><?= htmlspecialchars((string) $label, ENT_QUOTES, 'UTF-8'); ?></option>
|
$selectedSourcePages = (array) ($this->selected['sourcePages'] ?? []);
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
$renderNodes = static function (array $nodes) use (&$renderNodes, $selectedSourcePages): void {
|
||||||
|
if ($nodes === []) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<ul>';
|
||||||
|
|
||||||
|
foreach ($nodes as $node) {
|
||||||
|
$id = (int) ($node['id'] ?? 0);
|
||||||
|
$label = (string) ($node['label'] ?? ('Seite ' . $id));
|
||||||
|
$children = (array) ($node['children'] ?? []);
|
||||||
|
$checked = in_array($id, $selectedSourcePages, true) ? 'checked' : '';
|
||||||
|
|
||||||
|
echo '<li data-tree-item="sourcePages" data-tree-label="' . htmlspecialchars(strtolower($label), ENT_QUOTES, 'UTF-8') . '">';
|
||||||
|
echo '<label class="dc-page-item">';
|
||||||
|
echo '<input type="checkbox" name="sourcePages[]" value="' . $id . '" ' . $checked . '>';
|
||||||
|
echo '<span>' . htmlspecialchars($label, ENT_QUOTES, 'UTF-8') . '</span>';
|
||||||
|
echo '<span class="dc-page-id">[ID ' . $id . ']</span>';
|
||||||
|
echo '</label>';
|
||||||
|
|
||||||
|
if ($children !== []) {
|
||||||
|
$renderNodes($children);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</ul>';
|
||||||
|
};
|
||||||
|
|
||||||
|
$renderNodes((array) ($this->pageTreeNodes ?? []));
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -122,24 +164,102 @@
|
|||||||
<p><label><input type="checkbox" name="dryRun" value="1" <?= ($this->selected['dryRun'] ?? false) ? 'checked' : ''; ?>> Dry-Run (nur Vorschau, keine Schreibzugriffe)</label></p>
|
<p><label><input type="checkbox" name="dryRun" value="1" <?= ($this->selected['dryRun'] ?? false) ? 'checked' : ''; ?>> Dry-Run (nur Vorschau, keine Schreibzugriffe)</label></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Abschnitt 5: Ziel -->
|
<!-- Abschnitt 7: Ziel & Benennung -->
|
||||||
<div class="dc-section">
|
<div class="dc-section">
|
||||||
<h3>7. Ziel & Benennung</h3>
|
<h3>7. Ziel & Benennung</h3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<label>Ziel-Elternseite (Pflichtfeld):<br>
|
<strong>Ziel-Elternseite:</strong><br>
|
||||||
<select name="targetParentPage" required style="width:100%;">
|
<span class="dc-hint">Die kopierten Seiten werden als Unterseiten der ausgewaehlten Seite angelegt.</span>
|
||||||
<option value="">Bitte waehlen</option>
|
<input class="dc-filter" type="text" data-filter-for-tree="targetParentPage" placeholder="Seiten im Baum filtern...">
|
||||||
<?php foreach (($this->pageChoices ?? []) as $id => $label): ?>
|
<div class="dc-page-tree" id="targetParentPageTree" style="max-height:280px;">
|
||||||
<option value="<?= (int) $id; ?>" <?= ((int) ($this->selected['targetParentPage'] ?? 0) === (int) $id) ? 'selected' : ''; ?>><?= htmlspecialchars((string) $label, ENT_QUOTES, 'UTF-8'); ?></option>
|
<div class="dc-tree-option">
|
||||||
<?php endforeach; ?>
|
<label class="dc-page-item">
|
||||||
</select>
|
<input type="radio" name="targetParentPage" value="0" <?= ((int) ($this->selected['targetParentPage'] ?? 0) === 0) ? 'checked' : ''; ?>>
|
||||||
</label>
|
<em>— Auf Root-Ebene einfuegen —</em>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
$selectedTargetPage = (int) ($this->selected['targetParentPage'] ?? 0);
|
||||||
|
|
||||||
|
$renderTargetNodes = static function (array $nodes) use (&$renderTargetNodes, $selectedTargetPage): void {
|
||||||
|
if ($nodes === []) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<ul>';
|
||||||
|
|
||||||
|
foreach ($nodes as $node) {
|
||||||
|
$id = (int) ($node['id'] ?? 0);
|
||||||
|
$label = (string) ($node['label'] ?? ('Seite ' . $id));
|
||||||
|
$children = (array) ($node['children'] ?? []);
|
||||||
|
$checked = ($id > 0 && $id === $selectedTargetPage) ? 'checked' : '';
|
||||||
|
|
||||||
|
echo '<li data-tree-item="targetParentPage" data-tree-label="' . htmlspecialchars(strtolower($label), ENT_QUOTES, 'UTF-8') . '">';
|
||||||
|
echo '<label class="dc-page-item">';
|
||||||
|
echo '<input type="radio" name="targetParentPage" value="' . $id . '" ' . $checked . '>';
|
||||||
|
echo '<span>' . htmlspecialchars($label, ENT_QUOTES, 'UTF-8') . '</span>';
|
||||||
|
echo '<span class="dc-page-id">[ID ' . $id . ']</span>';
|
||||||
|
echo '</label>';
|
||||||
|
|
||||||
|
if ($children !== []) {
|
||||||
|
$renderTargetNodes($children);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</ul>';
|
||||||
|
};
|
||||||
|
|
||||||
|
$renderTargetNodes((array) ($this->pageTreeNodes ?? []));
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<label>Ziel-Verzeichnis fuer Dateien (z. B. files/kunden/kunde-x):<br>
|
<strong>Ziel-Verzeichnis fuer Dateien (optional):</strong><br>
|
||||||
<input type="text" name="targetDirectory" style="width:100%" placeholder="files/kunden/mein-kunde" value="<?= htmlspecialchars((string) ($this->selected['targetDirectory'] ?? ''), ENT_QUOTES, 'UTF-8'); ?>">
|
<span class="dc-hint">Quellverzeichnisse werden hierhin kopiert. Vorhandenes auswaehlen oder unten manuell eingeben (auch neue Pfade moeglich).</span>
|
||||||
</label>
|
<input class="dc-filter" type="text" data-filter-for-tree="targetDirTree" placeholder="Verzeichnisse filtern...">
|
||||||
|
<div class="dc-page-tree" id="targetDirTreeContainer" style="max-height:220px;">
|
||||||
|
<?php
|
||||||
|
$selectedTargetDir = (string) ($this->selected['targetDirectory'] ?? '');
|
||||||
|
|
||||||
|
$renderDirNodes = static function (array $nodes) use (&$renderDirNodes, $selectedTargetDir): void {
|
||||||
|
if ($nodes === []) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<ul>';
|
||||||
|
|
||||||
|
foreach ($nodes as $node) {
|
||||||
|
$path = (string) ($node['path'] ?? '');
|
||||||
|
$label = (string) ($node['label'] ?? $path);
|
||||||
|
$children = (array) ($node['children'] ?? []);
|
||||||
|
$selClass = ($path !== '' && $path === $selectedTargetDir) ? ' dc-dir-selected' : '';
|
||||||
|
|
||||||
|
echo '<li data-tree-item="targetDirTree" data-tree-label="' . htmlspecialchars(strtolower($label), ENT_QUOTES, 'UTF-8') . '" data-dir-path="' . htmlspecialchars($path, ENT_QUOTES, 'UTF-8') . '">';
|
||||||
|
echo '<span class="dc-page-item dc-dir-item' . $selClass . '" title="' . htmlspecialchars($path, ENT_QUOTES, 'UTF-8') . '">';
|
||||||
|
echo '<span>' . htmlspecialchars($label, ENT_QUOTES, 'UTF-8') . '</span>';
|
||||||
|
echo '<span class="dc-page-id">' . htmlspecialchars($path, ENT_QUOTES, 'UTF-8') . '</span>';
|
||||||
|
echo '</span>';
|
||||||
|
|
||||||
|
if ($children !== []) {
|
||||||
|
$renderDirNodes($children);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</ul>';
|
||||||
|
};
|
||||||
|
|
||||||
|
$renderDirNodes((array) ($this->directoryTreeNodes ?? []));
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<input type="text" id="targetDirectory" name="targetDirectory" style="width:100%; margin-top:0.5rem;" placeholder="z. B. files/kunden/mein-kunde" value="<?= htmlspecialchars((string) ($this->selected['targetDirectory'] ?? ''), ENT_QUOTES, 'UTF-8'); ?>">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<label>Praefix fuer Titel / Name / Alias der Kopien:<br>
|
<label>Praefix fuer Titel / Name / Alias der Kopien:<br>
|
||||||
<input type="text" name="namePrefix" style="width:100%" placeholder="z. B. kunde-x-" value="<?= htmlspecialchars((string) ($this->selected['namePrefix'] ?? ''), ENT_QUOTES, 'UTF-8'); ?>">
|
<input type="text" name="namePrefix" style="width:100%" placeholder="z. B. kunde-x-" value="<?= htmlspecialchars((string) ($this->selected['namePrefix'] ?? ''), ENT_QUOTES, 'UTF-8'); ?>">
|
||||||
@@ -174,6 +294,87 @@
|
|||||||
(function () {
|
(function () {
|
||||||
function byId(id) { return document.getElementById(id); }
|
function byId(id) { return document.getElementById(id); }
|
||||||
|
|
||||||
|
function childCheckboxesOf(li) {
|
||||||
|
var nested = li.querySelector(':scope > ul');
|
||||||
|
return nested ? nested.querySelectorAll('input[type="checkbox"]') : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function parentLiOf(li) {
|
||||||
|
var parentUl = li.parentElement;
|
||||||
|
if (!parentUl || parentUl.classList.contains('dc-page-tree')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var candidate = parentUl.closest('li[data-tree-item="sourcePages"]');
|
||||||
|
return candidate || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateParentState(li) {
|
||||||
|
var children = childCheckboxesOf(li);
|
||||||
|
if (!children.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var own = li.querySelector(':scope > label input[type="checkbox"]');
|
||||||
|
if (!own) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var checkedCount = 0;
|
||||||
|
children.forEach(function (cb) {
|
||||||
|
if (cb.checked) {
|
||||||
|
checkedCount++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (checkedCount === 0) {
|
||||||
|
own.checked = false;
|
||||||
|
own.indeterminate = false;
|
||||||
|
} else if (checkedCount === children.length) {
|
||||||
|
own.checked = true;
|
||||||
|
own.indeterminate = false;
|
||||||
|
} else {
|
||||||
|
own.checked = false;
|
||||||
|
own.indeterminate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function cascadeToChildren(li, checked) {
|
||||||
|
childCheckboxesOf(li).forEach(function (cb) {
|
||||||
|
cb.checked = checked;
|
||||||
|
cb.indeterminate = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshAllParentStates() {
|
||||||
|
var nodes = Array.prototype.slice.call(document.querySelectorAll('li[data-tree-item="sourcePages"]'));
|
||||||
|
nodes.reverse();
|
||||||
|
nodes.forEach(function (li) {
|
||||||
|
updateParentState(li);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
document.querySelectorAll('li[data-tree-item="sourcePages"] > label input[type="checkbox"]').forEach(function (checkbox) {
|
||||||
|
checkbox.addEventListener('change', function () {
|
||||||
|
var li = checkbox.closest('li[data-tree-item="sourcePages"]');
|
||||||
|
if (!li) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!checkbox.indeterminate) {
|
||||||
|
cascadeToChildren(li, checkbox.checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
var parent = parentLiOf(li);
|
||||||
|
while (parent) {
|
||||||
|
updateParentState(parent);
|
||||||
|
parent = parentLiOf(parent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
refreshAllParentStates();
|
||||||
|
|
||||||
document.querySelectorAll('[data-filter-for]').forEach(function (input) {
|
document.querySelectorAll('[data-filter-for]').forEach(function (input) {
|
||||||
input.addEventListener('input', function () {
|
input.addEventListener('input', function () {
|
||||||
var select = byId(input.getAttribute('data-filter-for'));
|
var select = byId(input.getAttribute('data-filter-for'));
|
||||||
@@ -185,6 +386,42 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.querySelectorAll('[data-filter-for-tree]').forEach(function (input) {
|
||||||
|
input.addEventListener('input', function () {
|
||||||
|
var key = input.getAttribute('data-filter-for-tree');
|
||||||
|
var query = (input.value || '').toLowerCase();
|
||||||
|
var items = Array.prototype.slice.call(document.querySelectorAll('[data-tree-item="' + key + '"]'));
|
||||||
|
|
||||||
|
if (query === '') {
|
||||||
|
items.forEach(function (item) {
|
||||||
|
item.hidden = false;
|
||||||
|
delete item.dataset.treeMatched;
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
items.reverse().forEach(function (item) {
|
||||||
|
var label = item.getAttribute('data-tree-label') || '';
|
||||||
|
var selfMatch = label.indexOf(query) !== -1;
|
||||||
|
var nested = item.querySelector(':scope > ul');
|
||||||
|
var childMatch = false;
|
||||||
|
|
||||||
|
if (nested) {
|
||||||
|
Array.prototype.forEach.call(nested.children, function (child) {
|
||||||
|
if (child.matches('[data-tree-item="' + key + '"]') && child.dataset.treeMatched === '1') {
|
||||||
|
childMatch = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var match = selfMatch || childMatch;
|
||||||
|
item.hidden = !match;
|
||||||
|
item.dataset.treeMatched = match ? '1' : '0';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
document.querySelectorAll('[data-select-all]').forEach(function (button) {
|
document.querySelectorAll('[data-select-all]').forEach(function (button) {
|
||||||
button.addEventListener('click', function () {
|
button.addEventListener('click', function () {
|
||||||
var select = byId(button.getAttribute('data-select-all'));
|
var select = byId(button.getAttribute('data-select-all'));
|
||||||
@@ -204,6 +441,71 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.querySelectorAll('[data-check-all]').forEach(function (button) {
|
||||||
|
button.addEventListener('click', function () {
|
||||||
|
var key = button.getAttribute('data-check-all');
|
||||||
|
|
||||||
|
document.querySelectorAll('[data-tree-item="' + key + '"] input[type="checkbox"]').forEach(function (checkbox) {
|
||||||
|
if (!checkbox.closest('li').hidden) {
|
||||||
|
checkbox.checked = true;
|
||||||
|
checkbox.indeterminate = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
refreshAllParentStates();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
document.querySelectorAll('[data-check-none]').forEach(function (button) {
|
||||||
|
button.addEventListener('click', function () {
|
||||||
|
var key = button.getAttribute('data-check-none');
|
||||||
|
|
||||||
|
document.querySelectorAll('[data-tree-item="' + key + '"] input[type="checkbox"]').forEach(function (checkbox) {
|
||||||
|
checkbox.checked = false;
|
||||||
|
checkbox.indeterminate = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
refreshAllParentStates();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Verzeichnisbaum: Klick befuellt Texteingabe
|
||||||
|
document.querySelectorAll('.dc-dir-item').forEach(function (span) {
|
||||||
|
span.addEventListener('click', function () {
|
||||||
|
var li = span.closest('[data-dir-path]');
|
||||||
|
var path = li ? li.getAttribute('data-dir-path') : '';
|
||||||
|
var input = document.getElementById('targetDirectory');
|
||||||
|
|
||||||
|
if (input) {
|
||||||
|
input.value = path || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
document.querySelectorAll('.dc-dir-item').forEach(function (s) {
|
||||||
|
s.classList.remove('dc-dir-selected');
|
||||||
|
});
|
||||||
|
|
||||||
|
span.classList.add('dc-dir-selected');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Texteingabe Ziel-Verzeichnis: Auswahl im Baum aufheben wenn manuell getippt
|
||||||
|
(function () {
|
||||||
|
var input = document.getElementById('targetDirectory');
|
||||||
|
if (!input) { return; }
|
||||||
|
input.addEventListener('input', function () {
|
||||||
|
var val = input.value.trim();
|
||||||
|
document.querySelectorAll('.dc-dir-item').forEach(function (s) {
|
||||||
|
var li = s.closest('[data-dir-path]');
|
||||||
|
var path = li ? li.getAttribute('data-dir-path') : '';
|
||||||
|
if (path === val) {
|
||||||
|
s.classList.add('dc-dir-selected');
|
||||||
|
} else {
|
||||||
|
s.classList.remove('dc-dir-selected');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})();
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -27,10 +27,12 @@ class DummyCopierModule extends BackendModule
|
|||||||
$this->Template->action = Environment::get('request');
|
$this->Template->action = Environment::get('request');
|
||||||
$this->Template->requestToken = $this->getCsrfToken();
|
$this->Template->requestToken = $this->getCsrfToken();
|
||||||
$this->Template->pageChoices = $this->getPageChoices($connection);
|
$this->Template->pageChoices = $this->getPageChoices($connection);
|
||||||
|
$this->Template->pageTreeNodes = $this->getPageTreeNodes($connection);
|
||||||
$this->Template->moduleChoices = $this->getModuleChoices($connection);
|
$this->Template->moduleChoices = $this->getModuleChoices($connection);
|
||||||
$this->Template->newsArchiveChoices = $this->getNewsArchiveChoices($connection);
|
$this->Template->newsArchiveChoices = $this->getNewsArchiveChoices($connection);
|
||||||
$this->Template->calendarChoices = $this->getCalendarChoices($connection);
|
$this->Template->calendarChoices = $this->getCalendarChoices($connection);
|
||||||
$this->Template->directoryChoices = $this->getDirectoryChoices();
|
$this->Template->directoryChoices = $this->getDirectoryChoices();
|
||||||
|
$this->Template->directoryTreeNodes = $this->getDirectoryTreeNodes();
|
||||||
|
|
||||||
$targetParentPageId = $this->parseSingleIdInput(Input::postRaw('targetParentPage'));
|
$targetParentPageId = $this->parseSingleIdInput(Input::postRaw('targetParentPage'));
|
||||||
$isPost = Input::post('FORM_SUBMIT') === 'tl_dummy_copier';
|
$isPost = Input::post('FORM_SUBMIT') === 'tl_dummy_copier';
|
||||||
@@ -229,6 +231,50 @@ class DummyCopierModule extends BackendModule
|
|||||||
return $choices;
|
return $choices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int,array<string,mixed>>
|
||||||
|
*/
|
||||||
|
private function getPageTreeNodes(Connection $connection): array
|
||||||
|
{
|
||||||
|
$rows = $connection->fetchAllAssociative('SELECT id, pid, title, alias FROM tl_page ORDER BY sorting, id');
|
||||||
|
$rowsByParent = [];
|
||||||
|
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
$pid = (int) ($row['pid'] ?? 0);
|
||||||
|
$rowsByParent[$pid][] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
$build = function (int $pid) use (&$build, $rowsByParent): array {
|
||||||
|
$nodes = [];
|
||||||
|
|
||||||
|
foreach ($rowsByParent[$pid] ?? [] as $row) {
|
||||||
|
$id = (int) ($row['id'] ?? 0);
|
||||||
|
|
||||||
|
if ($id < 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$title = trim((string) ($row['title'] ?? ''));
|
||||||
|
$alias = trim((string) ($row['alias'] ?? ''));
|
||||||
|
$label = $title !== '' ? $title : ('Seite ' . $id);
|
||||||
|
|
||||||
|
if ($alias !== '') {
|
||||||
|
$label .= ' (' . $alias . ')';
|
||||||
|
}
|
||||||
|
|
||||||
|
$nodes[] = [
|
||||||
|
'id' => $id,
|
||||||
|
'label' => $label,
|
||||||
|
'children' => $build($id),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $nodes;
|
||||||
|
};
|
||||||
|
|
||||||
|
return $build(0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<int,string>
|
* @return array<int,string>
|
||||||
*/
|
*/
|
||||||
@@ -295,6 +341,52 @@ class DummyCopierModule extends BackendModule
|
|||||||
return $choices;
|
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>
|
* @return array<int,string>
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user