2 /***************************************************************
5 * (c) 1999-2011 Kasper Skårhøj (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 * Contains TYPO3 Core Form generator - AKA "TCEforms"
30 * Revised for TYPO3 3.6 August/2003 by Kasper Skårhøj
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
38 * 'TCEforms' - Class for creating the backend editing forms.
40 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
41 * @coauthor René Fritz <r.fritz@colorcube.de>
45 class t3lib_TCEforms
{
47 // variables not commented yet.... (do so...)
48 var $palFieldArr = array();
49 var $disableWizards = 0;
50 var $isPalettedoc = 0;
51 var $paletteMargin = 1;
52 var $defStyle = ''; // 'font-family:Verdana;font-size:10px;';
53 var $cachedTSconfig = array();
54 var $cachedTSconfig_fieldLevel = array();
55 var $cachedLanguageFlag = array();
56 var $cachedAdditionalPreviewLanguages = NULL;
57 var $transformedRow = array();
59 var $printNeededJS = array();
60 var $hiddenFieldAccum = array();
61 var $TBE_EDITOR_fieldChanged_func = '';
63 var $prevBorderStyle = '[nothing here...]'; // Something unique...
64 var $allowUpload = 0; // If set direct upload fields will be shown
65 var $defaultLanguageData = array(); // Array where records in the default language is stored. (processed by transferdata)
66 var $defaultLanguageData_diff = array(); // Array where records in the default language is stored (raw without any processing. used for making diff)
67 var $additionalPreviewLanguageData = array();
71 var $backPath = ''; // Set this to the 'backPath' pointing back to the typo3 admin directory from the script where this form is displayed.
72 var $returnUrl = ''; // Alternative return URL path (default is t3lib_div::linkThisScript())
73 var $doSaveFieldName = ''; // Can be set to point to a field name in the form which will be set to '1' when the form is submitted with a *save* button. This way the recipient script can determine that the form was submitted for save and not "close" for example.
74 var $palettesCollapsed = 0; // Can be set TRUE/FALSE to whether palettes (secondary options) are in the topframe or in form. TRUE means they are NOT IN-form. So a collapsed palette is one, which is shown in the top frame, not in the page.
75 var $disableRTE = 0; // If set, the RTE is disabled (from form display, eg. by checkbox in the bottom of the page!)
76 var $globalShowHelp = 1; // If FALSE, then all CSH will be disabled, regardless of settings in $this->edit_showFieldHelp
77 var $localizationMode = ''; // If TRUE, the forms are rendering only localization relevant fields of the records.
78 var $fieldOrder = ''; // Overrule the field order set in TCA[types][showitem], eg for tt_content this value, 'bodytext,image', would make first the 'bodytext' field, then the 'image' field (if set for display)... and then the rest in the old order.
79 var $doPrintPalette = 1; // If set to FALSE, palettes will NEVER be rendered.
82 * Set to initialized clipboard object; Then the element browser will offer a link to paste in records from clipboard.
84 * @var t3lib_clipboard
87 var $enableClickMenu = FALSE; // Enable click menu on reference icons.
88 var $enableTabMenu = FALSE; // Enable Tab Menus.
89 var $renderReadonly = FALSE; // When enabled all fields are rendered non-editable.
91 var $form_rowsToStylewidth = 9.58; // Form field width compensation: Factor from NN4 form field widths to style-aware browsers (like NN6+ and MSIE, with the $GLOBALS['CLIENT']['FORMSTYLE'] value set)
92 var $form_largeComp = 1.33; // Form field width compensation: Compensation for large documents, doc-tab (editing)
93 var $charsPerRow = 40; // The number of chars expected per row when the height of a text area field is automatically calculated based on the number of characters found in the field content.
94 var $maxTextareaWidth = 48; // The maximum abstract value for textareas
95 var $maxInputWidth = 48; // The maximum abstract value for input fields
96 var $defaultMultipleSelectorStyle = 'width:250px;'; // Default style for the selector boxes used for multiple items in "select" and "group" types.
100 var $prependFormFieldNames = 'data'; // The string to prepend formfield names with.
101 var $prependCmdFieldNames = 'cmd'; // The string to prepend commands for tcemain::process_cmdmap with.
102 var $prependFormFieldNames_file = 'data_files'; // The string to prepend FILE form field names with.
103 var $formName = 'editform'; // The name attribute of the form.
104 var $allowOverrideMatrix = array(); // Whitelist that allows TCA field configuration to be overridden by TSconfig, @see overrideFieldConf()
108 var $perms_clause = ''; // Set by readPerms() (caching)
109 var $perms_clause_set = 0; // Set by readPerms() (caching-flag)
110 var $edit_showFieldHelp = ''; // Used to indicate the mode of CSH (Context Sensitive Help), whether it should be icons-only ('icon'), full description ('text') or not at all (blank).
111 var $docLarge = 0; // If set, the forms will be rendered a little wider, more precisely with a factor of $this->form_largeComp.
112 var $clientInfo = array(); // Loaded with info about the browser when class is instantiated.
113 var $RTEenabled = 0; // TRUE, if RTE is possible for the current user (based on result from BE_USER->isRTE())
114 var $RTEenabled_notReasons = ''; // If $this->RTEenabled was FALSE, you can find the reasons listed in this array which is filled with reasons why the RTE could not be loaded)
115 var $RTEcounter = 0; // Counter that is incremented before an RTE is created. Can be used for unique ids etc.
117 var $colorScheme; // Contains current color scheme
118 var $classScheme; // Contains current class scheme
119 var $defColorScheme; // Contains the default color scheme
120 var $defClassScheme; // Contains the default class scheme
121 var $fieldStyle; // Contains field style values
122 var $borderStyle; // Contains border style values.
124 var $commentMessages = array(); // An accumulation of messages from the class.
126 // INTERNAL, templates
127 var $totalWrap = '<hr />|<hr />'; // Total wrapping for the table rows.
128 var $fieldTemplate = '<strong>###FIELD_NAME###</strong><br />###FIELD_ITEM###<hr />'; // Field template
129 var $sectionWrap = ''; // Wrapping template code for a section
130 var $palFieldTemplateHeader = ''; // Template for palette headers
131 var $palFieldTemplate = ''; // Template for palettes
133 // INTERNAL, working memory
134 var $excludeElements = ''; // Set to the fields NOT to display, if any.
135 var $palettesRendered = array(); // During rendering of forms this will keep track of which palettes has already been rendered (so they are not rendered twice by mistake)
136 var $hiddenFieldListArr = array(); // This array of fields will be set as hidden-fields instead of rendered normally! For instance palette fields edited in the top frame are set as hidden fields since the main form has to submit the values. The top frame actually just sets the value in the main form!
137 var $requiredFields = array(); // Used to register input-field names, which are required. (Done during rendering of the fields). This information is then used later when the JavaScript is made.
138 var $requiredAdditional = array(); // Used to register input-field names, which are required an have additional requirements (e.g. like a date/time must be positive integer). The information of this array is merged with $this->requiredFields later.
139 var $requiredElements = array(); // Used to register the min and max number of elements for selectorboxes where that apply (in the "group" type for instance)
140 var $requiredNested = array(); // Used to determine where $requiredFields or $requiredElements are nested (in Tabs or IRRE)
141 var $renderDepth = 0; // Keeps track of the rendering depth of nested records.
142 var $savedSchemes = array(); // Color scheme buffer.
143 var $dynNestedStack = array(); // holds the path an element is nested in (e.g. required for RTEhtmlarea)
145 // Internal, registers for user defined functions etc.
146 var $additionalCode_pre = array(); // Additional HTML code, printed before the form.
147 var $additionalJS_pre = array(); // Additional JavaScript, printed before the form
148 var $additionalJS_post = array(); // Additional JavaScript printed after the form
149 var $additionalJS_submit = array(); // Additional JavaScript executed on submit; If you set "OK" variable it will raise an error about RTEs not being loaded and offer to block further submission.
150 var $additionalJS_delete = array(); // Additional JavaScript executed when section element is deleted. This is neceessary, for example, to correctly clean up HTMLArea RTE (bug #8232)
153 * Instance of t3lib_tceforms_inline
155 * @var t3lib_TCEforms_inline
158 var $hookObjectsMainFields = array(); // Array containing hook class instances called once for a form
159 var $hookObjectsSingleField = array(); // Array containing hook class instances called for each field
160 var $extraFormHeaders = array(); // Rows gettings inserted into the alt_doc headers (when called from alt_doc.php)
162 public $templateFile = ''; // Form templates, relative to typo3 directory
166 * Constructor function, setting internal variables, loading the styles used.
170 function __construct() {
171 $this->clientInfo
= t3lib_div
::clientInfo();
173 $this->RTEenabled
= $GLOBALS['BE_USER']->isRTE();
174 if (!$this->RTEenabled
) {
175 $this->RTEenabled_notReasons
= implode(LF
, $GLOBALS['BE_USER']->RTE_errors
);
176 $this->commentMessages
[] = 'RTE NOT ENABLED IN SYSTEM due to:' . LF
. $this->RTEenabled_notReasons
;
179 // Default color+class scheme
180 $this->defColorScheme
= array(
181 $GLOBALS['SOBE']->doc
->bgColor
, // Background for the field AND palette
182 t3lib_div
::modifyHTMLColorAll($GLOBALS['SOBE']->doc
->bgColor
, -20), // Background for the field header
183 t3lib_div
::modifyHTMLColorAll($GLOBALS['SOBE']->doc
->bgColor
, -10), // Background for the palette field header
184 'black', // Field header font color
185 '#666666' // Palette field header font color
187 $this->defColorScheme
= array();
189 // Override / Setting defaults from TBE_STYLES array
190 $this->resetSchemes();
192 // Setting the current colorScheme to default.
193 $this->defColorScheme
= $this->colorScheme
;
194 $this->defClassScheme
= $this->classScheme
;
196 // Define whitelist that allows TCA field configuration to be overridden by TSconfig, @see overrideFieldConf():
197 $this->allowOverrideMatrix
= array(
198 'input' => array('size', 'max'),
199 'text' => array('cols', 'rows', 'wrap'),
200 'check' => array('cols', 'showIfRTE'),
201 'select' => array('size', 'autoSizeMax', 'maxitems', 'minitems'),
202 'group' => array('size', 'autoSizeMax', 'max_size', 'show_thumbs', 'maxitems', 'minitems', 'disable_controls'),
203 'inline' => array('appearance', 'behaviour', 'foreign_label', 'foreign_selector', 'foreign_unique', 'maxitems', 'minitems', 'size', 'autoSizeMax', 'symmetric_label'),
206 // Create instance of t3lib_TCEforms_inline only if this a non-IRRE-AJAX call:
207 if (!isset($GLOBALS['ajaxID']) ||
strpos($GLOBALS['ajaxID'], 't3lib_TCEforms_inline::') !== 0) {
208 $this->inline
= t3lib_div
::makeInstance('t3lib_TCEforms_inline');
210 // Create instance of t3lib_TCEforms_suggest only if this a non-Suggest-AJAX call:
211 if (!isset($GLOBALS['ajaxID']) ||
strpos($GLOBALS['ajaxID'], 't3lib_TCEforms_suggest::') !== 0) {
212 $this->suggest
= t3lib_div
::makeInstance('t3lib_TCEforms_suggest');
215 // Prepare user defined objects (if any) for hooks which extend this function:
216 $this->hookObjectsMainFields
= array();
217 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'])) {
218 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'] as $classRef) {
219 $this->hookObjectsMainFields
[] = t3lib_div
::getUserObj($classRef);
222 $this->hookObjectsSingleField
= array();
223 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getSingleFieldClass'])) {
224 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getSingleFieldClass'] as $classRef) {
225 $this->hookObjectsSingleField
[] = t3lib_div
::getUserObj($classRef);
229 $this->templateFile
= 'templates/tceforms.html';
234 * Compatibility constructor.
236 * @deprecated since TYPO3 4.6 and will be removed in TYPO3 4.8. Use __construct() instead.
238 public function t3lib_TCEforms() {
239 t3lib_div
::logDeprecatedFunction();
240 // Note: we cannot call $this->__construct() here because it would call the derived class constructor and cause recursion
241 // This code uses official PHP behaviour (http://www.php.net/manual/en/language.oop5.basic.php) when $this in the
242 // statically called non-static method inherits $this from the caller's scope.
243 t3lib_TCEforms
::__construct();
247 * Initialize various internal variables.
251 function initDefaultBEmode() {
252 $this->prependFormFieldNames
= 'data';
253 $this->formName
= 'editform';
254 $this->setNewBEDesign();
255 $this->docLarge
= ($GLOBALS['BE_USER']->uc
['edit_wideDocument'] ?
1 : 0);
256 $this->edit_showFieldHelp
= $GLOBALS['BE_USER']->uc
['edit_showFieldHelp'];
258 $this->edit_docModuleUpload
= $GLOBALS['BE_USER']->uc
['edit_docModuleUpload'];
260 $this->inline
->init($this);
261 $this->suggest
->init($this);
265 /*******************************************************
267 * Rendering the forms, fields etc
269 *******************************************************/
272 * Will return the TCEform element for just a single field from a record.
273 * The field must be listed in the currently displayed fields (as found in [types][showitem]) for the record.
274 * This also means that the $table/$row supplied must be complete so the list of fields to show can be found correctly
276 * @param string The table name
277 * @param array The record from the table for which to render a field.
278 * @param string The field name to return the TCEform element for.
279 * @return string HTML output
280 * @see getMainFields()
282 function getSoloField($table, $row, $theFieldToReturn) {
283 if ($GLOBALS['TCA'][$table]) {
284 t3lib_div
::loadTCA($table);
285 $typeNum = $this->getRTypeNum($table, $row);
286 if ($GLOBALS['TCA'][$table]['types'][$typeNum]) {
287 $itemList = $GLOBALS['TCA'][$table]['types'][$typeNum]['showitem'];
289 $fields = t3lib_div
::trimExplode(',', $itemList, 1);
290 $excludeElements = $this->excludeElements
= $this->getExcludeElements($table, $row, $typeNum);
292 foreach ($fields as $fieldInfo) {
293 $parts = explode(';', $fieldInfo);
295 $theField = trim($parts[0]);
296 if (!in_array($theField, $excludeElements) && !strcmp($theField, $theFieldToReturn)) {
297 if ($GLOBALS['TCA'][$table]['columns'][$theField]) {
298 $sField = $this->getSingleField($table, $theField, $row, $parts[1], 1, $parts[3], $parts[2]);
299 return $sField['ITEM'];
309 * Based on the $table and $row of content, this displays the complete TCEform for the record.
310 * The input-$row is required to be preprocessed if necessary by eg. the t3lib_transferdata class. For instance the RTE content should be transformed through this class first.
312 * @param string The table name
313 * @param array The record from the table for which to render a field.
314 * @param integer Depth level
315 * @return string HTML output
316 * @see getSoloField()
318 function getMainFields($table, $row, $depth = 0) {
319 $this->renderDepth
= $depth;
322 $out_array = array(array());
323 $out_array_meta = array(array(
324 'title' => $this->getLL('l_generalTab')
329 $this->palettesRendered
= array();
330 $this->palettesRendered
[$this->renderDepth
][$table] = array();
332 // Hook: getMainFields_preProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
333 foreach ($this->hookObjectsMainFields
as $hookObj) {
334 if (method_exists($hookObj, 'getMainFields_preProcess')) {
335 $hookObj->getMainFields_preProcess($table, $row, $this);
339 if ($GLOBALS['TCA'][$table]) {
341 // Load the full TCA for the table.
342 t3lib_div
::loadTCA($table);
344 // Get dividers2tabs setting from TCA of the current table:
345 $dividers2tabs =& $GLOBALS['TCA'][$table]['ctrl']['dividers2tabs'];
347 // Load the description content for the table.
348 if ($this->edit_showFieldHelp ||
$this->doLoadTableDescr($table)) {
349 $GLOBALS['LANG']->loadSingleTableDescription($table);
351 // Get the current "type" value for the record.
352 $typeNum = $this->getRTypeNum($table, $row);
354 // Find the list of fields to display:
355 if ($GLOBALS['TCA'][$table]['types'][$typeNum]) {
356 $itemList = $GLOBALS['TCA'][$table]['types'][$typeNum]['showitem'];
357 if ($itemList) { // If such a list existed...
358 // Explode the field list and possibly rearrange the order of the fields, if configured for
359 $fields = t3lib_div
::trimExplode(',', $itemList, 1);
360 if ($this->fieldOrder
) {
361 $fields = $this->rearrange($fields);
364 // Get excluded fields, added fiels and put it together:
365 $excludeElements = $this->excludeElements
= $this->getExcludeElements($table, $row, $typeNum);
366 $fields = $this->mergeFieldsWithAddedFields($fields, $this->getFieldsToAdd($table, $row, $typeNum));
368 // If TCEforms will render a tab menu in the next step, push the name to the tab stack:
369 $tabIdentString = '';
370 $tabIdentStringMD5 = '';
371 if (strstr($itemList, '--div--') !== FALSE && $this->enableTabMenu
&& $dividers2tabs) {
372 $tabIdentString = 'TCEforms:' . $table . ':' . $row['uid'];
373 $tabIdentStringMD5 = $GLOBALS['TBE_TEMPLATE']->getDynTabMenuId($tabIdentString);
374 // Remember that were currently working on the general tab:
375 if (isset($fields[0]) && strpos($fields[0], '--div--') !== 0) {
376 $this->pushToDynNestedStack('tab', $tabIdentStringMD5 . '-1');
380 // Traverse the fields to render:
382 foreach ($fields as $fieldInfo) {
383 // Exploding subparts of the field configuration:
384 $parts = explode(';', $fieldInfo);
386 // Getting the style information out:
387 $color_style_parts = t3lib_div
::trimExplode('-', $parts[4]);
388 if (strcmp($color_style_parts[0], '')) {
389 $this->setColorScheme($GLOBALS['TBE_STYLES']['colorschemes'][intval($color_style_parts[0])]);
391 if (strcmp($color_style_parts[1], '')) {
392 $this->fieldStyle
= $GLOBALS['TBE_STYLES']['styleschemes'][intval($color_style_parts[1])];
393 if (!isset($this->fieldStyle
)) {
394 $this->fieldStyle
= $GLOBALS['TBE_STYLES']['styleschemes'][0];
397 if (strcmp($color_style_parts[2], '')) {
398 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
399 $this->borderStyle
= $GLOBALS['TBE_STYLES']['borderschemes'][intval($color_style_parts[2])];
400 if (!isset($this->borderStyle
)) {
401 $this->borderStyle
= $GLOBALS['TBE_STYLES']['borderschemes'][0];
406 $theField = $parts[0];
407 if (!in_array($theField, $excludeElements)) {
408 if ($GLOBALS['TCA'][$table]['columns'][$theField]) {
411 if ($parts[2] && !isset($this->palettesRendered
[$this->renderDepth
][$table][$parts[2]])) {
412 $sFieldPal = $this->getPaletteFields($table, $row, $parts[2]);
413 $this->palettesRendered
[$this->renderDepth
][$table][$parts[2]] = 1;
415 $sField = $this->getSingleField($table, $theField, $row, $parts[1], 0, $parts[3], $parts[2]);
417 $sField .= $sFieldPal;
420 $out_array[$out_sheet][$out_pointer] .= $sField;
421 } elseif ($theField == '--div--') {
423 $out_array[$out_sheet][$out_pointer] .= $this->getDivider();
425 if ($this->enableTabMenu
&& $dividers2tabs) {
426 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
427 // Remove last tab entry from the dynNestedStack:
429 // Remove the previous sheet from stack (if any):
430 $this->popFromDynNestedStack('tab', $tabIdentStringMD5 . '-' . ($out_sheet));
431 // Remember on which sheet we're currently working:
432 $this->pushToDynNestedStack('tab', $tabIdentStringMD5 . '-' . ($out_sheet +
1));
433 $out_array[$out_sheet] = array();
434 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
435 // Register newline for Tab
436 $out_array_meta[$out_sheet]['newline'] = ($parts[2] == "newline");
438 } else { // Setting alternative title for "General" tab if "--div--" is the very first element.
439 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
440 // Only add the first tab to the dynNestedStack if there are more tabs:
441 if ($tabIdentString && strpos($itemList, '--div--', strlen($fieldInfo))) {
442 $this->pushToDynNestedStack('tab', $tabIdentStringMD5 . '-1');
445 } elseif ($theField == '--palette--') {
446 if ($parts[2] && !isset($this->palettesRendered
[$this->renderDepth
][$table][$parts[2]])) {
447 // render a 'header' if not collapsed
448 if ($GLOBALS['TCA'][$table]['palettes'][$parts[2]]['canNotCollapse'] && $parts[1]) {
449 $out_array[$out_sheet][$out_pointer] .= $this->getPaletteFields($table, $row, $parts[2], $this->sL($parts[1]));
451 $out_array[$out_sheet][$out_pointer] .= $this->getPaletteFields($table, $row, $parts[2], '', '', $this->sL($parts[1]));
453 $this->palettesRendered
[$this->renderDepth
][$table][$parts[2]] = 1;
464 // Hook: getMainFields_postProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
465 foreach ($this->hookObjectsMainFields
as $hookObj) {
466 if (method_exists($hookObj, 'getMainFields_postProcess')) {
467 $hookObj->getMainFields_postProcess($table, $row, $this);
471 // Wrapping a border around it all:
472 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
475 $this->resetSchemes();
477 // Rendering Main palettes, if any
478 $mParr = t3lib_div
::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['mainpalette']);
481 foreach ($mParr as $mP) {
482 if (!isset($this->palettesRendered
[$this->renderDepth
][$table][$mP])) {
483 $temp_palettesCollapsed = $this->palettesCollapsed
;
484 $this->palettesCollapsed
= 0;
485 $label = ($i == 0 ?
$this->getLL('l_generalOptions') : $this->getLL('l_generalOptions_more'));
486 $out_array[$out_sheet][$out_pointer] .= $this->getPaletteFields($table, $row, $mP, $label);
487 $this->palettesCollapsed
= $temp_palettesCollapsed;
488 $this->palettesRendered
[$this->renderDepth
][$table][$mP] = 1;
490 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
492 if ($this->renderDepth
) {
493 $this->renderDepth
--;
498 // Return the imploded $out_array:
499 if ($out_sheet > 0) { // There were --div-- dividers around...
501 // Create parts array for the tab menu:
503 foreach ($out_array as $idx => $sheetContent) {
504 $content = implode('', $sheetContent);
506 // Wrap content (row) with table-tag, otherwise tab/sheet will be disabled (see getdynTabMenu() )
507 $content = '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . $content . '</table>';
509 $parts[$idx] = array(
510 'label' => $out_array_meta[$idx]['title'],
511 'content' => $content,
512 'newline' => $out_array_meta[$idx]['newline'], // Newline for this tab/sheet
516 if (count($parts) > 1) {
517 // Unset the current level of tab menus:
518 $this->popFromDynNestedStack('tab', $tabIdentStringMD5 . '-' . ($out_sheet +
1));
519 $dividersToTabsBehaviour = (isset($GLOBALS['TCA'][$table]['ctrl']['dividers2tabs'])
520 ?
$GLOBALS['TCA'][$table]['ctrl']['dividers2tabs']
522 $output = $this->getDynTabMenu($parts, $tabIdentString, $dividersToTabsBehaviour);
525 // If there is only one tab/part there is no need to wrap it into the dynTab code
526 $output = isset($parts[0]) ?
trim($parts[0]['content']) : '';
537 // Only one, so just implode:
538 $output = implode('', $out_array[$out_sheet]);
545 * Will return the TCEform elements for a pre-defined list of fields.
546 * Notice that this will STILL use the configuration found in the list [types][showitem] for those fields which are found there. So ideally the list of fields given as argument to this function should also be in the current [types][showitem] list of the record.
547 * Used for displaying forms for the frontend edit icons for instance.
549 * @param string The table name
550 * @param array The record array.
551 * @param string Commalist of fields from the table. These will be shown in the specified order in a form.
552 * @return string TCEform elements in a string.
554 function getListedFields($table, $row, $list) {
555 t3lib_div
::loadTCA($table);
556 if ($this->edit_showFieldHelp ||
$this->doLoadTableDescr($table)) {
557 $GLOBALS['LANG']->loadSingleTableDescription($table);
561 $types_fieldConfig = t3lib_BEfunc
::getTCAtypes($table, $row, 1);
563 $editFieldList = array_unique(t3lib_div
::trimExplode(',', $list, 1));
564 foreach ($editFieldList as $theFieldC) {
565 list($theField, $palFields) = preg_split('/\[|\]/', $theFieldC);
566 $theField = trim($theField);
567 $palFields = trim($palFields);
568 if ($GLOBALS['TCA'][$table]['columns'][$theField]) {
569 $parts = t3lib_div
::trimExplode(';', $types_fieldConfig[$theField]['origString']);
570 $sField = $this->getSingleField($table, $theField, $row, $parts[1], 0, $parts[3], 0); // Don't sent palette pointer - there are no options anyways for a field-list.
572 } elseif ($theField == '--div--') {
573 $out .= $this->getDivider();
576 $out .= $this->getPaletteFields($table, $row, '', '', implode(',', t3lib_div
::trimExplode('|', $palFields, 1)));
584 * Creates a palette (collection of secondary options).
586 * @param string The table name
587 * @param array The row array
588 * @param string The palette number/pointer
589 * @param string Header string for the palette (used when in-form). If not set, no header item is made.
590 * @param string Optional alternative list of fields for the palette
591 * @param string Optional Link text for activating a palette (when palettes does not have another form element to belong to).
592 * @return string HTML code.
594 function getPaletteFields($table, $row, $palette, $header = '', $itemList = '', $collapsedHeader = NULL) {
595 if (!$this->doPrintPalette
) {
600 $parts = $this->loadPaletteElements($table, $row, $palette, $itemList);
602 // Put palette together if there are fields in it:
607 foreach ($parts as $part) {
608 if ($part['NAME'] !== '--linebreak--') {
613 if ($realFields > 0) {
616 $out .= $this->intoTemplate(
617 array('HEADER' => htmlspecialchars($header)),
618 $this->palFieldTemplateHeader
622 $collapsed = $this->isPalettesCollapsed($table, $palette);
625 if ($collapsed && $collapsedHeader !== NULL) {
626 list($thePalIcon,) = $this->wrapOpenPalette(
627 t3lib_iconWorks
::getSpriteIcon(
628 'actions-system-options-view',
629 array('title' => htmlspecialchars($this->getLL('l_moreOptions')))
630 ), $table, $row, $palette, 1);
631 $thePalIcon = '<span style="margin-left: 20px;">' . $thePalIcon . $collapsedHeader . '</span>';
634 $paletteHtml = $this->wrapPaletteField($this->printPalette($parts), $table, $row, $palette, $collapsed);
636 $out .= $this->intoTemplate(
637 array('PALETTE' => $thePalIcon . $paletteHtml),
638 $this->palFieldTemplate
646 * Returns the form HTML code for a database table field.
648 * @param string The table name
649 * @param string The field name
650 * @param array The record to edit from the database table.
651 * @param string Alternative field name label to show.
652 * @param boolean Set this if the field is on a palette (in top frame), otherwise not. (if set, field will render as a hidden field).
653 * @param string The "extra" options from "Part 4" of the field configurations found in the "types" "showitem" list. Typically parsed by $this->getSpecConfFromString() in order to get the options as an associative array.
654 * @param integer The palette pointer.
655 * @return mixed String (normal) or array (palettes)
657 function getSingleField($table, $field, $row, $altName = '', $palette = 0, $extra = '', $pal = 0) {
659 // Hook: getSingleField_preProcess
660 foreach ($this->hookObjectsSingleField
as $hookObj) {
661 if (method_exists($hookObj, 'getSingleField_preProcess')) {
662 $hookObj->getSingleField_preProcess($table, $field, $row, $altName, $palette, $extra, $pal, $this);
668 $PA['altName'] = $altName;
669 $PA['palette'] = $palette;
670 $PA['extra'] = $extra;
673 // Make sure to load full $GLOBALS['TCA'] array for the table:
674 t3lib_div
::loadTCA($table);
676 // Get the TCA configuration for the current field:
677 $PA['fieldConf'] = $GLOBALS['TCA'][$table]['columns'][$field];
678 $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ?
$PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type']; // Using "form_type" locally in this script
680 $skipThisField = $this->inline
->skipField($table, $field, $row, $PA['fieldConf']['config']);
682 // Now, check if this field is configured and editable (according to excludefields + other configuration)
683 if (is_array($PA['fieldConf']) &&
685 (!$PA['fieldConf']['exclude'] ||
$GLOBALS['BE_USER']->check('non_exclude_fields', $table . ':' . $field)) &&
686 $PA['fieldConf']['config']['form_type'] != 'passthrough' &&
687 ($this->RTEenabled ||
!$PA['fieldConf']['config']['showIfRTE']) &&
688 (!$PA['fieldConf']['displayCond'] ||
$this->isDisplayCondition($PA['fieldConf']['displayCond'], $row)) &&
689 (!$GLOBALS['TCA'][$table]['ctrl']['languageField'] ||
$PA['fieldConf']['l10n_display'] ||
strcmp($PA['fieldConf']['l10n_mode'], 'exclude') ||
$row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] <= 0) &&
690 (!$GLOBALS['TCA'][$table]['ctrl']['languageField'] ||
!$this->localizationMode ||
$this->localizationMode
=== $PA['fieldConf']['l10n_cat'])
694 // Fetching the TSconfig for the current table/field. This includes the $row which means that
695 $PA['fieldTSConfig'] = $this->setTSconfig($table, $row, $field);
697 // If the field is NOT disabled from TSconfig (which it could have been) then render it
698 if (!$PA['fieldTSConfig']['disabled']) {
699 // Override fieldConf by fieldTSconfig:
700 $PA['fieldConf']['config'] = $this->overrideFieldConf($PA['fieldConf']['config'], $PA['fieldTSConfig']);
703 $PA['itemFormElName'] = $this->prependFormFieldNames
. '[' . $table . '][' . $row['uid'] . '][' . $field . ']'; // Form field name
704 $PA['itemFormElName_file'] = $this->prependFormFieldNames_file
. '[' . $table . '][' . $row['uid'] . '][' . $field . ']'; // Form field name, in case of file uploads
705 $PA['itemFormElValue'] = $row[$field]; // The value to show in the form field.
706 $PA['itemFormElID'] = $this->prependFormFieldNames
. '_' . $table . '_' . $row['uid'] . '_' . $field;
708 // set field to read-only if configured for translated records to show default language content as readonly
709 if ($PA['fieldConf']['l10n_display']
710 && t3lib_div
::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly')
711 && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] > 0) {
712 $PA['fieldConf']['config']['readOnly'] = TRUE;
713 $PA['itemFormElValue'] = $this->defaultLanguageData
[$table . ':' . $row['uid']][$field];
716 // Create a JavaScript code line which will ask the user to save/update the form due to changing the element. This is used for eg. "type" fields and others configured with "requestUpdate"
718 ($GLOBALS['TCA'][$table]['ctrl']['type'] && !strcmp($field, $GLOBALS['TCA'][$table]['ctrl']['type']))
719 ||
($GLOBALS['TCA'][$table]['ctrl']['requestUpdate']
720 && t3lib_div
::inList($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'], $field))) {
721 if ($GLOBALS['BE_USER']->jsConfirmation(1)) {
722 $alertMsgOnChange = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
724 $alertMsgOnChange = 'if (TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
727 $alertMsgOnChange = '';
730 // Render as a hidden field?
731 if (in_array($field, $this->hiddenFieldListArr
)) {
732 $this->hiddenFieldAccum
[] = '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
733 } else { // Render as a normal field:
735 // If the field is NOT a palette field, then we might create an icon which links to a palette for the field, if one exists.
736 if (!$PA['palette']) {
737 $paletteFields = $this->loadPaletteElements($table, $row, $PA['pal']);
738 if ($PA['pal'] && $this->isPalettesCollapsed($table, $PA['pal']) && count($paletteFields)) {
739 list($thePalIcon, $palJSfunc) = $this->wrapOpenPalette(t3lib_iconWorks
::getSpriteIcon('actions-system-options-view', array('title' => htmlspecialchars($this->getLL('l_moreOptions')))), $table, $row, $PA['pal'], 1);
745 // onFocus attribute to add to the field:
746 $PA['onFocus'] = (($palJSfunc && !$GLOBALS['BE_USER']->uc
['dontShowPalettesOnFocusInAB'])
747 ?
' onfocus="' . htmlspecialchars($palJSfunc) . '"'
752 $PA['label'] = ($PA['altName'] ?
$PA['altName'] : $PA['fieldConf']['label']);
753 $PA['label'] = ($PA['fieldTSConfig']['label'] ?
$PA['fieldTSConfig']['label'] : $PA['label']);
754 $PA['label'] = ($PA['fieldTSConfig']['label.'][$GLOBALS['LANG']->lang
] ?
$PA['fieldTSConfig']['label.'][$GLOBALS['LANG']->lang
] : $PA['label']);
755 $PA['label'] = $this->sL($PA['label']);
756 // JavaScript code for event handlers:
757 $PA['fieldChangeFunc'] = array();
758 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = "TBE_EDITOR.fieldChanged('" . $table . "','" . $row['uid'] . "','" . $field . "','" . $PA['itemFormElName'] . "');";
759 $PA['fieldChangeFunc']['alert'] = $alertMsgOnChange;
760 // if this is the child of an inline type and it is the field creating the label
761 if ($this->inline
->isInlineChildAndLabelField($table, $field)) {
762 $inlineObjectId = implode(
763 t3lib_TCEforms_inline
::Structure_Separator
,
765 $this->inline
->inlineNames
['object'],
770 $PA['fieldChangeFunc']['inline'] = "inline.handleChangedField('" . $PA['itemFormElName'] . "','" . $inlineObjectId . "');";
773 // Based on the type of the item, call a render function:
774 $item = $this->getSingleField_SW($table, $field, $row, $PA);
776 // Add language + diff
777 if ($PA['fieldConf']['l10n_display'] && (t3lib_div
::inList($PA['fieldConf']['l10n_display'], 'hideDiff') || t3lib_div
::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly'))) {
778 $renderLanguageDiff = FALSE;
780 $renderLanguageDiff = TRUE;
783 if ($renderLanguageDiff) {
784 $item = $this->renderDefaultLanguageContent($table, $field, $row, $item);
785 $item = $this->renderDefaultLanguageDiff($table, $field, $row, $item);
788 // If the record has been saved and the "linkTitleToSelf" is set, we make the field name into a link, which will load ONLY this field in alt_doc.php
789 $label = t3lib_div
::deHSCentities(htmlspecialchars($PA['label']));
790 if (t3lib_utility_Math
::canBeInterpretedAsInteger($row['uid']) && $PA['fieldTSConfig']['linkTitleToSelf'] && !t3lib_div
::_GP('columnsOnly')) {
791 $lTTS_url = $this->backPath
. 'alt_doc.php?edit[' . $table . '][' . $row['uid'] . ']=edit&columnsOnly=' . $field . '&returnUrl=' . rawurlencode($this->thisReturnUrl());
792 $label = '<a href="' . htmlspecialchars($lTTS_url) . '">' . $label . '</a>';
795 // wrap the label with help text
796 $PA['label'] = $label = t3lib_BEfunc
::wrapInHelp($table, $field, $label);
798 // Create output value:
799 if ($PA['fieldConf']['config']['form_type'] == 'user' && $PA['fieldConf']['config']['noTableWrapping']) {
801 } elseif ($PA['palette']) {
810 $out = $this->addUserTemplateMarkers($out, $table, $field, $row, $PA);
818 'PAL_LINK_ICON' => $thePalIcon,
821 $out = $this->addUserTemplateMarkers($out, $table, $field, $row, $PA);
823 $out = $this->intoTemplate($out);
827 $this->commentMessages
[] = $this->prependFormFieldNames
. '[' . $table . '][' . $row['uid'] . '][' . $field . ']: Disabled by TSconfig';
830 // Hook: getSingleField_postProcess
831 foreach ($this->hookObjectsSingleField
as $hookObj) {
832 if (method_exists($hookObj, 'getSingleField_postProcess')) {
833 $hookObj->getSingleField_postProcess($table, $field, $row, $out, $PA, $this);
836 // Return value (string or array)
841 * Rendering a single item for the form
843 * @param string Table name of record
844 * @param string Fieldname to render
845 * @param array The record
846 * @param array parameters array containing a lot of stuff. Value by Reference!
847 * @return string Returns the item as HTML code to insert
849 * @see getSingleField(), getSingleField_typeFlex_draw()
851 function getSingleField_SW($table, $field, $row, &$PA) {
852 $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ?
$PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type']; // Using "form_type" locally in this script
854 // Hook: getSingleField_beforeRender
855 foreach ($this->hookObjectsSingleField
as $hookObject) {
856 if (method_exists($hookObject, 'getSingleField_beforeRender')) {
857 $hookObject->getSingleField_beforeRender($table, $field, $row, $PA);
861 switch ($PA['fieldConf']['config']['form_type']) {
863 $item = $this->getSingleField_typeInput($table, $field, $row, $PA);
866 $item = $this->getSingleField_typeText($table, $field, $row, $PA);
869 $item = $this->getSingleField_typeCheck($table, $field, $row, $PA);
872 $item = $this->getSingleField_typeRadio($table, $field, $row, $PA);
875 $item = $this->getSingleField_typeSelect($table, $field, $row, $PA);
878 $item = $this->getSingleField_typeGroup($table, $field, $row, $PA);
881 $item = $this->inline
->getSingleField_typeInline($table, $field, $row, $PA);
884 $item = $this->getSingleField_typeNone($table, $field, $row, $PA);
887 $item = $this->getSingleField_typeUser($table, $field, $row, $PA);
890 $item = $this->getSingleField_typeFlex($table, $field, $row, $PA);
893 $item = $this->getSingleField_typeUnknown($table, $field, $row, $PA);
901 /**********************************************************
903 * Rendering of each TCEform field type
905 ************************************************************/
908 * Generation of TCEform elements of the type "input"
909 * This will render a single-line input form field, possibly with various control/validation features
911 * @param string The table name of the record
912 * @param string The field name which this element is supposed to edit
913 * @param array The record data array where the value(s) for the field can be found
914 * @param array An array with additional configuration options.
915 * @return string The HTML code for the TCEform field
917 function getSingleField_typeInput($table, $field, $row, &$PA) {
918 $config = $PA['fieldConf']['config'];
920 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
921 $size = t3lib_utility_Math
::forceIntegerInRange($config['size'] ?
$config['size'] : 30, 5, $this->maxInputWidth
);
922 $evalList = t3lib_div
::trimExplode(',', $config['eval'], 1);
923 $classAndStyleAttributes = $this->formWidthAsArray($size);
927 $cssClasses = array($classAndStyleAttributes['class']);
928 $cssStyle = $classAndStyleAttributes['style'];
930 if (!isset($config['checkbox'])) {
931 $config['checkbox'] = '0';
932 $checkboxIsset = FALSE;
934 $checkboxIsset = TRUE;
937 if (in_array('date', $evalList) ||
in_array('datetime', $evalList)) {
938 if (in_array('datetime', $evalList)) {
944 if (isset($config['range']['lower'])) {
945 $dateRange .= ' lower-' . intval($config['range']['lower']);
947 if (isset($config['range']['upper'])) {
948 $dateRange .= ' upper-' . intval($config['range']['upper']);
950 $inputId = uniqid('tceforms-' . $class . 'field-');
951 $cssClasses[] = 'tceforms-textfield tceforms-' . $class . 'field' . $dateRange;
952 $fieldAppendix = t3lib_iconWorks
::getSpriteIcon(
953 'actions-edit-pick-date',
955 'style' => 'cursor:pointer;',
956 'id' => 'picker-' . $inputId
959 } elseif (in_array('timesec', $evalList)) {
960 $inputId = uniqid('tceforms-timesecfield-');
961 $cssClasses[] = 'tceforms-textfield tceforms-timesecfield';
962 } elseif (in_array('year', $evalList)) {
963 $inputId = uniqid('tceforms-yearfield-');
964 $cssClasses[] = 'tceforms-textfield tceforms-yearfield';
965 } elseif (in_array('time', $evalList)) {
966 $inputId = uniqid('tceforms-timefield-');
967 $cssClasses[] = 'tceforms-textfield tceforms-timefield';
968 } elseif (in_array('int', $evalList)) {
969 $inputId = uniqid('tceforms-intfield-');
970 $cssClasses[] = 'tceforms-textfield tceforms-intfield';
971 } elseif (in_array('double2', $evalList)) {
972 $inputId = uniqid('tceforms-double2field-');
973 $cssClasses[] = 'tceforms-textfield tceforms-double2field';
975 $inputId = uniqid('tceforms-textfield-');
976 $cssClasses[] = 'tceforms-textfield';
977 if ($checkboxIsset === FALSE) {
978 $config['checkbox'] = '';
981 if (isset($config['wizards']['link'])) {
982 $inputId = uniqid('tceforms-linkfield-');
983 $cssClasses[] = 'tceforms-textfield tceforms-linkfield';
985 } elseif (isset($config['wizards']['color'])) {
986 $inputId = uniqid('tceforms-colorfield-');
987 $cssClasses[] = 'tceforms-textfield tceforms-colorfield';
990 if ($this->renderReadonly ||
$config['readOnly']) {
991 $itemFormElValue = $PA['itemFormElValue'];
992 if (in_array('date', $evalList)) {
993 $config['format'] = 'date';
994 } elseif (in_array('datetime', $evalList)) {
995 $config['format'] = 'datetime';
996 } elseif (in_array('time', $evalList)) {
997 $config['format'] = 'time';
999 if (in_array('password', $evalList)) {
1000 $itemFormElValue = $itemFormElValue ?
'*********' : '';
1002 return $this->getSingleField_typeNone_render($config, $itemFormElValue);
1005 foreach ($evalList as $func) {
1008 $this->registerRequiredProperty('field', $table . '_' . $row['uid'] . '_' . $field, $PA['itemFormElName']);
1009 // Mark this field for date/time disposal:
1010 if (array_intersect($evalList, array('date', 'datetime', 'time'))) {
1011 $this->requiredAdditional
[$PA['itemFormElName']]['isPositiveNumber'] = TRUE;
1015 if (t3lib_div
::hasValidClassPrefix($func)) {
1016 // Pair hook to the one in t3lib_TCEmain::checkValue_input_Eval()
1017 $evalObj = t3lib_div
::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
1018 if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue')) {
1020 'value' => $PA['itemFormElValue']
1022 $PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
1029 $paramsList = "'" . $PA['itemFormElName'] . "','" . implode(',', $evalList) . "','" . trim($config['is_in']) . "'," . (isset($config['checkbox']) ?
1 : 0) . ",'" . $config['checkbox'] . "'";
1030 if ((in_array('date', $evalList) ||
in_array('datetime', $evalList))) {
1031 $item .= '<span class="t3-tceforms-input-wrapper-datetime" onmouseOver="if (document.getElementById(\'' .
1032 $inputId . '\').value) {this.className=\'t3-tceforms-input-wrapper-datetime-hover\';} else {this.className=\'t3-tceforms-input-wrapper-datetime\';};" onmouseOut="this.className=\'t3-tceforms-input-wrapper-datetime\';">';
1034 // Add server timezone offset to UTC to our stored date
1035 if ($PA['itemFormElValue'] > 0) {
1036 $PA['itemFormElValue'] +
= date('Z', $PA['itemFormElValue']);
1039 $item .= '<span class="t3-tceforms-input-wrapper" onmouseOver="if (document.getElementById(\'' . $inputId .
1040 '\').value) {this.className=\'t3-tceforms-input-wrapper-hover\';} else {this.className=\'t3-tceforms-input-wrapper\';};" onmouseOut="this.className=\'t3-tceforms-input-wrapper\';">';
1043 $PA['fieldChangeFunc'] = array_merge(
1044 array('typo3form.fieldGet' => 'typo3form.fieldGet(' . $paramsList . ');'),
1045 $PA['fieldChangeFunc']
1047 // old function "checkbox" now the option to set the date / remove the date
1048 if (isset($config['checkbox'])) {
1049 $item .= t3lib_iconWorks
::getSpriteIcon('actions-input-clear', array('tag' => 'a', 'class' => 't3-tceforms-input-clearer', 'onclick' => 'document.getElementById(\'' . $inputId . '\').value=\'\';document.getElementById(\'' . $inputId . '\').focus();' . implode('', $PA['fieldChangeFunc'])));
1051 $mLgd = ($config['max'] ?
$config['max'] : 256);
1052 $iOnChange = implode('', $PA['fieldChangeFunc']);
1054 $item .= '<input type="text" id="' . $inputId .
1055 '" class="' . implode(' ', $cssClasses) . '" name="' . $PA['itemFormElName'] .
1056 '_hr" value="" style="' . $cssStyle . '" maxlength="' . $mLgd . '" onchange="' .
1057 htmlspecialchars($iOnChange) . '"' . $PA['onFocus'] . ' />'; // This is the EDITABLE form field.
1058 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' .
1059 htmlspecialchars($PA['itemFormElValue']) . '" />'; // This is the ACTUAL form field - values from the EDITABLE field must be transferred to this field which is the one that is written to the database.
1060 $item .= $fieldAppendix . '</span><div style="clear:both;"></div>';
1061 $this->extJSCODE
.= 'typo3form.fieldSet(' . $paramsList . ');';
1063 // going through all custom evaluations configured for this field
1064 foreach ($evalList as $evalData) {
1065 if (t3lib_div
::hasValidClassPrefix($evalData)) {
1066 $evalObj = t3lib_div
::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$evalData] . ':&' . $evalData);
1067 if (is_object($evalObj) && method_exists($evalObj, 'returnFieldJS')) {
1068 $this->extJSCODE
.= "\n\nfunction " . $evalData . "(value) {\n" . $evalObj->returnFieldJS() . "\n}\n";
1073 // Creating an alternative item without the JavaScript handlers.
1074 $altItem = '<input type="hidden" name="' . $PA['itemFormElName'] . '_hr" value="" />';
1075 $altItem .= '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1077 // Wrap a wizard around the item?
1078 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'] . '_hr', $specConf);
1084 * Generation of TCEform elements of the type "text"
1085 * This will render a <textarea> OR RTE area form field, possibly with various control/validation features
1087 * @param string The table name of the record
1088 * @param string The field name which this element is supposed to edit
1089 * @param array The record data array where the value(s) for the field can be found
1090 * @param array An array with additional configuration options.
1091 * @return string The HTML code for the TCEform field
1093 function getSingleField_typeText($table, $field, $row, &$PA) {
1096 $config = $PA['fieldConf']['config'];
1097 $evalList = t3lib_div
::trimExplode(',', $config['eval'], 1);
1099 if ($this->renderReadonly ||
$config['readOnly']) {
1100 return $this->getSingleField_typeNone_render($config, $PA['itemFormElValue']);
1103 // Setting columns number:
1104 $cols = t3lib_utility_Math
::forceIntegerInRange($config['cols'] ?
$config['cols'] : 30, 5, $this->maxTextareaWidth
);
1106 // Setting number of rows:
1107 $origRows = $rows = t3lib_utility_Math
::forceIntegerInRange($config['rows'] ?
$config['rows'] : 5, 1, 20);
1108 if (strlen($PA['itemFormElValue']) > $this->charsPerRow
* 2) {
1109 $cols = $this->maxTextareaWidth
;
1110 $rows = t3lib_utility_Math
::forceIntegerInRange(round(strlen($PA['itemFormElValue']) / $this->charsPerRow
), count(explode(LF
, $PA['itemFormElValue'])), 20);
1111 if ($rows < $origRows) {
1116 if (in_array('required', $evalList)) {
1117 $this->requiredFields
[$table . '_' . $row['uid'] . '_' . $field] = $PA['itemFormElName'];
1121 $RTEwasLoaded = 0; // Set TRUE, if the RTE is loaded; If not a normal textarea is shown.
1122 $RTEwouldHaveBeenLoaded = 0; // Set TRUE, if the RTE would have been loaded if it wasn't for the disable-RTE flag in the bottom of the page...
1124 // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. Traditionally, this is where RTE configuration has been found.
1125 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1127 // Setting up the altItem form field, which is a hidden field containing the value
1128 $altItem = '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1130 // If RTE is generally enabled (TYPO3_CONF_VARS and user settings)
1131 if ($this->RTEenabled
) {
1132 $p = t3lib_BEfunc
::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
1133 if (isset($specConf['richtext']) && (!$p['flag'] ||
!$row[$p['flag']])) { // If the field is configured for RTE and if any flag-field is not set to disable it.
1134 t3lib_BEfunc
::fixVersioningPid($table, $row);
1135 list($tscPID, $thePidValue) = $this->getTSCpid($table, $row['uid'], $row['pid']);
1137 // If the pid-value is not negative (that is, a pid could NOT be fetched)
1138 if ($thePidValue >= 0) {
1139 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', t3lib_BEfunc
::getPagesTSconfig($tscPID));
1140 $RTEtypeVal = t3lib_BEfunc
::getTCAtypeValue($table, $row);
1141 $thisConfig = t3lib_BEfunc
::RTEsetup($RTEsetup['properties'], $table, $field, $RTEtypeVal);
1143 if (!$thisConfig['disabled']) {
1144 if (!$this->disableRTE
) {
1145 $this->RTEcounter++
;
1147 // Find alternative relative path for RTE images/links:
1148 $eFile = t3lib_parsehtml_proc
::evalWriteFile($specConf['static_write'], $row);
1149 $RTErelPath = is_array($eFile) ?
dirname($eFile['relEditFile']) : '';
1151 // Get RTE object, draw form and set flag:
1152 $RTEobj = t3lib_BEfunc
::RTEgetObj();
1153 $item = $RTEobj->drawRTE($this, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue);
1156 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf, 1);
1160 $RTEwouldHaveBeenLoaded = 1;
1161 $this->commentMessages
[] = $PA['itemFormElName'] . ': RTE is disabled by the on-page RTE-flag (probably you can enable it by the check-box in the bottom of this page!)';
1164 $this->commentMessages
[] = $PA['itemFormElName'] . ': RTE is disabled by the Page TSconfig, "RTE"-key (eg. by RTE.default.disabled=0 or such)';
1167 $this->commentMessages
[] = $PA['itemFormElName'] . ': PID value could NOT be fetched. Rare error, normally with new records.';
1170 if (!isset($specConf['richtext'])) {
1171 $this->commentMessages
[] = $PA['itemFormElName'] . ': RTE was not configured for this field in TCA-types';
1173 if (!(!$p['flag'] ||
!$row[$p['flag']])) {
1174 $this->commentMessages
[] = $PA['itemFormElName'] . ': Field-flag (' . $PA['flag'] . ') has been set to disable RTE!';
1179 // Display ordinary field if RTE was not loaded.
1180 if (!$RTEwasLoaded) {
1181 if ($specConf['rte_only']) { // Show message, if no RTE (field can only be edited with RTE!)
1182 $item = '<p><em>' . htmlspecialchars($this->getLL('l_noRTEfound')) . '</em></p>';
1184 if ($specConf['nowrap']) {
1187 $wrap = ($config['wrap'] ?
$config['wrap'] : 'virtual');
1191 if ($specConf['fixed-font']) {
1192 $classes[] = 'fixed-font';
1194 if ($specConf['enable-tab']) {
1195 $classes[] = 'enable-tab';
1198 $formWidthText = $this->formWidthText($cols, $wrap);
1200 // Extract class attributes from $formWidthText (otherwise it would be added twice to the output)
1202 if (preg_match('/ class="(.+?)"/', $formWidthText, $res)) {
1203 $formWidthText = str_replace(' class="' . $res[1] . '"', '', $formWidthText);
1204 $classes = array_merge($classes, explode(' ', $res[1]));
1207 if (count($classes)) {
1208 $class = ' class="tceforms-textarea ' . implode(' ', $classes) . '"';
1210 $class = 'tceforms-textarea';
1213 $evalList = t3lib_div
::trimExplode(',', $config['eval'], 1);
1214 foreach ($evalList as $func) {
1217 $this->registerRequiredProperty('field', $table . '_' . $row['uid'] . '_' . $field, $PA['itemFormElName']);
1220 if (t3lib_div
::hasValidClassPrefix($func)) {
1221 // Pair hook to the one in t3lib_TCEmain::checkValue_input_Eval() and t3lib_TCEmain::checkValue_text_Eval()
1222 $evalObj = t3lib_div
::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
1223 if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue')) {
1225 'value' => $PA['itemFormElValue']
1227 $PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
1234 $iOnChange = implode('', $PA['fieldChangeFunc']);
1236 <textarea id="' . uniqid('tceforms-textarea-') . '" name="' . $PA['itemFormElName'] . '"' . $formWidthText . $class . ' rows="' . $rows . '" wrap="' . $wrap . '" onchange="' . htmlspecialchars($iOnChange) . '"' . $PA['onFocus'] . '>' .
1237 t3lib_div
::formatForTextarea($PA['itemFormElValue']) .
1239 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf, $RTEwouldHaveBeenLoaded);
1243 // Return field HTML:
1248 * Generation of TCEform elements of the type "check"
1249 * This will render a check-box OR an array of checkboxes
1251 * @param string The table name of the record
1252 * @param string The field name which this element is supposed to edit
1253 * @param array The record data array where the value(s) for the field can be found
1254 * @param array An array with additional configuration options.
1255 * @return string The HTML code for the TCEform field
1257 function getSingleField_typeCheck($table, $field, $row, &$PA) {
1258 $config = $PA['fieldConf']['config'];
1262 if ($this->renderReadonly ||
$config['readOnly']) {
1263 $disabled = ' disabled="disabled"';
1266 // Traversing the array of items:
1267 $selItems = $this->initItemArray($PA['fieldConf']);
1268 if ($config['itemsProcFunc']) {
1269 $selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
1272 if (!count($selItems)) {
1273 $selItems[] = array('', '');
1275 $thisValue = intval($PA['itemFormElValue']);
1277 $cols = intval($config['cols']);
1279 $item .= '<table border="0" cellspacing="0" cellpadding="0" class="typo3-TCEforms-checkboxArray">';
1280 for ($c = 0; $c < count($selItems); $c++
) {
1282 if (!($c %
$cols)) {
1285 $cBP = $this->checkBoxParams($PA['itemFormElName'], $thisValue, $c, count($selItems), implode('', $PA['fieldChangeFunc']));
1286 $cBName = $PA['itemFormElName'] . '_' . $c;
1287 $cBID = $PA['itemFormElID'] . '_' . $c;
1288 $item .= '<td nowrap="nowrap">' .
1289 '<input type="checkbox"' . $this->insertDefStyle('check') . ' value="1" name="' . $cBName . '"' . $cBP . $disabled . ' id="' . $cBID . '" />' .
1290 $this->wrapLabels('<label for="' . $cBID . '">' . htmlspecialchars($p[0]) . '</label> ') .
1292 if (($c %
$cols) +
1 == $cols) {
1297 $rest = $cols - ($c %
$cols);
1298 for ($c = 0; $c < $rest; $c++
) {
1299 $item .= '<td></td>';
1305 $item .= '</table>';
1307 for ($c = 0; $c < count($selItems); $c++
) {
1309 $cBP = $this->checkBoxParams($PA['itemFormElName'], $thisValue, $c, count($selItems), implode('', $PA['fieldChangeFunc']));
1310 $cBName = $PA['itemFormElName'] . '_' . $c;
1311 $cBID = $PA['itemFormElID'] . '_' . $c;
1312 $item .= ($c > 0 ?
'<br />' : '') .
1313 '<input type="checkbox"' . $this->insertDefStyle('check') . ' value="1" name="' . $cBName . '"' . $cBP . $PA['onFocus'] . $disabled . ' id="' . $cBID . '" />' .
1314 $this->wrapLabels('<label for="' . $cBID . '">' . htmlspecialchars($p[0]) . '</label>');
1318 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($thisValue) . '" />';
1325 * Generation of TCEform elements of the type "radio"
1326 * This will render a series of radio buttons.
1328 * @param string The table name of the record
1329 * @param string The field name which this element is supposed to edit
1330 * @param array The record data array where the value(s) for the field can be found
1331 * @param array An array with additional configuration options.
1332 * @return string The HTML code for the TCEform field
1334 function getSingleField_typeRadio($table, $field, $row, &$PA) {
1335 $config = $PA['fieldConf']['config'];
1339 if ($this->renderReadonly ||
$config['readOnly']) {
1340 $disabled = ' disabled="disabled"';
1343 // Get items for the array:
1344 $selItems = $this->initItemArray($PA['fieldConf']);
1345 if ($config['itemsProcFunc']) {
1346 $selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
1349 // Traverse the items, making the form elements:
1350 for ($c = 0; $c < count($selItems); $c++
) {
1352 $rID = $PA['itemFormElID'] . '_' . $c;
1353 $rOnClick = implode('', $PA['fieldChangeFunc']);
1354 $rChecked = (!strcmp($p[1], $PA['itemFormElValue']) ?
' checked="checked"' : '');
1355 $item .= '<input type="radio"' . $this->insertDefStyle('radio') . ' name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($p[1]) . '" onclick="' . htmlspecialchars($rOnClick) . '"' . $rChecked . $PA['onFocus'] . $disabled . ' id="' . $rID . '" />
1356 <label for="' . $rID . '">' . htmlspecialchars($p[0]) . '</label>
1364 * Generation of TCEform elements of the type "select"
1365 * This will render a selector box element, or possibly a special construction with two selector boxes. That depends on configuration.
1367 * @param string The table name of the record
1368 * @param string The field name which this element is supposed to edit
1369 * @param array The record data array where the value(s) for the field can be found
1370 * @param array An array with additional configuration options.
1371 * @return string The HTML code for the TCEform field
1373 function getSingleField_typeSelect($table, $field, $row, &$PA) {
1375 // Field configuration from TCA:
1376 $config = $PA['fieldConf']['config'];
1379 if ($this->renderReadonly ||
$config['readOnly']) {
1380 $disabled = ' disabled="disabled"';
1383 // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. See http://typo3.org/documentation/document-library/doc_core_api/Wizards_Configuratio/.
1384 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1386 // Getting the selector box items from the system
1387 $selItems = $this->addSelectOptionsToItemArray(
1388 $this->initItemArray($PA['fieldConf']),
1390 $this->setTSconfig($table, $row),
1393 // Possibly filter some items:
1394 $keepItemsFunc = create_function('$value', 'return $value[1];');
1395 $selItems = t3lib_div
::keepItemsInArray($selItems, $PA['fieldTSConfig']['keepItems'], $keepItemsFunc);
1396 // Possibly add some items:
1397 $selItems = $this->addItems($selItems, $PA['fieldTSConfig']['addItems.']);
1398 // Process items by a user function:
1399 if (isset($config['itemsProcFunc']) && $config['itemsProcFunc']) {
1400 $selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
1403 // Possibly remove some items:
1404 $removeItems = t3lib_div
::trimExplode(',', $PA['fieldTSConfig']['removeItems'], 1);
1405 foreach ($selItems as $tk => $p) {
1407 // Checking languages and authMode:
1408 $languageDeny = $GLOBALS['TCA'][$table]['ctrl']['languageField']
1409 && !strcmp($GLOBALS['TCA'][$table]['ctrl']['languageField'], $field)
1410 && !$GLOBALS['BE_USER']->checkLanguageAccess($p[1]);
1411 $authModeDeny = $config['form_type'] == 'select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table, $field, $p[1], $config['authMode']);
1412 if (in_array($p[1], $removeItems) ||
$languageDeny ||
$authModeDeny) {
1413 unset($selItems[$tk]);
1414 } elseif (isset($PA['fieldTSConfig']['altLabels.'][$p[1]])) {
1415 $selItems[$tk][0] = $this->sL($PA['fieldTSConfig']['altLabels.'][$p[1]]);
1418 // Removing doktypes with no access:
1419 if (($table === 'pages' ||
$table === 'pages_language_overlay') && $field === 'doktype') {
1420 if (!($GLOBALS['BE_USER']->isAdmin() || t3lib_div
::inList($GLOBALS['BE_USER']->groupData
['pagetypes_select'], $p[1]))) {
1421 unset($selItems[$tk]);
1426 // Creating the label for the "No Matching Value" entry.
1427 $nMV_label = isset($PA['fieldTSConfig']['noMatchingValue_label']) ?
$this->sL($PA['fieldTSConfig']['noMatchingValue_label']) : '[ ' . $this->getLL('l_noMatchingValue') . ' ]';
1429 // Prepare some values:
1430 $maxitems = intval($config['maxitems']);
1432 // If a SINGLE selector box...
1433 if ($maxitems <= 1 && $config['renderMode'] !== 'tree') {
1434 $item = $this->getSingleField_typeSelect_single($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1435 } elseif (!strcmp($config['renderMode'], 'checkbox')) { // Checkbox renderMode
1436 $item = $this->getSingleField_typeSelect_checkbox($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1437 } elseif (!strcmp($config['renderMode'], 'singlebox')) { // Single selector box renderMode
1438 $item = $this->getSingleField_typeSelect_singlebox($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1439 } elseif (!strcmp($config['renderMode'], 'tree')) { // Tree renderMode
1440 $treeClass = t3lib_div
::makeInstance('t3lib_TCEforms_Tree', $this);
1441 $item = $treeClass->renderField($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1442 } else { // Traditional multiple selector box:
1443 $item = $this->getSingleField_typeSelect_multiple($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1448 $altItem = '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1449 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf);
1456 * Creates a single-selector box
1457 * (Render function for getSingleField_typeSelect())
1459 * @param string See getSingleField_typeSelect()
1460 * @param string See getSingleField_typeSelect()
1461 * @param array See getSingleField_typeSelect()
1462 * @param array See getSingleField_typeSelect()
1463 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1464 * @param array Items available for selection
1465 * @param string Label for no-matching-value
1466 * @return string The HTML code for the item
1467 * @see getSingleField_typeSelect()
1469 function getSingleField_typeSelect_single($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
1470 // check against inline uniqueness
1471 $inlineParent = $this->inline
->getStructureLevel(-1);
1472 if (is_array($inlineParent) && $inlineParent['uid']) {
1473 if ($inlineParent['config']['foreign_table'] == $table && $inlineParent['config']['foreign_unique'] == $field) {
1474 $uniqueIds = $this->inline
->inlineData
['unique'][$this->inline
->inlineNames
['object'] . '[' . $table . ']']['used'];
1475 $PA['fieldChangeFunc']['inlineUnique'] = "inline.updateUnique(this,'" . $this->inline
->inlineNames
['object'] . '[' . $table . "]','" . $this->inline
->inlineNames
['form'] . "','" . $row['uid'] . "');";
1477 // hide uid of parent record for symmetric relations
1478 if ($inlineParent['config']['foreign_table'] == $table && ($inlineParent['config']['foreign_field'] == $field ||
$inlineParent['config']['symmetric_field'] == $field)) {
1479 $uniqueIds[] = $inlineParent['uid'];
1486 $noMatchingValue = 1;
1488 $selicons = array();
1489 $onlySelectedIconShown = 0;
1490 $size = intval($config['size']);
1491 $selectedStyle = ''; // Style set on <select/>
1495 $onChangeIcon = ''; // TODO: icon is used but never assigned
1497 if ($this->renderReadonly ||
$config['readOnly']) {
1498 $disabled = ' disabled="disabled"';
1499 $onlySelectedIconShown = 1;
1502 // Icon configuration:
1503 if ($config['suppress_icons'] == 'IF_VALUE_FALSE') {
1504 $suppressIcons = !$PA['itemFormElValue'] ?
1 : 0;
1505 } elseif ($config['suppress_icons'] == 'ONLY_SELECTED') {
1507 $onlySelectedIconShown = 1;
1508 } elseif ($config['suppress_icons']) {
1514 // Traverse the Array of selector box items:
1515 $optGroupStart = array();
1516 $optGroupOpen = FALSE;
1517 $classesForSelectTag = array();
1518 foreach ($selItems as $p) {
1519 $sM = (!strcmp($PA['itemFormElValue'], $p[1]) ?
' selected="selected"' : '');
1522 $noMatchingValue = 0;
1525 // Getting style attribute value (for icons):
1526 if ($config['iconsInOptionTags']) {
1527 $styleAttrValue = $this->optionTagStyle($p[2]);
1529 list($selectIconFile, $selectIconInfo) = $this->getIcon($p[2]);
1530 if (!empty($selectIconInfo)) {
1531 $selectedStyle = ' style="background-image:url(' . $selectIconFile . ');"';
1532 $classesForSelectTag[] = 'typo3-TCEforms-select-selectedItemWithBackgroundImage';
1537 // Compiling the <option> tag:
1538 if (!($p[1] != $PA['itemFormElValue'] && is_array($uniqueIds) && in_array($p[1], $uniqueIds))) {
1539 if (!strcmp($p[1], '--div--')) {
1540 $optGroupStart[0] = $p[0];
1541 if ($config['iconsInOptionTags']) {
1542 $optGroupStart[1] = $this->optgroupTagStyle($p[2]);
1544 $optGroupStart[1] = $styleAttrValue;
1548 if (count($optGroupStart)) {
1549 if ($optGroupOpen) { // Closing last optgroup before next one starts
1550 $opt[] = '</optgroup>' . LF
;
1552 $opt[] = '<optgroup label="' . t3lib_div
::deHSCentities(htmlspecialchars($optGroupStart[0])) . '"' .
1553 ($optGroupStart[1] ?
' style="' . htmlspecialchars($optGroupStart[1]) . '"' : '') .
1554 ' class="c-divider">' . LF
;
1555 $optGroupOpen = TRUE;
1557 $optGroupStart = array();
1559 $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' .
1561 ($styleAttrValue ?
' style="' . htmlspecialchars($styleAttrValue) . '"' : '') .
1562 '>' . t3lib_div
::deHSCentities(($p[0])) . '</option>' . LF
;
1566 // If there is an icon for the selector box (rendered in selicon-table below)...:
1567 // if there is an icon ($p[2]), icons should be shown, and, if only selected are visible, is it selected
1568 if ($p[2] && !$suppressIcons && (!$onlySelectedIconShown ||
$sM)) {
1569 list($selIconFile, $selIconInfo) = $this->getIcon($p[2]);
1570 if (!empty($selIconInfo)) {
1571 $iOnClick = $this->elName($PA['itemFormElName']) . '.selectedIndex=' . $c . '; ' .
1572 $this->elName($PA['itemFormElName']) . '.style.backgroundImage=' . $this->elName($PA['itemFormElName']) . '.options[' . $c . '].style.backgroundImage; ' .
1573 implode('', $PA['fieldChangeFunc']) . $this->blur() . 'return false;';
1575 $iOnClick = $this->elName($PA['itemFormElName']) . '.selectedIndex=' . $c . '; ' .
1576 $this->elName($PA['itemFormElName']) . '.className=' . $this->elName($PA['itemFormElName']) . '.options[' . $c . '].className; ' .
1577 implode('', $PA['fieldChangeFunc']) . $this->blur() . 'return false;';
1579 $selicons[] = array(
1580 (!$onlySelectedIconShown ?
'<a href="#" onclick="' . htmlspecialchars($iOnClick) . '">' : '') .
1581 $this->getIconHtml($p[2], htmlspecialchars($p[0]), htmlspecialchars($p[0])) .
1582 (!$onlySelectedIconShown ?
'</a>' : ''),
1588 if ($optGroupOpen) { // Closing optgroup if open
1589 $opt[] = '</optgroup>';
1590 $optGroupOpen = FALSE;
1593 // No-matching-value:
1594 if ($PA['itemFormElValue'] && $noMatchingValue && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1595 $nMV_label = @sprintf
($nMV_label, $PA['itemFormElValue']);
1596 $opt[] = '<option value="' . htmlspecialchars($PA['itemFormElValue']) . '" selected="selected">' . htmlspecialchars($nMV_label) . '</option>';
1599 // Create item form fields:
1600 $sOnChange = 'if (this.options[this.selectedIndex].value==\'--div--\') {this.selectedIndex=' . $sI . ';} ' . implode('', $PA['fieldChangeFunc']);
1602 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '_selIconVal" value="' . htmlspecialchars($sI) . '" />'; // MUST be inserted before the selector - else is the value of the hiddenfield here mysteriously submitted...
1604 if ($config['iconsInOptionTags']) {
1605 $classesForSelectTag[] = 'icon-select';
1607 $item .= '<select' . $selectedStyle . ' id="' . uniqid('tceforms-select-') . '" name="' . $PA['itemFormElName'] . '"' .
1608 $this->insertDefStyle('select', implode(' ', $classesForSelectTag)) .
1609 ($size ?
' size="' . $size . '"' : '') .
1610 ' onchange="' . htmlspecialchars($onChangeIcon . $sOnChange) . '"' .
1611 $PA['onFocus'] . $disabled . '>';
1612 $item .= implode('', $opt);
1613 $item .= '</select>';
1615 // Create icon table:
1616 if (count($selicons) && !$config['noIconsBelowSelect']) {
1617 $item .= '<table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-selectIcons">';
1618 $selicon_cols = intval($config['selicon_cols']);
1619 if (!$selicon_cols) {
1620 $selicon_cols = count($selicons);
1622 $sR = ceil(count($selicons) / $selicon_cols);
1623 $selicons = array_pad($selicons, $sR * $selicon_cols, '');
1624 for ($sa = 0; $sa < $sR; $sa++
) {
1626 for ($sb = 0; $sb < $selicon_cols; $sb++
) {
1627 $sk = ($sa * $selicon_cols +
$sb);
1628 $imgN = 'selIcon_' . $table . '_' . $row['uid'] . '_' . $field . '_' . $selicons[$sk][1];
1629 $imgS = ($selicons[$sk][2] ?
$this->backPath
. 'gfx/content_selected.gif' : 'clear.gif');
1630 $item .= '<td><img name="' . htmlspecialchars($imgN) . '" src="' . $imgS . '" width="7" height="10" alt="" /></td>';
1631 $item .= '<td>' . $selicons[$sk][0] . '</td>';
1635 $item .= '</table>';
1642 * Creates a checkbox list (renderMode = "checkbox")
1643 * (Render function for getSingleField_typeSelect())
1645 * @param string See getSingleField_typeSelect()
1646 * @param string See getSingleField_typeSelect()
1647 * @param array See getSingleField_typeSelect()
1648 * @param array See getSingleField_typeSelect()
1649 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1650 * @param array Items available for selection
1651 * @param string Label for no-matching-value
1652 * @return string The HTML code for the item
1653 * @see getSingleField_typeSelect()
1655 function getSingleField_typeSelect_checkbox($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
1657 if (empty($selItems)) {
1661 // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
1662 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
1666 if ($this->renderReadonly ||
$config['readOnly']) {
1667 $disabled = ' disabled="disabled"';
1670 // Traverse the Array of selector box items:
1674 $sOnChange = implode('', $PA['fieldChangeFunc']);
1675 $setAll = array(); // Used to accumulate the JS needed to restore the original selection.
1676 $unSetAll = array();
1677 foreach ($selItems as $p) {
1678 // Non-selectable element:
1679 if (!strcmp($p[1], '--div--')) {
1681 <tr class="c-header">
1682 <td colspan="3">' . htmlspecialchars($p[0]) . '</td>
1685 // Selected or not by default:
1687 if (isset($itemArray[$p[1]])) {
1688 $sM = ' checked="checked"';
1689 unset($itemArray[$p[1]]);
1696 $selIcon = t3lib_iconWorks
::getSpriteIcon('empty-empty');
1700 $rowId = uniqid('select_checkbox_row_');
1701 $onClickCell = $this->elName($PA['itemFormElName'] . '[' . $c . ']') . '.checked=!' . $this->elName($PA['itemFormElName'] . '[' . $c . ']') . '.checked;';
1702 $onClick = 'this.attributes.getNamedItem("class").nodeValue = ' . $this->elName($PA['itemFormElName'] . '[' . $c . ']') . '.checked ? "c-selectedItem" : "c-unselectedItem";';
1703 $setAll[] = $this->elName($PA['itemFormElName'] . '[' . $c . ']') . '.checked=1;';
1704 $setAll[] .= '$(\'' . $rowId . '\').removeClassName(\'c-unselectedItem\');$(\'' . $rowId . '\').addClassName(\'c-selectedItem\');';
1705 $unSetAll[] = $this->elName($PA['itemFormElName'] . '[' . $c . ']') . '.checked=0;';
1706 $unSetAll[] .= '$(\'' . $rowId . '\').removeClassName(\'c-selectedItem\');$(\'' . $rowId . '\').addClassName(\'c-unselectedItem\');';
1707 $restoreCmd[] = $this->elName($PA['itemFormElName'] . '[' . $c . ']') . '.checked=' . ($sM ?
1 : 0) . ';' .
1708 '$(\'' . $rowId . '\').removeClassName(\'c-selectedItem\');$(\'' . $rowId . '\').removeClassName(\'c-unselectedItem\');' .
1709 '$(\'' . $rowId . '\').addClassName(\'c-' . ($sM ?
'' : 'un') . 'selectedItem\');';
1711 // Check if some help text is available
1712 // Since TYPO3 4.5 help text is expected to be an associative array
1713 // with two key, "title" and "description"
1714 // For the sake of backwards compatibility, we test if the help text
1715 // is a string and use it as a description (this could happen if items
1716 // are modified with an itemProcFunc)
1719 $helpArray = array();
1720 if ((is_array($p[3]) && count($p[3]) > 0) ||
!empty($p[3])) {
1722 if (is_array($p[3])) {
1725 $helpArray['description'] = $p[3];
1729 $label = t3lib_div
::deHSCentities(htmlspecialchars($p[0]));
1731 $help = t3lib_BEfunc
::wrapInHelp('', '', '', $helpArray);
1735 <tr id="' . $rowId . '" class="' . ($sM ?
'c-selectedItem' : 'c-unselectedItem') . '" onclick="' . htmlspecialchars($onClick) . '" style="cursor: pointer;">
1736 <td class="c-checkbox"><input type="checkbox"' . $this->insertDefStyle('check') . ' name="' . htmlspecialchars($PA['itemFormElName'] . '[' . $c . ']') . '" value="' . htmlspecialchars($p[1]) . '"' . $sM . ' onclick="' . htmlspecialchars($sOnChange) . '"' . $PA['onFocus'] . ' /></td>
1737 <td class="c-labelCell" onclick="' . htmlspecialchars($onClickCell) . '">' .
1738 $this->getIconHtml($selIcon) .
1741 <td class="c-descr" onclick="' . htmlspecialchars($onClickCell) . '">' . ((empty($help)) ?
'' : $help) . '</td>
1748 // Remaining values (invalid):
1749 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1750 foreach ($itemArray as $theNoMatchValue => $temp) {
1751 // Compile <checkboxes> tag:
1752 array_unshift($tRows, '
1753 <tr class="c-invalidItem">
1754 <td class="c-checkbox"><input type="checkbox"' . $this->insertDefStyle('check') . ' name="' . htmlspecialchars($PA['itemFormElName'] . '[' . $c . ']') . '" value="' . htmlspecialchars($theNoMatchValue) . '" checked="checked" onclick="' . htmlspecialchars($sOnChange) . '"' . $PA['onFocus'] . $disabled . ' /></td>
1755 <td class="c-labelCell">' .
1756 t3lib_div
::deHSCentities(htmlspecialchars(@sprintf
($nMV_label, $theNoMatchValue))) .
1757 '</td><td> </td>
1763 // Add an empty hidden field which will send a blank value if all items are unselected.
1764 $item .= '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="" />';
1766 // Remaining checkboxes will get their set-all link:
1767 if (count($setAll)) {
1768 $tableHead = '<thead>
1769 <tr class="c-header-checkbox-controls t3-row-header">
1770 <td class="c-checkbox">
1771 <input type="checkbox" class="checkbox" onclick="if (checked) {' . htmlspecialchars(implode('', $setAll) . '} else {' . implode('', $unSetAll) . '}') . '">
1777 // Implode rows in table:
1779 <table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-select-checkbox">' .
1781 '<tbody>' . implode('', $tRows) . '</tbody>
1786 if (is_array($restoreCmd)) {
1787 $item .= '<a href="#" onclick="' . implode('', $restoreCmd) . ' return false;' . '">' .
1788 t3lib_iconWorks
::getSpriteIcon('actions-edit-undo', array('title' => htmlspecialchars($this->getLL('l_revertSelection')))) . '</a>';
1795 * Creates a selectorbox list (renderMode = "singlebox")
1796 * (Render function for getSingleField_typeSelect())
1798 * @param string See getSingleField_typeSelect()
1799 * @param string See getSingleField_typeSelect()
1800 * @param array See getSingleField_typeSelect()
1801 * @param array See getSingleField_typeSelect()
1802 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1803 * @param array Items available for selection
1804 * @param string Label for no-matching-value
1805 * @return string The HTML code for the item
1806 * @see getSingleField_typeSelect()
1808 function getSingleField_typeSelect_singlebox($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
1810 // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
1811 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
1815 if ($this->renderReadonly ||
$config['readOnly']) {
1816 $disabled = ' disabled="disabled"';
1819 // Traverse the Array of selector box items:
1821 $restoreCmd = array(); // Used to accumulate the JS needed to restore the original selection.
1823 foreach ($selItems as $p) {
1824 // Selected or not by default:
1826 if (isset($itemArray[$p[1]])) {
1827 $sM = ' selected="selected"';
1828 $restoreCmd[] = $this->elName($PA['itemFormElName'] . '[]') . '.options[' . $c . '].selected=1;';
1829 unset($itemArray[$p[1]]);
1832 // Non-selectable element:
1834 if (!strcmp($p[1], '--div--')) {
1835 $nonSel = ' onclick="this.selected=0;" class="c-divider"';
1838 // Icon style for option tag:
1839 if ($config['iconsInOptionTags']) {
1840 $styleAttrValue = $this->optionTagStyle($p[2]);
1843 // Compile <option> tag:
1844 $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' .
1847 ($styleAttrValue ?
' style="' . htmlspecialchars($styleAttrValue) . '"' : '') .
1848 '>' . t3lib_div
::deHSCentities(htmlspecialchars($p[0])) . '</option>';
1852 // Remaining values:
1853 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1854 foreach ($itemArray as $theNoMatchValue => $temp) {
1855 // Compile <option> tag:
1856 array_unshift($opt, '<option value="' . htmlspecialchars($theNoMatchValue) . '" selected="selected">' . t3lib_div
::deHSCentities(htmlspecialchars(@sprintf
($nMV_label, $theNoMatchValue))) . '</option>');
1860 // Compile selector box:
1861 $sOnChange = implode('', $PA['fieldChangeFunc']);
1862 $selector_itemListStyle = isset($config['itemListStyle']) ?
' style="' . htmlspecialchars($config['itemListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle
. '"';
1863 $size = intval($config['size']);
1864 $cssPrefix = ($size === 1) ?
'tceforms-select' : 'tceforms-multiselect';
1865 $size = $config['autoSizeMax'] ? t3lib_utility_Math
::forceIntegerInRange(count($selItems) +
1, t3lib_utility_Math
::forceIntegerInRange($size, 1), $config['autoSizeMax']) : $size;
1866 $selectBox = '<select id="' . uniqid($cssPrefix) . '" name="' . $PA['itemFormElName'] . '[]"' .
1867 $this->insertDefStyle('select', $cssPrefix) .
1868 ($size ?
' size="' . $size . '"' : '') .
1869 ' multiple="multiple" onchange="' . htmlspecialchars($sOnChange) . '"' .
1871 $selector_itemListStyle .
1878 // Add an empty hidden field which will send a blank value if all items are unselected.
1880 $item .= '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="" />';
1883 // Put it all into a table:
1885 <table border="0" cellspacing="0" cellpadding="0" width="1" class="typo3-TCEforms-select-singlebox">
1891 htmlspecialchars($this->getLL('l_holdDownCTRL')) .
1895 <a href="#" onclick="' . htmlspecialchars($this->elName($PA['itemFormElName'] . '[]') . '.selectedIndex=-1;' . implode('', $restoreCmd) . ' return false;') . '" title="' . htmlspecialchars($this->getLL('l_revertSelection')) . '">' .
1896 t3lib_iconWorks
::getSpriteIcon('actions-edit-undo') .
1907 * Creates a multiple-selector box (two boxes, side-by-side)
1908 * (Render function for getSingleField_typeSelect())
1910 * @param string See getSingleField_typeSelect()
1911 * @param string See getSingleField_typeSelect()
1912 * @param array See getSingleField_typeSelect()
1913 * @param array See getSingleField_typeSelect()
1914 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1915 * @param array Items available for selection
1916 * @param string Label for no-matching-value
1917 * @return string The HTML code for the item
1918 * @see getSingleField_typeSelect()
1920 function getSingleField_typeSelect_multiple($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
1924 if ($this->renderReadonly ||
$config['readOnly']) {
1925 $disabled = ' disabled="disabled"';
1928 // Setting this hidden field (as a flag that JavaScript can read out)
1930 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '_mul" value="' . ($config['multiple'] ?
1 : 0) . '" />';
1933 // Set max and min items:
1934 $maxitems = t3lib_utility_Math
::forceIntegerInRange($config['maxitems'], 0);
1938 $minitems = t3lib_utility_Math
::forceIntegerInRange($config['minitems'], 0);
1940 // Register the required number of elements:
1941 $this->registerRequiredProperty('range', $PA['itemFormElName'], array($minitems, $maxitems, 'imgName' => $table . '_' . $row['uid'] . '_' . $field));
1943 // Get "removeItems":
1944 $removeItems = t3lib_div
::trimExplode(',', $PA['fieldTSConfig']['removeItems'], 1);
1946 // Get the array with selected items:
1947 $itemArray = t3lib_div
::trimExplode(',', $PA['itemFormElValue'], 1);
1949 // Possibly filter some items:
1950 $keepItemsFunc = create_function('$value', '$parts=explode(\'|\',$value,2); return rawurldecode($parts[0]);');
1951 $itemArray = t3lib_div
::keepItemsInArray($itemArray, $PA['fieldTSConfig']['keepItems'], $keepItemsFunc);
1953 // Perform modification of the selected items array:
1954 foreach ($itemArray as $tk => $tv) {
1955 $tvP = explode('|', $tv, 2);
1956 $evalValue = $tvP[0];
1957 $isRemoved = in_array($evalValue, $removeItems) ||
($config['form_type'] == 'select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table, $field, $evalValue, $config['authMode']));
1958 if ($isRemoved && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1959 $tvP[1] = rawurlencode(@sprintf
($nMV_label, $evalValue));
1960 } elseif (isset($PA['fieldTSConfig']['altLabels.'][$evalValue])) {
1961 $tvP[1] = rawurlencode($this->sL($PA['fieldTSConfig']['altLabels.'][$evalValue]));
1963 if ($tvP[1] == '') {
1964 // Case: flexform, default values supplied, no label provided (bug #9795)
1965 foreach ($selItems as $selItem) {
1966 if ($selItem[1] == $tvP[0]) {
1967 $tvP[1] = html_entity_decode($selItem[0]);
1972 $itemArray[$tk] = implode('|', $tvP);
1974 $itemsToSelect = '';
1977 // Create option tags:
1979 $styleAttrValue = '';
1980 foreach ($selItems as $p) {
1981 if ($config['iconsInOptionTags']) {
1982 $styleAttrValue = $this->optionTagStyle($p[2]);
1984 $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' .
1985 ($styleAttrValue ?
' style="' . htmlspecialchars($styleAttrValue) . '"' : '') .
1986 '>' . $p[0] . '</option>';
1989 // Put together the selector box:
1990 $selector_itemListStyle = isset($config['itemListStyle']) ?
' style="' . htmlspecialchars($config['itemListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle
. '"';
1991 $size = intval($config['size']);
1992 $size = $config['autoSizeMax'] ? t3lib_utility_Math
::forceIntegerInRange(count($itemArray) +
1, t3lib_utility_Math
::forceIntegerInRange($size, 1), $config['autoSizeMax']) : $size;
1993 if ($config['exclusiveKeys']) {
1994 $sOnChange = 'setFormValueFromBrowseWin(\'' . $PA['itemFormElName'] . '\',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text,\'' . $config['exclusiveKeys'] . '\'); ';
1996 $sOnChange = 'setFormValueFromBrowseWin(\'' . $PA['itemFormElName'] . '\',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text); ';
1998 $sOnChange .= implode('', $PA['fieldChangeFunc']);
2000 <select id="' . uniqid('tceforms-multiselect-') . '" name="' . $PA['itemFormElName'] . '_sel"' .
2001 $this->insertDefStyle('select', 'tceforms-multiselect tceforms-itemstoselect') .
2002 ($size ?
' size="' . $size . '"' : '') .
2003 ' onchange="' . htmlspecialchars($sOnChange) . '"' .
2005 $selector_itemListStyle . '>
2011 // Pass to "dbFileIcons" function:
2014 'autoSizeMax' => t3lib_utility_Math
::forceIntegerInRange($config['autoSizeMax'], 0),
2015 'style' => isset($config['selectedListStyle']) ?
' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle
. '"',
2016 'dontShowMoveIcons' => ($maxitems <= 1),
2017 'maxitems' => $maxitems,
2020 'selector' => $this->getLL('l_selected') . ':<br />',
2021 'items' => $this->getLL('l_items') . ':<br />'
2024 'thumbnails' => $itemsToSelect,
2025 'readOnly' => $disabled
2027 $item .= $this->dbFileIcons($PA['itemFormElName'], '', '', $itemArray, '', $params, $PA['onFocus']);
2033 * Generation of TCEform elements of the type "group"
2034 * This will render a selectorbox into which elements from either the file system or database can be inserted. Relations.
2036 * @param string The table name of the record
2037 * @param string The field name which this element is supposed to edit
2038 * @param array The record data array where the value(s) for the field can be found
2039 * @param array An array with additional configuration options.
2040 * @return string The HTML code for the TCEform field
2042 function getSingleField_typeGroup($table, $field, $row, &$PA) {
2044 $config = $PA['fieldConf']['config'];
2045 $internal_type = $config['internal_type'];
2046 $show_thumbs = $config['show_thumbs'];
2047 $size = intval($config['size']);
2048 $maxitems = t3lib_utility_Math
::forceIntegerInRange($config['maxitems'], 0);
2052 $minitems = t3lib_utility_Math
::forceIntegerInRange($config['minitems'], 0);
2053 $allowed = trim($config['allowed']);
2054 $disallowed = trim($config['disallowed']);
2058 if ($this->renderReadonly ||
$config['readOnly']) {
2059 $disabled = ' disabled="disabled"';
2062 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '_mul" value="' . ($config['multiple'] ?
1 : 0) . '"' . $disabled . ' />';
2063 $this->registerRequiredProperty('range', $PA['itemFormElName'], array($minitems, $maxitems, 'imgName' => $table . '_' . $row['uid'] . '_' . $field));
2066 // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. See http://typo3.org/documentation/document-library/doc_core_api/Wizards_Configuratio/.
2067 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
2069 $PA['itemFormElID_file'] = $PA['itemFormElID'] . '_files';
2071 // whether the list and delete controls should be disabled
2072 $noList = isset($config['disable_controls']) && t3lib_div
::inList($config['disable_controls'], 'list');
2073 $noDelete = isset($config['disable_controls']) && t3lib_div
::inList($config['disable_controls'], 'delete');
2075 // if maxitems==1 then automatically replace the current item (in list and file selector)
2076 if ($maxitems === 1) {
2077 $this->additionalJS_post
[] = "TBE_EDITOR.clearBeforeSettingFormValueFromBrowseWin['" . $PA['itemFormElName'] . "'] = {
2078 itemFormElID_file: '" . $PA['itemFormElID_file'] . "'
2080 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = "setFormValueManipulate('" . $PA['itemFormElName'] . "', 'Remove'); " . $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'];
2081 } elseif ($noList) {
2082 // if the list controls have been removed and the maximum number is reached, remove the first entry to avoid "write once" field
2083 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = "setFormValueManipulate('" . $PA['itemFormElName'] . "', 'RemoveFirstIfFull', '" . $maxitems . "'); " . $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'];
2086 // Acting according to either "file" or "db" type:
2087 switch ((string) $config['internal_type']) {
2088 case 'file_reference':
2089 $config['uploadfolder'] = '';
2091 case 'file': // If the element is of the internal type "file":
2093 // Creating string showing allowed types:
2094 $tempFT = t3lib_div
::trimExplode(',', $allowed, TRUE);
2095 if (!count($tempFT)) {
2098 foreach ($tempFT as $ext) {
2100 $info .= strtoupper($ext) . ' ';
2103 // Creating string, showing disallowed types:
2104 $tempFT_dis = t3lib_div
::trimExplode(',', $disallowed, TRUE);
2105 if (count($tempFT_dis)) {
2108 foreach ($tempFT_dis as $ext) {
2110 $info .= '-' . strtoupper($ext) . ' ';
2114 // Making the array of file items:
2115 $itemArray = t3lib_div
::trimExplode(',', $PA['itemFormElValue'], TRUE);
2117 // Showing thumbnails:
2121 foreach ($itemArray as $imgRead) {
2122 $imgP = explode('|', $imgRead);
2123 $imgPath = rawurldecode($imgP[0]);
2126 $rowCopy[$field] = $imgPath;
2128 $imgs[] = '<span class="nobr">' . t3lib_BEfunc
::thumbCode($rowCopy, $table, $field, $this->backPath
, 'thumbs.php', $config['uploadfolder'], 0, ' align="middle"') .
2132 $thumbsnail = implode('<br />', $imgs);
2135 // Creating the element:
2138 'dontShowMoveIcons' => ($maxitems <= 1),
2139 'autoSizeMax' => t3lib_utility_Math
::forceIntegerInRange($config['autoSizeMax'], 0),
2140 'maxitems' => $maxitems,
2141 'style' => isset($config['selectedListStyle']) ?
' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle
. '"',
2143 'thumbnails' => $thumbsnail,
2144 'readOnly' => $disabled,
2145 'noBrowser' => $noList ||
(isset($config['disable_controls']) && t3lib_div
::inList($config['disable_controls'], 'browser')),
2146 'noList' => $noList,
2147 'noDelete' => $noDelete,
2149 $item .= $this->dbFileIcons($PA['itemFormElName'], 'file', implode(',', $tempFT), $itemArray, '', $params, $PA['onFocus']);
2151 if (!$disabled && !(isset($config['disable_controls']) && t3lib_div
::inList($config['disable_controls'], 'upload'))) {
2152 // Adding the upload field:
2153 if ($this->edit_docModuleUpload
&& $config['uploadfolder']) {
2154 $item .= '<div id="' . $PA['itemFormElID_file'] . '"><input type="file" name="' . $PA['itemFormElName_file'] . '" size="35" onchange="' . implode('', $PA['fieldChangeFunc']) . '" /></div>';
2158 case 'folder': // If the element is of the internal type "folder":
2160 // array of folder items:
2161 $itemArray = t3lib_div
::trimExplode(',', $PA['itemFormElValue'], 1);
2163 // Creating the element:
2166 'dontShowMoveIcons' => ($maxitems <= 1),
2167 'autoSizeMax' => t3lib_utility_Math
::forceIntegerInRange($config['autoSizeMax'], 0),
2168 'maxitems' => $maxitems,
2169 'style' => isset($config['selectedListStyle']) ?
2170 ' style="' . htmlspecialchars($config['selectedListStyle']) . '"'
2171 : ' style="' . $this->defaultMultipleSelectorStyle
. '"',
2173 'readOnly' => $disabled,
2174 'noBrowser' => $noList ||
(isset($config['disable_controls']) && t3lib_div
::inList($config['disable_controls'], 'browser')),
2175 'noList' => $noList,
2178 $item .= $this->dbFileIcons(
2179 $PA['itemFormElName'],
2188 case 'db': // If the element is of the internal type "db":
2190 // Creating string showing allowed types:
2191 $tempFT = t3lib_div
::trimExplode(',', $allowed, TRUE);
2192 if (!strcmp(trim($tempFT[0]), '*')) {
2193 $onlySingleTableAllowed = FALSE;
2194 $info .= '<span class="nobr">' .
2195 htmlspecialchars($this->getLL('l_allTables')) .
2197 } elseif ($tempFT) {
2198 $onlySingleTableAllowed = (count($tempFT) == 1);
2199 foreach ($tempFT as $theT) {
2200 $info .= '<span class="nobr">' .
2201 t3lib_iconWorks
::getSpriteIconForRecord($theT, array()) .
2202 htmlspecialchars($this->sL($GLOBALS['TCA'][$theT]['ctrl']['title'])) .
2207 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
2208 $itemArray = array();
2212 $temp_itemArray = t3lib_div
::trimExplode(',', $PA['itemFormElValue'], 1);
2213 foreach ($temp_itemArray as $dbRead) {
2214 $recordParts = explode('|', $dbRead);
2215 list($this_table, $this_uid) = t3lib_BEfunc
::splitTable_Uid($recordParts[0]);
2216 // For the case that no table was found and only a single table is defined to be allowed, use that one:
2217 if (!$this_table && $onlySingleTableAllowed) {
2218 $this_table = $allowed;
2220 $itemArray[] = array('table' => $this_table, 'id' => $this_uid);
2221 if (!$disabled && $show_thumbs) {
2222 $rr = t3lib_BEfunc
::getRecordWSOL($this_table, $this_uid);
2223 $imgs[] = '<span class="nobr">' .
2224 $this->getClickMenu(
2225 t3lib_iconWorks
::getSpriteIconForRecord(
2229 'style' => 'vertical-align:top',
2230 'title' => htmlspecialchars(t3lib_BEfunc
::getRecordPath($rr['pid'], $perms_clause, 15) . ' [UID: ' . $rr['uid'] . ']')
2237 t3lib_BEfunc
::getRecordTitle($this_table, $rr, TRUE) . ' <span class="typo3-dimmed"><em>[' . $rr['uid'] . ']</em></span>' .
2242 if (!$disabled && $show_thumbs) {
2243 $thumbsnail = implode('<br />', $imgs);
2246 // Creating the element:
2249 'dontShowMoveIcons' => ($maxitems <= 1),
2250 'autoSizeMax' => t3lib_utility_Math
::forceIntegerInRange($config['autoSizeMax'], 0),
2251 'maxitems' => $maxitems,
2252 'style' => isset($config['selectedListStyle']) ?
' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle
. '"',
2254 'thumbnails' => $thumbsnail,
2255 'readOnly' => $disabled,
2256 'noBrowser' => $noList ||
(isset($config['disable_controls']) && t3lib_div
::inList($config['disable_controls'], 'browser')),
2257 'noList' => $noList,
2259 $item .= $this->dbFileIcons($PA['itemFormElName'], 'db', implode(',', $tempFT), $itemArray, '', $params, $PA['onFocus'], $table, $field, $row['uid']);
2265 $altItem = '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
2267 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf);
2274 * Generation of TCEform elements of the type "none"
2275 * This will render a non-editable display of the content of the field.
2277 * @param string The table name of the record
2278 * @param string The field name which this element is supposed to edit
2279 * @param array The record data array where the value(s) for the field can be found
2280 * @param array An array with additional configuration options.
2281 * @return string The HTML code for the TCEform field
2283 function getSingleField_typeNone($table, $field, $row, &$PA) {
2285 $config = $PA['fieldConf']['config'];
2286 $itemValue = $PA['itemFormElValue'];
2288 return $this->getSingleField_typeNone_render($config, $itemValue);
2292 * HTML rendering of a value which is not editable.
2294 * @param array Configuration for the display
2295 * @param string The value to display
2296 * @return string The HTML code for the display
2297 * @see getSingleField_typeNone();
2299 function getSingleField_typeNone_render($config, $itemValue) {
2301 // is colorScheme[0] the right value?
2302 $divStyle = 'border:solid 1px ' . t3lib_div
::modifyHTMLColorAll($this->colorScheme
[0], -30) . ';' . $this->defStyle
. $this->formElStyle('none') . ' background-color: ' . $this->colorScheme
[0] . '; padding-left:1px;color:#555;';
2304 if ($config['format']) {
2305 $itemValue = $this->formatValue($config, $itemValue);
2308 $rows = intval($config['rows']);
2310 if (!$config['pass_content']) {
2311 $itemValue = nl2br(htmlspecialchars($itemValue));
2314 $cols = t3lib_utility_Math
::forceIntegerInRange($config['cols'] ?
$config['cols'] : 30, 5, $this->maxTextareaWidth
);
2315 if (!$config['fixedRows']) {
2316 $origRows = $rows = t3lib_utility_Math
::forceIntegerInRange($rows, 1, 20);
2317 if (strlen($itemValue) > $this->charsPerRow
* 2) {
2318 $cols = $this->maxTextareaWidth
;
2319 $rows = t3lib_utility_Math
::forceIntegerInRange(round(strlen($itemValue) / $this->charsPerRow
), count(explode(LF
, $itemValue)), 20);
2320 if ($rows < $origRows) {
2326 if ($this->docLarge
) {
2327 $cols = round($cols * $this->form_largeComp
);
2329 $width = ceil($cols * $this->form_rowsToStylewidth
);
2330 // hardcoded: 12 is the height of the font
2331 $height = $rows * 12;
2334 <div style="' . htmlspecialchars($divStyle . ' overflow:auto; height:' . $height . 'px; width:' . $width . 'px;') . '" class="' . htmlspecialchars($this->formElClass('none')) . '">' .
2338 if (!$config['pass_content']) {
2339 $itemValue = htmlspecialchars($itemValue);
2342 $cols = $config['cols'] ?
$config['cols'] : ($config['size'] ?
$config['size'] : $this->maxInputWidth
);
2343 if ($this->docLarge
) {
2344 $cols = round($cols * $this->form_largeComp
);
2346 $width = ceil($cols * $this->form_rowsToStylewidth
);
2348 // overflow:auto crashes mozilla here. Title tag is usefull when text is longer than the div box (overflow:hidden).
2350 <div style="' . htmlspecialchars($divStyle . ' overflow:hidden; width:' . $width . 'px;') . '" class="' . htmlspecialchars($this->formElClass('none')) . '" title="' . $itemValue . '">' .
2351 '<span class="nobr">' . (strcmp($itemValue, '') ?
$itemValue : ' ') . '</span>' .
2359 * Handler for Flex Forms
2361 * @param string The table name of the record
2362 * @param string The field name which this element is supposed to edit
2363 * @param array The record data array where the value(s) for the field can be found
2364 * @param array An array with additional configuration options.
2365 * @return string The HTML code for the TCEform field
2367 function getSingleField_typeFlex($table, $field, $row, &$PA) {
2370 $dataStructArray = t3lib_BEfunc
::getFlexFormDS($PA['fieldConf']['config'], $row, $table);
2373 // Manipulate Flexform DS via TSConfig and group access lists
2374 if (is_array($dataStructArray)) {
2375 $flexFormHelper = t3lib_div
::makeInstance('t3lib_TCEforms_Flexforms');
2376 $dataStructArray = $flexFormHelper->modifyFlexFormDS($dataStructArray, $table, $field, $row, $PA['fieldConf']);
2377 unset($flexFormHelper);
2380 // Get data structure:
2381 if (is_array($dataStructArray)) {
2384 $xmlData = $PA['itemFormElValue'];
2385 $xmlHeaderAttributes = t3lib_div
::xmlGetHeaderAttribs($xmlData);
2386 $storeInCharset = strtolower($xmlHeaderAttributes['encoding']);
2387 if ($storeInCharset) {
2388 $currentCharset = $GLOBALS['LANG']->charSet
;
2389 $xmlData = $GLOBALS['LANG']->csConvObj
->conv($xmlData, $storeInCharset, $currentCharset, 1);
2391 $editData = t3lib_div
::xml2array($xmlData);
2392 if (!is_array($editData)) { // Must be XML parsing error...
2393 $editData = array();
2394 } elseif (!isset($editData['meta']) ||
!is_array($editData['meta'])) {
2395 $editData['meta'] = array();
2398 // Find the data structure if sheets are found:
2399 $sheet = $editData['meta']['currentSheetId'] ?
$editData['meta']['currentSheetId'] : 'sDEF'; // Sheet to display
2401 // Create sheet menu:
2402 //TODO; Why is this commented out?
2403 // if (is_array($dataStructArray['sheets'])) {
2404 // #$item.=$this->getSingleField_typeFlex_sheetMenu($dataStructArray['sheets'], $PA['itemFormElName'].'[meta][currentSheetId]', $sheet).'<br />';
2407 // Create language menu:
2408 $langChildren = $dataStructArray['meta']['langChildren'] ?
1 : 0;
2409 $langDisabled = $dataStructArray['meta']['langDisable'] ?
1 : 0;
2411 $editData['meta']['currentLangId'] = array();
2413 // Look up page overlays:
2414 $checkPageLanguageOverlay = $GLOBALS['BE_USER']->getTSConfigVal('options.checkPageLanguageOverlay') ?
TRUE : FALSE;
2415 if ($checkPageLanguageOverlay) {
2416 $pageOverlays = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
2418 'pages_language_overlay',
2419 'pid=' . intval($row['pid']) .
2420 t3lib_BEfunc
::deleteClause('pages_language_overlay') .
2421 t3lib_BEfunc
::versioningPlaceholderClause('pages_language_overlay'),
2428 $languages = $this->getAvailableLanguages();
2430 foreach ($languages as $lInfo) {
2431 if ($GLOBALS['BE_USER']->checkLanguageAccess($lInfo['uid']) && (!$checkPageLanguageOverlay ||
$lInfo['uid'] <= 0 ||
is_array($pageOverlays[$lInfo['uid']]))) {
2432 $editData['meta']['currentLangId'][] = $lInfo['ISOcode'];
2435 if (!is_array($editData['meta']['currentLangId']) ||
!count($editData['meta']['currentLangId'])) {
2436 $editData['meta']['currentLangId'] = array('DEF');
2439 $editData['meta']['currentLangId'] = array_unique($editData['meta']['currentLangId']);
2441 //TODO: Why is this commented out?
2442 // if (!$langDisabled && count($languages) > 1) {
2443 // $item.=$this->getSingleField_typeFlex_langMenu($languages, $PA['itemFormElName'].'[meta][currentLangId]', $editData['meta']['currentLangId']).'<br />';
2446 $PA['_noEditDEF'] = FALSE;
2447 if ($langChildren ||
$langDisabled) {
2448 $rotateLang = array('DEF');
2450 if (!in_array('DEF', $editData['meta']['currentLangId'])) {
2451 array_unshift($editData['meta']['currentLangId'], 'DEF');
2452 $PA['_noEditDEF'] = TRUE;
2454 $rotateLang = $editData['meta']['currentLangId'];
2458 if (is_array($dataStructArray['sheets'])) {
2459 $tabsToTraverse = array_keys($dataStructArray['sheets']);
2461 $tabsToTraverse = array($sheet);
2464 foreach ($rotateLang as $lKey) {
2465 if (!$langChildren && !$langDisabled) {
2466 $item .= '<strong>' . $this->getLanguageIcon($table, $row, 'v' . $lKey) . $lKey . ':</strong>';
2469 $tabParts = array();
2470 foreach ($tabsToTraverse as $sheet) {
2471 list ($dataStruct, $sheet) = t3lib_div
::resolveSheetDefInDS($dataStructArray, $sheet);
2474 if (is_array($dataStruct['ROOT']) && is_array($dataStruct['ROOT']['el'])) {
2475 $lang = 'l' . $lKey; // Default language, other options are "lUK" or whatever country code (independant of system!!!)
2476 $PA['_valLang'] = $langChildren && !$langDisabled ?
$editData['meta']['currentLangId'] : 'DEF'; // Default language, other options are "lUK" or whatever country code (independant of system!!!)
2477 $PA['_lang'] = $lang;
2478 // Assemble key for loading the correct CSH file
2479 $dsPointerFields = t3lib_div
::trimExplode(',', $GLOBALS['TCA'][$table]['columns'][$field]['config']['ds_pointerField'], TRUE);
2480 $PA['_cshKey'] = $table . '.' . $field;
2481 foreach ($dsPointerFields as $key) {
2482 $PA['_cshKey'] .= '.' . $row[$key];
2485 // Push the sheet level tab to DynNestedStack
2486 if (is_array($dataStructArray['sheets'])) {
2487 $tabIdentString = $GLOBALS['TBE_TEMPLATE']->getDynTabMenuId('TCEFORMS:flexform:' . $PA['itemFormElName'] . $PA['_lang']);
2488 $this->pushToDynNestedStack('tab', $tabIdentString . '-' . (count($tabParts) +
1));
2491 $tRows = $this->getSingleField_typeFlex_draw(
2492 $dataStruct['ROOT']['el'],
2493 $editData['data'][$sheet][$lang],
2498 '[data][' . $sheet . '][' . $lang . ']'
2500 $sheetContent = '<div class="typo3-TCEforms-flexForm">' . $tRows . '</div>';
2503 // Pop the sheet level tab from DynNestedStack
2504 if (is_array($dataStructArray['sheets'])) {
2505 $this->popFromDynNestedStack('tab', $tabIdentString . '-' . (count($tabParts) +
1));
2508 $sheetContent = 'Data Structure ERROR: No ROOT element found for sheet "' . $sheet . '".';
2512 $tabParts[] = array(
2513 'label' => ($dataStruct['ROOT']['TCEforms']['sheetTitle'] ?
$this->sL($dataStruct['ROOT']['TCEforms']['sheetTitle']) : $sheet),
2514 'description' => ($dataStruct['ROOT']['TCEforms']['sheetDescription'] ?
$this->sL($dataStruct['ROOT']['TCEforms']['sheetDescription']) : ''),
2515 'linkTitle' => ($dataStruct['ROOT']['TCEforms']['sheetShortDescr'] ?
$this->sL($dataStruct['ROOT']['TCEforms']['sheetShortDescr']) : ''),
2516 'content' => $sheetContent
2520 if (is_array($dataStructArray['sheets'])) {
2521 $dividersToTabsBehaviour = (isset($GLOBALS['TCA'][$table]['ctrl']['dividers2tabs']) ?
$GLOBALS['TCA'][$table]['ctrl']['dividers2tabs'] : 1);
2522 $item .= $this->getDynTabMenu($tabParts, 'TCEFORMS:flexform:' . $PA['itemFormElName'] . $PA['_lang'], $dividersToTabsBehaviour);
2524 $item .= $sheetContent;
2528 $item = 'Data Structure ERROR: ' . $dataStructArray;
2535 * Creates the language menu for FlexForms:
2537 * @param [type] $languages: ...
2538 * @param [type] $elName: ...
2539 * @param [type] $selectedLanguage: ...
2540 * @param [type] $multi: ...
2541 * @return string HTML for menu
2543 function getSingleField_typeFlex_langMenu($languages, $elName, $selectedLanguage, $multi = 1) {
2545 foreach ($languages as $lArr) {
2546 $opt[] = '<option value="' . htmlspecialchars($lArr['ISOcode']) . '"' . (in_array($lArr['ISOcode'], $selectedLanguage) ?
' selected="selected"' : '') . '>' . htmlspecialchars($lArr['title']) . '</option>';
2549 $output = '<select id="' . uniqid('tceforms-multiselect-') . ' class="tceforms-select tceforms-multiselect tceforms-flexlangmenu" name="' . $elName . '[]"' . ($multi ?
' multiple="multiple" size="' . count($languages) . '"' : '') . '>' . implode('', $opt) . '</select>';
2555 * Creates the menu for selection of the sheets:
2557 * @param array Sheet array for which to render the menu
2558 * @param string Form element name of the field containing the sheet pointer
2559 * @param string Current sheet key
2560 * @return string HTML for menu
2562 function getSingleField_typeFlex_sheetMenu($sArr, $elName, $sheetKey) {
2565 $pct = round(100 / count($sArr));
2566 foreach ($sArr as $sKey => $sheetCfg) {
2567 if ($GLOBALS['BE_USER']->jsConfirmation(1)) {
2568 $onClick = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){' . $this->elName($elName) . ".value='" . $sKey . "'; TBE_EDITOR.submitForm()};";
2570 $onClick = 'if(TBE_EDITOR.checkSubmit(-1)){ ' . $this->elName($elName) . ".value='" . $sKey . "'; TBE_EDITOR.submitForm();}";
2574 $tCells[] = '<td width="' . $pct . '%" style="' . ($sKey == $sheetKey ?
'background-color: #9999cc; font-weight: bold;' : 'background-color: #aaaaaa;') . ' cursor: hand;" onclick="' . htmlspecialchars($onClick) . '" align="center">' .
2575 ($sheetCfg['ROOT']['TCEforms']['sheetTitle'] ?
$this->sL($sheetCfg['ROOT']['TCEforms']['sheetTitle']) : $sKey) .
2579 return '<table border="0" cellpadding="0" cellspacing="2" class="typo3-TCEforms-flexForm-sheetMenu"><tr>' . implode('', $tCells) . '</tr></table>';
2583 * Recursive rendering of flexforms
2585 * @param array (part of) Data Structure for which to render. Keys on first level is flex-form fields
2586 * @param array (part of) Data array of flexform corresponding to the input DS. Keys on first level is flex-form field names
2587 * @param string Table name, eg. tt_content
2588 * @param string Field name, eg. tx_templavoila_flex
2589 * @param array The particular record from $table in which the field $field is found
2590 * @param array Array of standard information for rendering of a form field in TCEforms, see other rendering functions too
2591 * @param string Form field prefix, eg. "[data][sDEF][lDEF][...][...]"
2592 * @param integer Indicates nesting level for the function call
2593 * @param string Prefix for ID-values
2594 * @param boolean Defines whether the next flexform level is open or closed. Comes from _TOGGLE pseudo field in FlexForm xml.
2595 * @return string HTMl code for form.
2597 function getSingleField_typeFlex_draw($dataStruct, $editData, $table, $field, $row, &$PA, $formPrefix = '', $level = 0, $idPrefix = 'ID', $toggleClosed = FALSE) {