Änderungen im Modul. Ausklappen desd Baumes
This commit is contained in:
BIN
mod_pdf_tree/.DS_Store
vendored
BIN
mod_pdf_tree/.DS_Store
vendored
Binary file not shown.
Binary file not shown.
@@ -41,7 +41,7 @@ class ModEisAnzeigeHelper
|
||||
* Hauptfunktion zum Rendern des Baums
|
||||
*/
|
||||
public static function renderTree(array $items, int $parentId = null): string
|
||||
{
|
||||
{
|
||||
if (!isset($items[$parentId])) {
|
||||
return '';
|
||||
}
|
||||
@@ -53,27 +53,39 @@ class ModEisAnzeigeHelper
|
||||
$rawName = $item['title'] ?: $item['name'];
|
||||
$fileId = (int) $item['id'];
|
||||
|
||||
// Dateiendung .pdf entfernen
|
||||
// Dateiendung .pdf entfernen und escapen
|
||||
$displayName = preg_replace('/\.pdf$/i', '', $rawName);
|
||||
$displayName = htmlspecialchars($displayName);
|
||||
$displayName = htmlspecialchars($displayName, ENT_QUOTES, 'UTF-8');
|
||||
|
||||
if ($isFolder) {
|
||||
$fileCount = self::countFilesRecursive($items, $item['id']);
|
||||
|
||||
// WICHTIG: Toggle-Element einfügen – dein JS hängt hier dran
|
||||
$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 .= '</li>';
|
||||
} else {
|
||||
$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 = '';
|
||||
if (!empty($item['path']) && file_exists($item['path'])) {
|
||||
$size = filesize($item['path']);
|
||||
$tooltip = ' title="Größe: ' . self::formatFileSize($size) . '"';
|
||||
$sizeStr = '';
|
||||
if (!empty($item['path']) && is_file($item['path'])) {
|
||||
$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 .= '📄 <a class="file-link" href="' . $link . '"' . $tooltip . '>' . $displayName . '</a>' . $sizeStr;
|
||||
$html .= '📄 <a class="file-link" href="' . $link . '"' . $tooltip . '>' . $displayName . '</a>';
|
||||
$html .= '</li>';
|
||||
}
|
||||
@@ -81,7 +93,7 @@ class ModEisAnzeigeHelper
|
||||
|
||||
$html .= '</ul>';
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zählt alle PDF-Dateien unterhalb eines Ordners rekursiv
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
display: inline-block;
|
||||
user-select: none;
|
||||
}
|
||||
.pdf-tree .meta { color: #666; }
|
||||
|
||||
/* Optionale visuelle Trennung bei Dateien */
|
||||
.file-link {
|
||||
|
||||
Reference in New Issue
Block a user