[TASK] Move record-related entrypoints to backend routing
[Packages/TYPO3.CMS.git] / typo3 / sysext / recordlist / Classes / Controller / ElementBrowserFramesetController.php
1 <?php
2 namespace TYPO3\CMS\Recordlist\Controller;
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
17 use Psr\Http\Message\ServerRequestInterface;
18 use Psr\Http\Message\ResponseInterface;
19 use TYPO3\CMS\Core\Http\Response;
20 use TYPO3\CMS\Backend\Template\DocumentTemplate;
21 use TYPO3\CMS\Backend\Utility\BackendUtility;
22 use TYPO3\CMS\Core\Page\PageRenderer;
23 use TYPO3\CMS\Core\Utility\GeneralUtility;
24 use TYPO3\CMS\Lang\LanguageService;
25
26 /**
27 * Script Class, putting the frameset together.
28 */
29 class ElementBrowserFramesetController implements \TYPO3\CMS\Core\Http\ControllerInterface {
30
31 /**
32 * Internal, dynamic
33 *
34 * @var string
35 */
36 public $content;
37
38 /**
39 * @var PageRenderer
40 */
41 protected $pageRenderer = NULL;
42
43 /**
44 * Constructor
45 */
46 public function __construct() {
47 $GLOBALS['SOBE'] = $this;
48 }
49
50 /**
51 * Injects the request object for the current request or subrequest
52 * As this controller goes only through the main() method, it is rather simple for now
53 *
54 * @param ServerRequestInterface $request
55 * @return ResponseInterface $response
56 */
57 public function processRequest(ServerRequestInterface $request) {
58 $this->main();
59
60 /** @var Response $response */
61 $response = GeneralUtility::makeInstance(Response::class);
62 $response->getBody()->write($this->content);
63 return $response;
64 }
65
66 /**
67 * Main function.
68 * Creates the header code in XHTML, the JavaScript, then the frameset for the two frames.
69 *
70 * @return void
71 */
72 public function main() {
73 // Setting GPvars:
74 $mode = GeneralUtility::_GP('mode');
75 $bparams = GeneralUtility::_GP('bparams');
76 $moduleUrl = BackendUtility::getModuleUrl('wizard_element_browser') . '&mode=';
77 $documentTemplate = $this->getDocumentTemplate();
78 $documentTemplate->JScode = $documentTemplate->wrapScriptTags('
79 function closing() { //
80 close();
81 }
82 function setParams(mode,params) { //
83 parent.content.location.href = ' . GeneralUtility::quoteJSvalue($moduleUrl) . '+mode+"&bparams="+params;
84 }
85 if (!window.opener) {
86 alert("ERROR: Sorry, no link to main window... Closing");
87 close();
88 }
89 ');
90
91 // build the header part
92 $documentTemplate->startPage($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:TYPO3_Element_Browser'));
93
94 // URL for the inner main frame:
95 $url = $moduleUrl . rawurlencode($mode) . '&bparams=' . rawurlencode($bparams);
96
97 // Create the frameset for the window
98 // Formerly there were a ' onunload="closing();"' in the <frameset> tag - but it failed on Safari browser on Mac unless the handler was "onUnload"
99 $this->content = $this->getPageRenderer()->render(PageRenderer::PART_HEADER) .
100 '<frameset rows="*,1" framespacing="0" frameborder="0" border="0">
101 <frame name="content" src="' . htmlspecialchars($url) . '" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto" noresize="noresize" />
102 <frame name="menu" src="' . htmlspecialchars(BackendUtility::getModuleUrl('dummy')) . '" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" noresize="noresize" />
103 </frameset>
104 </html>
105 ';
106 }
107
108 /**
109 * Outputs the page content.
110 *
111 * @return void
112 * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use processRequest() instead
113 */
114 public function printContent() {
115 GeneralUtility::logDeprecatedFunction();
116 echo $this->content;
117 }
118
119 /**
120 * @return DocumentTemplate
121 */
122 protected function getDocumentTemplate() {
123 return $GLOBALS['TBE_TEMPLATE'];
124 }
125
126 /**
127 * @return LanguageService
128 */
129 protected function getLanguageService() {
130 return $GLOBALS['LANG'];
131 }
132
133 /**
134 * @return PageRenderer
135 */
136 protected function getPageRenderer() {
137 if ($this->pageRenderer === NULL) {
138 $this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
139 }
140
141 return $this->pageRenderer;
142 }
143
144 }