70d093d0ba3c9cb3a6053fac4e4a086521a59435
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / class.tslib_frameset.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2012 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28 /**
29 * Rendering of framesets
30 *
31 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
32 * @package TYPO3
33 * @subpackage tslib
34 */
35 class tslib_frameset {
36
37 /**
38 * Generates a frameset based on input configuration in a TypoScript array.
39 *
40 * @param array The TypoScript properties of the PAGE object property "frameSet.". See link.
41 * @return string A <frameset> tag.
42 * @see TSpagegen::renderContentWithHeader()
43 */
44 function make($setup) {
45 $content = '';
46 if (is_array($setup)) {
47 $sKeyArray = t3lib_TStemplate::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 = t3lib_div::makeInstance('tslib_frameset');
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 Configuration for the parameter generation for the FRAME set. See link
74 * @param integer 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 * @see make(), t3lib_TStemplate::linkData()
79 */
80 function frameParams($setup, $typeNum) {
81 $paramStr = '';
82 $name = $setup['obj'];
83
84 if ($setup['src'] || $setup['src.']) {
85 $src = $setup['src'];
86 if (is_array($setup['src.'])) {
87 $src = $GLOBALS['TSFE']->cObj->stdWrap($src, $setup['src.']);
88 }
89 $paramStr .= ' src="' . htmlspecialchars($src) . '"';
90 } else {
91 $LD = $GLOBALS['TSFE']->tmpl->linkData(
92 $GLOBALS['TSFE']->page,
93 '',
94 $GLOBALS['TSFE']->no_cache,
95 '',
96 '',
97 ($setup['options'] ? '&' . $setup['options'] : '') .
98 $GLOBALS['TSFE']->cObj->getClosestMPvalueForPage($GLOBALS['TSFE']->page['uid']), intval($typeNum)
99 );
100 $finalURL = $LD['totalURL'];
101 $paramStr .= ' src="' . htmlspecialchars($finalURL) . '"';
102 }
103 if ($setup['name']) {
104 $paramStr .= ' name="' . $setup['name'] . '"';
105 } else {
106 $paramStr .= ' name="' . $name . '"';
107 }
108 if ($setup['params']) {
109 $paramStr .= ' ' . $setup['params'];
110 }
111 return $paramStr;
112 }
113
114 /**
115 * Creates the attributes for a <frameset> tag based on a conf array($setup)
116 *
117 * @param array The setup array(TypoScript properties)
118 * @return string Attributes with preceeding space.
119 * @access private
120 * @see make()
121 */
122 function framesetParams($setup) {
123 $paramStr = '';
124 if ($setup['cols']) {
125 $paramStr .= ' cols="' . $setup['cols'] . '"';
126 }
127 if ($setup['rows']) {
128 $paramStr .= ' rows="' . $setup['rows'] . '"';
129 }
130 if ($setup['params']) {
131 $paramStr .= ' ' . $setup['params'];
132 }
133 return $paramStr;
134 }
135 }
136 ?>