Added feature #11148: Remove static require_once() to t3lib and tslib and use autoloa...
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_tceforms_fe.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2009 Kasper Skaarhoj (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 * [CLASS/FUNCTION INDEX of SCRIPT]
29 *
30 *
31 *
32 * 60: class t3lib_TCEforms_FE extends t3lib_TCEforms
33 * 68: public function wrapLabels($str)
34 * 78: public function printPalette(array $paletteArray)
35 * 102: public function setFancyDesign()
36 * 131: public function loadJavascriptLib($lib)
37 * 146: public function addStyleSheet($key, $href, $title='', $relation='stylesheet')
38 *
39 * TOTAL FUNCTIONS: 5
40 * (This index is automatically created/updated by the extension "extdeveval")
41 *
42 */
43
44 /**
45 * Contains a frontend version of the TYPO3 Core Form generator - AKA "TCEforms"
46 *
47 * $Id$
48 *
49 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
50 */
51
52
53
54 /**
55 * Extension class for the rendering of TCEforms in the frontend
56 *
57 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
58 */
59 class t3lib_TCEforms_FE extends t3lib_TCEforms {
60
61 /**
62 * Function for wrapping labels.
63 *
64 * @param string The string to wrap
65 * @return string
66 */
67 public function wrapLabels($str) {
68 return '<font face="verdana" size="1" color="black">' . $str . '</font>';
69 }
70
71 /**
72 * Prints the palette in the frontend editing (forms-on-page?)
73 *
74 * @param array The palette array to print
75 * @return string HTML output
76 */
77 public function printPalette(array $paletteArray) {
78 $out = '';
79 $bgColor = ' bgcolor="#D6DAD0"';
80 foreach($paletteArray as $content) {
81 $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>';
82 $iRow[] = '<td valign="top">' .
83 '<img name="req_' . $content['TABLE'].'_' . $content['ID'] . '_' . $content['FIELD'] . '" src="clear.gif" width="10" height="10" alt="" />' .
84 '<img name="cm_' . $content['TABLE'].'_' . $content['ID'] . '_' . $content['FIELD'] . '" src="clear.gif" width="7" height="10" alt="" />' .
85 '</td><td nowrap="nowrap" valign="top">' . $content['ITEM'] . $content['HELP_ICON'] . '</td>';
86 }
87 $out = '<table border="0" cellpadding="0" cellspacing="0">
88 <tr><td><img src="clear.gif" width="' . intval($this->paletteMargin) . '" height="1" alt="" /></td>' . implode('', $hRow) . '</tr>
89 <tr><td></td>' . implode('', $iRow) . '</tr>
90 </table>';
91
92 return $out;
93 }
94
95 /**
96 * Sets the fancy front-end design of the editor.
97 * Frontend
98 *
99 * @return void
100 */
101 public function setFancyDesign() {
102 $this->fieldTemplate = '
103 <tr>
104 <td nowrap="nowrap" bgcolor="#F6F2E6">###FIELD_HELP_ICON###<font face="verdana" size="1" color="black"><b>###FIELD_NAME###</b></font>###FIELD_HELP_TEXT###</td>
105 </tr>
106 <tr>
107 <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>
108 </tr> ';
109
110 $this->totalWrap = '<table border="0" cellpadding="1" cellspacing="0" bgcolor="black"><tr><td><table border="0" cellpadding="2" cellspacing="0">|</table></td></tr></table>';
111
112 $this->palFieldTemplate = '
113 <tr>
114 <td nowrap="nowrap" bgcolor="#ABBBB4"><font face="verdana" size="1" color="black">###FIELD_PALETTE###</font></td>
115 </tr> ';
116 $this->palFieldTemplateHeader = '
117 <tr>
118 <td nowrap="nowrap" bgcolor="#F6F2E6"><font face="verdana" size="1" color="black"><b>###FIELD_HEADER###</b></font></td>
119 </tr> ';
120 }
121
122 /**
123 * Includes a javascript library that exists in the core /typo3/ directory. The
124 * backpath is automatically applied.
125 * This method adds the library to $GLOBALS['TSFE']->additionalHeaderData[$lib].
126 *
127 * @param string $lib: Library name. Call it with the full path like "contrib/prototype/prototype.js" to load it
128 * @return void
129 */
130 public function loadJavascriptLib($lib) {
131 if (!isset($GLOBALS['TSFE']->additionalHeaderData[$lib])) {
132 $GLOBALS['TSFE']->additionalHeaderData[$lib] = '<script type="text/javascript" src="' . $this->backPath . $lib . '"></script>';
133 }
134 }
135
136 /**
137 * Insert additional style sheet link
138 *
139 * @param string $key: some key identifying the style sheet
140 * @param string $href: uri to the style sheet file
141 * @param string $title: value for the title attribute of the link element
142 * @return string $relation: value for the rel attribute of the link element
143 * @return void
144 */
145 public function addStyleSheet($key, $href, $title='', $relation='stylesheet') {
146 if (!isset($GLOBALS['TSFE']->additionalHeaderData[$key])) {
147 $GLOBALS['TSFE']->additionalHeaderData[$key] = '<link rel="' . $relation . '" type="text/css" href="' . $href . '"' . ($title ? (' title="' . $title . '"') : '') . ' />';
148 }
149 }
150 }
151
152 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tceforms_fe.php']) {
153 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tceforms_fe.php']);
154 }
155
156 ?>