TYPO3 CMS  TYPO3_6-2
LinkViewHelper.php
Go to the documentation of this file.
1 <?php
3 
4 /* *
5  * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
6  * *
7  * It is free software; you can redistribute it and/or modify it under *
8  * the terms of the GNU Lesser General Public License, either version 3 *
9  * of the License, or (at your option) any later version. *
10  * *
11  * *
12  * This script is distributed in the hope that it will be useful, but *
13  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
14  * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
15  * General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU Lesser General Public *
18  * License along with the script. *
19  * If not, see http://www.gnu.org/licenses/lgpl.html *
20  * *
21  * The TYPO3 project - inspiring people to share! *
22  * */
39 
43  protected $tagName = 'a';
44 
51  public function initializeArguments() {
53  $this->registerTagAttribute('name', 'string', 'Specifies the name of an anchor');
54  $this->registerTagAttribute('rel', 'string', 'Specifies the relationship between the current document and the linked document');
55  $this->registerTagAttribute('rev', 'string', 'Specifies the relationship between the linked document and the current document');
56  $this->registerTagAttribute('target', 'string', 'Specifies where to open the linked document');
57  $this->registerArgument('addQueryStringMethod', 'string', 'Method to be used for query string');
58  }
59 
71  public function render($action = NULL, $arguments = array(), $section = '', $format = '', $ajax = FALSE) {
72  if ($ajax === TRUE) {
73  $uri = $this->getAjaxUri();
74  } else {
75  $uri = $this->getWidgetUri();
76  }
77  $this->tag->addAttribute('href', $uri);
78  $this->tag->setContent($this->renderChildren());
79  return $this->tag->render();
80  }
81 
87  protected function getAjaxUri() {
88  $action = $this->arguments['action'];
89  $arguments = $this->arguments['arguments'];
90  if ($action === NULL) {
91  $action = $this->controllerContext->getRequest()->getControllerActionName();
92  }
93  $arguments['id'] = $GLOBALS['TSFE']->id;
94  // TODO page type should be configurable
95  $arguments['type'] = 7076;
96  $arguments['fluid-widget-id'] = $this->controllerContext->getRequest()->getWidgetContext()->getAjaxWidgetIdentifier();
97  $arguments['action'] = $action;
98  return '?' . http_build_query($arguments, NULL, '&');
99  }
100 
106  protected function getWidgetUri() {
107  $uriBuilder = $this->controllerContext->getUriBuilder();
108  $argumentPrefix = $this->controllerContext->getRequest()->getArgumentPrefix();
109  $arguments = $this->hasArgument('arguments') ? $this->arguments['arguments'] : array();
110  if ($this->hasArgument('action')) {
111  $arguments['action'] = $this->arguments['action'];
112  }
113  if ($this->hasArgument('format') && $this->arguments['format'] !== '') {
114  $arguments['format'] = $this->arguments['format'];
115  }
116  return $uriBuilder->reset()
117  ->setArguments(array($argumentPrefix => $arguments))
118  ->setSection($this->arguments['section'])
119  ->setAddQueryString(TRUE)
120  ->setAddQueryStringMethod($this->arguments['addQueryStringMethod'])
121  ->setArgumentsToBeExcludedFromQueryString(array($argumentPrefix, 'cHash'))
122  ->setFormat($this->arguments['format'])
123  ->build();
124  }
125 }
registerTagAttribute($name, $type, $description, $required=FALSE, $default=NULL)
registerArgument($name, $type, $description, $required=FALSE, $defaultValue=NULL)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]