TYPO3 CMS  TYPO3_7-6
AbstractElementBrowser.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 
26 
32 abstract class AbstractElementBrowser
33 {
37  protected $doc;
38 
42  protected $pageRenderer = null;
43 
49  protected $thisScript = '';
50 
54  protected $iconFactory;
55 
78  protected $bparams;
79 
83  public function __construct()
84  {
85  $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
86  $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
87  $this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
88  $this->pageRenderer->loadJquery();
89  $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Recordlist/ElementBrowser');
90 
91  $this->initialize();
92  }
93 
99  protected function initialize()
100  {
101  $this->determineScriptUrl();
102  $this->initVariables();
103  }
104 
110  protected function determineScriptUrl()
111  {
112  if ($routePath = GeneralUtility::_GP('route')) {
113  $router = GeneralUtility::makeInstance(Router::class);
114  $route = $router->match($routePath);
115  $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
116  $this->thisScript = (string)$uriBuilder->buildUriFromRoute($route->getOption('_identifier'));
117  } elseif ($moduleName = GeneralUtility::_GP('M')) {
118  $this->thisScript = BackendUtility::getModuleUrl($moduleName);
119  } else {
120  $this->thisScript = GeneralUtility::getIndpEnv('SCRIPT_NAME');
121  }
122  }
123 
127  protected function initVariables()
128  {
129  $this->bparams = GeneralUtility::_GP('bparams');
130  if ($this->bparams === null) {
131  $this->bparams = '';
132  }
133  }
134 
140  protected function initDocumentTemplate()
141  {
142  $this->doc->bodyTagId = 'typo3-browse-links-php';
143 
144  $bodyDataAttributes = array_merge(
145  $this->getBParamDataAttributes(),
146  $this->getBodyTagAttributes()
147  );
148  foreach ($bodyDataAttributes as $attributeName => $value) {
149  $this->doc->bodyTagAdditions .= ' ' . $attributeName . '="' . htmlspecialchars($value) . '"';
150  }
151 
152  // unset the default jumpToUrl() function as we ship our own
153  unset($this->doc->JScodeArray['jumpToUrl']);
154  }
155 
159  abstract protected function getBodyTagAttributes();
160 
166  protected function getBParamDataAttributes()
167  {
168  list($fieldRef, $rteParams, $rteConfig, , $irreObjectId, $irreCheckUniqueAction, $irreAddAction, $irreInsertAction) = explode('|', $this->bparams);
169 
170  return [
171  'data-this-script-url' => strpos($this->thisScript, '?') === false ? $this->thisScript . '?' : $this->thisScript . '&',
172  'data-form-field-name' => 'data[' . $fieldRef . '][' . $rteParams . '][' . $rteConfig . ']',
173  'data-field-reference' => $fieldRef,
174  'data-field-reference-slashed' => addslashes($fieldRef),
175  'data-rte-parameters' => $rteParams,
176  'data-rte-configuration' => $rteConfig,
177  'data-irre-object-id' => $irreObjectId,
178  'data-irre-check-unique-action' => $irreCheckUniqueAction,
179  'data-irre-add-action' => $irreAddAction,
180  'data-irre-insert-action' => $irreInsertAction,
181  ];
182  }
183 
187  protected function getLanguageService()
188  {
189  return $GLOBALS['LANG'];
190  }
191 
195  protected function getBackendUser()
196  {
197  return $GLOBALS['BE_USER'];
198  }
199 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']