-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboot.php
More file actions
75 lines (63 loc) · 2.34 KB
/
boot.php
File metadata and controls
75 lines (63 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* SYNCH - Modern Key-Based File Synchronization for REDAXO
*
* Dieses Addon bietet eine moderne, key-basierte Synchronisation
* zwischen Dateisystem und Datenbank ohne die Legacy-Altlasten
* des developer Addons.
*/
use KLXM\Synch\Manager;
use KLXM\Synch\OutputFilter;
// Console-Modus überspringen
if (rex::getConsole()) {
return;
}
// Während Installation/Deinstallation nicht synchronisieren
if (rex::isSetup() || rex::isBackend() && rex_get('function') === 'install') {
return;
}
// Output Filter für Backend registrieren (Lösch-Buttons entfernen)
if (rex::isBackend()) {
$syncDirection = (string) rex_addon::get('synch')->getConfig('sync_direction', 'files_to_db');
$currentPage = rex_be_controller::getCurrentPage();
$backendFunction = rex_request('function', 'string');
if (
$syncDirection === 'files_to_db'
&& $currentPage === 'modules/modules'
&& in_array($backendFunction, ['add', 'edit', 'delete'], true)
) {
rex_response::sendRedirect(rex_url::backendPage('modules/modules'));
}
OutputFilter::register();
}
// Automatische Synchronisation nur wenn explizit aktiviert
$addon = rex_addon::get('synch');
// Synchronisation ist standardmäßig deaktiviert bis explizit aktiviert
$syncBackend = $addon->getConfig('sync_backend', false);
$syncFrontend = $addon->getConfig('sync_frontend', false); // Default: false
// Auto-Sync pausiert?
$isPaused = $addon->getConfig('auto_sync_paused', false);
// Automatische Pause nach 30 Minuten aufheben
if ($isPaused) {
$pausedAt = $addon->getConfig('auto_sync_paused_at', 0);
if ($pausedAt && (time() - $pausedAt) > 30 * 60) { // 30 Minuten
$addon->setConfig('auto_sync_paused', false);
$addon->removeConfig('auto_sync_paused_at');
$isPaused = false;
}
}
if (
!$isPaused && // Nicht pausiert
((!rex::isBackend() && $syncFrontend) ||
(rex::getUser() && rex::isBackend() && $syncBackend))
) {
rex_extension::register('PACKAGES_INCLUDED', static function (): void {
// Nur für Admins ausführen (wie Developer Addon)
if (rex::isDebugMode() || (rex::getUser() && rex::getUser()->isAdmin())) {
// Change Detection - nur synchronisieren wenn sich etwas geändert hat
if (Manager::hasChanges()) {
Manager::start();
}
}
});
}