Letzte Version
This commit is contained in:
Binary file not shown.
@@ -5,17 +5,23 @@
|
||||
<file driver="mysql" charset="utf8">install/sql/mysql/install.utf8.sql</file>
|
||||
</sql>
|
||||
</install>
|
||||
<uninstall>
|
||||
<sql>
|
||||
<file driver="mysql" charset="utf8">install/sql/mysql/uninstall.mysql.utf8.sql</file>
|
||||
</sql>
|
||||
</uninstall>
|
||||
<uninstall>
|
||||
<sql>
|
||||
<file driver="mysql" charset="utf8">install/sql/mysql/uninstall.mysql.utf8.sql</file>
|
||||
</sql>
|
||||
</uninstall>
|
||||
<name>com_eis</name>
|
||||
<creationDate>2025-07-23</creationDate>
|
||||
<author>Thomas Spohr powert by OpenAI</author>
|
||||
<version>1.0.0</version>
|
||||
<description>EIS Minimal-Komponente</description>
|
||||
<namespace path="src">EIS\Component\EIS</namespace>
|
||||
|
||||
<files folder="site">
|
||||
<folder>src</folder>
|
||||
</files>
|
||||
|
||||
|
||||
<administration>
|
||||
<menu>COM_EIS_MENU</menu>
|
||||
<submenu>
|
||||
|
||||
BIN
com_eis/eis.zip
Normal file
BIN
com_eis/eis.zip
Normal file
Binary file not shown.
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace EIS\Component\EIS;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
@@ -11,15 +12,24 @@ 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'));
|
||||
|
||||
// DownloadController explizit registrieren
|
||||
$container->set(
|
||||
DownloadController::class,
|
||||
fn(Container $c) => new DownloadController()
|
||||
);
|
||||
|
||||
// Komponentenschnittstelle
|
||||
$container->set(
|
||||
ComponentInterface::class,
|
||||
static fn(Container $c) => new MVCComponent(
|
||||
|
||||
62
com_eis/site/src/Controller/DownloadController.php
Normal file
62
com_eis/site/src/Controller/DownloadController.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace EIS\Component\EIS\Site\Controller;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
|
||||
class DownloadController extends BaseController
|
||||
{
|
||||
public function download()
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
$user = Factory::getUser();
|
||||
$input = $app->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;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user