|
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 TYPO3 pages. 00018 * 00019 * = Examples = 00020 * 00021 * <code title="link to the current page"> 00022 * <f:link.page>page link</f:link.page> 00023 * </code> 00024 * <output> 00025 * <a href="index.php?id=123">page link</f:link.action> 00026 * (depending on the current page and your TS configuration) 00027 * </output> 00028 * 00029 * <code title="query parameters"> 00030 * <f:link.page pageUid="1" additionalParams="{foo: 'bar'}">page link</f:link.page> 00031 * </code> 00032 * <output> 00033 * <a href="index.php?id=1&foo=bar">page link</f:link.action> 00034 * (depending on your TS configuration) 00035 * </output> 00036 * 00037 * <code title="query parameters for extensions"> 00038 * <f:link.page pageUid="1" additionalParams="{extension_key: {foo: 'bar'}}">page link</f:link.page> 00039 * </code> 00040 * <output> 00041 * <a href="index.php?id=1&extension_key[foo]=bar">page link</f:link.action> 00042 * (depending on your TS configuration) 00043 * </output> 00044 * 00045 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later 00046 */ 00047 class Tx_Fluid_ViewHelpers_Link_PageViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractTagBasedViewHelper { 00048 00049 /** 00050 * @var string 00051 */ 00052 protected $tagName = 'a'; 00053 00054 /** 00055 * Arguments initialization 00056 * 00057 * @return void 00058 * @author Sebastian Kurfürst <sebastian@typo3.org> 00059 */ 00060 public function initializeArguments() { 00061 $this->registerUniversalTagAttributes(); 00062 $this->registerTagAttribute('target', 'string', 'Target of link', FALSE); 00063 $this->registerTagAttribute('rel', 'string', 'Specifies the relationship between the current document and the linked document', FALSE); 00064 } 00065 00066 /** 00067 * @param integer $page target page. See TypoLink destination 00068 * @param array $additionalParams query parameters to be attached to the resulting URI 00069 * @param integer $pageType type of the target page. See typolink.parameter 00070 * @param boolean $noCache set this to disable caching for the target page. You should not need this. 00071 * @param boolean $noCacheHash set this to supress the cHash query parameter created by TypoLink. You should not need this. 00072 * @param string $section the anchor to be added to the URI 00073 * @param boolean $linkAccessRestrictedPages If set, links pointing to access restricted pages will still link to the page even though the page cannot be accessed. 00074 * @param boolean $absolute If set, the URI of the rendered link is absolute 00075 * @param boolean $addQueryString If set, the current query parameters will be kept in the URI 00076 * @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = TRUE 00077 * @return string Rendered page URI 00078 * @author Bastian Waidelich <bastian@typo3.org> 00079 */ 00080 public function render($pageUid = NULL, array $additionalParams = array(), $pageType = 0, $noCache = FALSE, $noCacheHash = FALSE, $section = '', $linkAccessRestrictedPages = FALSE, $absolute = FALSE, $addQueryString = FALSE, array $argumentsToBeExcludedFromQueryString = array()) { 00081 $uriBuilder = $this->controllerContext->getUriBuilder(); 00082 $uri = $uriBuilder 00083 ->reset() 00084 ->setTargetPageUid($pageUid) 00085 ->setTargetPageType($pageType) 00086 ->setNoCache($noCache) 00087 ->setUseCacheHash(!$noCacheHash) 00088 ->setSection($section) 00089 ->setLinkAccessRestrictedPages($linkAccessRestrictedPages) 00090 ->setArguments($additionalParams) 00091 ->setCreateAbsoluteUri($absolute) 00092 ->setAddQueryString($addQueryString) 00093 ->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString) 00094 ->build(); 00095 00096 $this->tag->addAttribute('href', $uri); 00097 $this->tag->setContent($this->renderChildren()); 00098 00099 return $this->tag->render(); 00100 } 00101 } 00102 00103 00104 ?>
1.8.0