4207[~TASK] Fluid: made action argument optional in Uri/ActionViewHelper. Relates...
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Uri / ActionViewHelper.php
1 <?php
2
3 /* *
4 * This script is part of the TYPO3 project - inspiring people to share! *
5 * *
6 * TYPO3 is free software; you can redistribute it and/or modify it under *
7 * the terms of the GNU General Public License version 2 as published by *
8 * the Free Software Foundation. *
9 * *
10 * This script is distributed in the hope that it will be useful, but *
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
12 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
13 * Public License for more details. *
14 * */
15
16 /**
17 * A view helper for creating URIs to extbase actions.
18 *
19 * = Examples =
20 *
21 * <code title="URI to the show-action of the current controller">
22 * <f:uri.action action="show" />
23 * </code>
24 *
25 * Output:
26 * index.php?id=123&tx_myextension_plugin[action]=show&tx_myextension_plugin[controller]=Standard&cHash=xyz
27 * (depending on the current page and your TS configuration)
28 *
29 * @package Fluid
30 * @subpackage ViewHelpers
31 * @version $Id$
32 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
33 * @scope prototype
34 *
35 * @package
36 * @subpackage
37 * @version $Id$
38 */
39 class Tx_Fluid_ViewHelpers_Uri_ActionViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
40
41 /**
42 * @param string $action Target action
43 * @param array $arguments Arguments
44 * @param string $controller Target controller. If NULL current controllerName is used
45 * @param string $extensionName Target Extension Name (without "tx_" prefix and no underscores). If NULL the current extension name is used
46 * @param string $pluginName Target plugin. If empty, the current plugin name is used
47 * @param integer $page target page. See TypoLink destination
48 * @param integer $pageType type of the target page. See typolink.parameter
49 * @param boolean $noCache set this to disable caching for the target page. You should not need this.
50 * @param boolean $noCacheHash set this to supress the cHash query parameter created by TypoLink. You should not need this.
51 * @param string $section the anchor to be added to the URI
52 * @param string $format The requested format, e.g. ".html"
53 * @param boolean $linkAccessRestrictedPages If set, links pointing to access restricted pages will still link to the page even though the page cannot be accessed.
54 * @param array $additionalParams additional query parameters that won't be prefixed like $arguments (overrule $arguments)
55 * @param boolean $absolute If set, an absolute URI is rendered
56 * @param boolean $addQueryString If set, the current query parameters will be kept in the URI
57 * @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = TRUE
58 * @return string Rendered link
59 * @author Sebastian Kurf├╝rst <sebastian@typo3.org>
60 * @author Bastian Waidelich <bastian@typo3.org>
61 */
62 public function render($action = NULL, array $arguments = array(), $controller = NULL, $extensionName = NULL, $pluginName = NULL, $pageUid = NULL, $pageType = 0, $noCache = FALSE, $noCacheHash = FALSE, $section = '', $format = '', $linkAccessRestrictedPages = FALSE, array $additionalParams = array(), $absolute = FALSE, $addQueryString = FALSE, array $argumentsToBeExcludedFromQueryString = array()) {
63 $uriBuilder = $this->controllerContext->getUriBuilder();
64 $uri = $uriBuilder
65 ->reset()
66 ->setTargetPageUid($pageUid)
67 ->setTargetPageType($pageType)
68 ->setNoCache($noCache)
69 ->setUseCacheHash(!$noCacheHash)
70 ->setSection($section)
71 ->setFormat($format)
72 ->setLinkAccessRestrictedPages($linkAccessRestrictedPages)
73 ->setArguments($additionalParams)
74 ->setCreateAbsoluteUri($absolute)
75 ->setAddQueryString($addQueryString)
76 ->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString)
77 ->uriFor($action, $arguments, $controller, $extensionName, $pluginName);
78
79 return $uri;
80 }
81 }
82 ?>