[CLEANUP] Cleanup phpDoc 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 /**
18 * Rendering of framesets
19 *
20 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
21 */
22 class FramesetRenderer {
23
24 /**
25 * Generates a frameset based on input configuration in a TypoScript array.
26 *
27 * @param array $setup The TypoScript properties of the PAGE object property "frameSet.". See link.
28 * @return string A <frameset> tag.
29 * @see TSpagegen::renderContentWithHeader()
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 int $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 */
66 public function frameParams($setup, $typeNum) {
67 $paramStr = '';
68 $name = $setup['obj'];
69 if ($setup['src'] || $setup['src.']) {
70 $src = $setup['src'];
71 if (is_array($setup['src.'])) {
72 $src = $GLOBALS['TSFE']->cObj->stdWrap($src, $setup['src.']);
73 }
74 $paramStr .= ' src="' . htmlspecialchars($src) . '"';
75 } else {
76 $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);
77 $finalURL = $LD['totalURL'];
78 $paramStr .= ' src="' . htmlspecialchars($finalURL) . '"';
79 }
80 if ($setup['name']) {
81 $paramStr .= ' name="' . $setup['name'] . '"';
82 } else {
83 $paramStr .= ' name="' . $name . '"';
84 }
85 if ($setup['params']) {
86 $paramStr .= ' ' . $setup['params'];
87 }
88 return $paramStr;
89 }
90
91 /**
92 * Creates the attributes for a <frameset> tag based on a conf array($setup)
93 *
94 * @param array $setup The setup array(TypoScript properties)
95 * @return string Attributes with preceeding space.
96 * @access private
97 * @see make()
98 */
99 public function framesetParams($setup) {
100 $paramStr = '';
101 if ($setup['cols']) {
102 $paramStr .= ' cols="' . $setup['cols'] . '"';
103 }
104 if ($setup['rows']) {
105 $paramStr .= ' rows="' . $setup['rows'] . '"';
106 }
107 if ($setup['params']) {
108 $paramStr .= ' ' . $setup['params'];
109 }
110 return $paramStr;
111 }
112
113 }