diff --git a/Classes/Controller/DocModuleController.php b/Classes/Controller/DocModuleController.php index 095c244..bb7846d 100644 --- a/Classes/Controller/DocModuleController.php +++ b/Classes/Controller/DocModuleController.php @@ -8,11 +8,7 @@ use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; use TYPO3\CMS\Core\Http\HtmlResponse; -use TYPO3\CMS\Core\Information\Typo3Version; -use TYPO3\CMS\Core\Page\JavaScriptModuleInstruction; -use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Core\Utility\PathUtility; use TYPO3\CMS\Extbase\Mvc\Controller\ControllerInterface; use TYPO3\CMS\Extbase\Mvc\RequestInterface; use TYPO3\CMS\Fluid\View\StandaloneView; @@ -59,7 +55,7 @@ private function getStandaloneView(): StandaloneView $view = GeneralUtility::makeInstance(StandaloneView::class); $view->setTemplatePathAndFilename($templatePathAndFilename); $view->assignMultiple([ - 'docRootPath' => $uri, + 'docRootPath' => $uri->__toString(), 'documentationName' => $documentationName, 'darkMode' => $settings['darkMode'] ?? false ]); diff --git a/Classes/Controller/DocServeController.php b/Classes/Controller/DocServeController.php index d14b762..9dc1a39 100644 --- a/Classes/Controller/DocServeController.php +++ b/Classes/Controller/DocServeController.php @@ -66,16 +66,22 @@ public function mainAction(ServerRequestInterface $request): ResponseInterface private function getFile(string $path): string { $path = PathUtility::getCanonicalPath($path); - if (!StringUtility::beginsWith($path, $this->extensionConfiguration['documentationRootPath'] ?? '')) { + if (!str_starts_with($path, $this->extensionConfiguration['documentationRootPath'] ?? '')) { return ''; } + $fileInfo = pathinfo($path); if (!in_array(strtolower($fileInfo['extension']), ['png', 'svg', 'gif', 'md', 'doc', 'docx', 'jpeg', 'jpg'], true)) { return ''; } - $file = Environment::getPublicPath() . $path; + if (\str_starts_with($path, 'EXT:')) { + $file = GeneralUtility::getFileAbsFileName($path); + } else { + $file = Environment::getPublicPath() . $path; + } + if (!is_file($file)) { return ''; } diff --git a/Classes/Widgets/CtaWidget.php b/Classes/Widgets/CtaWidget.php new file mode 100644 index 0000000..1d24f4c --- /dev/null +++ b/Classes/Widgets/CtaWidget.php @@ -0,0 +1,19 @@ +services(); if ($containerBuilder->hasDefinition(Dashboard::class)) { - $services->set('dashboard.widget.gotoProjectDocumentation') - ->class(CtaWidget::class) - ->arg('$view', new Reference('dashboard.views.widget')) - ->arg('$buttonProvider', new Reference(ExtDocButtonProvider::class)) - ->arg('$options', ['text' => 'LLL:EXT:doc/Resources/Private/Language/locallang.xlf:widget.text']) - ->tag('dashboard.widget', [ - 'identifier' => 'gotoProjectDocumentation', - 'groupNames' => 'documentation', - 'title' => 'LLL:EXT:doc/Resources/Private/Language/locallang.xlf:widget.title', - 'description' => 'LLL:EXT:doc/Resources/Private/Language/locallang.xlf:widget.description', - 'iconIdentifier' => 'content-widget-text', - 'height' => 'small' - ]) - ; + $services->set('dashboard.widget.gotoProjectDocumentation')->class(CtaWidget::class) + ->autoconfigure() + ->autowire() + ->arg('$buttonProvider', new Reference(ExtDocButtonProvider::class)) + ->arg('$options', ['text' => 'LLL:EXT:doc/Resources/Private/Language/locallang.xlf:widget.text']) + ->tag('dashboard.widget', [ + 'identifier' => 'gotoProjectDocumentation', + 'groupNames' => 'documentation', + 'title' => 'LLL:EXT:doc/Resources/Private/Language/locallang.xlf:widget.title', + 'description' => 'LLL:EXT:doc/Resources/Private/Language/locallang.xlf:widget.description', + 'iconIdentifier' => 'content-widget-text', + 'height' => 'small' + ]); + $services->set('GeorgRinger\Doc\Widgets\Provider\ExtDocButtonProvider') ->arg('$title', 'LLL:EXT:doc/Resources/Private/Language/locallang.xlf:widget.buttonText') diff --git a/Resources/Private/Templates/Module.html b/Resources/Private/Templates/Module.html index 66b5845..2079a3b 100644 --- a/Resources/Private/Templates/Module.html +++ b/Resources/Private/Templates/Module.html @@ -25,8 +25,9 @@
- diff --git a/Resources/Public/JavaScript/widget-cta.js b/Resources/Public/JavaScript/widget-cta.js new file mode 100644 index 0000000..c16e715 --- /dev/null +++ b/Resources/Public/JavaScript/widget-cta.js @@ -0,0 +1,11 @@ +document.addEventListener('DOMContentLoaded', function () { + setTimeout(() => { + document.querySelectorAll('.widget-cta[href="open-docs-module"]').forEach(element => { + element.addEventListener('click', function (event) { + event.preventDefault(); + var TYPO3 = TYPO3 || top.TYPO3; + TYPO3.ModuleMenu.App.showModule('help_doc'); + }); + }); + }, 750); +}); \ No newline at end of file diff --git a/composer.json b/composer.json index eb4c236..2c4f216 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "georgringer/doc", "type": "typo3-cms-extension", "description": "Render documentation based on markdown files directly in the backend", - "version": "2.0.0", + "version": "3.0.0", "keywords": [ "TYPO3", "documentation", @@ -19,7 +19,7 @@ "GPL-2.0-or-later" ], "require": { - "typo3/cms-core": "^9 || ^10 || ^11 || ^12" + "typo3/cms-core": "^13" }, "autoload": { "psr-4": { diff --git a/ext_emconf.php b/ext_emconf.php index c5ccbde..490bb9f 100755 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -4,13 +4,13 @@ 'title' => 'Markdown docs for everybody', 'description' => 'Render documentation based on markdown files directly in the backend', 'category' => 'be', - 'version' => '1.1.1', + 'version' => '3.0.0', 'state' => 'beta', 'author' => 'Georg Ringer', 'author_email' => 'mail@ringer.it', 'constraints' => [ 'depends' => [ - 'typo3' => '9.5.9-11.6.99', + 'typo3' => '13.0.0-13.4.99', ], 'conflicts' => [], 'suggests' => [] diff --git a/ext_tables.php b/ext_tables.php deleted file mode 100644 index dc91489..0000000 --- a/ext_tables.php +++ /dev/null @@ -1,15 +0,0 @@ - \GeorgRinger\Doc\Controller\DocModuleController::class . '::mainAction', - 'access' => 'group,user', - 'name' => 'help_doc', - 'icon' => 'EXT:doc/Resources/Public/Icons/module-doc.svg', - 'labels' => 'LLL:EXT:doc/Resources/Private/Language/locallang_mod.xlf' - ] -);