393 lines
18 KiB
Plaintext
393 lines
18 KiB
Plaintext
<form action="<?= $this->action; ?>" method="post" style="max-width:900px;">
|
|
<input type="hidden" name="REQUEST_TOKEN" value="<?= $this->requestToken; ?>">
|
|
<input type="hidden" name="FORM_SUBMIT" value="tl_dummy_copier">
|
|
|
|
<h2>Dummy Copier</h2>
|
|
|
|
<style>
|
|
.dc-tools { margin: 0.25rem 0 0.5rem; display: flex; gap: 0.5rem; }
|
|
.dc-filter { width: 100%; margin: 0.25rem 0; }
|
|
.dc-button { padding: 0.15rem 0.45rem; }
|
|
.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-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; }
|
|
</style>
|
|
|
|
<!-- Abschnitt 1: Quell-Seiten -->
|
|
<div class="dc-section">
|
|
<h3>1. Quell-Seiten auswaehlen</h3>
|
|
<p class="dc-hint">Alle Artikel und Inhaltselemente der gewaehlten Seiten werden automatisch mitkopiert (sofern Option "inkl. Content" aktiv ist).</p>
|
|
<p>
|
|
<label>Quell-Seiten (Mehrfachauswahl):<br>
|
|
<input class="dc-filter" type="text" data-filter-for-tree="sourcePages" placeholder="Seiten im Baum filtern...">
|
|
<span class="dc-tools">
|
|
<button class="dc-button" type="button" data-check-all="sourcePages">Alle</button>
|
|
<button class="dc-button" type="button" data-check-none="sourcePages">Keine</button>
|
|
</span>
|
|
<div class="dc-page-tree" id="sourcePages">
|
|
<?php
|
|
$selectedSourcePages = (array) ($this->selected['sourcePages'] ?? []);
|
|
|
|
$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>
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Abschnitt 2: Quell-Module -->
|
|
<div class="dc-section">
|
|
<h3>2. Quell-Module auswaehlen</h3>
|
|
<p class="dc-hint">Ausgewaehlte Module werden kopiert; Referenzen in den kopierten Seiten werden automatisch auf die neuen Module umgebogen.</p>
|
|
<p>
|
|
<label>Module (Mehrfachauswahl):<br>
|
|
<input class="dc-filter" type="text" data-filter-for="sourceModules" placeholder="Module filtern...">
|
|
<span class="dc-tools">
|
|
<button class="dc-button" type="button" data-select-all="sourceModules">Alle</button>
|
|
<button class="dc-button" type="button" data-select-none="sourceModules">Keine</button>
|
|
</span>
|
|
<select id="sourceModules" name="sourceModules[]" multiple size="10" style="width:100%;">
|
|
<?php foreach (($this->moduleChoices ?? []) as $id => $label): ?>
|
|
<option value="<?= (int) $id; ?>" <?= in_array((int) $id, ($this->selected['sourceModules'] ?? []), true) ? 'selected' : ''; ?>><?= htmlspecialchars((string) $label, ENT_QUOTES, 'UTF-8'); ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</label>
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Abschnitt 3: Quell-Verzeichnisse -->
|
|
<div class="dc-section">
|
|
<h3>3. Newsarchive auswaehlen (optional)</h3>
|
|
<p class="dc-hint">Ausgewaehlte Newsarchive und ihre Newsbeitraege werden kopiert.</p>
|
|
<p>
|
|
<label>Newsarchive (Mehrfachauswahl):<br>
|
|
<input class="dc-filter" type="text" data-filter-for="sourceNewsArchives" placeholder="Newsarchive filtern...">
|
|
<span class="dc-tools">
|
|
<button class="dc-button" type="button" data-select-all="sourceNewsArchives">Alle</button>
|
|
<button class="dc-button" type="button" data-select-none="sourceNewsArchives">Keine</button>
|
|
</span>
|
|
<select id="sourceNewsArchives" name="sourceNewsArchives[]" multiple size="8" style="width:100%;">
|
|
<?php foreach (($this->newsArchiveChoices ?? []) as $id => $label): ?>
|
|
<option value="<?= (int) $id; ?>" <?= in_array((int) $id, ($this->selected['sourceNewsArchives'] ?? []), true) ? 'selected' : ''; ?>><?= htmlspecialchars((string) $label, ENT_QUOTES, 'UTF-8'); ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</label>
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Abschnitt 4: Kalender -->
|
|
<div class="dc-section">
|
|
<h3>4. Kalender auswaehlen (optional)</h3>
|
|
<p class="dc-hint">Ausgewaehlte Kalender und ihre Events werden kopiert.</p>
|
|
<p>
|
|
<label>Kalender (Mehrfachauswahl):<br>
|
|
<input class="dc-filter" type="text" data-filter-for="sourceCalendars" placeholder="Kalender filtern...">
|
|
<span class="dc-tools">
|
|
<button class="dc-button" type="button" data-select-all="sourceCalendars">Alle</button>
|
|
<button class="dc-button" type="button" data-select-none="sourceCalendars">Keine</button>
|
|
</span>
|
|
<select id="sourceCalendars" name="sourceCalendars[]" multiple size="8" style="width:100%;">
|
|
<?php foreach (($this->calendarChoices ?? []) as $id => $label): ?>
|
|
<option value="<?= (int) $id; ?>" <?= in_array((int) $id, ($this->selected['sourceCalendars'] ?? []), true) ? 'selected' : ''; ?>><?= htmlspecialchars((string) $label, ENT_QUOTES, 'UTF-8'); ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</label>
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Abschnitt 5: Quell-Verzeichnisse -->
|
|
<div class="dc-section">
|
|
<h3>5. Quell-Verzeichnisse auswaehlen (optional)</h3>
|
|
<p class="dc-hint">Optionale Dateiverzeichnisse, die gespiegelt werden sollen.</p>
|
|
<p>
|
|
<label>Verzeichnisse (Mehrfachauswahl):<br>
|
|
<input class="dc-filter" type="text" data-filter-for="sourceDirectories" placeholder="Verzeichnisse filtern...">
|
|
<span class="dc-tools">
|
|
<button class="dc-button" type="button" data-select-all="sourceDirectories">Alle</button>
|
|
<button class="dc-button" type="button" data-select-none="sourceDirectories">Keine</button>
|
|
</span>
|
|
<select id="sourceDirectories" name="sourceDirectories[]" multiple size="8" style="width:100%;">
|
|
<?php foreach (($this->directoryChoices ?? []) as $path => $label): ?>
|
|
<option value="<?= htmlspecialchars((string) $path, ENT_QUOTES, 'UTF-8'); ?>" <?= in_array((string) $path, ($this->selected['sourceDirectories'] ?? []), true) ? 'selected' : ''; ?>><?= htmlspecialchars((string) $label, ENT_QUOTES, 'UTF-8'); ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</label>
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Abschnitt 4: Kopieroptionen -->
|
|
<div class="dc-section">
|
|
<h3>6. Kopieroptionen</h3>
|
|
<p><label><input type="checkbox" name="includeContent" value="1" <?= ($this->selected['includeContent'] ?? true) ? 'checked' : ''; ?>> Artikel & Inhaltselemente der Seiten mitkopieren</label></p>
|
|
<p><label><input type="checkbox" name="copyModules" value="1" <?= ($this->selected['copyModules'] ?? true) ? 'checked' : ''; ?>> Module kopieren und in den kopierten Seiten neu verlinken</label></p>
|
|
<p><label><input type="checkbox" name="copyDirectories" value="1" <?= ($this->selected['copyDirectories'] ?? false) ? 'checked' : ''; ?>> Ausgewaehlte Verzeichnisse in Ziel-Verzeichnis kopieren</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>
|
|
|
|
<!-- Abschnitt 5: Ziel -->
|
|
<div class="dc-section">
|
|
<h3>7. Ziel & Benennung</h3>
|
|
<p>
|
|
<label>Ziel-Elternseite (Pflichtfeld):<br>
|
|
<select name="targetParentPage" required style="width:100%;">
|
|
<option value="">Bitte waehlen</option>
|
|
<?php foreach (($this->pageChoices ?? []) as $id => $label): ?>
|
|
<option value="<?= (int) $id; ?>" <?= ((int) ($this->selected['targetParentPage'] ?? 0) === (int) $id) ? 'selected' : ''; ?>><?= htmlspecialchars((string) $label, ENT_QUOTES, 'UTF-8'); ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</label>
|
|
</p>
|
|
<p>
|
|
<label>Ziel-Verzeichnis fuer Dateien (z. B. files/kunden/kunde-x):<br>
|
|
<input type="text" name="targetDirectory" style="width:100%" placeholder="files/kunden/mein-kunde" value="<?= htmlspecialchars((string) ($this->selected['targetDirectory'] ?? ''), ENT_QUOTES, 'UTF-8'); ?>">
|
|
</label>
|
|
</p>
|
|
<p>
|
|
<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'); ?>">
|
|
</label>
|
|
</p>
|
|
</div>
|
|
|
|
<p><button class="tl_submit" type="submit">Ausfuehren</button></p>
|
|
|
|
<?php if (isset($this->result) && \is_object($this->result)): ?>
|
|
<h3>Ergebnis</h3>
|
|
<pre><?= htmlspecialchars(json_encode([
|
|
'copiedPages' => $this->result->copiedPages,
|
|
'copiedModules' => $this->result->copiedModules,
|
|
'copiedContent' => $this->result->copiedContent,
|
|
'copiedNewsArchives'=> $this->result->copiedNewsArchives,
|
|
'copiedNewsItems' => $this->result->copiedNewsItems,
|
|
'copiedCalendars' => $this->result->copiedCalendars,
|
|
'copiedEvents' => $this->result->copiedEvents,
|
|
'copiedDirectories' => $this->result->copiedDirectories,
|
|
'pageMap' => $this->result->pageMap,
|
|
'moduleMap' => $this->result->moduleMap,
|
|
'newsArchiveMap' => $this->result->newsArchiveMap,
|
|
'calendarMap' => $this->result->calendarMap,
|
|
'newsItemMap' => $this->result->newsItemMap,
|
|
'eventMap' => $this->result->eventMap,
|
|
'notes' => $this->result->notes,
|
|
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), ENT_QUOTES, 'UTF-8'); ?></pre>
|
|
<?php endif; ?>
|
|
|
|
<script>
|
|
(function () {
|
|
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) {
|
|
input.addEventListener('input', function () {
|
|
var select = byId(input.getAttribute('data-filter-for'));
|
|
if (!select) { return; }
|
|
var query = (input.value || '').toLowerCase();
|
|
Array.prototype.forEach.call(select.options, function (option) {
|
|
option.hidden = query !== '' && option.text.toLowerCase().indexOf(query) === -1;
|
|
});
|
|
});
|
|
});
|
|
|
|
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) {
|
|
button.addEventListener('click', function () {
|
|
var select = byId(button.getAttribute('data-select-all'));
|
|
if (!select) { return; }
|
|
Array.prototype.forEach.call(select.options, function (option) {
|
|
if (!option.hidden) { option.selected = true; }
|
|
});
|
|
});
|
|
});
|
|
|
|
document.querySelectorAll('[data-select-none]').forEach(function (button) {
|
|
button.addEventListener('click', function () {
|
|
var select = byId(button.getAttribute('data-select-none'));
|
|
if (!select) { return; }
|
|
Array.prototype.forEach.call(select.options, function (option) {
|
|
option.selected = false;
|
|
});
|
|
});
|
|
});
|
|
|
|
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();
|
|
});
|
|
});
|
|
})();
|
|
</script>
|
|
</form>
|