TYPO3 CMS  TYPO3_7-6
ElementBrowserController.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 
25 
30 {
42  protected $mode;
43 
49  public $doc;
50 
54  public function __construct()
55  {
56  $GLOBALS['SOBE'] = $this;
57 
58  // Creating backend template object:
59  // this might not be needed but some classes refer to $GLOBALS['SOBE']->doc, so ...
60  $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
61  // Apply the same styles as those of the base script
62  $this->doc->bodyTagId = 'typo3-browse-links-php';
63 
64  $this->init();
65  }
66 
72  protected function init()
73  {
74  $this->getLanguageService()->includeLLFile('EXT:lang/locallang_browse_links.xlf');
75 
76  $this->mode = GeneralUtility::_GP('mode');
77  }
78 
87  public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
88  {
89  // Fallback for old calls, which use mode "wizard" or "rte" for link selection
90  if ($this->mode === 'wizard' || $this->mode === 'rte') {
91  return $response->withStatus(303)->withHeader('Location', BackendUtility::getModuleUrl('wizard_link', $_GET, false, true));
92  }
93 
94  $response->getBody()->write($this->main());
95  return $response;
96  }
97 
103  public function main()
104  {
105  $content = '';
106 
107  // Render type by user func
108  $browserRendered = false;
109  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'])) {
110  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'] as $classRef) {
111  $browserRenderObj = GeneralUtility::getUserObj($classRef);
112  if (is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render')) {
113  if ($browserRenderObj->isValid($this->mode, $this)) {
114  $content = $browserRenderObj->render($this->mode, $this);
115  $browserRendered = true;
116  break;
117  }
118  }
119  }
120  }
121 
122  // if type was not rendered use default rendering functions
123  if (!$browserRendered) {
124  $browser = $this->getElementBrowserInstance();
125 
126  $backendUser = $this->getBackendUser();
127  $modData = $backendUser->getModuleData('browse_links.php', 'ses');
128  list($modData) = $browser->processSessionData($modData);
129  $backendUser->pushModuleData('browse_links.php', $modData);
130 
131  $content = $browser->render();
132  }
133 
134  return $content;
135  }
136 
145  protected function getElementBrowserInstance()
146  {
147  $className = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ElementBrowsers'][$this->mode];
148  $browser = GeneralUtility::makeInstance($className);
149  if (!$browser instanceof ElementBrowserInterface) {
150  throw new \UnexpectedValueException('The specified element browser "' . $className . '" does not implement the required ElementBrowserInterface', 1442763890);
151  }
152  return $browser;
153  }
154 
158  protected function getLanguageService()
159  {
160  return $GLOBALS['LANG'];
161  }
162 
166  protected function getBackendUser()
167  {
168  return $GLOBALS['BE_USER'];
169  }
170 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
mainAction(ServerRequestInterface $request, ResponseInterface $response)