[TASK] Remove superfluous parenthesis in sysext frontend
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / Page / FramesetRenderer.php
1 <?php
2 namespace TYPO3\CMS\Frontend\Page;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 1999-2012 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * Rendering of framesets
31 *
32 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
33 * @package TYPO3
34 * @subpackage tslib
35 */
36 class FramesetRenderer {
37
38 /**
39 * Generates a frameset based on input configuration in a TypoScript array.
40 *
41 * @param array $setup The TypoScript properties of the PAGE object property "frameSet.". See link.
42 * @return string A <frameset> tag.
43 * @see TSpagegen::renderContentWithHeader()
44 * @todo Define visibility
45 */
46 public function make($setup) {
47 $content = '';
48 if (is_array($setup)) {
49 $sKeyArray = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($setup);
50 foreach ($sKeyArray as $theKey) {
51 $theValue = $setup[$theKey];
52 if (intval($theKey) && ($conf = $setup[$theKey . '.'])) {
53 switch ($theValue) {
54 case 'FRAME':
55 $typeNum = intval($GLOBALS['TSFE']->tmpl->setup[$conf['obj'] . '.']['typeNum']);
56 if (!$conf['src'] && !$typeNum) {
57 $typeNum = -1;
58 }
59 $content .= '<frame' . $this->frameParams($conf, $typeNum) . ' />' . LF;
60 break;
61 case 'FRAMESET':
62 $frameset = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\FramesetRenderer');
63 $content .= $frameset->make($conf) . LF;
64 break;
65 }
66 }
67 }
68 return '<frameset' . $this->framesetParams($setup) . '>' . LF . $content . '</frameset>';
69 }
70 }
71
72 /**
73 * Creates the attributes for a <frame> tag based on a $conf array and the type number
74 *
75 * @param array $setup Configuration for the parameter generation for the FRAME set. See link
76 * @param integer $typeNum The typenumber to use for the link.
77 * @return string String with attributes for the frame-tag. With a prefixed space character.
78 * @access private
79 * @link http://typo3.org/documentation/document-library/references/doc_core_tsref/current/view/7/9/
80 * @see make(), t3lib_TStemplate::linkData()
81 * @todo Define visibility
82 */
83 public function frameParams($setup, $typeNum) {
84 $paramStr = '';
85 $name = $setup['obj'];
86 if ($setup['src'] || $setup['src.']) {
87 $src = $setup['src'];
88 if (is_array($setup['src.'])) {
89 $src = $GLOBALS['TSFE']->cObj->stdWrap($src, $setup['src.']);
90 }
91 $paramStr .= ' src="' . htmlspecialchars($src) . '"';
92 } else {
93 $LD = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page, '', $GLOBALS['TSFE']->no_cache, '', '', ($setup['options'] ? '&' . $setup['options'] : '') . $GLOBALS['TSFE']->cObj->getClosestMPvalueForPage($GLOBALS['TSFE']->page['uid']), intval($typeNum));
94 $finalURL = $LD['totalURL'];
95 $paramStr .= ' src="' . htmlspecialchars($finalURL) . '"';
96 }
97 if ($setup['name']) {
98 $paramStr .= ' name="' . $setup['name'] . '"';
99 } else {
100 $paramStr .= ' name="' . $name . '"';
101 }
102 if ($setup['params']) {
103 $paramStr .= ' ' . $setup['params'];
104 }
105 return $paramStr;
106 }
107
108 /**
109 * Creates the attributes for a <frameset> tag based on a conf array($setup)
110 *
111 * @param array $setup The setup array(TypoScript properties)
112 * @return string Attributes with preceeding space.
113 * @access private
114 * @see make()
115 * @todo Define visibility
116 */
117 public function framesetParams($setup) {
118 $paramStr = '';
119 if ($setup['cols']) {
120 $paramStr .= ' cols="' . $setup['cols'] . '"';
121 }
122 if ($setup['rows']) {
123 $paramStr .= ' rows="' . $setup['rows'] . '"';
124 }
125 if ($setup['params']) {
126 $paramStr .= ' ' . $setup['params'];
127 }
128 return $paramStr;
129 }
130
131 }
132
133
134 ?>