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