2 /***************************************************************
5 * (c) 1999-2008 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 * Displays the secondary-options palette for the TCEFORMs wherever they are shown.
31 * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
34 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
37 * [CLASS/FUNCTION INDEX of SCRIPT]
41 * 81: class formRender extends t3lib_TCEforms
42 * 91: function printPalette($palArr)
45 * 154: class formRender_vert extends t3lib_TCEforms
46 * 163: function printPalette($palArr)
49 * 223: class SC_alt_palette
50 * 247: function init()
51 * 301: function main()
52 * 341: function printContent()
55 * (This index is automatically created/updated by the extension "extdeveval")
62 require('template.php');
63 require_once(PATH_t3lib
.'class.t3lib_tceforms.php');
64 require_once(PATH_t3lib
.'class.t3lib_transferdata.php');
65 require_once(PATH_t3lib
.'class.t3lib_loaddbgroup.php');
66 $LANG->includeLLFile('EXT:lang/locallang_alt_doc.xml');
74 * Class for rendering the form fields.
75 * Extending the TCEforms class
77 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
80 * @deprecated since TYPO3 4.3, will be removed in TYPO3 4.5
82 class formRender
extends t3lib_TCEforms
{
85 * Creates the HTML content for the palette
86 * (Horizontally, for display in the top frame)
87 * (Used if GET var "backRef" IS set)
89 * @param array Array of information from which the fields are built.
90 * @return string HTML output
92 function printPalette($palArr) {
95 // For each element on the palette, write a few table cells with the field name, content and control images:
96 foreach($palArr as $content) {
99 '<img name="req_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" class="c-reqIcon" src="clear.gif" width="10" height="10" alt="" />'.
100 '<img name="cm_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" class="c-cmIcon" src="clear.gif" width="7" height="10" alt="" />'.
102 <td class="c-label">'.
103 $content['NAME'].' '.
106 $content['ITEM'].$content['HELP_ICON'].
110 // Finally, wrap it all in a table:
116 TCEforms palette, rendered in top frame.
118 <table border="0" cellpadding="0" cellspacing="0" id="typo3-TCEforms-palette">
120 <td class="c-close">'.
121 '<a href="#" onclick="closePal();return false;"><img'.t3lib_iconWorks
::skinImg('','gfx/close_12h.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.close',1).'" alt="" /></a>'.
129 // Return the result:
148 * Child class for alternative rendering of form fields (when the secondary fields are shown in a little window rather than the top bar).
149 * (Used if GET var "backRef" is not set, presuming a window is opened instead.)
151 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
155 class formRender_vert
extends t3lib_TCEforms
{
158 * Creates the HTML content for the palette.
159 * (Vertically, for display in a browser window, not top frame)
161 * @param array Array of information from which the fields are built.
162 * @return string HTML output
164 function printPalette($palArr) {
166 $bgColor=' bgcolor="'.$this->colorScheme
[2].'"';
168 // For each element on the palette, write a few table cells with the field name, content and control images:
169 foreach($palArr as $content) {
172 <td><img src="clear.gif" width="'.intval($this->paletteMargin
).'" height="1" alt="" /></td>
173 <td'.$bgColor.'> </td>
174 <td nowrap="nowrap"'.$bgColor.'><font color="'.$this->colorScheme
[4].'">'.$content['NAME'].'</font></td>
179 <td valign="top"><img name="req_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="10" height="10" vspace="4" alt="" /><img name="cm_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="7" height="10" vspace="4" alt="" /></td>
180 <td nowrap="nowrap" valign="top">'.$content['ITEM'].$content['HELP_ICON'].'</td>
184 // Adding the close button:
189 <td nowrap="nowrap" valign="top">
191 <input type="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.close',1).'" onclick="closePal(); return false;" />
195 // Finally, wrap it all in a table:
197 <table border="0" cellpadding="0" cellspacing="0" id="typo3-TCEforms-palette-vert">
198 '.implode('',$iRow).'
217 * Script Class for rendering the palette form for TCEforms in some other frame (in top frame, horizontally)
218 * It can also be called in a pop-up window in which case a vertically oriented set of form fields are rendered instead.
220 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
224 class SC_alt_palette
{
227 var $content; // Content accumulation
228 var $backRef; // String, which is the reference back to the window which opened this one.
229 var $formRef; // String, which is the reference to the form.
230 var $doc; // Template object.
232 // Internal, static: GPvar:
233 var $formName; // Form name
234 var $GPbackref; // The value of the original backRef GPvar (not necessarily the same as $this->backRef)
235 var $inData; // Contains tablename, uid and palette number
236 var $prependFormFieldNames; // Prefix for form fields.
237 var $rec; // The "record" with the data to display in the form fields.
244 * Constructor for the class
250 // Setting GPvars, etc.
251 $this->formName
= t3lib_div
::_GP('formName');
252 $this->GPbackref
= t3lib_div
::_GP('backRef');
253 $this->inData
= t3lib_div
::_GP('inData');
254 $this->prependFormFieldNames
= t3lib_div
::_GP('prependFormFieldNames');
255 $this->rec
= t3lib_div
::_GP('rec');
257 // Making references:
258 $this->backRef
= $this->GPbackref ?
$this->GPbackref
: 'window.opener';
259 # $this->backRef = 'top.content.list_frame.view_frame';
261 $this->formRef
= $this->backRef
.'.document.'.$this->formName
;
263 // Start template object:
264 $this->doc
= t3lib_div
::makeInstance('template');
265 $this->doc
->bodyTagMargins
['x']=0;
266 $this->doc
->bodyTagMargins
['y']=0;
267 $this->doc
->form
='<form action="#" method="post" name="'.htmlspecialchars($this->formName
).'" onsubmit="return false;">';
268 $this->doc
->backPath
= '';
270 // In case the palette is opened in a SEPARATE window (as the case is with frontend editing) then another body-tag id should be used (so we don't get the background image for the palette shown!)
271 if (!$this->GPbackref
) $this->doc
->bodyTagId
.= '-vert';
273 // Setting JavaScript functions for the header:
274 $this->doc
->JScode
= $this->doc
->wrapScriptTags('
275 var serialNumber = "";
276 function timeout_func() { //
277 if ('.$this->backRef
.' && '.$this->backRef
.'.document && '.$this->formRef
.') {
278 if ('.$this->formRef
.'["_serialNumber"]) {
280 if ('.$this->formRef
.'["_serialNumber"].value != serialNumber) {closePal(); return false;}
282 serialNumber = '.$this->formRef
.'["_serialNumber"].value;
285 window.setTimeout("timeout_func();",1*1000);
288 function closePal() { //
289 '.($this->GPbackref?
'window.location.href="alt_topmenu_dummy.php";':'close();').'
297 * Main function, rendering the palette form
305 $inData = explode(':',$this->inData
);
308 if (is_array($inData) && count($inData)==3) {
310 // Create the TCEforms object:
311 $tceforms = $this->GPbackref ?
new formRender() : new formRender_vert();
312 $tceforms->initDefaultBEMode();
313 $tceforms->palFieldTemplate
='###FIELD_PALETTE###';
314 $tceforms->palettesCollapsed
=0;
315 $tceforms->isPalettedoc
=$this->backRef
;
317 $tceforms->formName
= $this->formName
;
318 $tceforms->prependFormFieldNames
= $this->prependFormFieldNames
;
320 // Initialize other data:
323 $thePalNum = $inData[2];
324 $this->rec
['uid']=$theUid;
326 // Getting the palette fields rendered:
327 $panel.=$tceforms->getPaletteFields($table,$this->rec
,$thePalNum,'',implode(',',array_keys($this->rec
)));
330 // Add all the content, including JavaScript as needed.
331 $this->content
.=$tceforms->printNeededJSFunctions_top().$formContent.$tceforms->printNeededJSFunctions();
334 // Assemble the page:
335 $tempContent = $this->content
;
336 $this->content
= $this->doc
->startPage('TYPO3 Edit Palette');
337 $this->content
.= $tempContent;
341 * Outputting the accumulated content to screen
345 function printContent() {
346 $this->content
.= $this->doc
->endPage();
347 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
353 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/alt_palette.php']) {
354 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/alt_palette.php']);
360 $SOBE = t3lib_div
::makeInstance('SC_alt_palette');
363 $SOBE->printContent();