‪TYPO3CMS  10.4
AbstractElementBrowser.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
25 
33 {
37  protected ‪$moduleTemplate;
38 
42  protected ‪$pageRenderer;
43 
49  protected ‪$thisScript = '';
50 
54  protected ‪$iconFactory;
55 
74  protected ‪$bparams;
75 
79  public function ‪__construct()
80  {
81  $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
82  $this->moduleTemplate->getDocHeaderComponent()->disable();
83  $this->moduleTemplate->getView()->setTemplate('ElementBrowser');
84  $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
85  $this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
86  $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Recordlist/ElementBrowser');
87  $this->‪initialize();
88  }
89 
93  protected function ‪initialize()
94  {
95  $this->‪determineScriptUrl();
96  $this->‪initVariables();
97  }
98 
102  protected function ‪determineScriptUrl()
103  {
104  if ($routePath = GeneralUtility::_GP('route')) {
105  $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
106  $this->‪thisScript = (string)$uriBuilder->buildUriFromRoutePath($routePath);
107  } else {
108  $this->‪thisScript = GeneralUtility::getIndpEnv('SCRIPT_NAME');
109  }
110  }
111 
112  protected function ‪initVariables()
113  {
114  $this->bparams = GeneralUtility::_GP('bparams');
115  if ($this->bparams === null) {
116  $this->bparams = '';
117  }
118  }
119 
123  protected function ‪setBodyTagParameters()
124  {
125  $bodyDataAttributes = array_merge(
126  $this->getBParamDataAttributes(),
127  $this->getBodyTagAttributes()
128  );
129  $bodyTag = $this->moduleTemplate->getBodyTag();
130  $bodyTag = str_replace('>', ' ' . GeneralUtility::implodeAttributes($bodyDataAttributes, true, true) . '>', $bodyTag);
131  $this->moduleTemplate->setBodyTag($bodyTag);
132  }
133 
137  abstract protected function getBodyTagAttributes();
138 
144  protected function getBParamDataAttributes()
145  {
146  [$fieldRef, $rteParams, $rteConfig, , $irreObjectId] = explode('|', $this->bparams);
147 
148  return [
149  'data-this-script-url' => strpos($this->‪thisScript, '?') === false ? $this->‪thisScript . '?' : $this->‪thisScript . '&',
150  'data-form-field-name' => 'data[' . $fieldRef . '][' . $rteParams . '][' . $rteConfig . ']',
151  'data-field-reference' => $fieldRef,
152  'data-field-reference-slashed' => addslashes($fieldRef),
153  'data-rte-parameters' => $rteParams,
154  'data-rte-configuration' => $rteConfig,
155  'data-irre-object-id' => $irreObjectId,
156  ];
157  }
158 
162  protected function ‪getLanguageService()
163  {
164  return ‪$GLOBALS['LANG'];
165  }
166 
170  protected function ‪getBackendUser()
171  {
172  return ‪$GLOBALS['BE_USER'];
173  }
174 }
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\$pageRenderer
‪PageRenderer $pageRenderer
Definition: AbstractElementBrowser.php:40
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\$thisScript
‪string $thisScript
Definition: AbstractElementBrowser.php:46
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\getBackendUser
‪BackendUserAuthentication getBackendUser()
Definition: AbstractElementBrowser.php:165
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\thisScript
‪array< string, function getBodyTagAttributes();protected array< string, function getBParamDataAttributes() {[ $fieldRef, $rteParams, $rteConfig,, $irreObjectId]=explode('|', $this->bparams);return['data-this-script-url'=> strpos( $this->thisScript, '?')===false ? $this-> thisScript
Definition: AbstractElementBrowser.php:144
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:33
‪TYPO3\CMS\Backend\Template\ModuleTemplate
Definition: ModuleTemplate.php:43
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\getLanguageService
‪array< string, getBodyTagAttributes();protected array< string, function getBParamDataAttributes() {[ $fieldRef, $rteParams, $rteConfig,, $irreObjectId]=explode('|', $this->bparams);return['data-this-script-url'=> strpos( $this->thisScript, '?')===false ? $this-> LanguageService function getLanguageService()
Definition: AbstractElementBrowser.php:157
‪TYPO3\CMS\Core\Page\PageRenderer
Definition: PageRenderer.php:42
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:38
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\determineScriptUrl
‪determineScriptUrl()
Definition: AbstractElementBrowser.php:97
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser
Definition: AbstractElementBrowser.php:33
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\__construct
‪__construct()
Definition: AbstractElementBrowser.php:74
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\initVariables
‪initVariables()
Definition: AbstractElementBrowser.php:107
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\$moduleTemplate
‪ModuleTemplate $moduleTemplate
Definition: AbstractElementBrowser.php:36
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\$iconFactory
‪IconFactory $iconFactory
Definition: AbstractElementBrowser.php:50
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\initialize
‪initialize()
Definition: AbstractElementBrowser.php:88
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\$bparams
‪string $bparams
Definition: AbstractElementBrowser.php:69
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Recordlist\Browser\AbstractElementBrowser\setBodyTagParameters
‪setBodyTagParameters()
Definition: AbstractElementBrowser.php:118
‪TYPO3\CMS\Recordlist\Browser
Definition: AbstractElementBrowser.php:16