‪TYPO3CMS  10.4
ElementBrowserController.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 
18 use Psr\Http\Message\ResponseInterface;
19 use Psr\Http\Message\ServerRequestInterface;
27 
33 {
45  protected ‪$mode;
46 
50  public function ‪__construct()
51  {
52  ‪$GLOBALS['SOBE'] = $this;
53  $this->‪init();
54  }
55 
59  protected function ‪init()
60  {
61  $this->‪getLanguageService()->‪includeLLFile('EXT:recordlist/Resources/Private/Language/locallang_browse_links.xlf');
62 
63  $this->mode = GeneralUtility::_GP('mode');
64  }
65 
73  public function ‪mainAction(ServerRequestInterface $request): ResponseInterface
74  {
75  // Fallback for old calls, which use mode "wizard" or "rte" for link selection
76  if ($this->mode === 'wizard' || $this->mode === 'rte') {
77  $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
78  return new ‪RedirectResponse((string)$uriBuilder->buildUriFromRoute('wizard_link', $_GET), 303);
79  }
80  return new ‪HtmlResponse($this->‪main());
81  }
82 
88  protected function ‪main()
89  {
90  $content = '';
91 
92  // Render type by user func
93  $browserRendered = false;
94  foreach (‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'] ?? [] as $className) {
95  $browserRenderObj = GeneralUtility::makeInstance($className);
96  if (is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render')) {
97  if ($browserRenderObj->isValid($this->mode, $this)) {
98  $content = $browserRenderObj->render($this->mode, $this);
99  $browserRendered = true;
100  break;
101  }
102  }
103  }
104 
105  // if type was not rendered use default rendering functions
106  if (!$browserRendered) {
107  $browser = $this->‪getElementBrowserInstance();
108 
109  $backendUser = $this->‪getBackendUser();
110  $modData = $backendUser->getModuleData('browse_links.php', 'ses');
111  [$modData] = $browser->processSessionData($modData);
112  $backendUser->pushModuleData('browse_links.php', $modData);
113 
114  $content = $browser->render();
115  }
116 
117  return $content;
118  }
119 
128  protected function ‪getElementBrowserInstance()
129  {
130  $className = ‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ElementBrowsers'][‪$this->mode];
131  $browser = GeneralUtility::makeInstance($className);
132  if (!$browser instanceof ‪ElementBrowserInterface) {
133  throw new \UnexpectedValueException('The specified element browser "' . $className . '" does not implement the required ElementBrowserInterface', 1442763890);
134  }
135  return $browser;
136  }
137 
141  protected function ‪getLanguageService()
142  {
143  return ‪$GLOBALS['LANG'];
144  }
145 
149  protected function ‪getBackendUser()
150  {
151  return ‪$GLOBALS['BE_USER'];
152  }
153 }
‪TYPO3\CMS\Recordlist\Controller\ElementBrowserController\getLanguageService
‪LanguageService getLanguageService()
Definition: ElementBrowserController.php:140
‪TYPO3\CMS\Core\Localization\LanguageService\includeLLFile
‪array includeLLFile($fileRef, $setGlobal=null, $mergeLocalOntoDefault=null)
Definition: LanguageService.php:297
‪TYPO3\CMS\Recordlist\Browser\ElementBrowserInterface
Definition: ElementBrowserInterface.php:19
‪TYPO3\CMS\Recordlist\Controller\ElementBrowserController
Definition: ElementBrowserController.php:33
‪TYPO3\CMS\Recordlist\Controller\ElementBrowserController\getElementBrowserInstance
‪ElementBrowserInterface getElementBrowserInstance()
Definition: ElementBrowserController.php:127
‪TYPO3\CMS\Recordlist\Controller\ElementBrowserController\getBackendUser
‪BackendUserAuthentication getBackendUser()
Definition: ElementBrowserController.php:148
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:38
‪TYPO3\CMS\Recordlist\Controller
Definition: AbstractLinkBrowserController.php:16
‪TYPO3\CMS\Recordlist\Controller\ElementBrowserController\main
‪string main()
Definition: ElementBrowserController.php:87
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Recordlist\Controller\ElementBrowserController\__construct
‪__construct()
Definition: ElementBrowserController.php:49
‪TYPO3\CMS\Core\Http\RedirectResponse
Definition: RedirectResponse.php:28
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Recordlist\Controller\ElementBrowserController\init
‪init()
Definition: ElementBrowserController.php:58
‪TYPO3\CMS\Recordlist\Controller\ElementBrowserController\mainAction
‪ResponseInterface mainAction(ServerRequestInterface $request)
Definition: ElementBrowserController.php:72
‪TYPO3\CMS\Core\Http\HtmlResponse
Definition: HtmlResponse.php:26
‪TYPO3\CMS\Recordlist\Controller\ElementBrowserController\$mode
‪string $mode
Definition: ElementBrowserController.php:44