[CLEANUP] The correct case must be used for standard PHP types in phpdoc
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Link / PageViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Fluid\ViewHelpers\Link;
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 view helper for creating links to TYPO3 pages.
19 *
20 * = Examples =
21 *
22 * <code title="link to the current page">
23 * <f:link.page>page link</f:link.page>
24 * </code>
25 * <output>
26 * <a href="index.php?id=123">page link</f:link.action>
27 * (depending on the current page and your TS configuration)
28 * </output>
29 *
30 * <code title="query parameters">
31 * <f:link.page pageUid="1" additionalParams="{foo: 'bar'}">page link</f:link.page>
32 * </code>
33 * <output>
34 * <a href="index.php?id=1&foo=bar">page link</f:link.action>
35 * (depending on your TS configuration)
36 * </output>
37 *
38 * <code title="query parameters for extensions">
39 * <f:link.page pageUid="1" additionalParams="{extension_key: {foo: 'bar'}}">page link</f:link.page>
40 * </code>
41 * <output>
42 * <a href="index.php?id=1&extension_key[foo]=bar">page link</f:link.action>
43 * (depending on your TS configuration)
44 * </output>
45 */
46 class PageViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper
47 {
48 /**
49 * @var string
50 */
51 protected $tagName = 'a';
52
53 /**
54 * Arguments initialization
55 */
56 public function initializeArguments()
57 {
58 parent::initializeArguments();
59 $this->registerUniversalTagAttributes();
60 $this->registerTagAttribute('target', 'string', 'Target of link', false);
61 $this->registerTagAttribute('rel', 'string', 'Specifies the relationship between the current document and the linked document', false);
62 }
63
64 /**
65 * @param int|null $pageUid target page. See TypoLink destination
66 * @param array $additionalParams query parameters to be attached to the resulting URI
67 * @param int $pageType type of the target page. See typolink.parameter
68 * @param bool $noCache set this to disable caching for the target page. You should not need this.
69 * @param bool $noCacheHash set this to suppress the cHash query parameter created by TypoLink. You should not need this.
70 * @param string $section the anchor to be added to the URI
71 * @param bool $linkAccessRestrictedPages If set, links pointing to access restricted pages will still link to the page even though the page cannot be accessed.
72 * @param bool $absolute If set, the URI of the rendered link is absolute
73 * @param bool $addQueryString If set, the current query parameters will be kept in the URI
74 * @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = TRUE
75 * @param string $addQueryStringMethod Set which parameters will be kept. Only active if $addQueryString = TRUE
76 * @return string Rendered page URI
77 */
78 public function render($pageUid = null, array $additionalParams = [], $pageType = 0, $noCache = false, $noCacheHash = false, $section = '', $linkAccessRestrictedPages = false, $absolute = false, $addQueryString = false, array $argumentsToBeExcludedFromQueryString = [], $addQueryStringMethod = null)
79 {
80 $uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder();
81 $uri = $uriBuilder->reset()
82 ->setTargetPageUid($pageUid)
83 ->setTargetPageType($pageType)
84 ->setNoCache($noCache)
85 ->setUseCacheHash(!$noCacheHash)
86 ->setSection($section)
87 ->setLinkAccessRestrictedPages($linkAccessRestrictedPages)
88 ->setArguments($additionalParams)
89 ->setCreateAbsoluteUri($absolute)
90 ->setAddQueryString($addQueryString)
91 ->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString)
92 ->setAddQueryStringMethod($addQueryStringMethod)
93 ->build();
94 if ((string)$uri !== '') {
95 $this->tag->addAttribute('href', $uri);
96 $this->tag->setContent($this->renderChildren());
97 $result = $this->tag->render();
98 } else {
99 $result = $this->renderChildren();
100 }
101 return $result;
102 }
103 }