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