1
|
|
|
<?php |
2
|
|
|
namespace DERHANSEN\SfEventMgt\ViewHelpers\Uri; |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
* This file is part of the TYPO3 CMS project. |
6
|
|
|
* |
7
|
|
|
* It is free software; you can redistribute it and/or modify it under |
8
|
|
|
* the terms of the GNU General Public License, either version 2 |
9
|
|
|
* of the License, or any later version. |
10
|
|
|
* |
11
|
|
|
* For the full copyright and license information, please read the |
12
|
|
|
* LICENSE.txt file that was distributed with this source code. |
13
|
|
|
* |
14
|
|
|
* The TYPO3 project - inspiring people to share! |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* A viewhelper with the same functionality as the f:uri.page viewhelper, |
19
|
|
|
* but this viewhelper builds frontend links with buildFrontendUri, so links |
20
|
|
|
* to FE pages can get generated in the TYPO3 backend |
21
|
|
|
* |
22
|
|
|
* @author Torben Hansen <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
class PageViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper |
25
|
|
|
{ |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Creates a TSFE object which can be used in Backend |
29
|
|
|
* |
30
|
|
|
* @return void |
31
|
|
|
*/ |
32
|
|
|
protected function buildTsfe() |
33
|
|
|
{ |
34
|
|
|
if (!is_object($GLOBALS['TT'])) { |
35
|
|
|
$GLOBALS['TT'] = $this->getTimeTrackerInstance(); |
36
|
|
|
$GLOBALS['TT']->start(); |
37
|
|
|
} |
38
|
|
|
$GLOBALS['TSFE'] = $this->getTsfeInstance(); |
39
|
|
|
$GLOBALS['TSFE']->initFEuser(); |
40
|
|
|
$GLOBALS['TSFE']->fetch_the_id(); |
41
|
|
|
$GLOBALS['TSFE']->getPageAndRootline(); |
42
|
|
|
$GLOBALS['TSFE']->initTemplate(); |
43
|
|
|
$GLOBALS['TSFE']->getConfigArray(); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Returns a new instance of the TypoScriptFrontendController |
48
|
|
|
* |
49
|
|
|
* @return object |
50
|
|
|
*/ |
51
|
|
|
protected function getTsfeInstance() |
52
|
|
|
{ |
53
|
|
|
$tsfeClassname = 'TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController'; |
54
|
|
|
return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($tsfeClassname, |
55
|
|
|
$GLOBALS['TYPO3_CONF_VARS'], $this->pid, '0', 1, '', '', '', ''); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Returns a new instance of TimeTracker |
60
|
|
|
* |
61
|
|
|
* @return object |
62
|
|
|
*/ |
63
|
|
|
protected function getTimeTrackerInstance() |
64
|
|
|
{ |
65
|
|
|
return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TimeTracker\\TimeTracker'); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param integer|NULL $pageUid target PID |
70
|
|
|
* @param array $additionalParams query parameters to be attached to the resulting URI |
71
|
|
|
* @param integer $pageType type of the target page. See typolink.parameter |
72
|
|
|
* @param boolean $noCache set this to disable caching for the target page. You should not need this. |
73
|
|
|
* @param boolean $noCacheHash set this to supress the cHash query parameter created by TypoLink. You should not need this. |
74
|
|
|
* @param string $section the anchor to be added to the URI |
75
|
|
|
* @param boolean $linkAccessRestrictedPages If set, links pointing to access restricted pages will still link to the page even though the page cannot be accessed. |
76
|
|
|
* @param boolean $absolute If set, the URI of the rendered link is absolute |
77
|
|
|
* @param boolean $addQueryString If set, the current query parameters will be kept in the URI |
78
|
|
|
* @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = TRUE |
79
|
|
|
* @param string $addQueryStringMethod Set which parameters will be kept. Only active if $addQueryString = TRUE |
80
|
|
|
* @return string Rendered page URI |
81
|
|
|
*/ |
82
|
|
|
public function render( |
83
|
|
|
$pageUid = null, |
84
|
|
|
array $additionalParams = [], |
85
|
|
|
$pageType = 0, |
86
|
|
|
$noCache = false, |
87
|
|
|
$noCacheHash = false, |
88
|
|
|
$section = '', |
89
|
|
|
$linkAccessRestrictedPages = false, |
90
|
|
|
$absolute = false, |
91
|
|
|
$addQueryString = false, |
92
|
|
|
array $argumentsToBeExcludedFromQueryString = [], |
93
|
|
|
$addQueryStringMethod = null |
94
|
|
|
) { |
95
|
|
|
$this->buildTsfe(); |
96
|
|
|
$uriBuilder = $this->controllerContext->getUriBuilder(); |
97
|
|
|
$uri = $uriBuilder->setTargetPageUid($pageUid)->setTargetPageType($pageType)->setNoCache($noCache)->setUseCacheHash(!$noCacheHash)->setSection($section)->setLinkAccessRestrictedPages($linkAccessRestrictedPages)->setArguments($additionalParams)->setCreateAbsoluteUri($absolute)->setAddQueryString($addQueryString)->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString)->setAddQueryStringMethod($addQueryStringMethod)->buildFrontendUri(); |
98
|
|
|
return $uri; |
99
|
|
|
} |
100
|
|
|
} |