[BUGFIX] getPageOverlay_preProcess respect changes done in hooks
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / Page / FramesetRenderer.php
1 <?php
2 namespace TYPO3\CMS\Frontend\Page;
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\Core\Utility\ArrayUtility;
18 use TYPO3\CMS\Core\Utility\GeneralUtility;
19
20 /**
21 * Rendering of framesets
22 */
23 class FramesetRenderer
24 {
25 /**
26 * Generates a frameset based on input configuration in a TypoScript array.
27 *
28 * @param array $setup The TypoScript properties of the PAGE object property "frameSet.". See link.
29 * @return string A <frameset> tag.
30 * @see \TYPO3\CMS\Frontend\Page\PageGenerator::renderContentWithHeader()
31 */
32 public function make($setup)
33 {
34 $content = '';
35 if (is_array($setup)) {
36 $sKeyArray = ArrayUtility::filterAndSortByNumericKeys($setup);
37 foreach ($sKeyArray as $theKey) {
38 $theValue = $setup[$theKey];
39 if ((int)$theKey && ($conf = $setup[$theKey . '.'])) {
40 switch ($theValue) {
41 case 'FRAME':
42 $typeNum = (int)$GLOBALS['TSFE']->tmpl->setup[$conf['obj'] . '.']['typeNum'];
43 if (!$conf['src'] && !$typeNum) {
44 $typeNum = -1;
45 }
46 $content .= '<frame' . $this->frameParams($conf, $typeNum) . ' />' . LF;
47 break;
48 case 'FRAMESET':
49 $frameset = GeneralUtility::makeInstance(__CLASS__);
50 $content .= $frameset->make($conf) . LF;
51 break;
52 }
53 }
54 }
55 return '<frameset' . $this->framesetParams($setup) . '>' . LF . $content . '</frameset>';
56 }
57 return '';
58 }
59
60 /**
61 * Creates the attributes for a <frame> tag based on a $conf array and the type number
62 *
63 * @param array $setup Configuration for the parameter generation for the FRAME set. See link
64 * @param int $typeNum The typenumber to use for the link.
65 * @return string String with attributes for the frame-tag. With a prefixed space character.
66 * @access private
67 * @link https://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Frameset/
68 */
69 public function frameParams($setup, $typeNum)
70 {
71 $paramStr = '';
72 $name = $setup['obj'];
73 if ($setup['src'] || $setup['src.']) {
74 $src = $setup['src'];
75 if (is_array($setup['src.'])) {
76 $src = $GLOBALS['TSFE']->cObj->stdWrap($src, $setup['src.']);
77 }
78 $paramStr .= ' src="' . htmlspecialchars($src) . '"';
79 } else {
80 $LD = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page, '', $GLOBALS['TSFE']->no_cache, '', '', ($setup['options'] ? '&' . $setup['options'] : '') . $GLOBALS['TSFE']->cObj->getClosestMPvalueForPage($GLOBALS['TSFE']->page['uid']), (int)$typeNum);
81 $finalURL = $LD['totalURL'];
82 $paramStr .= ' src="' . htmlspecialchars($finalURL) . '"';
83 }
84 if ($setup['name']) {
85 $paramStr .= ' name="' . $setup['name'] . '"';
86 } else {
87 $paramStr .= ' name="' . $name . '"';
88 }
89 if ($setup['params']) {
90 $paramStr .= ' ' . $setup['params'];
91 }
92 return $paramStr;
93 }
94
95 /**
96 * Creates the attributes for a <frameset> tag based on a conf array($setup)
97 *
98 * @param array $setup The setup array(TypoScript properties)
99 * @return string Attributes with preceding space.
100 * @access private
101 * @see make()
102 */
103 public function framesetParams($setup)
104 {
105 $paramStr = '';
106 if ($setup['cols']) {
107 $paramStr .= ' cols="' . $setup['cols'] . '"';
108 }
109 if ($setup['rows']) {
110 $paramStr .= ' rows="' . $setup['rows'] . '"';
111 }
112 if ($setup['params']) {
113 $paramStr .= ' ' . $setup['params'];
114 }
115 return $paramStr;
116 }
117 }