diff --git a/com_eis/.DS_Store b/com_eis/.DS_Store index 5ccbf1b..1efc6c6 100644 Binary files a/com_eis/.DS_Store and b/com_eis/.DS_Store differ diff --git a/com_eis/Archiv.zip b/com_eis/Archiv.zip index 390d08d..8321fab 100644 Binary files a/com_eis/Archiv.zip and b/com_eis/Archiv.zip differ diff --git a/com_eis/administrator/.DS_Store b/com_eis/administrator/.DS_Store index 1310777..2431bac 100644 Binary files a/com_eis/administrator/.DS_Store and b/com_eis/administrator/.DS_Store differ diff --git a/com_eis/administrator/src/.DS_Store b/com_eis/administrator/src/.DS_Store index 9398dad..889bb74 100644 Binary files a/com_eis/administrator/src/.DS_Store and b/com_eis/administrator/src/.DS_Store differ diff --git a/com_eis/administrator/src/Controller/DisplayController.php b/com_eis/administrator/src/Controller/DisplayController.php index ab8e989..faa372f 100644 --- a/com_eis/administrator/src/Controller/DisplayController.php +++ b/com_eis/administrator/src/Controller/DisplayController.php @@ -34,7 +34,10 @@ class DisplayController extends BaseController $path = SettingsHelper::getSetting('document_root', '/var/www/pdf'); if (!$path || !is_dir($path)) { - $app->enqueueMessage(Text::sprintf('COM_EIS_MSG_PATH_NOT_EXISTS', $path) ?: ('Pfad ungültig oder nicht gesetzt: ' . $path), 'error'); + $app->enqueueMessage( + Text::sprintf('COM_EIS_MSG_PATH_NOT_EXISTS', $path) ?: ('Pfad ungültig oder nicht gesetzt: ' . $path), + 'error' + ); $this->setRedirect(Route::_('index.php?option=com_eis&view=main', false)); return; } @@ -45,12 +48,16 @@ class DisplayController extends BaseController // Alte Einträge löschen (Hinweis: Dann sind ALLE eingefügten „neu“) $db->truncateTable('#__eis_documents'); - // In Datenbank speichern und neue IDs sammeln + // In Datenbank speichern und neue IDs sammeln (nur Dateien) $newIds = $this->saveToDb($data, null, $db); // Neue IDs im UserState für die View -> virtueller Ordner "Neue Dokumente" $app->setUserState('com_eis.new_ids', $newIds); + // NEU: dauerhaft speichern (für das Frontend-Modul) + SettingsHelper::setSetting('last_new_ids', json_encode($newIds, JSON_UNESCAPED_SLASHES)); + SettingsHelper::setSetting('last_scan_at', date('Y-m-d H:i:s')); + // Erfolgsmeldung $app->enqueueMessage(Text::_('COM_EIS_MSG_SCAN_DONE') ?: 'PDF-Struktur erfolgreich gespeichert.', 'message'); $this->setRedirect(Route::_('index.php?option=com_eis&view=main', false)); @@ -90,7 +97,7 @@ class DisplayController extends BaseController } } - // Alphabetisch stabil sortieren (Ordner/Dateien je Ebene) + // Alphabetisch stabil sortieren usort($result, static function ($a, $b) { return strcasecmp((string)$a['name'], (string)$b['name']); }); diff --git a/mod_pdf_tree/Archiv.zip b/mod_pdf_tree/Archiv.zip index a994139..58762ba 100644 Binary files a/mod_pdf_tree/Archiv.zip and b/mod_pdf_tree/Archiv.zip differ diff --git a/mod_pdf_tree/helper.php b/mod_pdf_tree/helper.php index 0068002..91cee9d 100644 --- a/mod_pdf_tree/helper.php +++ b/mod_pdf_tree/helper.php @@ -31,16 +31,55 @@ class ModEisAnzeigeHelper // Sortieren nach name (case-insensitive) foreach ($grouped as &$group) { - usort($group, fn($a, $b) => strcasecmp($a['name'], $b['name'])); + usort($group, fn($a, $b) => strcasecmp((string)$a['name'], (string)$b['name'])); } return $grouped; } + /** Liest param/value aus #__eis_settings (Key/Value) */ + private static function getSetting(string $param, $default = '') + { + $db = Factory::getDbo(); + try { + $q = $db->getQuery(true) + ->select($db->quoteName('value')) + ->from($db->quoteName('#__eis_settings')) + ->where($db->quoteName('param') . ' = ' . $db->quote($param)) + ->setLimit(1); + $db->setQuery($q); + $val = $db->loadResult(); + return ($val !== null && $val !== '') ? $val : $default; + } catch (\Throwable $e) { + return $default; + } + } + + /** Holt die zuletzt gespeicherten neuen Datei-IDs (vom Backend-Scan) */ + private static function getLastNewIds(): array + { + $json = (string) self::getSetting('last_new_ids', '[]'); + $arr = json_decode($json, true); + if (!is_array($arr)) return []; + return array_values(array_unique(array_map('intval', $arr))); + } + + /** Baut einen flachen Index id => row über alle Items */ + private static function buildFlatIndex(array $grouped): array + { + $idx = []; + foreach ($grouped as $group) { + foreach ($group as $row) { + $idx[(int) $row['id']] = $row; + } + } + return $idx; + } + /** - * Hauptfunktion zum Rendern des Baums + * Hauptfunktion zum Rendern des Baums (klassisch, ohne „Neue Dokumente“) * - Nutzt title als alternativen Anzeigenamen (Fallback name) - * - Fügt für Ordner eine klickbare Label-Zeile hinzu (bessere Tap-Ziele auf iPad) + * - Fügt für Ordner eine klickbare Label-Zeile hinzu * - Liefert data-* Attribute für spätere Inline-Edits / Preview */ public static function renderTree(array $items, ?int $parentId = null): string @@ -61,46 +100,23 @@ class ModEisAnzeigeHelper $displayName = htmlspecialchars($displayName, ENT_QUOTES, 'UTF-8'); if ($isFolder) { - $fileCount = self::countFilesRecursive($items, $item['id']); + $fileCount = self::countFilesRecursive($items, (int)$item['id']); // Ordner-