Mit deutscher Sprache
This commit is contained in:
BIN
com_eis/administrator/.DS_Store
vendored
Normal file
BIN
com_eis/administrator/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
com_eis/administrator/language/.DS_Store
vendored
Normal file
BIN
com_eis/administrator/language/.DS_Store
vendored
Normal file
Binary file not shown.
9
com_eis/administrator/language/de-DE/de-DE.com_eis.ini
Normal file
9
com_eis/administrator/language/de-DE/de-DE.com_eis.ini
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
COM_EIS_DOCUMENT_PATH="Dokumentenpfad"
|
||||
COM_EIS_DOCUMENT_PATH_LABEL="Pfad zu den PDF-Dokumenten"
|
||||
COM_EIS_SCAN_DOCUMENTS="Dokumente einlesen"
|
||||
COM_EIS_MAIN="EIS Hauptansicht"
|
||||
COM_EIS_MENU="EIS"
|
||||
COM_EIS_CONFIG="Einstellungen"
|
||||
COM_EIS_MAINTENANCE="Wartung"
|
||||
COM_EIS_PDF_TREE="Verzeichnisbaum"
|
||||
@@ -0,0 +1 @@
|
||||
COM_EIS="EIS Komponente"
|
||||
9
com_eis/administrator/language/en-GB/en-GB.com_eis.ini
Normal file
9
com_eis/administrator/language/en-GB/en-GB.com_eis.ini
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
COM_EIS_DOCUMENT_PATH="Dokumentenpfad"
|
||||
COM_EIS_DOCUMENT_PATH_LABEL="Pfad zu den PDF-Dokumenten"
|
||||
COM_EIS_SCAN_DOCUMENTS="Dokumente einlesen"
|
||||
COM_EIS_MAIN="EIS Hauptansicht"
|
||||
COM_EIS_MENU="EIS"
|
||||
COM_EIS_CONFIG="Einstellungen"
|
||||
COM_EIS_MAINTENANCE="Wartung"
|
||||
COM_EIS_PDF_TREE="Verzeichnisbaum"
|
||||
@@ -0,0 +1 @@
|
||||
COM_EIS="EIS Komponente"
|
||||
40
com_eis/administrator/services/provider.php
Normal file
40
com_eis/administrator/services/provider.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace EIS\Component\EIS;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Extension\Service\Provider\ComponentDispatcherFactory;
|
||||
use Joomla\CMS\Extension\Service\Provider\MVCFactory;
|
||||
use Joomla\CMS\Extension\Service\Provider\RouterFactory;
|
||||
use Joomla\CMS\Extension\ComponentInterface;
|
||||
use Joomla\CMS\Extension\MVCComponent;
|
||||
use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use EIS\Component\EIS\Site\Controller\DownloadController;
|
||||
|
||||
return new class implements ServiceProviderInterface
|
||||
{
|
||||
public function register(Container $container): void
|
||||
{
|
||||
// MVC-Basisregistrierung
|
||||
$container->registerServiceProvider(new ComponentDispatcherFactory('\\EIS\\Component\\EIS'));
|
||||
$container->registerServiceProvider(new MVCFactory('\\EIS\\Component\\EIS'));
|
||||
$container->registerServiceProvider(new RouterFactory('\\EIS\\Component\\EIS'));
|
||||
|
||||
// Optional: DownloadController explizit registrieren (kann auch weggelassen werden)
|
||||
$container->set(
|
||||
DownloadController::class,
|
||||
fn(Container $c) => new DownloadController()
|
||||
);
|
||||
|
||||
// Komponentenschnittstelle
|
||||
$container->set(
|
||||
ComponentInterface::class,
|
||||
static fn(Container $c) => new MVCComponent(
|
||||
$c->get(ComponentDispatcherFactoryInterface::class)
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
18
com_eis/administrator/sql/install.mysql.utf8.sql
Normal file
18
com_eis/administrator/sql/install.mysql.utf8.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
CREATE TABLE IF NOT EXISTS `#__eis_documents` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`path` TEXT NOT NULL,
|
||||
`parent_id` INT UNSIGNED DEFAULT NULL,
|
||||
`is_folder` TINYINT(1) DEFAULT 0,
|
||||
`title` VARCHAR(255) DEFAULT NULL,
|
||||
`description` TEXT DEFAULT NULL,
|
||||
`ordering` INT DEFAULT 0,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `#__eis_settings` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`pdf_path` TEXT NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
2
com_eis/administrator/sql/uninstall.mysql.utf8.sql
Normal file
2
com_eis/administrator/sql/uninstall.mysql.utf8.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
DROP TABLE IF EXISTS `#__eis_settings`;
|
||||
DROP TABLE IF EXISTS `#__eis_documents`;
|
||||
61
com_eis/administrator/sql/updates/1.1.2.sql
Normal file
61
com_eis/administrator/sql/updates/1.1.2.sql
Normal file
@@ -0,0 +1,61 @@
|
||||
-- UTF-8, kein BOM
|
||||
-- EIS – Schema-Update 1.1.1
|
||||
-- Ziel: fehlende Tabellen anlegen, fehlende Spalten/Indizes ergänzen.
|
||||
|
||||
-- ==========================================================
|
||||
-- 1) Einstellungen (neu in 1.1.1)
|
||||
-- ==========================================================
|
||||
CREATE TABLE IF NOT EXISTS `#__eis_settings` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`param` VARCHAR(191) NOT NULL,
|
||||
`value` TEXT NULL,
|
||||
`created` DATETIME NULL DEFAULT NULL,
|
||||
`modified` DATETIME NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uniq_param` (`param`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
INSERT IGNORE INTO `#__eis_settings` (`param`, `value`, `created`, `modified`)
|
||||
VALUES ('document_root', '', NOW(), NOW());
|
||||
|
||||
-- ==========================================================
|
||||
-- 2) Dokumente (Bestand absichern)
|
||||
-- Falls ältere Installationen die Tabelle nicht haben.
|
||||
-- ==========================================================
|
||||
CREATE TABLE IF NOT EXISTS `#__eis_documents` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`path` TEXT NOT NULL,
|
||||
`parent_id` INT UNSIGNED DEFAULT NULL,
|
||||
`is_folder` TINYINT(1) NOT NULL DEFAULT 0,
|
||||
`title` VARCHAR(255) DEFAULT NULL,
|
||||
`description` TEXT DEFAULT NULL,
|
||||
`ordering` INT NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- Falls es Altbestände ohne neue Spalten gab, Spalten idempotent ergänzen
|
||||
ALTER TABLE `#__eis_documents`
|
||||
ADD COLUMN IF NOT EXISTS `title` VARCHAR(255) DEFAULT NULL,
|
||||
ADD COLUMN IF NOT EXISTS `description` TEXT DEFAULT NULL,
|
||||
ADD COLUMN IF NOT EXISTS `ordering` INT NOT NULL DEFAULT 0,
|
||||
MODIFY COLUMN `is_folder` TINYINT(1) NOT NULL DEFAULT 0;
|
||||
|
||||
-- Nützliche Indizes (idempotent)
|
||||
CREATE INDEX IF NOT EXISTS `idx_eis_docs_parent` ON `#__eis_documents` (`parent_id`);
|
||||
CREATE INDEX IF NOT EXISTS `idx_eis_docs_ordering` ON `#__eis_documents` (`ordering`);
|
||||
CREATE INDEX IF NOT EXISTS `idx_eis_docs_name` ON `#__eis_documents` (`name`);
|
||||
|
||||
-- Optional: Selbst-Referenz als FK (nur wenn du ON DELETE CASCADE willst)
|
||||
-- Achtung: MySQL verlangt gleiche Kollation/Engine; Namen idempotent prüfen:
|
||||
-- (MySQL kennt kein "ADD CONSTRAINT IF NOT EXISTS", daher defensiv erst droppen)
|
||||
-- SET @fk_exists := (
|
||||
-- SELECT COUNT(*)
|
||||
-- FROM information_schema.REFERENTIAL_CONSTRAINTS
|
||||
-- WHERE CONSTRAINT_SCHEMA = DATABASE()
|
||||
-- AND CONSTRAINT_NAME = 'fk_eis_docs_parent'
|
||||
-- );
|
||||
-- SET @sql := IF(@fk_exists = 0,
|
||||
-- 'ALTER TABLE `#__eis_documents` ADD CONSTRAINT `fk_eis_docs_parent` FOREIGN KEY (`parent_id`) REFERENCES `#__eis_documents`(`id`) ON DELETE CASCADE;',
|
||||
-- 'SELECT 1');
|
||||
-- PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
BIN
com_eis/administrator/src/.DS_Store
vendored
Normal file
BIN
com_eis/administrator/src/.DS_Store
vendored
Normal file
Binary file not shown.
46
com_eis/administrator/src/Controller/ConfigController.php
Normal file
46
com_eis/administrator/src/Controller/ConfigController.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
namespace EIS\Component\EIS\Administrator\Controller;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
class ConfigController extends BaseController
|
||||
{
|
||||
public function save(): void
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
$input = $app->getInput();
|
||||
$db = Factory::getDbo();
|
||||
|
||||
// Eingabe
|
||||
$pdfPath = $input->getString('pdf_path', '');
|
||||
|
||||
// Existiert ein Eintrag?
|
||||
$query = $db->getQuery(true)
|
||||
->select('COUNT(*)')
|
||||
->from($db->quoteName('#__eis_settings'));
|
||||
$db->setQuery($query);
|
||||
$exists = (int) $db->loadResult() > 0;
|
||||
|
||||
if ($exists) {
|
||||
// Update
|
||||
$query = $db->getQuery(true)
|
||||
->update($db->quoteName('#__eis_settings'))
|
||||
->set($db->quoteName('pdf_path') . ' = ' . $db->quote($pdfPath));
|
||||
} else {
|
||||
// Insert
|
||||
$query = $db->getQuery(true)
|
||||
->insert($db->quoteName('#__eis_settings'))
|
||||
->columns([$db->quoteName('pdf_path')])
|
||||
->values($db->quote($pdfPath));
|
||||
}
|
||||
|
||||
$db->setQuery($query)->execute();
|
||||
|
||||
$app->enqueueMessage('Pfad gespeichert: ' . $pdfPath, 'message');
|
||||
$this->setRedirect(Route::_('index.php?option=com_eis&view=config', false));
|
||||
}
|
||||
}
|
||||
141
com_eis/administrator/src/Controller/DisplayController.php
Normal file
141
com_eis/administrator/src/Controller/DisplayController.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
namespace EIS\Component\EIS\Administrator\Controller;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
|
||||
class DisplayController extends BaseController
|
||||
{
|
||||
protected $default_view = 'main';
|
||||
|
||||
/**
|
||||
* Button-Aktion: PDF-Verzeichnis scannen und in Datenbank speichern
|
||||
*/
|
||||
public function scan(): void
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
|
||||
// Pfad aus Tabelle laden
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('pdf_path'))
|
||||
->from($db->quoteName('#__eis_settings'))
|
||||
->order('id ASC')
|
||||
->setLimit(1);
|
||||
|
||||
$db->setQuery($query);
|
||||
$path = $db->loadResult();
|
||||
|
||||
if (!$path || !is_dir($path)) {
|
||||
Factory::getApplication()->enqueueMessage('Pfad ungültig oder nicht gesetzt: ' . $path, 'error');
|
||||
$this->setRedirect('index.php?option=com_eis&view=main');
|
||||
return;
|
||||
}
|
||||
|
||||
// Verzeichnis rekursiv scannen
|
||||
$data = $this->scanFolder($path);
|
||||
|
||||
// Alte Einträge löschen
|
||||
$db->truncateTable('#__eis_documents');
|
||||
|
||||
// In Datenbank speichern
|
||||
$this->saveToDb($data, null, $db);
|
||||
|
||||
// Erfolgsmeldung
|
||||
Factory::getApplication()->enqueueMessage('PDF-Struktur erfolgreich gespeichert.', 'message');
|
||||
$this->setRedirect('index.php?option=com_eis&view=main');
|
||||
}
|
||||
|
||||
/**
|
||||
* Rekursive Verzeichnisanalyse
|
||||
*/
|
||||
private function scanFolder(string $dir): array
|
||||
{
|
||||
$result = [];
|
||||
if (!is_dir($dir)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
foreach (scandir($dir) as $file) {
|
||||
if ($file === '.' || $file === '..') {
|
||||
continue;
|
||||
}
|
||||
$fullPath = $dir . DIRECTORY_SEPARATOR . $file;
|
||||
|
||||
if (is_dir($fullPath)) {
|
||||
$result[] = [
|
||||
'name' => $file,
|
||||
'children' => $this->scanFolder($fullPath)
|
||||
];
|
||||
} elseif (is_file($fullPath) && strtolower(pathinfo($file, PATHINFO_EXTENSION)) === 'pdf') {
|
||||
$result[] = [
|
||||
'name' => $file,
|
||||
'path' => $fullPath
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Struktur rekursiv in die Datenbank schreiben
|
||||
*/
|
||||
private function saveToDb(array $items, ?int $parentId, DatabaseDriver $db): void
|
||||
{
|
||||
foreach ($items as $item) {
|
||||
$name = $db->quote($item['name']);
|
||||
$path = $db->quote($item['path'] ?? ''); // Leerer String statt NULL
|
||||
$parent = $parentId !== null ? (int) $parentId : 'NULL';
|
||||
$isFolder = isset($item['children']) ? 1 : 0;
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->insert($db->quoteName('#__eis_documents'))
|
||||
->columns(['name', 'path', 'parent_id', 'is_folder'])
|
||||
->values("$name, $path, $parent, $isFolder");
|
||||
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
$insertedId = $db->insertid();
|
||||
|
||||
if ($isFolder && !empty($item['children'])) {
|
||||
$this->saveToDb($item['children'], $insertedId, $db);
|
||||
}
|
||||
}
|
||||
}
|
||||
public function rename(): void
|
||||
{
|
||||
// CSRF prüfen
|
||||
\Joomla\CMS\Session\Session::checkToken() or jexit(\JText::_('JINVALID_TOKEN'));
|
||||
|
||||
$app = \Joomla\CMS\Factory::getApplication();
|
||||
$id = (int) $app->input->get('id');
|
||||
$title = trim((string) $app->input->get('title', '', 'STRING'));
|
||||
|
||||
if ($id <= 0) {
|
||||
$app->enqueueMessage('Ungültige ID', 'error');
|
||||
$this->setRedirect('index.php?option=com_eis&view=main');
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var \Joomla\Database\DatabaseDriver $db */
|
||||
$db = \Joomla\CMS\Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->update($db->quoteName('#__eis_documents'))
|
||||
->set($db->quoteName('title') . ' = ' . ($title === '' ? 'NULL' : $db->quote($title)))
|
||||
->where($db->quoteName('id') . ' = ' . (int) $id);
|
||||
|
||||
try {
|
||||
$db->setQuery($query)->execute();
|
||||
$app->enqueueMessage('Anzeigename gespeichert', 'message');
|
||||
} catch (\Throwable $e) {
|
||||
$app->enqueueMessage('Fehler beim Speichern: ' . $e->getMessage(), 'error');
|
||||
}
|
||||
|
||||
$this->setRedirect('index.php?option=com_eis&view=main');
|
||||
}
|
||||
}
|
||||
10
com_eis/administrator/src/Extension/EISComponent.php
Normal file
10
com_eis/administrator/src/Extension/EISComponent.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace EIS\Component\EIS\Administrator\Extension;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Extension\MVCComponent;
|
||||
|
||||
final class EISComponent extends MVCComponent
|
||||
{
|
||||
}
|
||||
112
com_eis/administrator/src/Helper/TreeHelper.php
Normal file
112
com_eis/administrator/src/Helper/TreeHelper.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace EIS\Component\EIS\Administrator\Helper;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
|
||||
class TreeHelper
|
||||
{
|
||||
/** Lädt #__eis_documents, gruppiert nach parent_id und sortiert */
|
||||
public static function getItems(): array
|
||||
{
|
||||
/** @var DatabaseDriver $db */
|
||||
$db = Factory::getDbo();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('*')
|
||||
->from($db->quoteName('#__eis_documents'))
|
||||
->order($db->quoteName('ordering') . ' ASC');
|
||||
|
||||
$rows = $db->setQuery($query)->loadAssocList();
|
||||
|
||||
$grouped = [];
|
||||
foreach ($rows as $row) {
|
||||
$pid = $row['parent_id'] === null ? null : (int) $row['parent_id'];
|
||||
$grouped[$pid][] = $row;
|
||||
}
|
||||
|
||||
// alphabetisch nach name
|
||||
foreach ($grouped as &$group) {
|
||||
usort($group, fn($a, $b) => strcasecmp($a['name'], $b['name']));
|
||||
}
|
||||
|
||||
return $grouped;
|
||||
}
|
||||
|
||||
/** Baum rendern (nutzt title als alternativen Anzeigenamen) */
|
||||
public static function renderTree(array $items, ?int $parentId = null): string
|
||||
{
|
||||
if (!isset($items[$parentId])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$html = '<ul class="pdf-tree">';
|
||||
|
||||
foreach ($items[$parentId] as $item) {
|
||||
$isFolder = (bool) $item['is_folder'];
|
||||
$rawName = $item['title'] ?: $item['name'];
|
||||
$display = preg_replace('/\.pdf$/i', '', (string) $rawName);
|
||||
$display = htmlspecialchars($display, ENT_QUOTES, 'UTF-8');
|
||||
$id = (int) $item['id'];
|
||||
if ($isFolder) {
|
||||
$fileCount = self::countFilesRecursive($items, $id);
|
||||
|
||||
$html .= '<li class="folder"'
|
||||
. ' data-id="' . $id . '"'
|
||||
. ' data-title="' . htmlspecialchars((string)($item['title'] ?? ''), ENT_QUOTES, 'UTF-8') . '"'
|
||||
. ' data-name="' . htmlspecialchars((string)$item['name'], ENT_QUOTES, 'UTF-8') . '"'
|
||||
. '>';
|
||||
$html .= '<span class="toggle" role="button" aria-label="Ordner umschalten" tabindex="0">▶</span> ';
|
||||
$html .= '<span class="folder-label">📁 ' . $display . ' <small class="count">(' . (int)$fileCount . ')</small></span>';
|
||||
$html .= self::renderTree($items, $id);
|
||||
$html .= '</li>';
|
||||
} else {
|
||||
$sizeStr = '';
|
||||
if (!empty($item['path']) && is_file($item['path'])) {
|
||||
$size = @filesize($item['path']);
|
||||
if ($size !== false) {
|
||||
$sizeStr = ' <small class="meta">(' . self::formatFileSize((int) $size) . ')</small>';
|
||||
}
|
||||
}
|
||||
|
||||
$html .= '<li class="file"'
|
||||
. ' data-id="' . $id . '"'
|
||||
. ' data-title="' . htmlspecialchars((string)($item['title'] ?? ''), ENT_QUOTES, 'UTF-8') . '"'
|
||||
. ' data-name="' . htmlspecialchars((string)$item['name'], ENT_QUOTES, 'UTF-8') . '"'
|
||||
. '>';
|
||||
$html .= '<span class="file-label">📄 ' . $display . $sizeStr . '</span>';
|
||||
$html .= '</li>';
|
||||
}
|
||||
}
|
||||
|
||||
$html .= '</ul>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
private static function countFilesRecursive(array $items, int $parentId): int
|
||||
{
|
||||
$count = 0;
|
||||
if (!isset($items[$parentId])) {
|
||||
return 0;
|
||||
}
|
||||
foreach ($items[$parentId] as $item) {
|
||||
if ((bool) $item['is_folder']) {
|
||||
$count += self::countFilesRecursive($items, (int)$item['id']);
|
||||
} else {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
private static function formatFileSize(int $bytes): string
|
||||
{
|
||||
if ($bytes >= 1073741824) return number_format($bytes / 1073741824, 2) . ' GB';
|
||||
if ($bytes >= 1048576) return number_format($bytes / 1048576, 1) . ' MB';
|
||||
if ($bytes >= 1024) return number_format($bytes / 1024, 0) . ' KB';
|
||||
return $bytes . ' B';
|
||||
}
|
||||
}
|
||||
BIN
com_eis/administrator/src/View/.DS_Store
vendored
Normal file
BIN
com_eis/administrator/src/View/.DS_Store
vendored
Normal file
Binary file not shown.
32
com_eis/administrator/src/View/Config/HtmlView.php
Normal file
32
com_eis/administrator/src/View/Config/HtmlView.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace EIS\Component\EIS\Administrator\View\Config;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\CMS\Factory;
|
||||
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
protected $form;
|
||||
protected $item;
|
||||
|
||||
public function display($tpl = null): void
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('*')
|
||||
->from($db->quoteName('#__eis_settings'))
|
||||
->setLimit(1);
|
||||
|
||||
$db->setQuery($query);
|
||||
$this->item = $db->loadAssoc();
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
public function getItem()
|
||||
{
|
||||
return $this->item;
|
||||
}
|
||||
}
|
||||
20
com_eis/administrator/src/View/Main/HtmlView.php
Normal file
20
com_eis/administrator/src/View/Main/HtmlView.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace EIS\Component\EIS\Administrator\View\Main;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use EIS\Component\EIS\Administrator\Helper\TreeHelper;
|
||||
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
public function display($tpl = null): void
|
||||
{
|
||||
// Baumdaten laden und fürs Template bereitstellen
|
||||
$items = TreeHelper::getItems();
|
||||
$this->treeHtml = TreeHelper::renderTree($items);
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
}
|
||||
BIN
com_eis/administrator/tmpl/.DS_Store
vendored
Normal file
BIN
com_eis/administrator/tmpl/.DS_Store
vendored
Normal file
Binary file not shown.
38
com_eis/administrator/tmpl/config/default.php
Normal file
38
com_eis/administrator/tmpl/config/default.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Session\Session;
|
||||
|
||||
$item = $this->getItem();
|
||||
$pdfPath = $item['pdf_path'] ?? '';
|
||||
?>
|
||||
|
||||
<h2><?php echo Text::_('COM_EIS_CONFIG_TITLE'); ?></h2>
|
||||
|
||||
<form action="<?php echo Route::_('index.php?option=com_eis&task=config.save'); ?>" method="post" name="adminForm" id="adminForm">
|
||||
<div class="form-horizontal">
|
||||
<fieldset class="adminform">
|
||||
<legend><?php echo Text::_('COM_EIS_FIELDSET_SETTINGS'); ?></legend>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="pdf_path">
|
||||
<?php echo Text::_('COM_EIS_FIELD_PDF_PATH'); ?>
|
||||
</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="pdf_path" id="pdf_path" value="<?php echo htmlspecialchars($pdfPath, ENT_QUOTES); ?>" size="60" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<?php echo Text::_('JSAVE'); ?>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
</form>
|
||||
234
com_eis/administrator/tmpl/main/default.php
Normal file
234
com_eis/administrator/tmpl/main/default.php
Normal file
@@ -0,0 +1,234 @@
|
||||
<?php
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Language\Text;
|
||||
?>
|
||||
|
||||
<!-- Scan-Formular -->
|
||||
<form action="<?php echo Route::_('index.php?option=com_eis&task=display.scan'); ?>" method="post" name="adminForm" id="adminForm">
|
||||
<div class="form-horizontal">
|
||||
<fieldset class="adminform">
|
||||
<legend><?php echo Text::_('COM_EIS_DOCUMENT_PATH'); ?></legend>
|
||||
<!-- Optional: Hier später Pfad aus Einstellungen anzeigen -->
|
||||
</fieldset>
|
||||
|
||||
<div class="mt-2">
|
||||
<button class="btn btn-primary" type="submit">
|
||||
<?php echo Text::_('COM_EIS_SCAN_DOCUMENTS'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
</form>
|
||||
|
||||
<hr>
|
||||
|
||||
<?php $hasTree = !empty($this->treeHtml); ?>
|
||||
|
||||
<?php if (!$hasTree): ?>
|
||||
<p class="text-muted">
|
||||
<?php echo Text::_('COM_EIS_NO_DOCUMENTS_FOUND') ?: 'Noch keine Dokumente in der Datenbank. Bitte zuerst „Dokumente einlesen“ ausführen.'; ?>
|
||||
</p>
|
||||
<?php else: ?>
|
||||
|
||||
<style>
|
||||
/* Layout */
|
||||
.eis-flex {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.eis-tree-wrap {
|
||||
flex: 1 1 auto;
|
||||
background: #f9f9f9;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 6px;
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
.eis-edit {
|
||||
flex: 0 0 360px;
|
||||
background: #fff;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 6px;
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
.eis-edit h4 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
/* Baum */
|
||||
.pdf-tree {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.pdf-tree ul {
|
||||
list-style: none;
|
||||
margin-left: 1.5em;
|
||||
padding: 0;
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Unterebenen eingeklappt */
|
||||
.pdf-tree li {
|
||||
margin: .3em 0;
|
||||
}
|
||||
|
||||
.folder>.toggle {
|
||||
cursor: pointer;
|
||||
width: 1em;
|
||||
display: inline-block;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.folder>.folder-label,
|
||||
.file>.file-label {
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.pdf-tree .meta {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.pdf-tree .count {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* Steuerleiste */
|
||||
.controls {
|
||||
margin-bottom: .75em;
|
||||
}
|
||||
|
||||
.controls button {
|
||||
margin-right: .5em;
|
||||
}
|
||||
</style>
|
||||
|
||||
<h3 class="mt-3"><?php echo Text::_('COM_EIS_PDF_TREE') ?: 'PDF-Baum'; ?></h3>
|
||||
|
||||
<div class="eis-flex">
|
||||
|
||||
<!-- Linke Seite: Baum -->
|
||||
<div class="eis-tree-wrap">
|
||||
<div class="controls">
|
||||
<button id="eis-expand-all" type="button" class="btn btn-sm btn-secondary">
|
||||
<?php echo Text::_('JGLOBAL_EXPAND_ALL') ?: 'Ausklappen'; ?>
|
||||
</button>
|
||||
<button id="eis-collapse-all" type="button" class="btn btn-sm btn-secondary">
|
||||
<?php echo Text::_('JGLOBAL_COLLAPSE_ALL') ?: 'Einklappen'; ?>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="tree">
|
||||
<?php echo $this->treeHtml; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Rechte Seite: Inline-Bearbeitungsformular -->
|
||||
<div class="eis-edit">
|
||||
<h4><?php echo Text::_('COM_EIS_EDIT_TITLE') ?: 'Anzeigename bearbeiten'; ?></h4>
|
||||
<form action="<?php echo Route::_('index.php?option=com_eis&task=display.rename'); ?>" method="post" id="eis-rename-form">
|
||||
<div class="control-group">
|
||||
<label for="eis-current-name"><?php echo Text::_('COM_EIS_FIELD_NAME') ?: 'Originalname'; ?></label>
|
||||
<input type="text" id="eis-current-name" class="form-control" value="" readonly>
|
||||
</div>
|
||||
|
||||
<div class="control-group" style="margin-top:.5rem;">
|
||||
<label for="eis-title"><?php echo Text::_('COM_EIS_FIELD_TITLE') ?: 'Anzeigename (optional)'; ?></label>
|
||||
<input type="text" name="title" id="eis-title" class="form-control" value="" placeholder="<?php echo Text::_('COM_EIS_PLACEHOLDER_TITLE') ?: 'Leer lassen = automatisch aus Dateiname'; ?>">
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="id" id="eis-id" value="">
|
||||
|
||||
<div style="margin-top:.75rem;">
|
||||
<button type="submit" class="btn btn-success">
|
||||
<?php echo Text::_('JSAVE') ?: 'Speichern'; ?>
|
||||
</button>
|
||||
<button type="button" id="eis-clear-title" class="btn btn-light">
|
||||
<?php echo Text::_('JDEFAULT') ?: 'Zurücksetzen'; ?>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const wrap = document.querySelector('.eis-tree-wrap');
|
||||
const form = document.getElementById('eis-rename-form');
|
||||
const idField = document.getElementById('eis-id');
|
||||
const nameField = document.getElementById('eis-current-name');
|
||||
const titleField = document.getElementById('eis-title');
|
||||
const clearBtn = document.getElementById('eis-clear-title');
|
||||
|
||||
if (!wrap || !form) return;
|
||||
|
||||
// Einzelnes Toggle: Caret ODER Label
|
||||
wrap.addEventListener('click', (e) => {
|
||||
const t = e.target;
|
||||
|
||||
// Toggle (Caret oder Label für Ordner)
|
||||
if (t.classList.contains('toggle') || t.classList.contains('folder-label')) {
|
||||
const li = t.closest('li.folder');
|
||||
if (li) {
|
||||
// direkte Kind-UL finden
|
||||
let childUl = null;
|
||||
for (const el of li.children) {
|
||||
if (el.tagName === 'UL') {
|
||||
childUl = el;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (childUl) {
|
||||
const open = childUl.style.display === 'block';
|
||||
childUl.style.display = open ? 'none' : 'block';
|
||||
const caret = li.querySelector(':scope > .toggle') || li.querySelector('.toggle');
|
||||
if (caret) caret.textContent = open ? '▶' : '▼';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Auswahl fürs Bearbeiten: Klick auf Ordner- oder Datei-Label
|
||||
if (t.classList.contains('folder-label') || t.classList.contains('file-label')) {
|
||||
const li = t.closest('li');
|
||||
if (!li) return;
|
||||
|
||||
const id = li.getAttribute('data-id') || '';
|
||||
const title = li.getAttribute('data-title') || '';
|
||||
const name = li.getAttribute('data-name') || '';
|
||||
|
||||
idField.value = id;
|
||||
nameField.value = name;
|
||||
titleField.value = title;
|
||||
titleField.focus();
|
||||
}
|
||||
});
|
||||
|
||||
// "Zurücksetzen" = Anzeigename löschen (fällt auf Dateiname zurück)
|
||||
clearBtn?.addEventListener('click', () => {
|
||||
titleField.value = '';
|
||||
titleField.focus();
|
||||
});
|
||||
|
||||
// Global: Alle aus-/einklappen
|
||||
document.getElementById('eis-expand-all')?.addEventListener('click', () => {
|
||||
document.querySelectorAll('.pdf-tree ul').forEach(ul => ul.style.display = 'block');
|
||||
document.querySelectorAll('.pdf-tree .toggle').forEach(t => t.textContent = '▼');
|
||||
});
|
||||
document.getElementById('eis-collapse-all')?.addEventListener('click', () => {
|
||||
document.querySelectorAll('.pdf-tree ul').forEach(ul => ul.style.display = 'none');
|
||||
document.querySelectorAll('.pdf-tree .toggle').forEach(t => t.textContent = '▶');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php endif; ?>
|
||||
Reference in New Issue
Block a user