diff --git a/EIS.docx b/EIS.docx
new file mode 100644
index 0000000..6c9ed6b
Binary files /dev/null and b/EIS.docx differ
diff --git a/com_eis/administrator/src/Controller/DisplayController.php b/com_eis/administrator/src/Controller/DisplayController.php
index bd615e6..637d2e0 100644
--- a/com_eis/administrator/src/Controller/DisplayController.php
+++ b/com_eis/administrator/src/Controller/DisplayController.php
@@ -11,6 +11,7 @@ use Joomla\CMS\Router\Route;
use Joomla\CMS\Session\Session;
use Joomla\Database\DatabaseDriver;
use EIS\Component\EIS\Administrator\Helper\SettingsHelper;
+use EIS\Component\EIS\Administrator\Service\DocumentScanner;
class DisplayController extends BaseController
{
@@ -19,50 +20,29 @@ class DisplayController extends BaseController
/**
* Button-Aktion: PDF-Verzeichnis scannen und in Datenbank speichern
*/
+
public function scan(): void
- {
- // CSRF prüfen (Form hat Token)
- if (!Session::checkToken('post')) {
- throw new \RuntimeException(Text::_('JINVALID_TOKEN'), 403);
- }
-
- $app = Factory::getApplication();
- /** @var DatabaseDriver $db */
- $db = Factory::getDbo();
-
- // Pfad aus Settings laden (Key/Value); Default /var/www/pdf
- $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'
- );
- $this->setRedirect(Route::_('index.php?option=com_eis&view=main', false));
- return;
- }
-
- // Verzeichnis rekursiv scannen
- $data = $this->scanFolder($path);
-
- // Alte Einträge löschen (Hinweis: Dann sind ALLE eingefügten „neu“)
- $db->truncateTable('#__eis_documents');
-
- // 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));
+{
+ // CSRF prüfen (Form hat Token)
+ if (!Session::checkToken('post')) {
+ throw new \RuntimeException(Text::_('JINVALID_TOKEN'), 403);
}
+ $app = Factory::getApplication();
+
+ try {
+ $newIds = DocumentScanner::run();
+
+ // Wie bisher: New IDs für die View (virtueller Ordner "Neue Dokumente")
+ $app->setUserState('com_eis.new_ids', $newIds);
+
+ $app->enqueueMessage(Text::_('COM_EIS_MSG_SCAN_DONE') ?: 'PDF-Struktur erfolgreich gespeichert.', 'message');
+ } catch (\Throwable $e) {
+ $app->enqueueMessage($e->getMessage(), 'error');
+ }
+
+ $this->setRedirect(Route::_('index.php?option=com_eis&view=main', false));
+}
/**
* Rekursive Verzeichnisanalyse
*/
diff --git a/com_eis/Archiv.zip b/com_eis/eis.zip
similarity index 58%
rename from com_eis/Archiv.zip
rename to com_eis/eis.zip
index ff67252..e3a716d 100644
Binary files a/com_eis/Archiv.zip and b/com_eis/eis.zip differ
diff --git a/mod_pdf_tree/Archiv.zip b/mod_pdf_tree/Archiv2.zip
similarity index 100%
rename from mod_pdf_tree/Archiv.zip
rename to mod_pdf_tree/Archiv2.zip
diff --git a/plugins/task/eisdocumentenscan/eisdocumentscan.php b/plugins/task/eisdocumentenscan/eisdocumentscan.php
new file mode 100644
index 0000000..979a247
--- /dev/null
+++ b/plugins/task/eisdocumentenscan/eisdocumentscan.php
@@ -0,0 +1,53 @@
+ [
+ 'langConstPrefix' => 'PLG_TASK_EISDOCUMENTSCAN_TASK_DOCUMENTSCAN',
+ 'method' => 'documentscan',
+ 'form' => 'documentscan',
+ ],
+ ];
+
+ public static function getSubscribedEvents(): array
+ {
+ return [
+ // Wichtig: auf Trait-Methoden mappen!
+ 'onTaskOptionsList' => 'advertiseRoutines',
+ 'onExecuteTask' => 'standardRoutineHandler',
+ 'onContentPrepareForm' => 'enhanceTaskItemForm',
+ ];
+ }
+
+ /**
+ * Muss int Status zurückgeben
+ */
+ public function documentscan(ExecuteTaskEvent $event): int
+ {
+ try {
+ DocumentScanner::run();
+
+ $this->logTask('EIS Dokumentenscan erfolgreich', 'info');
+
+ return Status::OK;
+ } catch (\Throwable $e) {
+ $this->logTask('EIS Dokumentenscan FEHLER: ' . $e->getMessage(), 'error');
+
+ return Status::KNOCKOUT;
+ }
+ }
+}
diff --git a/plugins/task/eisdocumentenscan/eisdocumentscan.xml b/plugins/task/eisdocumentenscan/eisdocumentscan.xml
new file mode 100644
index 0000000..d30a66a
--- /dev/null
+++ b/plugins/task/eisdocumentenscan/eisdocumentscan.xml
@@ -0,0 +1,18 @@
+
+