TYPO3 CMS  TYPO3_7-6
UriViewHelper.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 {
46  public function initializeArguments()
47  {
48  $this->registerArgument('addQueryStringMethod', 'string', 'Method to be used for query string');
49  }
50 
62  public function render($action = null, $arguments = [], $section = '', $format = '', $ajax = false)
63  {
64  if ($ajax === true) {
65  return $this->getAjaxUri();
66  } else {
67  return $this->getWidgetUri();
68  }
69  }
70 
76  protected function getAjaxUri()
77  {
78  $action = $this->arguments['action'];
79  $arguments = $this->arguments['arguments'];
80  if ($action === null) {
81  $action = $this->controllerContext->getRequest()->getControllerActionName();
82  }
83  $arguments['id'] = $GLOBALS['TSFE']->id;
84  // @todo page type should be configurable
85  $arguments['type'] = 7076;
86  $arguments['fluid-widget-id'] = $this->controllerContext->getRequest()->getWidgetContext()->getAjaxWidgetIdentifier();
87  $arguments['action'] = $action;
88  return '?' . http_build_query($arguments, null, '&');
89  }
90 
96  protected function getWidgetUri()
97  {
98  $uriBuilder = $this->controllerContext->getUriBuilder();
99  $argumentPrefix = $this->controllerContext->getRequest()->getArgumentPrefix();
100  $arguments = $this->hasArgument('arguments') ? $this->arguments['arguments'] : [];
101  if ($this->hasArgument('action')) {
102  $arguments['action'] = $this->arguments['action'];
103  }
104  if ($this->hasArgument('format') && $this->arguments['format'] !== '') {
105  $arguments['format'] = $this->arguments['format'];
106  }
107  return $uriBuilder->reset()
108  ->setArguments([$argumentPrefix => $arguments])
109  ->setSection($this->arguments['section'])
110  ->setAddQueryString(true)
111  ->setAddQueryStringMethod($this->arguments['addQueryStringMethod'])
112  ->setArgumentsToBeExcludedFromQueryString([$argumentPrefix, 'cHash'])
113  ->setFormat($this->arguments['format'])
114  ->build();
115  }
116 }
registerArgument($name, $type, $description, $required=false, $defaultValue=null)
render($action=null, $arguments=[], $section='', $format='', $ajax=false)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']