|
TYPO3 API
SVNRelease
|
00001 <?php 00002 00003 /* * 00004 * This script is part of the TYPO3 project - inspiring people to share! * 00005 * * 00006 * TYPO3 is free software; you can redistribute it and/or modify it under * 00007 * the terms of the GNU General Public License version 2 as published by * 00008 * the Free Software Foundation. * 00009 * * 00010 * This script is distributed in the hope that it will be useful, but * 00011 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * 00012 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * 00013 * Public License for more details. * 00014 * */ 00015 00016 /** 00017 * A view helper for creating links to extbase actions. 00018 * 00019 * = Examples = 00020 * 00021 * <code title="link to the show-action of the current controller"> 00022 * <f:link.action action="show">action link</f:link.action> 00023 * </code> 00024 * <output> 00025 * <a href="index.php?id=123&tx_myextension_plugin[action]=show&tx_myextension_plugin[controller]=Standard&cHash=xyz">action link</f:link.action> 00026 * (depending on the current page and your TS configuration) 00027 * </output> 00028 * 00029 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later 00030 */ 00031 class Tx_Fluid_ViewHelpers_Link_ActionViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractTagBasedViewHelper { 00032 00033 /** 00034 * @var string 00035 */ 00036 protected $tagName = 'a'; 00037 00038 /** 00039 * Arguments initialization 00040 * 00041 * @return void 00042 * @author Bastian Waidelich <bastian@typo3.org> 00043 */ 00044 public function initializeArguments() { 00045 $this->registerUniversalTagAttributes(); 00046 $this->registerTagAttribute('name', 'string', 'Specifies the name of an anchor'); 00047 $this->registerTagAttribute('rel', 'string', 'Specifies the relationship between the current document and the linked document'); 00048 $this->registerTagAttribute('rev', 'string', 'Specifies the relationship between the linked document and the current document'); 00049 $this->registerTagAttribute('target', 'string', 'Specifies where to open the linked document'); 00050 } 00051 00052 /** 00053 * @param string $action Target action 00054 * @param array $arguments Arguments 00055 * @param string $controller Target controller. If NULL current controllerName is used 00056 * @param string $extensionName Target Extension Name (without "tx_" prefix and no underscores). If NULL the current extension name is used 00057 * @param string $pluginName Target plugin. If empty, the current plugin name is used 00058 * @param integer $pageUid target page. See TypoLink destination 00059 * @param integer $pageType type of the target page. See typolink.parameter 00060 * @param boolean $noCache set this to disable caching for the target page. You should not need this. 00061 * @param boolean $noCacheHash set this to supress the cHash query parameter created by TypoLink. You should not need this. 00062 * @param string $section the anchor to be added to the URI 00063 * @param string $format The requested format, e.g. ".html" 00064 * @param boolean $linkAccessRestrictedPages If set, links pointing to access restricted pages will still link to the page even though the page cannot be accessed. 00065 * @param array $additionalParams additional query parameters that won't be prefixed like $arguments (overrule $arguments) 00066 * @param boolean $absolute If set, the URI of the rendered link is absolute 00067 * @param boolean $addQueryString If set, the current query parameters will be kept in the URI 00068 * @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = TRUE 00069 * @return string Rendered link 00070 * @author Sebastian Kurfürst <sebastian@typo3.org> 00071 * @author Bastian Waidelich <bastian@typo3.org> 00072 */ 00073 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()) { 00074 $uriBuilder = $this->controllerContext->getUriBuilder(); 00075 $uri = $uriBuilder 00076 ->reset() 00077 ->setTargetPageUid($pageUid) 00078 ->setTargetPageType($pageType) 00079 ->setNoCache($noCache) 00080 ->setUseCacheHash(!$noCacheHash) 00081 ->setSection($section) 00082 ->setFormat($format) 00083 ->setLinkAccessRestrictedPages($linkAccessRestrictedPages) 00084 ->setArguments($additionalParams) 00085 ->setCreateAbsoluteUri($absolute) 00086 ->setAddQueryString($addQueryString) 00087 ->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString) 00088 ->uriFor($action, $arguments, $controller, $extensionName, $pluginName); 00089 00090 $this->tag->addAttribute('href', $uri); 00091 $this->tag->setContent($this->renderChildren()); 00092 00093 return $this->tag->render(); 00094 } 00095 } 00096 ?>
1.8.0