Version mit sicherem Download

This commit is contained in:
Thomas Spohr
2025-08-18 11:34:09 +02:00
parent 33fa9c8f94
commit bd7e720c47
13 changed files with 43 additions and 35 deletions

BIN
.DS_Store vendored

Binary file not shown.

BIN
com_eis/.DS_Store vendored

Binary file not shown.

BIN
com_eis/Archiv.zip Normal file

Binary file not shown.

View File

@@ -11,10 +11,10 @@
</sql> </sql>
</uninstall> </uninstall>
<name>com_eis</name> <name>com_eis</name>
<creationDate>2025-07-23</creationDate> <creationDate>2025-09-18</creationDate>
<author>Thomas Spohr powert by OpenAI</author> <author>Thomas Spohr powert by OpenAI</author>
<version>1.0.0</version> <version>1.0.1</version>
<description>EIS Minimal-Komponente</description> <description>EIS Komponente</description>
<namespace path="src">EIS\Component\EIS</namespace> <namespace path="src">EIS\Component\EIS</namespace>
<files folder="site"> <files folder="site">

Binary file not shown.

BIN
com_eis/src/.DS_Store vendored

Binary file not shown.

Binary file not shown.

BIN
mod_pdf_tree/.DS_Store vendored

Binary file not shown.

BIN
mod_pdf_tree/Archiv.zip Normal file

Binary file not shown.

View File

@@ -2,6 +2,7 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
use Joomla\CMS\Factory; use Joomla\CMS\Factory;
use Joomla\CMS\Router\Route;
use Joomla\Database\DatabaseDriver; use Joomla\Database\DatabaseDriver;
class ModEisAnzeigeHelper class ModEisAnzeigeHelper
@@ -21,13 +22,18 @@ class ModEisAnzeigeHelper
$rows = $db->setQuery($query)->loadAssocList(); $rows = $db->setQuery($query)->loadAssocList();
// Nach parent_id gruppieren // Nach parent_id gruppieren und alphabetisch sortieren
$grouped = []; $grouped = [];
foreach ($rows as $row) { foreach ($rows as $row) {
$pid = $row['parent_id'] === null ? null : (int) $row['parent_id']; $pid = $row['parent_id'] === null ? null : (int) $row['parent_id'];
$grouped[$pid][] = $row; $grouped[$pid][] = $row;
} }
// Sortieren nach name (case-insensitive)
foreach ($grouped as &$group) {
usort($group, fn($a, $b) => strcasecmp($a['name'], $b['name']));
}
return $grouped; return $grouped;
} }
@@ -44,22 +50,31 @@ class ModEisAnzeigeHelper
foreach ($items[$parentId] as $item) { foreach ($items[$parentId] as $item) {
$isFolder = (bool) $item['is_folder']; $isFolder = (bool) $item['is_folder'];
$title = htmlspecialchars($item['title'] ?: $item['name']); $rawName = $item['title'] ?: $item['name'];
$path = self::convertToRelativeUrl($item['path'] ?? ''); $fileId = (int) $item['id'];
// Erweiterung .pdf im Titel entfernen (nur Anzeige, nicht Link) // Dateiendung .pdf entfernen
$displayTitle = preg_replace('/\.pdf$/i', '', $title); $displayName = preg_replace('/\.pdf$/i', '', $rawName);
$displayName = htmlspecialchars($displayName);
if ($isFolder) { if ($isFolder) {
$fileCount = self::countFilesRecursive($items, $item['id']); $fileCount = self::countFilesRecursive($items, $item['id']);
$html .= '<li class="folder">'; $html .= '<li class="folder">';
$html .= '<span class="toggle">▶</span>'; $html .= '📁 ' . $displayName . ' <small>(' . $fileCount . ')</small>';
$html .= '<span class="folder-icon">📁</span> ' . $displayTitle . ' <small>(' . $fileCount . ')</small>';
$html .= self::renderTree($items, $item['id']); $html .= self::renderTree($items, $item['id']);
$html .= '</li>'; $html .= '</li>';
} else { } else {
$link = Route::_('index.php?option=com_eis&task=download.download&id=' . $fileId);
// Tooltip mit Dateigröße
$tooltip = '';
if (!empty($item['path']) && file_exists($item['path'])) {
$size = filesize($item['path']);
$tooltip = ' title="Größe: ' . self::formatFileSize($size) . '"';
}
$html .= '<li class="file">'; $html .= '<li class="file">';
$html .= '<span class="file-icon">📄</span><a class="file-link" href="' . htmlspecialchars($path) . '" title="' . $title . '">' . $displayTitle . '</a>'; $html .= '📄 <a class="file-link" href="' . $link . '"' . $tooltip . '>' . $displayName . '</a>';
$html .= '</li>'; $html .= '</li>';
} }
} }
@@ -68,25 +83,6 @@ class ModEisAnzeigeHelper
return $html; return $html;
} }
/**
* Konvertiert absoluten Serverpfad in URL
*/
private static function convertToRelativeUrl(string $fullPath): string
{
// Absoluter Serverpfad zum Joomla-Root
$webRoot = '/var/www/joomla';
$webBase = ''; // ggf. '/unterordner', wenn Joomla in Subdir
if (str_starts_with($fullPath, $webRoot)) {
$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
}
/** /**
* Zählt alle PDF-Dateien unterhalb eines Ordners rekursiv * Zählt alle PDF-Dateien unterhalb eines Ordners rekursiv
*/ */
@@ -108,4 +104,20 @@ class ModEisAnzeigeHelper
return $count; return $count;
} }
/**
* Formatierte Dateigröße für Tooltip
*/
private static function formatFileSize(int $bytes): string
{
if ($bytes >= 1073741824) {
return number_format($bytes / 1073741824, 2) . ' GB';
} elseif ($bytes >= 1048576) {
return number_format($bytes / 1048576, 1) . ' MB';
} elseif ($bytes >= 1024) {
return number_format($bytes / 1024, 0) . ' KB';
} else {
return $bytes . ' B';
}
}
} }

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="5.0" client="site" method="upgrade"> <extension type="module" version="5.0" client="site" method="upgrade">
<name>EIS-Anzeige</name> <name>EIS-Anzeige</name>
<author>Ich</author> <author>Thomas Spohr</author>
<version>1.0.1</version> <version>1.0.1</version>
<description>Anzeige des PDF-Baums mit Dokumentenzählung und Expand/Collapse-All</description> <description>Anzeige des PDF-Baums mit Dokumentenzählung und Expand/Collapse-All</description>
<files> <files>

Binary file not shown.

View File

@@ -10,8 +10,6 @@
border: 1px solid #ddd; border: 1px solid #ddd;
border-radius: 6px; border-radius: 6px;
box-shadow: 0 4px 10px rgba(0,0,0,0.05); box-shadow: 0 4px 10px rgba(0,0,0,0.05);
width: 100%;
max-width: 100%; /* Oder: max-width: 1400px; */
} }
.pdf-tree-container { .pdf-tree-container {
@@ -35,7 +33,6 @@
border: none; border: none;
display: block; display: block;
} }
.pdf-tree { .pdf-tree {
list-style: none; list-style: none;
margin: 0; margin: 0;
@@ -48,7 +45,6 @@
display: none; display: none;
} }
.pdf-tree li { .pdf-tree li {
margin: 0.3em 0; margin: 0.3em 0;
} }