|
1
|
|
|
<?php |
|
2
|
|
|
namespace DERHANSEN\SfEventMgt\ViewHelpers; |
|
3
|
|
|
|
|
4
|
|
|
/* |
|
5
|
|
|
* This file is part of the Extension "sf_event_mgt" for TYPO3 CMS. |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please read the |
|
8
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface; |
|
12
|
|
|
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper; |
|
13
|
|
|
use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface; |
|
14
|
|
|
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* ViewHelper to render the page title and indexed search title |
|
18
|
|
|
*/ |
|
19
|
|
|
class TitleViewHelper extends AbstractViewHelper implements CompilableInterface |
|
20
|
|
|
{ |
|
21
|
|
|
use CompileWithRenderStatic; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Initialize arguments |
|
25
|
|
|
*/ |
|
26
|
|
|
public function initializeArguments() |
|
27
|
|
|
{ |
|
28
|
|
|
parent::initializeArguments(); |
|
29
|
|
|
$this->registerArgument('pageTitle', 'String', 'The page title'); |
|
30
|
|
|
$this->registerArgument( |
|
31
|
|
|
'indexedDocTitle', |
|
32
|
|
|
'string', |
|
33
|
|
|
'The title for the event in indexed search result', |
|
34
|
|
|
false |
|
35
|
|
|
); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param array $arguments |
|
40
|
|
|
* @param \Closure $renderChildrenClosure |
|
41
|
|
|
* @param RenderingContextInterface $renderingContext |
|
42
|
|
|
*/ |
|
43
|
|
|
public static function renderStatic( |
|
44
|
|
|
array $arguments, |
|
45
|
|
|
\Closure $renderChildrenClosure, |
|
46
|
|
|
RenderingContextInterface $renderingContext |
|
47
|
|
|
) { |
|
48
|
|
|
$pageTitle = isset($arguments['pageTitle']) ? $arguments['pageTitle'] : ''; |
|
49
|
|
|
$indexedDocTitle = isset($arguments['indexedDocTitle']) ? $arguments['indexedDocTitle'] : $pageTitle; |
|
50
|
|
|
if ($pageTitle !== '') { |
|
51
|
|
|
$GLOBALS['TSFE']->altPageTitle = $pageTitle; |
|
52
|
|
|
} |
|
53
|
|
|
if ($indexedDocTitle !== '') { |
|
54
|
|
|
$GLOBALS['TSFE']->indexedDocTitle = $indexedDocTitle; |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|