[TASK] Remove the "@todo define visibility" in ext:frontend
[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 * Rendering of framesets
18 *
19 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
20 */
21 class FramesetRenderer {
22
23 /**
24 * Generates a frameset based on input configuration in a TypoScript array.
25 *
26 * @param array $setup The TypoScript properties of the PAGE object property "frameSet.". See link.
27 * @return string A <frameset> tag.
28 * @see TSpagegen::renderContentWithHeader()
29 */
30 public function make($setup) {
31 $content = '';
32 if (is_array($setup)) {
33 $sKeyArray = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($setup);
34 foreach ($sKeyArray as $theKey) {
35 $theValue = $setup[$theKey];
36 if ((int)$theKey && ($conf = $setup[$theKey . '.'])) {
37 switch ($theValue) {
38 case 'FRAME':
39 $typeNum = (int)$GLOBALS['TSFE']->tmpl->setup[$conf['obj'] . '.']['typeNum'];
40 if (!$conf['src'] && !$typeNum) {
41 $typeNum = -1;
42 }
43 $content .= '<frame' . $this->frameParams($conf, $typeNum) . ' />' . LF;
44 break;
45 case 'FRAMESET':
46 $frameset = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\FramesetRenderer');
47 $content .= $frameset->make($conf) . LF;
48 break;
49 }
50 }
51 }
52 return '<frameset' . $this->framesetParams($setup) . '>' . LF . $content . '</frameset>';
53 }
54 }
55
56 /**
57 * Creates the attributes for a <frame> tag based on a $conf array and the type number
58 *
59 * @param array $setup Configuration for the parameter generation for the FRAME set. See link
60 * @param integer $typeNum The typenumber to use for the link.
61 * @return string String with attributes for the frame-tag. With a prefixed space character.
62 * @access private
63 * @link http://typo3.org/documentation/document-library/references/doc_core_tsref/current/view/7/9/
64 */
65 public function frameParams($setup, $typeNum) {
66 $paramStr = '';
67 $name = $setup['obj'];
68 if ($setup['src'] || $setup['src.']) {
69 $src = $setup['src'];
70 if (is_array($setup['src.'])) {
71 $src = $GLOBALS['TSFE']->cObj->stdWrap($src, $setup['src.']);
72 }
73 $paramStr .= ' src="' . htmlspecialchars($src) . '"';
74 } else {
75 $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);
76 $finalURL = $LD['totalURL'];
77 $paramStr .= ' src="' . htmlspecialchars($finalURL) . '"';
78 }
79 if ($setup['name']) {
80 $paramStr .= ' name="' . $setup['name'] . '"';
81 } else {
82 $paramStr .= ' name="' . $name . '"';
83 }
84 if ($setup['params']) {
85 $paramStr .= ' ' . $setup['params'];
86 }
87 return $paramStr;
88 }
89
90 /**
91 * Creates the attributes for a <frameset> tag based on a conf array($setup)
92 *
93 * @param array $setup The setup array(TypoScript properties)
94 * @return string Attributes with preceeding space.
95 * @access private
96 * @see make()
97 */
98 public function framesetParams($setup) {
99 $paramStr = '';
100 if ($setup['cols']) {
101 $paramStr .= ' cols="' . $setup['cols'] . '"';
102 }
103 if ($setup['rows']) {
104 $paramStr .= ' rows="' . $setup['rows'] . '"';
105 }
106 if ($setup['params']) {
107 $paramStr .= ' ' . $setup['params'];
108 }
109 return $paramStr;
110 }
111
112 }