‪TYPO3CMS  9.5
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 
24 
32 {
36  protected ‪$doc;
37 
41  protected ‪$pageRenderer;
42 
48  protected ‪$thisScript = '';
49 
53  protected ‪$iconFactory;
54 
76  protected ‪$bparams;
77 
81  public function ‪__construct()
82  {
83  $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
84  $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
85  $this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
86  $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Recordlist/ElementBrowser');
87 
88  $this->‪initialize();
89  }
90 
94  protected function ‪initialize()
95  {
96  $this->‪determineScriptUrl();
97  $this->‪initVariables();
98  }
99 
103  protected function ‪determineScriptUrl()
104  {
105  if ($routePath = GeneralUtility::_GP('route')) {
106  $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
107  $this->thisScript = (string)$uriBuilder->buildUriFromRoutePath($routePath);
108  } else {
109  $this->thisScript = GeneralUtility::getIndpEnv('SCRIPT_NAME');
110  }
111  }
112 
115  protected function ‪initVariables()
116  {
117  $this->bparams = GeneralUtility::_GP('bparams');
118  if ($this->bparams === null) {
119  $this->bparams = '';
120  }
121  }
122 
126  protected function ‪initDocumentTemplate()
127  {
128  $bodyDataAttributes = array_merge(
130  $this->‪getBodyTagAttributes()
131  );
132  foreach ($bodyDataAttributes as $attributeName => $value) {
133  $this->doc->bodyTagAdditions .= ' ' . $attributeName . '="' . htmlspecialchars($value) . '"';
134  }
135 
136  // unset the default jumpToUrl() function as we ship our own
137  unset($this->doc->JScodeArray['jumpToUrl']);
138  }
139 
143  abstract protected function ‪getBodyTagAttributes();
144 
150  protected function ‪getBParamDataAttributes()
151  {
152  list($fieldRef, $rteParams, $rteConfig, , $irreObjectId, $irreCheckUniqueAction, $irreAddAction, $irreInsertAction) = explode('|', $this->bparams);
153 
154  return [
155  'data-this-script-url' => strpos($this->thisScript, '?') === false ? $this->thisScript . '?' : $this->thisScript . '&',
156  'data-form-field-name' => 'data[' . $fieldRef . '][' . $rteParams . '][' . $rteConfig . ']',
157  'data-field-reference' => $fieldRef,
158  'data-field-reference-slashed' => addslashes($fieldRef),
159  'data-rte-parameters' => $rteParams,
160  'data-rte-configuration' => $rteConfig,
161  'data-irre-object-id' => $irreObjectId,
162  'data-irre-check-unique-action' => $irreCheckUniqueAction,
163  'data-irre-add-action' => $irreAddAction,
164  'data-irre-insert-action' => $irreInsertAction,
165  ];
166  }
167 
171  protected function ‪getLanguageService()
172  {
173  return ‪$GLOBALS['LANG'];
174  }
175 
179  protected function ‪getBackendUser()
180  {
181  return ‪$GLOBALS['BE_USER'];
182  }
183 }
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\$pageRenderer
‪PageRenderer $pageRenderer
Definition: AbstractElementBrowser.php:39
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\getBodyTagAttributes
‪string[] getBodyTagAttributes()
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\$thisScript
‪string $thisScript
Definition: AbstractElementBrowser.php:45
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\getBackendUser
‪BackendUserAuthentication getBackendUser()
Definition: AbstractElementBrowser.php:174
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:31
‪TYPO3\CMS\Core\Page\PageRenderer
Definition: PageRenderer.php:35
‪TYPO3\CMS\Backend\Template\DocumentTemplate
Definition: DocumentTemplate.php:48
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:35
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\determineScriptUrl
‪determineScriptUrl()
Definition: AbstractElementBrowser.php:98
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser
Definition: AbstractElementBrowser.php:32
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\__construct
‪__construct()
Definition: AbstractElementBrowser.php:76
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\initDocumentTemplate
‪initDocumentTemplate()
Definition: AbstractElementBrowser.php:121
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:45
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\getBParamDataAttributes
‪string[] getBParamDataAttributes()
Definition: AbstractElementBrowser.php:145
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\getLanguageService
‪LanguageService getLanguageService()
Definition: AbstractElementBrowser.php:166
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\initVariables
‪initVariables()
Definition: AbstractElementBrowser.php:110
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\$iconFactory
‪IconFactory $iconFactory
Definition: AbstractElementBrowser.php:49
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\initialize
‪initialize()
Definition: AbstractElementBrowser.php:89
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\$bparams
‪string $bparams
Definition: AbstractElementBrowser.php:71
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\$doc
‪DocumentTemplate $doc
Definition: AbstractElementBrowser.php:35
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Recordlist\Browser
Definition: AbstractElementBrowser.php:2