TYPO3 CMS  TYPO3_8-7
UriViewHelper.php
Go to the documentation of this file.
1 <?php
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 
33 {
39  public function initializeArguments()
40  {
41  parent::initializeArguments();
42  $this->registerArgument('useCacheHash', 'bool', 'True whether the cache hash should be appended to the URL', false, true);
43  $this->registerArgument('addQueryStringMethod', 'string', 'Method to be used for query string');
44  $this->registerArgument('action', 'string', 'Target action');
45  $this->registerArgument('arguments', 'array', 'Arguments', false, []);
46  $this->registerArgument('section', 'string', 'The anchor to be added to the URI', false, '');
47  $this->registerArgument('format', 'string', 'The requested format, e.g. ".html', false, '');
48  $this->registerArgument('ajax', 'bool', 'TRUE if the URI should be to an AJAX widget, FALSE otherwise.', false, false);
49  }
50 
57  public function render()
58  {
59  $ajax = $this->arguments['ajax'];
60 
61  if ($ajax === true) {
62  return $this->getAjaxUri();
63  }
64  return $this->getWidgetUri();
65 
66  return static::getWidgetUri($renderingContext, $arguments);
67  }
68 
74  protected function getAjaxUri()
75  {
76  $action = $this->arguments['action'];
77  $arguments = $this->arguments['arguments'];
78  if ($action === null) {
79  $action = $this->controllerContext->getRequest()->getControllerActionName();
80  }
81  $arguments['id'] = $GLOBALS['TSFE']->id;
82  // @todo page type should be configurable
83  $arguments['type'] = 7076;
84  $arguments['fluid-widget-id'] = $this->controllerContext->getRequest()->getWidgetContext()->getAjaxWidgetIdentifier();
85  $arguments['action'] = $action;
86  return '?' . http_build_query($arguments, null, '&');
87  }
88 
94  protected function getWidgetUri()
95  {
96  $uriBuilder = $this->controllerContext->getUriBuilder();
97  $argumentPrefix = $this->controllerContext->getRequest()->getArgumentPrefix();
98  $arguments = $this->hasArgument('arguments') ? $this->arguments['arguments'] : [];
99  if ($this->hasArgument('action')) {
100  $arguments['action'] = $this->arguments['action'];
101  }
102  if ($this->hasArgument('format') && $this->arguments['format'] !== '') {
103  $arguments['format'] = $this->arguments['format'];
104  }
105  return $uriBuilder->reset()
106  ->setArguments([$argumentPrefix => $arguments])
107  ->setSection($this->arguments['section'])
108  ->setUseCacheHash($this->arguments['useCacheHash'])
109  ->setAddQueryString(true)
110  ->setAddQueryStringMethod($this->arguments['addQueryStringMethod'])
111  ->setArgumentsToBeExcludedFromQueryString([$argumentPrefix, 'cHash'])
112  ->setFormat($this->arguments['format'])
113  ->build();
114  }
115 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']