diff --git a/com_eis/Archiv.zip b/com_eis/Archiv.zip deleted file mode 100644 index f9d4b23..0000000 Binary files a/com_eis/Archiv.zip and /dev/null differ diff --git a/com_eis/eis.xml b/com_eis/eis.xml index fff3d50..71da673 100644 --- a/com_eis/eis.xml +++ b/com_eis/eis.xml @@ -5,17 +5,23 @@ install/sql/mysql/install.utf8.sql - - - install/sql/mysql/uninstall.mysql.utf8.sql - - + + + install/sql/mysql/uninstall.mysql.utf8.sql + + com_eis 2025-07-23 Thomas Spohr powert by OpenAI 1.0.0 EIS Minimal-Komponente EIS\Component\EIS + + + src + + + COM_EIS_MENU diff --git a/com_eis/eis.zip b/com_eis/eis.zip new file mode 100644 index 0000000..c26791c Binary files /dev/null and b/com_eis/eis.zip differ diff --git a/com_eis/services/provider.php b/com_eis/services/provider.php index 745360f..e081340 100644 --- a/com_eis/services/provider.php +++ b/com_eis/services/provider.php @@ -1,4 +1,5 @@ registerServiceProvider(new ComponentDispatcherFactory('\\EIS\\Component\\EIS')); $container->registerServiceProvider(new MVCFactory('\\EIS\\Component\\EIS')); $container->registerServiceProvider(new RouterFactory('\\EIS\\Component\\EIS')); + // DownloadController explizit registrieren + $container->set( + DownloadController::class, + fn(Container $c) => new DownloadController() + ); + + // Komponentenschnittstelle $container->set( ComponentInterface::class, static fn(Container $c) => new MVCComponent( diff --git a/com_eis/site/src/Controller/DownloadController.php b/com_eis/site/src/Controller/DownloadController.php new file mode 100644 index 0000000..7113aca --- /dev/null +++ b/com_eis/site/src/Controller/DownloadController.php @@ -0,0 +1,62 @@ +input; + + // Nur für eingeloggte Benutzer + if ($user->guest) { + $app->enqueueMessage('Bitte zuerst einloggen.', 'warning'); + $app->redirect(Route::_('index.php?option=com_users&view=login', false)); + return; + } + + // ID aus URL lesen + $id = $input->getInt('id'); + if (!$id) { + throw new \RuntimeException("Keine Dokument-ID übergeben."); + } + + // Datenbankabfrage + /** @var DatabaseDriver $db */ + $db = Factory::getDbo(); + + $query = $db->getQuery(true) + ->select($db->quoteName(['path', 'name'])) + ->from($db->quoteName('#__eis_documents')) + ->where($db->quoteName('id') . ' = ' . (int) $id) + ->where($db->quoteName('is_folder') . ' = 0'); + + $row = $db->setQuery($query)->loadAssoc(); + + if (!$row) { + throw new \RuntimeException("PDF nicht gefunden oder kein gültiges Dokument."); + } + + $filePath = $row['path']; + $fileName = $row['name']; + + if (!file_exists($filePath)) { + throw new \RuntimeException("Datei existiert nicht auf dem Server."); + } + + // PDF-Datei ausgeben + header('Content-Type: application/pdf'); + header('Content-Disposition: inline; filename="' . basename($fileName) . '"'); + header('Content-Length: ' . filesize($filePath)); + readfile($filePath); + exit; + } +} diff --git a/com_eis/src/View/Main/HtmlView.php b/com_eis/src/View/Main/HtmlView.php index 5403239..4637434 100644 --- a/com_eis/src/View/Main/HtmlView.php +++ b/com_eis/src/View/Main/HtmlView.php @@ -4,7 +4,6 @@ namespace EIS\Component\EIS\Administrator\View\Main; \defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; - class HtmlView extends BaseHtmlView { public function display($tpl = null): void diff --git a/mod_pdf_tree/Archiv.zip b/mod_pdf_tree/Archiv.zip deleted file mode 100644 index 8032246..0000000 Binary files a/mod_pdf_tree/Archiv.zip and /dev/null differ diff --git a/mod_pdf_tree/helper.php b/mod_pdf_tree/helper.php index c2f74db..eeb6832 100644 --- a/mod_pdf_tree/helper.php +++ b/mod_pdf_tree/helper.php @@ -9,7 +9,6 @@ class ModEisAnzeigeHelper /** * Holt alle PDF-Elemente aus der Datenbank */ - public static function getItems(): array { /** @var DatabaseDriver $db */ @@ -35,7 +34,6 @@ class ModEisAnzeigeHelper /** * Hauptfunktion zum Rendern des Baums */ - public static function renderTree(array $items, int $parentId = null): string { if (!isset($items[$parentId])) { @@ -47,19 +45,21 @@ class ModEisAnzeigeHelper foreach ($items[$parentId] as $item) { $isFolder = (bool) $item['is_folder']; $title = htmlspecialchars($item['title'] ?: $item['name']); - // $path = htmlspecialchars($item['path'] ?? ''); - $path = htmlspecialchars(self::convertToRelativeUrl($item['path'] ?? '')); + $path = self::convertToRelativeUrl($item['path'] ?? ''); + + // Erweiterung .pdf im Titel entfernen (nur Anzeige, nicht Link) + $displayTitle = preg_replace('/\.pdf$/i', '', $title); if ($isFolder) { $fileCount = self::countFilesRecursive($items, $item['id']); $html .= ''; $html .= '▶'; - $html .= '' . $title . ' (' . $fileCount . ')'; + $html .= '📁 ' . $displayTitle . ' (' . $fileCount . ')'; $html .= self::renderTree($items, $item['id']); $html .= ''; } else { $html .= ''; - $html .= '' . $title . ''; + $html .= '📄' . $displayTitle . ''; $html .= ''; } } @@ -68,22 +68,25 @@ class ModEisAnzeigeHelper return $html; } - /** * Konvertiert absoluten Serverpfad in URL */ private static function convertToRelativeUrl(string $fullPath): string { - // <== HIER den absoluten Pfad zu deinem Webroot anpassen - $webRoot = '/var/www/vhosts/ts-it24.net/stbv.ts-it24.net'; - $webBase = ''; // ggf. '/subdir' falls Joomla in Unterordner + // Absoluter Serverpfad zum Joomla-Root + $webRoot = '/var/www/joomla'; + $webBase = ''; // ggf. '/unterordner', wenn Joomla in Subdir if (str_starts_with($fullPath, $webRoot)) { - return $webBase . str_replace($webRoot, '', $fullPath); + $relativePath = str_replace($webRoot, '', $fullPath); + // Leerzeichen und Sonderzeichen escapen + $relativePath = implode('/', array_map('rawurlencode', explode('/', $relativePath))); + return rtrim(\JUri::root(), '/') . $webBase . $relativePath; } - return $fullPath; // Fallback: Original verwenden + return $fullPath; // Fallback } + /** * Zählt alle PDF-Dateien unterhalb eines Ordners rekursiv */ @@ -96,7 +99,7 @@ class ModEisAnzeigeHelper } foreach ($items[$parentId] as $item) { - if ((bool)$item['is_folder']) { + if ((bool) $item['is_folder']) { $count += self::countFilesRecursive($items, $item['id']); } else { $count++; diff --git a/mod_pdf_tree/mod_eis_anzeige.zip b/mod_pdf_tree/mod_eis_anzeige.zip new file mode 100644 index 0000000..21ae967 Binary files /dev/null and b/mod_pdf_tree/mod_eis_anzeige.zip differ diff --git a/mod_pdf_tree/tmpl/default.php b/mod_pdf_tree/tmpl/default.php index b518678..96744fe 100644 --- a/mod_pdf_tree/tmpl/default.php +++ b/mod_pdf_tree/tmpl/default.php @@ -1,8 +1,6 @@ - - + ausklappen einklappen + - - + = ModEisAnzeigeHelper::renderTree($items); ?> - - - \ No newline at end of file +