Änderungen im Modul. Ausklappen desd Baumes

This commit is contained in:
Thomas Spohr
2025-08-18 11:58:50 +02:00
parent bd7e720c47
commit 7396cf9f51
4 changed files with 53 additions and 40 deletions

BIN
mod_pdf_tree/.DS_Store vendored

Binary file not shown.

Binary file not shown.

View File

@@ -41,7 +41,7 @@ class ModEisAnzeigeHelper
* Hauptfunktion zum Rendern des Baums * Hauptfunktion zum Rendern des Baums
*/ */
public static function renderTree(array $items, int $parentId = null): string public static function renderTree(array $items, int $parentId = null): string
{ {
if (!isset($items[$parentId])) { if (!isset($items[$parentId])) {
return ''; return '';
} }
@@ -53,27 +53,39 @@ class ModEisAnzeigeHelper
$rawName = $item['title'] ?: $item['name']; $rawName = $item['title'] ?: $item['name'];
$fileId = (int) $item['id']; $fileId = (int) $item['id'];
// Dateiendung .pdf entfernen // Dateiendung .pdf entfernen und escapen
$displayName = preg_replace('/\.pdf$/i', '', $rawName); $displayName = preg_replace('/\.pdf$/i', '', $rawName);
$displayName = htmlspecialchars($displayName); $displayName = htmlspecialchars($displayName, ENT_QUOTES, 'UTF-8');
if ($isFolder) { if ($isFolder) {
$fileCount = self::countFilesRecursive($items, $item['id']); $fileCount = self::countFilesRecursive($items, $item['id']);
// WICHTIG: Toggle-Element einfügen dein JS hängt hier dran
$html .= '<li class="folder">'; $html .= '<li class="folder">';
$html .= '📁 ' . $displayName . ' <small>(' . $fileCount . ')</small>'; $html .= '<span class="toggle" role="button" aria-label="Ordner umschalten" tabindex="0">▶</span> ';
$html .= '📁 ' . $displayName . ' <small>(' . (int) $fileCount . ')</small>';
// Kindknoten
$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); $link = Route::_('index.php?option=com_eis&task=download.download&id=' . $fileId);
// Tooltip mit Dateigröße // Tooltip + (neu) inline-Anzeige der Dateigröße, falls der Pfad existiert
$tooltip = ''; $tooltip = '';
if (!empty($item['path']) && file_exists($item['path'])) { $sizeStr = '';
$size = filesize($item['path']); if (!empty($item['path']) && is_file($item['path'])) {
$tooltip = ' title="Größe: ' . self::formatFileSize($size) . '"'; $size = @filesize($item['path']);
if ($size !== false) {
$formatted = self::formatFileSize((int) $size);
$tooltip = ' title="Größe: ' . $formatted . '"';
// Sichtbar neben dem Dateinamen anzeigen
//$sizeStr = ' <small class="meta">(' . $formatted . ')</small>';
}
} }
$html .= '<li class="file">'; $html .= '<li class="file">';
//$html .= '📄 <a class="file-link" href="' . $link . '"' . $tooltip . '>' . $displayName . '</a>' . $sizeStr;
$html .= '📄 <a class="file-link" href="' . $link . '"' . $tooltip . '>' . $displayName . '</a>'; $html .= '📄 <a class="file-link" href="' . $link . '"' . $tooltip . '>' . $displayName . '</a>';
$html .= '</li>'; $html .= '</li>';
} }
@@ -81,7 +93,7 @@ class ModEisAnzeigeHelper
$html .= '</ul>'; $html .= '</ul>';
return $html; return $html;
} }
/** /**
* Zählt alle PDF-Dateien unterhalb eines Ordners rekursiv * Zählt alle PDF-Dateien unterhalb eines Ordners rekursiv

View File

@@ -55,6 +55,7 @@
display: inline-block; display: inline-block;
user-select: none; user-select: none;
} }
.pdf-tree .meta { color: #666; }
/* Optionale visuelle Trennung bei Dateien */ /* Optionale visuelle Trennung bei Dateien */
.file-link { .file-link {