2 /***************************************************************
5 * (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
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.
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.
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.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * [CLASS/FUNCTION INDEX of SCRIPT]
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')
40 * (This index is automatically created/updated by the extension "extdeveval")
45 * Contains a frontend version of the TYPO3 Core Form generator - AKA "TCEforms"
49 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
55 * Extension class for the rendering of TCEforms in the frontend
57 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
59 class t3lib_TCEforms_FE
extends t3lib_TCEforms
{
62 * Constructs this object.
64 public function __construct() {
65 $this->initializeTemplateContainer();
66 parent
::__construct();
70 * Function for wrapping labels.
72 * @param string The string to wrap
75 public function wrapLabels($str) {
76 return '<font face="verdana" size="1" color="black">' . $str . '</font>';
80 * Prints the palette in the frontend editing (forms-on-page?)
82 * @param array The palette array to print
83 * @return string HTML output
85 public function printPalette(array $paletteArray) {
87 $bgColor = ' bgcolor="#D6DAD0"';
88 foreach($paletteArray as $content) {
89 $hRow[] = '<td' . $bgColor . '><font face="verdana" size="1"> </font></td><td nowrap="nowrap"' . $bgColor . '><font color="#666666" face="verdana" size="1">' . $content['NAME'] . '</font></td>';
90 $iRow[] = '<td valign="top">' .
91 '<img name="req_' . $content['TABLE'].'_' . $content['ID'] . '_' . $content['FIELD'] . '" src="clear.gif" width="10" height="10" alt="" />' .
92 '<img name="cm_' . $content['TABLE'].'_' . $content['ID'] . '_' . $content['FIELD'] . '" src="clear.gif" width="7" height="10" alt="" />' .
93 '</td><td nowrap="nowrap" valign="top">' . $content['ITEM'] . $content['HELP_ICON'] . '</td>';
95 $out = '<table border="0" cellpadding="0" cellspacing="0">
96 <tr><td><img src="clear.gif" width="' . intval($this->paletteMargin
) . '" height="1" alt="" /></td>' . implode('', $hRow) . '</tr>
97 <tr><td></td>' . implode('', $iRow) . '</tr>
104 * Sets the fancy front-end design of the editor.
109 public function setFancyDesign() {
110 $this->fieldTemplate
= '
112 <td nowrap="nowrap" bgcolor="#F6F2E6">###FIELD_HELP_ICON###<font face="verdana" size="1" color="black"><b>###FIELD_NAME###</b></font>###FIELD_HELP_TEXT###</td>
115 <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>
118 $this->totalWrap
= '<table border="0" cellpadding="1" cellspacing="0" bgcolor="black"><tr><td><table border="0" cellpadding="2" cellspacing="0">|</table></td></tr></table>';
120 $this->palFieldTemplate
= '
122 <td nowrap="nowrap" bgcolor="#ABBBB4"><font face="verdana" size="1" color="black">###FIELD_PALETTE###</font></td>
124 $this->palFieldTemplateHeader
= '
126 <td nowrap="nowrap" bgcolor="#F6F2E6"><font face="verdana" size="1" color="black"><b>###FIELD_HEADER###</b></font></td>
131 * Includes a javascript library that exists in the core /typo3/ directory. The
132 * backpath is automatically applied.
133 * This method adds the library to $GLOBALS['TSFE']->additionalHeaderData[$lib].
135 * @param string $lib: Library name. Call it with the full path like "contrib/prototype/prototype.js" to load it
138 public function loadJavascriptLib($lib) {
139 /** @var $pageRenderer t3lib_PageRenderer */
140 $pageRenderer = $GLOBALS['TSFE']->getPageRenderer();
141 $pageRenderer->addJsLibrary($lib, $this->prependBackPath($lib));
146 * Insert additional style sheet link
148 * @param string $key: some key identifying the style sheet
149 * @param string $href: uri to the style sheet file
150 * @param string $title: value for the title attribute of the link element
151 * @return string $relation: value for the rel attribute of the link element
154 public function addStyleSheet($key, $href, $title='', $relation='stylesheet') {
155 /** @var $pageRenderer t3lib_PageRenderer */
156 $pageRenderer = $GLOBALS['TSFE']->getPageRenderer();
157 $pageRenderer->addCssFile($this->prependBackPath($href), $relation, 'screen', $title);
161 * Initializes an anonymous template container.
162 * The created container can be compared to alt_doc.php in backend-only disposal.
166 public function initializeTemplateContainer() {
167 t3lib_div
::requireOnce(PATH_typo3
. 'template.php');
168 $GLOBALS['TBE_TEMPLATE'] = t3lib_div
::makeInstance('frontendDoc');
170 $GLOBALS['SOBE'] = new stdClass();
171 $GLOBALS['SOBE']->doc
= $GLOBALS['TBE_TEMPLATE'];
175 * Prepends backPath to given URL if it's not an absolute URL
180 private function prependBackPath($url) {
181 if (strpos($url, '://') !== FALSE ||
substr($url, 0, 1) === '/') {
184 return $this->backPath
. $url;
190 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_tceforms_fe.php']) {
191 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_tceforms_fe.php']);