[BUGFIX] Autoloader Cache is not updated
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_tceforms_fe.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 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 * Contains a frontend version of the TYPO3 Core Form generator - AKA "TCEforms"
30 *
31 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
32 */
33
34
35 /**
36 * Extension class for the rendering of TCEforms in the frontend
37 *
38 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
39 */
40 class t3lib_TCEforms_FE extends t3lib_TCEforms {
41
42 /**
43 * Constructs this object.
44 */
45 public function __construct() {
46 $this->initializeTemplateContainer();
47 parent::__construct();
48 }
49
50 /**
51 * Function for wrapping labels.
52 *
53 * @param string The string to wrap
54 * @return string
55 */
56 public function wrapLabels($str) {
57 return '<font face="verdana" size="1" color="black">' . $str . '</font>';
58 }
59
60 /**
61 * Prints the palette in the frontend editing (forms-on-page?)
62 *
63 * @param array The palette array to print
64 * @return string HTML output
65 */
66 public function printPalette(array $paletteArray) {
67 $out = '';
68 $bgColor = ' bgcolor="#D6DAD0"';
69 foreach ($paletteArray as $content) {
70 $hRow[] = '<td' . $bgColor . '><font face="verdana" size="1">&nbsp;</font></td><td nowrap="nowrap"' . $bgColor . '><font color="#666666" face="verdana" size="1">' . $content['NAME'] . '</font></td>';
71 $iRow[] = '<td valign="top">' .
72 '<img name="req_' . $content['TABLE'] . '_' . $content['ID'] . '_' . $content['FIELD'] . '" src="clear.gif" width="10" height="10" alt="" />' .
73 '<img name="cm_' . $content['TABLE'] . '_' . $content['ID'] . '_' . $content['FIELD'] . '" src="clear.gif" width="7" height="10" alt="" />' .
74 '</td><td nowrap="nowrap" valign="top">' . $content['ITEM'] . $content['HELP_ICON'] . '</td>';
75 }
76 $out = '<table border="0" cellpadding="0" cellspacing="0">
77 <tr><td><img src="clear.gif" width="' . intval($this->paletteMargin) . '" height="1" alt="" /></td>' . implode('', $hRow) . '</tr>
78 <tr><td></td>' . implode('', $iRow) . '</tr>
79 </table>';
80
81 return $out;
82 }
83
84 /**
85 * Sets the fancy front-end design of the editor.
86 * Frontend
87 *
88 * @return void
89 */
90 public function setFancyDesign() {
91 $this->fieldTemplate = '
92 <tr>
93 <td nowrap="nowrap" bgcolor="#F6F2E6">###FIELD_HELP_ICON###<font face="verdana" size="1" color="black"><strong>###FIELD_NAME###</strong></font>###FIELD_HELP_TEXT###</td>
94 </tr>
95 <tr>
96 <td nowrap="nowrap" bgcolor="#ABBBB4"><img name="req_###FIELD_TABLE###_###FIELD_ID###_###FIELD_FIELD###" src="clear.gif" width="10" height="10" alt="" /><img name="cm_###FIELD_TABLE###_###FIELD_ID###_###FIELD_FIELD###" src="clear.gif" width="7" height="10" alt="" /><font face="verdana" size="1" color="black">###FIELD_ITEM###</font>###FIELD_PAL_LINK_ICON###</td>
97 </tr> ';
98
99 $this->totalWrap = '<table border="0" cellpadding="1" cellspacing="0" bgcolor="black"><tr><td><table border="0" cellpadding="2" cellspacing="0">|</table></td></tr></table>';
100
101 $this->palFieldTemplate = '
102 <tr>
103 <td nowrap="nowrap" bgcolor="#ABBBB4"><font face="verdana" size="1" color="black">###FIELD_PALETTE###</font></td>
104 </tr> ';
105 $this->palFieldTemplateHeader = '
106 <tr>
107 <td nowrap="nowrap" bgcolor="#F6F2E6"><font face="verdana" size="1" color="black"><strong>###FIELD_HEADER###</strong></font></td>
108 </tr> ';
109 }
110
111 /**
112 * Includes a javascript library that exists in the core /typo3/ directory. The
113 * backpath is automatically applied.
114 * This method adds the library to $GLOBALS['TSFE']->additionalHeaderData[$lib].
115 *
116 * @param string $lib: Library name. Call it with the full path like "contrib/prototype/prototype.js" to load it
117 * @return void
118 */
119 public function loadJavascriptLib($lib) {
120 /** @var $pageRenderer t3lib_PageRenderer */
121 $pageRenderer = $GLOBALS['TSFE']->getPageRenderer();
122 $pageRenderer->addJsLibrary($lib, $this->prependBackPath($lib));
123
124 }
125
126 /**
127 * Insert additional style sheet link
128 *
129 * @param string $key: some key identifying the style sheet
130 * @param string $href: uri to the style sheet file
131 * @param string $title: value for the title attribute of the link element
132 * @return string $relation: value for the rel attribute of the link element
133 * @return void
134 */
135 public function addStyleSheet($key, $href, $title = '', $relation = 'stylesheet') {
136 /** @var $pageRenderer t3lib_PageRenderer */
137 $pageRenderer = $GLOBALS['TSFE']->getPageRenderer();
138 $pageRenderer->addCssFile($this->prependBackPath($href), $relation, 'screen', $title);
139 }
140
141 /**
142 * Initializes an anonymous template container.
143 * The created container can be compared to alt_doc.php in backend-only disposal.
144 *
145 * @return void
146 */
147 public function initializeTemplateContainer() {
148 t3lib_div::requireOnce(PATH_typo3 . 'template.php');
149 $GLOBALS['TBE_TEMPLATE'] = t3lib_div::makeInstance('frontendDoc');
150 $GLOBALS['TBE_TEMPLATE']->getPageRenderer()->addInlineSetting(
151 '', 'PATH_typo3', t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')) . '/' . TYPO3_mainDir
152 );
153
154 $GLOBALS['SOBE'] = new stdClass();
155 $GLOBALS['SOBE']->doc = $GLOBALS['TBE_TEMPLATE'];
156 }
157
158 /**
159 * Prepends backPath to given URL if it's not an absolute URL
160 *
161 * @param string $url
162 * @return string
163 */
164 private function prependBackPath($url) {
165 if (strpos($url, '://') !== FALSE || substr($url, 0, 1) === '/') {
166 return $url;
167 } else {
168 return $this->backPath . $url;
169 }
170
171 }
172 }
173
174 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tceforms_fe.php'])) {
175 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tceforms_fe.php']);
176 }
177
178 ?>