Löschen/Deaktivierung
This commit is contained in:
@@ -1 +1 @@
|
|||||||
1.2.5
|
1.2.6
|
||||||
@@ -276,6 +276,13 @@ export function initEditor() {
|
|||||||
async function confirmUnsavedChanges() {
|
async function confirmUnsavedChanges() {
|
||||||
const dirty = await hasUnsavedChanges();
|
const dirty = await hasUnsavedChanges();
|
||||||
if (!dirty) return 'ok';
|
if (!dirty) return 'ok';
|
||||||
|
try {
|
||||||
|
const currentSnapshot = await buildCurrentSnapshot();
|
||||||
|
if (currentSnapshot && savedSnapshot && currentSnapshot === savedSnapshot) {
|
||||||
|
clearDirty();
|
||||||
|
return 'ok';
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
const choice = await showUnsavedDialog();
|
const choice = await showUnsavedDialog();
|
||||||
if (choice === 'save') {
|
if (choice === 'save') {
|
||||||
const okSave = await save();
|
const okSave = await save();
|
||||||
|
|||||||
@@ -2231,17 +2231,44 @@ class ApiKernel
|
|||||||
{
|
{
|
||||||
$out = [];
|
$out = [];
|
||||||
$seen = [];
|
$seen = [];
|
||||||
$matches = function (?string $html) use ($templateId): bool {
|
$matches = function (?string $html, array $libKinds = []) use ($templateId): bool {
|
||||||
if (!$html) return false;
|
if (!$html) return false;
|
||||||
$id = preg_quote((string)$templateId, '/');
|
$id = preg_quote((string)$templateId, '/');
|
||||||
$typePattern = '/data-ref-type\s*=\s*(["\"])template\1/i';
|
$typePattern = '/data-ref-type\s*=\s*(["\"])template\1/i';
|
||||||
$idPattern = '/data-ref-id\s*=\s*(["\"])' . $id . '\1/i';
|
$idPattern = '/data-ref-id\s*=\s*(["\"])' . $id . '\1/i';
|
||||||
return (bool)(preg_match($typePattern, $html) && preg_match($idPattern, $html));
|
$jsonTypePattern = '/"data-ref-type"\s*:\s*"template"/i';
|
||||||
|
$jsonIdPattern = '/"data-ref-id"\s*:\s*("?)(?:' . $id . ')\1/i';
|
||||||
|
$hasHtmlAttrs = (bool)(preg_match($typePattern, $html) && preg_match($idPattern, $html));
|
||||||
|
if ($hasHtmlAttrs) return true;
|
||||||
|
if (preg_match($jsonTypePattern, $html) && preg_match($jsonIdPattern, $html)) return true;
|
||||||
|
|
||||||
|
$kindPattern = '/data-lib-(?:kind|section)\s*=\s*(["\"])([^"\']+)\1/i';
|
||||||
|
$libIdPattern = '/data-lib-id\s*=\s*(["\"])' . $id . '\1/i';
|
||||||
|
if (preg_match($libIdPattern, $html)) {
|
||||||
|
if (!$libKinds) return true;
|
||||||
|
if (preg_match($kindPattern, $html, $m)) {
|
||||||
|
$kind = strtolower(trim((string)($m[2] ?? '')));
|
||||||
|
if ($kind !== '' && in_array($kind, $libKinds, true)) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$jsonLibIdPattern = '/"data-lib-id"\s*:\s*("?)(?:' . $id . ')\1/i';
|
||||||
|
$jsonLibKindPattern = '/"data-lib-(?:kind|section)"\s*:\s*"([^"]+)"/i';
|
||||||
|
if (preg_match($jsonLibIdPattern, $html)) {
|
||||||
|
if (!$libKinds) return true;
|
||||||
|
if (preg_match($jsonLibKindPattern, $html, $m)) {
|
||||||
|
$kind = strtolower(trim((string)($m[1] ?? '')));
|
||||||
|
if ($kind !== '' && in_array($kind, $libKinds, true)) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
if ($this->useUnifiedContent()) {
|
if ($this->useUnifiedContent()) {
|
||||||
$section = $this->ensureEmailtemplateSection($customerId);
|
$section = $this->ensureEmailtemplateSection($customerId);
|
||||||
if (!$section) return [];
|
if (!$section) return [];
|
||||||
|
$libKinds = [strtolower((string)($section['slug'] ?? 'emailtemplate'))];
|
||||||
|
|
||||||
$itemsTable = $this->contentItemsTable();
|
$itemsTable = $this->contentItemsTable();
|
||||||
if (!$this->tableExists($itemsTable)) return [];
|
if (!$this->tableExists($itemsTable)) return [];
|
||||||
@@ -2291,7 +2318,7 @@ class ApiKernel
|
|||||||
];
|
];
|
||||||
$found = false;
|
$found = false;
|
||||||
foreach ($blobs as $blob) {
|
foreach ($blobs as $blob) {
|
||||||
if ($matches($blob)) { $found = true; break; }
|
if ($matches($blob, $libKinds)) { $found = true; break; }
|
||||||
}
|
}
|
||||||
if ($found) {
|
if ($found) {
|
||||||
$id = (int)($row['id'] ?? 0);
|
$id = (int)($row['id'] ?? 0);
|
||||||
@@ -2307,6 +2334,7 @@ class ApiKernel
|
|||||||
if (!$this->useUnifiedContent()) {
|
if (!$this->useUnifiedContent()) {
|
||||||
$table = $this->tableMap['templates'] ?? null;
|
$table = $this->tableMap['templates'] ?? null;
|
||||||
if ($table && $this->tableExists($table)) {
|
if ($table && $this->tableExists($table)) {
|
||||||
|
$libKinds = ['templates', 'template', 'emailtemplate'];
|
||||||
[$idCol, $allCols] = $this->resolveIdCol('templates');
|
[$idCol, $allCols] = $this->resolveIdCol('templates');
|
||||||
$htmlCol = $this->firstExisting($allCols, ['html', 'body', 'markup', 'content']);
|
$htmlCol = $this->firstExisting($allCols, ['html', 'body', 'markup', 'content']);
|
||||||
$jsonCol = $this->firstExisting($allCols, ['json_content']);
|
$jsonCol = $this->firstExisting($allCols, ['json_content']);
|
||||||
@@ -2332,7 +2360,7 @@ class ApiKernel
|
|||||||
];
|
];
|
||||||
$found = false;
|
$found = false;
|
||||||
foreach ($blobs as $blob) {
|
foreach ($blobs as $blob) {
|
||||||
if ($matches($blob)) { $found = true; break; }
|
if ($matches($blob, $libKinds)) { $found = true; break; }
|
||||||
}
|
}
|
||||||
if ($found) {
|
if ($found) {
|
||||||
$id = (int)($row['id'] ?? 0);
|
$id = (int)($row['id'] ?? 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user