9eea799aee21af33d58e59fa442c4e1179e4fd6a
[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 TYPO3\CMS\Backend\Template\DocumentTemplate;
18 use TYPO3\CMS\Backend\Utility\BackendUtility;
19 use TYPO3\CMS\Core\Page\PageRenderer;
20 use TYPO3\CMS\Core\Utility\GeneralUtility;
21 use TYPO3\CMS\Lang\LanguageService;
22
23 /**
24 * Script Class, putting the frameset together.
25 */
26 class ElementBrowserFramesetController {
27
28 /**
29 * Internal, dynamic
30 *
31 * @var string
32 */
33 public $content;
34
35 /**
36 * @var PageRenderer
37 */
38 protected $pageRenderer = NULL;
39
40 /**
41 * Main function.
42 * Creates the header code in XHTML, the JavaScript, then the frameset for the two frames.
43 *
44 * @return void
45 */
46 public function main() {
47 // Setting GPvars:
48 $mode = GeneralUtility::_GP('mode');
49 $bparams = GeneralUtility::_GP('bparams');
50 $moduleUrl = BackendUtility::getModuleUrl('wizard_element_browser') . '&mode=';
51 $documentTemplate = $this->getDocumentTemplate();
52 $documentTemplate->JScode = $documentTemplate->wrapScriptTags('
53 function closing() { //
54 close();
55 }
56 function setParams(mode,params) { //
57 parent.content.location.href = ' . GeneralUtility::quoteJSvalue($moduleUrl) . '+mode+"&bparams="+params;
58 }
59 if (!window.opener) {
60 alert("ERROR: Sorry, no link to main window... Closing");
61 close();
62 }
63 ');
64
65 // build the header part
66 $documentTemplate->startPage($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:TYPO3_Element_Browser'));
67
68 // URL for the inner main frame:
69 $url = $GLOBALS['BACK_PATH'] . $moduleUrl . rawurlencode($mode) . '&bparams=' . rawurlencode($bparams);
70
71 // Create the frameset for the window
72 // Formerly there were a ' onunload="closing();"' in the <frameset> tag - but it failed on Safari browser on Mac unless the handler was "onUnload"
73 $this->content = $this->getPageRenderer()->render(PageRenderer::PART_HEADER) .
74 '<frameset rows="*,1" framespacing="0" frameborder="0" border="0">
75 <frame name="content" src="' . htmlspecialchars($url) . '" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto" noresize="noresize" />
76 <frame name="menu" src="' . htmlspecialchars(BackendUtility::getModuleUrl('dummy')) . '" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" noresize="noresize" />
77 </frameset>
78 </html>
79 ';
80 }
81
82 /**
83 * Outputs the page content.
84 *
85 * @return void
86 */
87 public function printContent() {
88 echo $this->content;
89 }
90
91 /**
92 * @return DocumentTemplate
93 */
94 protected function getDocumentTemplate() {
95 return $GLOBALS['TBE_TEMPLATE'];
96 }
97
98 /**
99 * @return LanguageService
100 */
101 protected function getLanguageService() {
102 return $GLOBALS['LANG'];
103 }
104
105 /**
106 * @return PageRenderer
107 */
108 protected function getPageRenderer() {
109 if ($this->pageRenderer === NULL) {
110 $this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
111 }
112
113 return $this->pageRenderer;
114 }
115
116 }