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