[BUGFIX] Invalid links to documentation
[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 use TYPO3\CMS\Core\TypoScript\TemplateService;
18 use TYPO3\CMS\Core\Utility\GeneralUtility;
19
20 /**
21 * Rendering of framesets
22 */
23 class FramesetRenderer {
24
25 /**
26 * Generates a frameset based on input configuration in a TypoScript array.
27 *
28 * @param array $setup The TypoScript properties of the PAGE object property "frameSet.". See link.
29 * @return string A <frameset> tag.
30 * @see \TYPO3\CMS\Frontend\Page\PageGenerator::renderContentWithHeader()
31 */
32 public function make($setup) {
33 $content = '';
34 if (is_array($setup)) {
35 $sKeyArray = TemplateService::sortedKeyList($setup);
36 foreach ($sKeyArray as $theKey) {
37 $theValue = $setup[$theKey];
38 if ((int)$theKey && ($conf = $setup[$theKey . '.'])) {
39 switch ($theValue) {
40 case 'FRAME':
41 $typeNum = (int)$GLOBALS['TSFE']->tmpl->setup[$conf['obj'] . '.']['typeNum'];
42 if (!$conf['src'] && !$typeNum) {
43 $typeNum = -1;
44 }
45 $content .= '<frame' . $this->frameParams($conf, $typeNum) . ' />' . LF;
46 break;
47 case 'FRAMESET':
48 $frameset = GeneralUtility::makeInstance(__CLASS__);
49 $content .= $frameset->make($conf) . LF;
50 break;
51 }
52 }
53 }
54 return '<frameset' . $this->framesetParams($setup) . '>' . LF . $content . '</frameset>';
55 }
56 }
57
58 /**
59 * Creates the attributes for a <frame> tag based on a $conf array and the type number
60 *
61 * @param array $setup Configuration for the parameter generation for the FRAME set. See link
62 * @param int $typeNum The typenumber to use for the link.
63 * @return string String with attributes for the frame-tag. With a prefixed space character.
64 * @access private
65 * @link http://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Frameset/
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 preceding space.
97 * @access private
98 * @see make()
99 */
100 public function framesetParams($setup) {
101 $paramStr = '';
102 if ($setup['cols']) {
103 $paramStr .= ' cols="' . $setup['cols'] . '"';
104 }
105 if ($setup['rows']) {
106 $paramStr .= ' rows="' . $setup['rows'] . '"';
107 }
108 if ($setup['params']) {
109 $paramStr .= ' ' . $setup['params'];
110 }
111 return $paramStr;
112 }
113
114 }