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