|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* (c) Kitodo. Key to digital objects e.V. <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* This file is part of the Kitodo and TYPO3 projects. |
|
6
|
|
|
* |
|
7
|
|
|
* @license GNU General Public License version 3 or later. |
|
8
|
|
|
* For the full copyright and license information, please read the |
|
9
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Kitodo\Dlf\ViewHelpers; |
|
13
|
|
|
|
|
14
|
|
|
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; |
|
15
|
|
|
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; |
|
16
|
|
|
use TYPO3\CMS\Core\Page\PageRenderer; |
|
17
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Add inline JavaScript code to footer * |
|
21
|
|
|
*/ |
|
22
|
|
|
class JsFooterViewHelper extends AbstractViewHelper |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* Initialize arguments. |
|
26
|
|
|
*/ |
|
27
|
|
|
public function initializeArguments() |
|
28
|
|
|
{ |
|
29
|
|
|
parent::initializeArguments(); |
|
30
|
|
|
$this->registerArgument('inlineCode', 'string', 'Inline JavaScript', true); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* |
|
35
|
|
|
* @param array $arguments |
|
36
|
|
|
* @param \Closure $renderChildrenClosure |
|
37
|
|
|
* @param RenderingContextInterface $renderingContext |
|
38
|
|
|
*/ |
|
39
|
|
|
public static function renderStatic( |
|
40
|
|
|
array $arguments, |
|
41
|
|
|
\Closure $renderChildrenClosure, |
|
42
|
|
|
RenderingContextInterface $renderingContext |
|
43
|
|
|
) { |
|
44
|
|
|
$inlineCode = $arguments['inlineCode']; |
|
45
|
|
|
|
|
46
|
|
|
/** @var $pageRenderer PageRenderer */ |
|
47
|
|
|
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); |
|
48
|
|
|
$pageRenderer->addJsFooterInlineCode('js-dlf-inline-footer', $inlineCode); |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|