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