Skip to content

Commit

Permalink
[FEATURE] Add dashboard widget for quick access of the project docume…
Browse files Browse the repository at this point in the history
…ntation
  • Loading branch information
georgringer authored Jan 25, 2021
2 parents 42e996e + 5bebf78 commit 49a6620
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 0 deletions.
51 changes: 51 additions & 0 deletions Classes/Widgets/Provider/ExtDocButtonProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);

namespace GeorgRinger\Doc\Widgets\Provider;

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Dashboard\Widgets\ButtonProviderInterface;

/**
* Provide link for project documentation.
* Check whether EXT:doc is enabled and add link to module.
* No link is returned if not enabled.
*/
class ExtDocButtonProvider implements ButtonProviderInterface
{
/**
* @var string
*/
private $title;

/**
* @var string
*/
private $target;

public function __construct(string $title, string $target = '')
{
$this->title = $title;
$this->target = $target;
}

public function getTitle(): string
{
return $this->title;
}

public function getLink(): string
{
if (ExtensionManagementUtility::isLoaded('doc')) {
return 'javascript:top.goToModule(' . GeneralUtility::quoteJSvalue('help_doc') . ');';
}

return '';
}

public function getTarget(): string
{
return $this->target;
}
}
35 changes: 35 additions & 0 deletions Configuration/Services.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);

namespace GeorgRinger\Doc;

use GeorgRinger\Doc\Widgets\Provider\ExtDocButtonProvider;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\DependencyInjection\Reference;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Dashboard\Widgets\CtaWidget;

return function (ContainerConfigurator $configurator) {
$services = $configurator->services();

if (ExtensionManagementUtility::isLoaded('dashboard')) {
$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('GeorgRinger\Doc\Widgets\Provider\ExtDocButtonProvider')
->arg('$title', 'LLL:EXT:doc/Resources/Private/Language/locallang.xlf:widget.buttonText')
;
}
};
20 changes: 20 additions & 0 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff">
<file t3:id="1609228987" source-language="en" datatype="plaintext" original="EXT:doc/Resources/Private/Language/locallang.xlf" product-name="doc">
<header/>
<body>
<trans-unit id="widget.title" resname="widget.title">
<source>Project Documentation</source>
</trans-unit>
<trans-unit id="widget.description" resname="widget.description">
<source>Add a shortcut to the project documentation.</source>
</trans-unit>
<trans-unit id="widget.text" resname="widget.text">
<source>The project documentation is the first place to go for all questions about this TYPO3 installation.</source>
</trans-unit>
<trans-unit id="widget.buttonText" resname="widget.buttonText">
<source>Show Project Documentation</source>
</trans-unit>
</body>
</file>
</xliff>

0 comments on commit 49a6620

Please sign in to comment.