[TASK] Fix styling of NULL value fields
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Form / FormEngine.php
1 <?php
2 namespace TYPO3\CMS\Backend\Form;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * Contains TYPO3 Core Form generator - AKA "TCEforms"
31 *
32 * Revised for TYPO3 3.6 August/2003 by Kasper Skårhøj
33 * XHTML compliant
34 *
35 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
36 */
37 /**
38 * 'TCEforms' - Class for creating the backend editing forms.
39 *
40 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
41 * @coauthor René Fritz <r.fritz@colorcube.de>
42 */
43 class FormEngine {
44
45 // variables not commented yet.... (do so...)
46 /**
47 * @todo Define visibility
48 */
49 public $palFieldArr = array();
50
51 /**
52 * @todo Define visibility
53 */
54 public $disableWizards = 0;
55
56 /**
57 * @todo Define visibility
58 */
59 public $isPalettedoc = 0;
60
61 /**
62 * @todo Define visibility
63 */
64 public $paletteMargin = 1;
65
66 // 'font-family:Verdana;font-size:10px;';
67 /**
68 * @todo Define visibility
69 */
70 public $defStyle = '';
71
72 /**
73 * @todo Define visibility
74 */
75 public $cachedTSconfig = array();
76
77 /**
78 * @todo Define visibility
79 */
80 public $cachedTSconfig_fieldLevel = array();
81
82 /**
83 * @todo Define visibility
84 */
85 public $cachedLanguageFlag = array();
86
87 /**
88 * @todo Define visibility
89 */
90 public $cachedAdditionalPreviewLanguages = NULL;
91
92 /**
93 * @todo Define visibility
94 */
95 public $transformedRow = array();
96
97 /**
98 * @todo Define visibility
99 */
100 public $extJSCODE = '';
101
102 /**
103 * @todo Define visibility
104 */
105 public $printNeededJS = array();
106
107 /**
108 * @todo Define visibility
109 */
110 public $hiddenFieldAccum = array();
111
112 /**
113 * @todo Define visibility
114 */
115 public $TBE_EDITOR_fieldChanged_func = '';
116
117 /**
118 * @todo Define visibility
119 */
120 public $loadMD5_JS = 1;
121
122 // Something unique...
123 /**
124 * @todo Define visibility
125 */
126 public $prevBorderStyle = '[nothing here...]';
127
128 // If set direct upload fields will be shown
129 /**
130 * @todo Define visibility
131 */
132 public $allowUpload = 0;
133
134 // Array where records in the default language is stored. (processed by transferdata)
135 /**
136 * @todo Define visibility
137 */
138 public $defaultLanguageData = array();
139
140 // Array where records in the default language is stored (raw without any processing. used for making diff)
141 /**
142 * @todo Define visibility
143 */
144 public $defaultLanguageData_diff = array();
145
146 /**
147 * @todo Define visibility
148 */
149 public $additionalPreviewLanguageData = array();
150
151 // EXTERNAL, static
152 // Set this to the 'backPath' pointing back to the typo3 admin directory from the script where this form is displayed.
153 /**
154 * @todo Define visibility
155 */
156 public $backPath = '';
157
158 // Alternative return URL path (default is t3lib_div::linkThisScript())
159 /**
160 * @todo Define visibility
161 */
162 public $returnUrl = '';
163
164 // 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.
165 /**
166 * @todo Define visibility
167 */
168 public $doSaveFieldName = '';
169
170 // 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.
171 /**
172 * @todo Define visibility
173 */
174 public $palettesCollapsed = 0;
175
176 // If set, the RTE is disabled (from form display, eg. by checkbox in the bottom of the page!)
177 /**
178 * @todo Define visibility
179 */
180 public $disableRTE = 0;
181
182 // If FALSE, then all CSH will be disabled, regardless of settings in $this->edit_showFieldHelp
183 /**
184 * @todo Define visibility
185 */
186 public $globalShowHelp = 1;
187
188 // If TRUE, the forms are rendering only localization relevant fields of the records.
189 /**
190 * @todo Define visibility
191 */
192 public $localizationMode = '';
193
194 // 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.
195 /**
196 * @todo Define visibility
197 */
198 public $fieldOrder = '';
199
200 // If set to FALSE, palettes will NEVER be rendered.
201 /**
202 * @todo Define visibility
203 */
204 public $doPrintPalette = 1;
205
206 /**
207 * Set to initialized clipboard object; Then the element browser will offer a link to paste in records from clipboard.
208 *
209 * @var \TYPO3\CMS\Backend\Clipboard\Clipboard
210 * @todo Define visibility
211 */
212 public $clipObj = FALSE;
213
214 // Enable click menu on reference icons.
215 /**
216 * @todo Define visibility
217 */
218 public $enableClickMenu = FALSE;
219
220 // Enable Tab Menus.
221 /**
222 * @todo Define visibility
223 */
224 public $enableTabMenu = FALSE;
225
226 // When enabled all fields are rendered non-editable.
227 /**
228 * @todo Define visibility
229 */
230 public $renderReadonly = FALSE;
231
232 // 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)
233 /**
234 * @todo Define visibility
235 */
236 public $form_rowsToStylewidth = 9.58;
237
238 /**
239 * Value that gets added for style="width: ...px" for textareas compared to input fields.
240 *
241 * @var integer
242 */
243 protected $form_additionalTextareaStyleWidth = 23;
244
245 // Form field width compensation: Compensation for large documents, doc-tab (editing)
246 /**
247 * @todo Define visibility
248 */
249 public $form_largeComp = 1.33;
250
251 // 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.
252 /**
253 * @todo Define visibility
254 */
255 public $charsPerRow = 40;
256
257 // The maximum abstract value for textareas
258 /**
259 * @todo Define visibility
260 */
261 public $maxTextareaWidth = 48;
262
263 // The maximum abstract value for input fields
264 /**
265 * @todo Define visibility
266 */
267 public $maxInputWidth = 48;
268
269 // Default style for the selector boxes used for multiple items in "select" and "group" types.
270 /**
271 * @todo Define visibility
272 */
273 public $defaultMultipleSelectorStyle = 'width:310px;';
274
275 // INTERNAL, static
276 // The string to prepend formfield names with.
277 /**
278 * @todo Define visibility
279 */
280 public $prependFormFieldNames = 'data';
281
282 // The string to prepend commands for tcemain::process_cmdmap with.
283 /**
284 * @todo Define visibility
285 */
286 public $prependCmdFieldNames = 'cmd';
287
288 // The string to prepend FILE form field names with.
289 /**
290 * @todo Define visibility
291 */
292 public $prependFormFieldNames_file = 'data_files';
293
294 /**
295 * The string to prepend form field names that are active (not NULL).
296 *
297 * @var string
298 */
299 protected $prependFormFieldNamesActive = 'control[active]';
300
301 // The name attribute of the form.
302 /**
303 * @todo Define visibility
304 */
305 public $formName = 'editform';
306
307 // Whitelist that allows TCA field configuration to be overridden by TSconfig, @see overrideFieldConf()
308 /**
309 * @todo Define visibility
310 */
311 public $allowOverrideMatrix = array();
312
313 // INTERNAL, dynamic
314 // Set by readPerms() (caching)
315 /**
316 * @todo Define visibility
317 */
318 public $perms_clause = '';
319
320 // Set by readPerms() (caching-flag)
321 /**
322 * @todo Define visibility
323 */
324 public $perms_clause_set = 0;
325
326 // Used to indicate the mode of CSH (Context Sensitive Help), whether it should be icons-only ('icon') or not at all (blank).
327 /**
328 * @todo Define visibility
329 */
330 public $edit_showFieldHelp = '';
331
332 // If set, the forms will be rendered a little wider, more precisely with a factor of $this->form_largeComp.
333 /**
334 * @todo Define visibility
335 */
336 public $docLarge = 0;
337
338 // Loaded with info about the browser when class is instantiated.
339 /**
340 * @todo Define visibility
341 */
342 public $clientInfo = array();
343
344 // TRUE, if RTE is possible for the current user (based on result from BE_USER->isRTE())
345 /**
346 * @todo Define visibility
347 */
348 public $RTEenabled = 0;
349
350 // 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)
351 /**
352 * @todo Define visibility
353 */
354 public $RTEenabled_notReasons = '';
355
356 // Counter that is incremented before an RTE is created. Can be used for unique ids etc.
357 /**
358 * @todo Define visibility
359 */
360 public $RTEcounter = 0;
361
362 // Contains current color scheme
363 /**
364 * @todo Define visibility
365 */
366 public $colorScheme;
367
368 // Contains current class scheme
369 /**
370 * @todo Define visibility
371 */
372 public $classScheme;
373
374 // Contains the default color scheme
375 /**
376 * @todo Define visibility
377 */
378 public $defColorScheme;
379
380 // Contains the default class scheme
381 /**
382 * @todo Define visibility
383 */
384 public $defClassScheme;
385
386 // Contains field style values
387 /**
388 * @todo Define visibility
389 */
390 public $fieldStyle;
391
392 // Contains border style values.
393 /**
394 * @todo Define visibility
395 */
396 public $borderStyle;
397
398 // An accumulation of messages from the class.
399 /**
400 * @todo Define visibility
401 */
402 public $commentMessages = array();
403
404 // INTERNAL, templates
405 // Total wrapping for the table rows.
406 /**
407 * @todo Define visibility
408 */
409 public $totalWrap = '<hr />|<hr />';
410
411 // Field template
412 /**
413 * @todo Define visibility
414 */
415 public $fieldTemplate = '<strong>###FIELD_NAME###</strong><br />###FIELD_ITEM###<hr />';
416
417 /**
418 * Template subpart for palette fields.
419 *
420 * @var string
421 */
422 protected $paletteFieldTemplate;
423
424 // Wrapping template code for a section
425 /**
426 * @todo Define visibility
427 */
428 public $sectionWrap = '';
429
430 // Template for palette headers
431 /**
432 * @todo Define visibility
433 */
434 public $palFieldTemplateHeader = '';
435
436 // Template for palettes
437 /**
438 * @todo Define visibility
439 */
440 public $palFieldTemplate = '';
441
442 // INTERNAL, working memory
443 // Set to the fields NOT to display, if any.
444 /**
445 * @todo Define visibility
446 */
447 public $excludeElements = '';
448
449 // During rendering of forms this will keep track of which palettes has already been rendered (so they are not rendered twice by mistake)
450 /**
451 * @todo Define visibility
452 */
453 public $palettesRendered = array();
454
455 // 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!
456 /**
457 * @todo Define visibility
458 */
459 public $hiddenFieldListArr = array();
460
461 // 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.
462 /**
463 * @todo Define visibility
464 */
465 public $requiredFields = array();
466
467 // 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.
468 /**
469 * @todo Define visibility
470 */
471 public $requiredAdditional = array();
472
473 // Used to register the min and max number of elements for selectorboxes where that apply (in the "group" type for instance)
474 /**
475 * @todo Define visibility
476 */
477 public $requiredElements = array();
478
479 // Used to determine where $requiredFields or $requiredElements are nested (in Tabs or IRRE)
480 /**
481 * @todo Define visibility
482 */
483 public $requiredNested = array();
484
485 // Keeps track of the rendering depth of nested records.
486 /**
487 * @todo Define visibility
488 */
489 public $renderDepth = 0;
490
491 // Color scheme buffer.
492 /**
493 * @todo Define visibility
494 */
495 public $savedSchemes = array();
496
497 // holds the path an element is nested in (e.g. required for RTEhtmlarea)
498 /**
499 * @todo Define visibility
500 */
501 public $dynNestedStack = array();
502
503 // Internal, registers for user defined functions etc.
504 // Additional HTML code, printed before the form.
505 /**
506 * @todo Define visibility
507 */
508 public $additionalCode_pre = array();
509
510 // Additional JavaScript, printed before the form
511 /**
512 * @todo Define visibility
513 */
514 public $additionalJS_pre = array();
515
516 // Additional JavaScript printed after the form
517 /**
518 * @todo Define visibility
519 */
520 public $additionalJS_post = array();
521
522 // 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.
523 /**
524 * @todo Define visibility
525 */
526 public $additionalJS_submit = array();
527
528 // Additional JavaScript executed when section element is deleted. This is necessary, for example, to correctly clean up HTMLArea RTE (bug #8232)
529 /**
530 * @todo Define visibility
531 */
532 public $additionalJS_delete = array();
533
534 /**
535 * Instance of t3lib_tceforms_inline
536 *
537 * @var \TYPO3\CMS\Backend\Form\Element\InlineElement
538 * @todo Define visibility
539 */
540 public $inline;
541
542 // Array containing hook class instances called once for a form
543 /**
544 * @todo Define visibility
545 */
546 public $hookObjectsMainFields = array();
547
548 // Array containing hook class instances called for each field
549 /**
550 * @todo Define visibility
551 */
552 public $hookObjectsSingleField = array();
553
554 // Rows gettings inserted into the alt_doc headers (when called from alt_doc.php)
555 /**
556 * @todo Define visibility
557 */
558 public $extraFormHeaders = array();
559
560 public $templateFile = '';
561
562 // Form templates, relative to typo3 directory
563 /**
564 * Constructor function, setting internal variables, loading the styles used.
565 *
566 * @return void
567 * @todo Define visibility
568 */
569 public function __construct() {
570 $this->clientInfo = \TYPO3\CMS\Core\Utility\GeneralUtility::clientInfo();
571 $this->RTEenabled = $GLOBALS['BE_USER']->isRTE();
572 if (!$this->RTEenabled) {
573 $this->RTEenabled_notReasons = implode(LF, $GLOBALS['BE_USER']->RTE_errors);
574 $this->commentMessages[] = 'RTE NOT ENABLED IN SYSTEM due to:' . LF . $this->RTEenabled_notReasons;
575 }
576 // Default color+class scheme
577 $this->defColorScheme = array(
578 $GLOBALS['SOBE']->doc->bgColor,
579 // Background for the field AND palette
580 \TYPO3\CMS\Core\Utility\GeneralUtility::modifyHTMLColorAll($GLOBALS['SOBE']->doc->bgColor, -20),
581 // Background for the field header
582 \TYPO3\CMS\Core\Utility\GeneralUtility::modifyHTMLColorAll($GLOBALS['SOBE']->doc->bgColor, -10),
583 // Background for the palette field header
584 'black',
585 // Field header font color
586 '#666666'
587 );
588 $this->defColorScheme = array();
589 // Override / Setting defaults from TBE_STYLES array
590 $this->resetSchemes();
591 // Setting the current colorScheme to default.
592 $this->defColorScheme = $this->colorScheme;
593 $this->defClassScheme = $this->classScheme;
594 // Define whitelist that allows TCA field configuration to be overridden by TSconfig, @see overrideFieldConf():
595 $this->allowOverrideMatrix = array(
596 'input' => array('size', 'max', 'readOnly'),
597 'text' => array('cols', 'rows', 'wrap', 'readOnly'),
598 'check' => array('cols', 'showIfRTE', 'readOnly'),
599 'select' => array('size', 'autoSizeMax', 'maxitems', 'minitems', 'readOnly'),
600 'group' => array('size', 'autoSizeMax', 'max_size', 'show_thumbs', 'maxitems', 'minitems', 'disable_controls', 'readOnly'),
601 'inline' => array('appearance', 'behaviour', 'foreign_label', 'foreign_selector', 'foreign_unique', 'maxitems', 'minitems', 'size', 'autoSizeMax', 'symmetric_label', 'readOnly')
602 );
603 // Create instance of t3lib_TCEforms_inline only if this a non-IRRE-AJAX call:
604 if (!isset($GLOBALS['ajaxID']) || strpos($GLOBALS['ajaxID'], 'TYPO3\\CMS\\Backend\\Form\\Element\\InlineElement::') !== 0) {
605 $this->inline = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\Element\\InlineElement');
606 }
607 // Create instance of t3lib_TCEforms_suggest only if this a non-Suggest-AJAX call:
608 if (!isset($GLOBALS['ajaxID']) || strpos($GLOBALS['ajaxID'], 'TYPO3\\CMS\\Backend\\Form\\Element\\SuggestElement::') !== 0) {
609 $this->suggest = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\Element\\SuggestElement');
610 }
611 // Prepare user defined objects (if any) for hooks which extend this function:
612 $this->hookObjectsMainFields = array();
613 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'])) {
614 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'] as $classRef) {
615 $this->hookObjectsMainFields[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
616 }
617 }
618 $this->hookObjectsSingleField = array();
619 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getSingleFieldClass'])) {
620 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getSingleFieldClass'] as $classRef) {
621 $this->hookObjectsSingleField[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
622 }
623 }
624 $this->templateFile = 'templates/tceforms.html';
625 }
626
627 /**
628 * Initialize various internal variables.
629 *
630 * @return void
631 * @todo Define visibility
632 */
633 public function initDefaultBEmode() {
634 $this->prependFormFieldNames = 'data';
635 $this->formName = 'editform';
636 $this->setNewBEDesign();
637 $this->docLarge = $GLOBALS['BE_USER']->uc['edit_wideDocument'] ? 1 : 0;
638 $this->edit_showFieldHelp = $GLOBALS['BE_USER']->uc['edit_showFieldHelp'];
639 $this->edit_docModuleUpload = $GLOBALS['BE_USER']->uc['edit_docModuleUpload'];
640 $this->inline->init($this);
641 $this->suggest->init($this);
642 }
643
644 /*******************************************************
645 *
646 * Rendering the forms, fields etc
647 *
648 *******************************************************/
649 /**
650 * Will return the TCEform element for just a single field from a record.
651 * The field must be listed in the currently displayed fields (as found in [types][showitem]) for the record.
652 * This also means that the $table/$row supplied must be complete so the list of fields to show can be found correctly
653 *
654 * @param string $table The table name
655 * @param array $row The record from the table for which to render a field.
656 * @param string $theFieldToReturn The field name to return the TCEform element for.
657 * @return string HTML output
658 * @see getMainFields()
659 * @todo Define visibility
660 */
661 public function getSoloField($table, $row, $theFieldToReturn) {
662 if ($GLOBALS['TCA'][$table]) {
663 \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($table);
664 $typeNum = $this->getRTypeNum($table, $row);
665 if ($GLOBALS['TCA'][$table]['types'][$typeNum]) {
666 $itemList = $GLOBALS['TCA'][$table]['types'][$typeNum]['showitem'];
667 if ($itemList) {
668 $fields = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $itemList, 1);
669 $excludeElements = ($this->excludeElements = $this->getExcludeElements($table, $row, $typeNum));
670 foreach ($fields as $fieldInfo) {
671 $parts = explode(';', $fieldInfo);
672 $theField = trim($parts[0]);
673 if (!in_array($theField, $excludeElements) && !strcmp($theField, $theFieldToReturn)) {
674 if ($GLOBALS['TCA'][$table]['columns'][$theField]) {
675 $sField = $this->getSingleField($table, $theField, $row, $parts[1], 1, $parts[3], $parts[2]);
676 return $sField['ITEM'];
677 }
678 }
679 }
680 }
681 }
682 }
683 }
684
685 /**
686 * Based on the $table and $row of content, this displays the complete TCEform for the record.
687 * 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.
688 *
689 * @param string $table The table name
690 * @param array $row The record from the table for which to render a field.
691 * @param integer $depth Depth level
692 * @param array $overruleTypesArray Overrule types array. Can be used to override the showitem etc. configuration for the TCA types of the table. Can contain all settings which are possible in the TCA 'types' section. See e.g. $TCA['tt_content']['types'].
693 * @return string HTML output
694 * @see getSoloField()
695 * @todo Define visibility
696 */
697 public function getMainFields($table, array $row, $depth = 0, array $overruleTypesArray = array()) {
698 $this->renderDepth = $depth;
699 // Init vars:
700 $out_array = array(array());
701 $out_array_meta = array(
702 array(
703 'title' => $this->getLL('l_generalTab')
704 )
705 );
706 $out_pointer = 0;
707 $out_sheet = 0;
708 $this->palettesRendered = array();
709 $this->palettesRendered[$this->renderDepth][$table] = array();
710 // Hook: getMainFields_preProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
711 foreach ($this->hookObjectsMainFields as $hookObj) {
712 if (method_exists($hookObj, 'getMainFields_preProcess')) {
713 $hookObj->getMainFields_preProcess($table, $row, $this);
714 }
715 }
716 if ($GLOBALS['TCA'][$table]) {
717 // Load the full TCA for the table.
718 \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($table);
719 // Get dividers2tabs setting from TCA of the current table:
720 $dividers2tabs = &$GLOBALS['TCA'][$table]['ctrl']['dividers2tabs'];
721 // Load the description content for the table.
722 if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table)) {
723 $GLOBALS['LANG']->loadSingleTableDescription($table);
724 }
725 // Get the current "type" value for the record.
726 $typeNum = $this->getRTypeNum($table, $row);
727 // Find the list of fields to display:
728 if ($GLOBALS['TCA'][$table]['types'][$typeNum]) {
729 $itemList = $GLOBALS['TCA'][$table]['types'][$typeNum]['showitem'];
730 if (is_array($overruleTypesArray) && isset($overruleTypesArray[$typeNum]['showitem'])) {
731 $itemList = $overruleTypesArray[$typeNum]['showitem'];
732 }
733 // If such a list existed...
734 if ($itemList) {
735 // Explode the field list and possibly rearrange the order of the fields, if configured for
736 $fields = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $itemList, 1);
737 if ($this->fieldOrder) {
738 $fields = $this->rearrange($fields);
739 }
740 // Get excluded fields, added fiels and put it together:
741 $excludeElements = ($this->excludeElements = $this->getExcludeElements($table, $row, $typeNum));
742 $fields = $this->mergeFieldsWithAddedFields($fields, $this->getFieldsToAdd($table, $row, $typeNum));
743 // If TCEforms will render a tab menu in the next step, push the name to the tab stack:
744 $tabIdentString = '';
745 $tabIdentStringMD5 = '';
746 if (strstr($itemList, '--div--') !== FALSE && $this->enableTabMenu && $dividers2tabs) {
747 $tabIdentString = 'TCEforms:' . $table . ':' . $row['uid'];
748 $tabIdentStringMD5 = $GLOBALS['TBE_TEMPLATE']->getDynTabMenuId($tabIdentString);
749 // Remember that were currently working on the general tab:
750 if (isset($fields[0]) && strpos($fields[0], '--div--') !== 0) {
751 $this->pushToDynNestedStack('tab', $tabIdentStringMD5 . '-1');
752 }
753 }
754 // Traverse the fields to render:
755 $cc = 0;
756 foreach ($fields as $fieldInfo) {
757 // Exploding subparts of the field configuration:
758 $parts = explode(';', $fieldInfo);
759 // Getting the style information out:
760 $color_style_parts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('-', $parts[4]);
761 if (strcmp($color_style_parts[0], '')) {
762 $this->setColorScheme($GLOBALS['TBE_STYLES']['colorschemes'][intval($color_style_parts[0])]);
763 }
764 if (strcmp($color_style_parts[1], '')) {
765 $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][intval($color_style_parts[1])];
766 if (!isset($this->fieldStyle)) {
767 $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][0];
768 }
769 }
770 if (strcmp($color_style_parts[2], '')) {
771 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
772 $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][intval($color_style_parts[2])];
773 if (!isset($this->borderStyle)) {
774 $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][0];
775 }
776 }
777 // Render the field:
778 $theField = $parts[0];
779 if (!in_array($theField, $excludeElements)) {
780 if ($GLOBALS['TCA'][$table]['columns'][$theField]) {
781 $sFieldPal = '';
782 if ($parts[2] && !isset($this->palettesRendered[$this->renderDepth][$table][$parts[2]])) {
783 $sFieldPal = $this->getPaletteFields($table, $row, $parts[2]);
784 $this->palettesRendered[$this->renderDepth][$table][$parts[2]] = 1;
785 }
786 $sField = $this->getSingleField($table, $theField, $row, $parts[1], 0, $parts[3], $parts[2]);
787 if ($sField) {
788 $sField .= $sFieldPal;
789 }
790 $out_array[$out_sheet][$out_pointer] .= $sField;
791 } elseif ($theField == '--div--') {
792 if ($cc > 0) {
793 $out_array[$out_sheet][$out_pointer] .= $this->getDivider();
794 if ($this->enableTabMenu && $dividers2tabs) {
795 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
796 // Remove last tab entry from the dynNestedStack:
797 $out_sheet++;
798 // Remove the previous sheet from stack (if any):
799 $this->popFromDynNestedStack('tab', $tabIdentStringMD5 . '-' . $out_sheet);
800 // Remember on which sheet we're currently working:
801 $this->pushToDynNestedStack('tab', $tabIdentStringMD5 . '-' . ($out_sheet + 1));
802 $out_array[$out_sheet] = array();
803 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
804 // Register newline for Tab
805 $out_array_meta[$out_sheet]['newline'] = $parts[2] == 'newline';
806 }
807 } else {
808 // Setting alternative title for "General" tab if "--div--" is the very first element.
809 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
810 // Only add the first tab to the dynNestedStack if there are more tabs:
811 if ($tabIdentString && strpos($itemList, '--div--', strlen($fieldInfo))) {
812 $this->pushToDynNestedStack('tab', $tabIdentStringMD5 . '-1');
813 }
814 }
815 } elseif ($theField == '--palette--') {
816 if ($parts[2] && !isset($this->palettesRendered[$this->renderDepth][$table][$parts[2]])) {
817 // Render a 'header' if not collapsed
818 if ($GLOBALS['TCA'][$table]['palettes'][$parts[2]]['canNotCollapse'] && $parts[1]) {
819 $out_array[$out_sheet][$out_pointer] .= $this->getPaletteFields($table, $row, $parts[2], $this->sL($parts[1]));
820 } else {
821 $out_array[$out_sheet][$out_pointer] .= $this->getPaletteFields($table, $row, $parts[2], '', '', $this->sL($parts[1]));
822 }
823 $this->palettesRendered[$this->renderDepth][$table][$parts[2]] = 1;
824 }
825 }
826 }
827 $cc++;
828 }
829 }
830 }
831 }
832 // Hook: getMainFields_postProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
833 foreach ($this->hookObjectsMainFields as $hookObj) {
834 if (method_exists($hookObj, 'getMainFields_postProcess')) {
835 $hookObj->getMainFields_postProcess($table, $row, $this);
836 }
837 }
838 // Wrapping a border around it all:
839 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
840 // Resetting styles:
841 $this->resetSchemes();
842 // Rendering Main palettes, if any
843 $mParr = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['mainpalette']);
844 $i = 0;
845 if (count($mParr)) {
846 foreach ($mParr as $mP) {
847 if (!isset($this->palettesRendered[$this->renderDepth][$table][$mP])) {
848 $temp_palettesCollapsed = $this->palettesCollapsed;
849 $this->palettesCollapsed = 0;
850 $label = $i == 0 ? $this->getLL('l_generalOptions') : $this->getLL('l_generalOptions_more');
851 $out_array[$out_sheet][$out_pointer] .= $this->getPaletteFields($table, $row, $mP, $label);
852 $this->palettesCollapsed = $temp_palettesCollapsed;
853 $this->palettesRendered[$this->renderDepth][$table][$mP] = 1;
854 }
855 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
856 $i++;
857 if ($this->renderDepth) {
858 $this->renderDepth--;
859 }
860 }
861 }
862 // Return the imploded $out_array:
863 // There were --div-- dividers around...
864 if ($out_sheet > 0) {
865 // Create parts array for the tab menu:
866 $parts = array();
867 foreach ($out_array as $idx => $sheetContent) {
868 $content = implode('', $sheetContent);
869 if ($content) {
870 // Wrap content (row) with table-tag, otherwise tab/sheet will be disabled (see getdynTabMenu() )
871 $content = '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . $content . '</table>';
872 }
873 $parts[$idx] = array(
874 'label' => $out_array_meta[$idx]['title'],
875 'content' => $content,
876 'newline' => $out_array_meta[$idx]['newline']
877 );
878 }
879 if (count($parts) > 1) {
880 // Unset the current level of tab menus:
881 $this->popFromDynNestedStack('tab', $tabIdentStringMD5 . '-' . ($out_sheet + 1));
882 $dividersToTabsBehaviour = isset($GLOBALS['TCA'][$table]['ctrl']['dividers2tabs']) ? $GLOBALS['TCA'][$table]['ctrl']['dividers2tabs'] : 1;
883 $output = $this->getDynTabMenu($parts, $tabIdentString, $dividersToTabsBehaviour);
884 } else {
885 // If there is only one tab/part there is no need to wrap it into the dynTab code
886 $output = isset($parts[0]) ? trim($parts[0]['content']) : '';
887 }
888 $output = '
889 <tr>
890 <td colspan="2">
891 ' . $output . '
892 </td>
893 </tr>';
894 } else {
895 // Only one, so just implode:
896 $output = implode('', $out_array[$out_sheet]);
897 }
898 return $output;
899 }
900
901 /**
902 * Will return the TCEform elements for a pre-defined list of fields.
903 * 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.
904 * Used for displaying forms for the frontend edit icons for instance.
905 *
906 * @param string $table The table name
907 * @param array $row The record array.
908 * @param string $list Commalist of fields from the table. These will be shown in the specified order in a form.
909 * @return string TCEform elements in a string.
910 * @todo Define visibility
911 */
912 public function getListedFields($table, $row, $list) {
913 \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($table);
914 if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table)) {
915 $GLOBALS['LANG']->loadSingleTableDescription($table);
916 }
917 $out = '';
918 $types_fieldConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getTCAtypes($table, $row, 1);
919 $editFieldList = array_unique(\TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $list, 1));
920 foreach ($editFieldList as $theFieldC) {
921 list($theField, $palFields) = preg_split('/\\[|\\]/', $theFieldC);
922 $theField = trim($theField);
923 $palFields = trim($palFields);
924 if ($GLOBALS['TCA'][$table]['columns'][$theField]) {
925 $parts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(';', $types_fieldConfig[$theField]['origString']);
926 // Don't sent palette pointer - there are no options anyways for a field-list.
927 $sField = $this->getSingleField($table, $theField, $row, $parts[1], 0, $parts[3], 0);
928 $out .= $sField;
929 } elseif ($theField == '--div--') {
930 $out .= $this->getDivider();
931 }
932 if ($palFields) {
933 $out .= $this->getPaletteFields($table, $row, '', '', implode(',', \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('|', $palFields, 1)));
934 }
935 }
936 return $out;
937 }
938
939 /**
940 * Creates a palette (collection of secondary options).
941 *
942 * @param string $table The table name
943 * @param array $row The row array
944 * @param string $palette The palette number/pointer
945 * @param string $header Header string for the palette (used when in-form). If not set, no header item is made.
946 * @param string $itemList Optional alternative list of fields for the palette
947 * @param string $collapsedHeader Optional Link text for activating a palette (when palettes does not have another form element to belong to).
948 * @return string HTML code.
949 * @todo Define visibility
950 */
951 public function getPaletteFields($table, $row, $palette, $header = '', $itemList = '', $collapsedHeader = NULL) {
952 if (!$this->doPrintPalette) {
953 return '';
954 }
955 $out = '';
956 $parts = $this->loadPaletteElements($table, $row, $palette, $itemList);
957 // Put palette together if there are fields in it:
958 if (count($parts)) {
959 $realFields = 0;
960 foreach ($parts as $part) {
961 if ($part['NAME'] !== '--linebreak--') {
962 $realFields++;
963 }
964 }
965 if ($realFields > 0) {
966 if ($header) {
967 $out .= $this->intoTemplate(array('HEADER' => htmlspecialchars($header)), $this->palFieldTemplateHeader);
968 }
969 $collapsed = $this->isPalettesCollapsed($table, $palette);
970 // Check if the palette is a hidden palette
971 $isHiddenPalette = !empty($GLOBALS['TCA'][$table]['palettes'][$palette]['isHiddenPalette']);
972 $thePalIcon = '';
973 if ($collapsed && $collapsedHeader !== NULL && !$isHiddenPalette) {
974 list($thePalIcon, ) = $this->wrapOpenPalette(\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-system-options-view', array('title' => htmlspecialchars($this->getLL('l_moreOptions')))), $table, $row, $palette, 1);
975 $thePalIcon = '<span style="margin-left: 20px;">' . $thePalIcon . $collapsedHeader . '</span>';
976 }
977 $paletteHtml = $this->wrapPaletteField($this->printPalette($parts), $table, $row, $palette, $collapsed);
978 $out .= $this->intoTemplate(array('PALETTE' => $thePalIcon . $paletteHtml), $this->palFieldTemplate);
979 }
980 }
981 return $out;
982 }
983
984 /**
985 * Returns the form HTML code for a database table field.
986 *
987 * @param string $table The table name
988 * @param string $field The field name
989 * @param array $row The record to edit from the database table.
990 * @param string $altName Alternative field name label to show.
991 * @param boolean $palette Set this if the field is on a palette (in top frame), otherwise not. (if set, field will render as a hidden field).
992 * @param string $extra 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.
993 * @param integer $pal The palette pointer.
994 * @return mixed String (normal) or array (palettes)
995 * @todo Define visibility
996 */
997 public function getSingleField($table, $field, $row, $altName = '', $palette = 0, $extra = '', $pal = 0) {
998 // Hook: getSingleField_preProcess
999 foreach ($this->hookObjectsSingleField as $hookObj) {
1000 if (method_exists($hookObj, 'getSingleField_preProcess')) {
1001 $hookObj->getSingleField_preProcess($table, $field, $row, $altName, $palette, $extra, $pal, $this);
1002 }
1003 }
1004 $out = '';
1005 $PA = array();
1006 $PA['altName'] = $altName;
1007 $PA['palette'] = $palette;
1008 $PA['extra'] = $extra;
1009 $PA['pal'] = $pal;
1010 // Make sure to load full $GLOBALS['TCA'] array for the table:
1011 \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($table);
1012 // Get the TCA configuration for the current field:
1013 $PA['fieldConf'] = $GLOBALS['TCA'][$table]['columns'][$field];
1014 $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ? $PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type'];
1015 // Using "form_type" locally in this script
1016 $skipThisField = $this->inline->skipField($table, $field, $row, $PA['fieldConf']['config']);
1017 // Now, check if this field is configured and editable (according to excludefields + other configuration)
1018 if (is_array($PA['fieldConf']) && !$skipThisField && (!$PA['fieldConf']['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $table . ':' . $field)) && $PA['fieldConf']['config']['form_type'] != 'passthrough' && ($this->RTEenabled || !$PA['fieldConf']['config']['showIfRTE']) && (!$PA['fieldConf']['displayCond'] || $this->isDisplayCondition($PA['fieldConf']['displayCond'], $row)) && (!$GLOBALS['TCA'][$table]['ctrl']['languageField'] || $PA['fieldConf']['l10n_display'] || strcmp($PA['fieldConf']['l10n_mode'], 'exclude') || $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] <= 0) && (!$GLOBALS['TCA'][$table]['ctrl']['languageField'] || !$this->localizationMode || $this->localizationMode === $PA['fieldConf']['l10n_cat'])) {
1019 // Fetching the TSconfig for the current table/field. This includes the $row which means that
1020 $PA['fieldTSConfig'] = $this->setTSconfig($table, $row, $field);
1021 // If the field is NOT disabled from TSconfig (which it could have been) then render it
1022 if (!$PA['fieldTSConfig']['disabled']) {
1023 // Override fieldConf by fieldTSconfig:
1024 $PA['fieldConf']['config'] = $this->overrideFieldConf($PA['fieldConf']['config'], $PA['fieldTSConfig']);
1025 // Init variables:
1026 $PA['itemFormElName'] = $this->prependFormFieldNames . '[' . $table . '][' . $row['uid'] . '][' . $field . ']';
1027 // Form field name, in case of file uploads
1028 $PA['itemFormElName_file'] = $this->prependFormFieldNames_file . '[' . $table . '][' . $row['uid'] . '][' . $field . ']';
1029 // Form field name, to activate elements
1030 // If the "eval" list contains "null", elements can be deactivated which results in storing NULL to database
1031 $PA['itemFormElNameActive'] = $this->prependFormFieldNamesActive . '[' . $table . '][' . $row['uid'] . '][' . $field . ']';
1032 // The value to show in the form field.
1033 $PA['itemFormElValue'] = $row[$field];
1034 $PA['itemFormElID'] = $this->prependFormFieldNames . '_' . $table . '_' . $row['uid'] . '_' . $field;
1035 // Set field to read-only if configured for translated records to show default language content as readonly
1036 if ($PA['fieldConf']['l10n_display'] && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly') && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] > 0) {
1037 $PA['fieldConf']['config']['readOnly'] = TRUE;
1038 $PA['itemFormElValue'] = $this->defaultLanguageData[$table . ':' . $row['uid']][$field];
1039 }
1040 if (strpos($GLOBALS['TCA'][$table]['ctrl']['type'], ':') === FALSE) {
1041 $typeField = $GLOBALS['TCA'][$table]['ctrl']['type'];
1042 } else {
1043 $typeField = substr($GLOBALS['TCA'][$table]['ctrl']['type'], 0, strpos($GLOBALS['TCA'][$table]['ctrl']['type'], ':'));
1044 }
1045 // 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"
1046 if ($GLOBALS['TCA'][$table]['ctrl']['type'] && !strcmp($field, $typeField) || $GLOBALS['TCA'][$table]['ctrl']['requestUpdate'] && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'], $field)) {
1047 if ($GLOBALS['BE_USER']->jsConfirmation(1)) {
1048 $alertMsgOnChange = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
1049 } else {
1050 $alertMsgOnChange = 'if (TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
1051 }
1052 } else {
1053 $alertMsgOnChange = '';
1054 }
1055 // Render as a hidden field?
1056 if (in_array($field, $this->hiddenFieldListArr)) {
1057 $this->hiddenFieldAccum[] = '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1058 } else {
1059 // Render as a normal field:
1060 // 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.
1061 if (!$PA['palette']) {
1062 $paletteFields = $this->loadPaletteElements($table, $row, $PA['pal']);
1063 if ($PA['pal'] && $this->isPalettesCollapsed($table, $PA['pal']) && count($paletteFields)) {
1064 list($thePalIcon, $palJSfunc) = $this->wrapOpenPalette(\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-system-options-view', array('title' => htmlspecialchars($this->getLL('l_moreOptions')))), $table, $row, $PA['pal'], 1);
1065 } else {
1066 $thePalIcon = '';
1067 $palJSfunc = '';
1068 }
1069 }
1070 // onFocus attribute to add to the field:
1071 $PA['onFocus'] = $palJSfunc && !$GLOBALS['BE_USER']->uc['dontShowPalettesOnFocusInAB'] ? ' onfocus="' . htmlspecialchars($palJSfunc) . '"' : '';
1072 // Find item
1073 $item = '';
1074 $PA['label'] = $PA['altName'] ? $PA['altName'] : $PA['fieldConf']['label'];
1075 $PA['label'] = $PA['fieldTSConfig']['label'] ? $PA['fieldTSConfig']['label'] : $PA['label'];
1076 $PA['label'] = $PA['fieldTSConfig']['label.'][$GLOBALS['LANG']->lang] ? $PA['fieldTSConfig']['label.'][$GLOBALS['LANG']->lang] : $PA['label'];
1077 $PA['label'] = $this->sL($PA['label']);
1078 // JavaScript code for event handlers:
1079 $PA['fieldChangeFunc'] = array();
1080 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = 'TBE_EDITOR.fieldChanged(\'' . $table . '\',\'' . $row['uid'] . '\',\'' . $field . '\',\'' . $PA['itemFormElName'] . '\');';
1081 $PA['fieldChangeFunc']['alert'] = $alertMsgOnChange;
1082 // If this is the child of an inline type and it is the field creating the label
1083 if ($this->inline->isInlineChildAndLabelField($table, $field)) {
1084 $inlineObjectId = implode(\TYPO3\CMS\Backend\Form\Element\InlineElement::Structure_Separator, array(
1085 $this->inline->inlineNames['object'],
1086 $table,
1087 $row['uid']
1088 ));
1089 $PA['fieldChangeFunc']['inline'] = 'inline.handleChangedField(\'' . $PA['itemFormElName'] . '\',\'' . $inlineObjectId . '\');';
1090 }
1091 // Based on the type of the item, call a render function:
1092 $item = $this->getSingleField_SW($table, $field, $row, $PA);
1093 // Add language + diff
1094 if ($PA['fieldConf']['l10n_display'] && (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($PA['fieldConf']['l10n_display'], 'hideDiff') || \TYPO3\CMS\Core\Utility\GeneralUtility::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly'))) {
1095 $renderLanguageDiff = FALSE;
1096 } else {
1097 $renderLanguageDiff = TRUE;
1098 }
1099 if ($renderLanguageDiff) {
1100 $item = $this->renderDefaultLanguageContent($table, $field, $row, $item);
1101 $item = $this->renderDefaultLanguageDiff($table, $field, $row, $item);
1102 }
1103 // 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
1104 $label = \TYPO3\CMS\Core\Utility\GeneralUtility::deHSCentities(htmlspecialchars($PA['label']));
1105 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($row['uid']) && $PA['fieldTSConfig']['linkTitleToSelf'] && !\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('columnsOnly')) {
1106 $lTTS_url = $this->backPath . 'alt_doc.php?edit[' . $table . '][' . $row['uid'] . ']=edit&columnsOnly=' . $field . '&returnUrl=' . rawurlencode($this->thisReturnUrl());
1107 $label = '<a href="' . htmlspecialchars($lTTS_url) . '">' . $label . '</a>';
1108 }
1109 // Wrap the label with help text
1110 $PA['label'] = ($label = \TYPO3\CMS\Backend\Utility\BackendUtility::wrapInHelp($table, $field, $label));
1111 // Create output value:
1112 if ($PA['fieldConf']['config']['form_type'] == 'user' && $PA['fieldConf']['config']['noTableWrapping']) {
1113 $out = $item;
1114 } elseif ($PA['palette']) {
1115 // Array:
1116 $out = array(
1117 'NAME' => $label,
1118 'ID' => $row['uid'],
1119 'FIELD' => $field,
1120 'TABLE' => $table,
1121 'ITEM' => $item,
1122 'ITEM_NULLVALUE' => $this->renderNullValueWidget($table, $field, $row, $PA),
1123 );
1124 $out = $this->addUserTemplateMarkers($out, $table, $field, $row, $PA);
1125 } else {
1126 // String:
1127 $out = array(
1128 'NAME' => $label,
1129 'ITEM' => $item,
1130 'TABLE' => $table,
1131 'ID' => $row['uid'],
1132 'PAL_LINK_ICON' => $thePalIcon,
1133 'FIELD' => $field,
1134 'ITEM_NULLVALUE' => $this->renderNullValueWidget($table, $field, $row, $PA),
1135 );
1136 $out = $this->addUserTemplateMarkers($out, $table, $field, $row, $PA);
1137 // String:
1138 $out = $this->intoTemplate($out);
1139 }
1140 }
1141 } else {
1142 $this->commentMessages[] = $this->prependFormFieldNames . '[' . $table . '][' . $row['uid'] . '][' . $field . ']: Disabled by TSconfig';
1143 }
1144 }
1145 // Hook: getSingleField_postProcess
1146 foreach ($this->hookObjectsSingleField as $hookObj) {
1147 if (method_exists($hookObj, 'getSingleField_postProcess')) {
1148 $hookObj->getSingleField_postProcess($table, $field, $row, $out, $PA, $this);
1149 }
1150 }
1151 // Return value (string or array)
1152 return $out;
1153 }
1154
1155 /**
1156 * Rendering a single item for the form
1157 *
1158 * @param string $table Table name of record
1159 * @param string $field Fieldname to render
1160 * @param array $row The record
1161 * @param array $PA Parameters array containing a lot of stuff. Value by Reference!
1162 * @return string Returns the item as HTML code to insert
1163 * @access private
1164 * @see getSingleField(), getSingleField_typeFlex_draw()
1165 * @todo Define visibility
1166 */
1167 public function getSingleField_SW($table, $field, $row, &$PA) {
1168 $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ? $PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type'];
1169 // Using "form_type" locally in this script
1170 // Hook: getSingleField_beforeRender
1171 foreach ($this->hookObjectsSingleField as $hookObject) {
1172 if (method_exists($hookObject, 'getSingleField_beforeRender')) {
1173 $hookObject->getSingleField_beforeRender($table, $field, $row, $PA);
1174 }
1175 }
1176 switch ($PA['fieldConf']['config']['form_type']) {
1177 case 'input':
1178 $item = $this->getSingleField_typeInput($table, $field, $row, $PA);
1179 break;
1180 case 'text':
1181 $item = $this->getSingleField_typeText($table, $field, $row, $PA);
1182 break;
1183 case 'check':
1184 $item = $this->getSingleField_typeCheck($table, $field, $row, $PA);
1185 break;
1186 case 'radio':
1187 $item = $this->getSingleField_typeRadio($table, $field, $row, $PA);
1188 break;
1189 case 'select':
1190 $item = $this->getSingleField_typeSelect($table, $field, $row, $PA);
1191 break;
1192 case 'group':
1193 $item = $this->getSingleField_typeGroup($table, $field, $row, $PA);
1194 break;
1195 case 'inline':
1196 $item = $this->inline->getSingleField_typeInline($table, $field, $row, $PA);
1197 break;
1198 case 'none':
1199 $item = $this->getSingleField_typeNone($table, $field, $row, $PA);
1200 break;
1201 case 'user':
1202 $item = $this->getSingleField_typeUser($table, $field, $row, $PA);
1203 break;
1204 case 'flex':
1205 $item = $this->getSingleField_typeFlex($table, $field, $row, $PA);
1206 break;
1207 default:
1208 $item = $this->getSingleField_typeUnknown($table, $field, $row, $PA);
1209 break;
1210 }
1211 return $item;
1212 }
1213
1214 /**********************************************************
1215 *
1216 * Rendering of each TCEform field type
1217 *
1218 ************************************************************/
1219 /**
1220 * Generation of TCEform elements of the type "input"
1221 * This will render a single-line input form field, possibly with various control/validation features
1222 *
1223 * @param string $table The table name of the record
1224 * @param string $field The field name which this element is supposed to edit
1225 * @param array $row The record data array where the value(s) for the field can be found
1226 * @param array $PA An array with additional configuration options.
1227 * @return string The HTML code for the TCEform field
1228 * @todo Define visibility
1229 */
1230 public function getSingleField_typeInput($table, $field, $row, &$PA) {
1231 $config = $PA['fieldConf']['config'];
1232 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1233 $size = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['size'] ? $config['size'] : 30, 5, $this->maxInputWidth);
1234 $evalList = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $config['eval'], 1);
1235 $classAndStyleAttributes = $this->formWidthAsArray($size);
1236 $fieldAppendix = '';
1237 $item = '';
1238 $cssClasses = array($classAndStyleAttributes['class']);
1239 $cssStyle = $classAndStyleAttributes['style'];
1240 if (!isset($config['checkbox'])) {
1241 $config['checkbox'] = '0';
1242 $checkboxIsset = FALSE;
1243 } else {
1244 $checkboxIsset = TRUE;
1245 }
1246 if (in_array('date', $evalList) || in_array('datetime', $evalList)) {
1247 if (in_array('datetime', $evalList)) {
1248 $class = 'datetime';
1249 } else {
1250 $class = 'date';
1251 }
1252 $dateRange = '';
1253 if (isset($config['range']['lower'])) {
1254 $dateRange .= ' lower-' . intval($config['range']['lower']);
1255 }
1256 if (isset($config['range']['upper'])) {
1257 $dateRange .= ' upper-' . intval($config['range']['upper']);
1258 }
1259 $inputId = uniqid('tceforms-' . $class . 'field-');
1260 $cssClasses[] = 'tceforms-textfield tceforms-' . $class . 'field' . $dateRange;
1261 $fieldAppendix = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-edit-pick-date', array(
1262 'style' => 'cursor:pointer;',
1263 'id' => 'picker-' . $inputId
1264 ));
1265 } elseif (in_array('timesec', $evalList)) {
1266 $inputId = uniqid('tceforms-timesecfield-');
1267 $cssClasses[] = 'tceforms-textfield tceforms-timesecfield';
1268 } elseif (in_array('year', $evalList)) {
1269 $inputId = uniqid('tceforms-yearfield-');
1270 $cssClasses[] = 'tceforms-textfield tceforms-yearfield';
1271 } elseif (in_array('time', $evalList)) {
1272 $inputId = uniqid('tceforms-timefield-');
1273 $cssClasses[] = 'tceforms-textfield tceforms-timefield';
1274 } elseif (in_array('int', $evalList)) {
1275 $inputId = uniqid('tceforms-intfield-');
1276 $cssClasses[] = 'tceforms-textfield tceforms-intfield';
1277 } elseif (in_array('double2', $evalList)) {
1278 $inputId = uniqid('tceforms-double2field-');
1279 $cssClasses[] = 'tceforms-textfield tceforms-double2field';
1280 } else {
1281 $inputId = uniqid('tceforms-textfield-');
1282 $cssClasses[] = 'tceforms-textfield';
1283 if ($checkboxIsset === FALSE) {
1284 $config['checkbox'] = '';
1285 }
1286 }
1287 if (isset($config['wizards']['link'])) {
1288 $inputId = uniqid('tceforms-linkfield-');
1289 $cssClasses[] = 'tceforms-textfield tceforms-linkfield';
1290 } elseif (isset($config['wizards']['color'])) {
1291 $inputId = uniqid('tceforms-colorfield-');
1292 $cssClasses[] = 'tceforms-textfield tceforms-colorfield';
1293 }
1294 if ($this->renderReadonly || $config['readOnly']) {
1295 $itemFormElValue = $PA['itemFormElValue'];
1296 if (in_array('date', $evalList)) {
1297 $config['format'] = 'date';
1298 } elseif (in_array('datetime', $evalList)) {
1299 $config['format'] = 'datetime';
1300 } elseif (in_array('time', $evalList)) {
1301 $config['format'] = 'time';
1302 }
1303 if (in_array('password', $evalList)) {
1304 $itemFormElValue = $itemFormElValue ? '*********' : '';
1305 }
1306 return $this->getSingleField_typeNone_render($config, $itemFormElValue);
1307 }
1308 foreach ($evalList as $func) {
1309 switch ($func) {
1310 case 'required':
1311 $this->registerRequiredProperty('field', $table . '_' . $row['uid'] . '_' . $field, $PA['itemFormElName']);
1312 // Mark this field for date/time disposal:
1313 if (array_intersect($evalList, array('date', 'datetime', 'time'))) {
1314 $this->requiredAdditional[$PA['itemFormElName']]['isPositiveNumber'] = TRUE;
1315 }
1316 break;
1317 default:
1318 // Pair hook to the one in t3lib_TCEmain::checkValue_input_Eval()
1319 $evalObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
1320 if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue')) {
1321 $_params = array(
1322 'value' => $PA['itemFormElValue']
1323 );
1324 $PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
1325 }
1326 break;
1327 }
1328 }
1329 $paramsList = '\'' . $PA['itemFormElName'] . '\',\'' . implode(',', $evalList) . '\',\'' . trim($config['is_in']) . '\',' . (isset($config['checkbox']) ? 1 : 0) . ',\'' . $config['checkbox'] . '\'';
1330 if (in_array('date', $evalList) || in_array('datetime', $evalList)) {
1331 $item .= '<span class="t3-tceforms-input-wrapper-datetime" onmouseOver="if (document.getElementById(\'' . $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\';">';
1332 // Add server timezone offset to UTC to our stored date
1333 if ($PA['itemFormElValue'] > 0) {
1334 $PA['itemFormElValue'] += date('Z', $PA['itemFormElValue']);
1335 }
1336 } else {
1337 $item .= '<span class="t3-tceforms-input-wrapper" onmouseOver="if (document.getElementById(\'' . $inputId . '\').value) {this.className=\'t3-tceforms-input-wrapper-hover\';} else {this.className=\'t3-tceforms-input-wrapper\';};" onmouseOut="this.className=\'t3-tceforms-input-wrapper\';">';
1338 }
1339 $PA['fieldChangeFunc'] = array_merge(array('typo3form.fieldGet' => 'typo3form.fieldGet(' . $paramsList . ');'), $PA['fieldChangeFunc']);
1340 // Old function "checkbox" now the option to set the date / remove the date
1341 if (isset($config['checkbox'])) {
1342 $item .= \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-input-clear', array('tag' => 'a', 'class' => 't3-tceforms-input-clearer', 'onclick' => 'document.getElementById(\'' . $inputId . '\').value=\'\';document.getElementById(\'' . $inputId . '\').focus();' . implode('', $PA['fieldChangeFunc'])));
1343 }
1344 $mLgd = $config['max'] ? $config['max'] : 256;
1345 $iOnChange = implode('', $PA['fieldChangeFunc']);
1346 $cssClasses[] = 'hasDefaultValue';
1347 $item .= '<input type="text" ' . $this->getPlaceholderAttribute($table, $field, $config, $row) . 'id="' . $inputId . '" ' . 'class="' . implode(' ', $cssClasses) . '" ' . 'name="' . $PA['itemFormElName'] . '_hr" ' . 'value=""' . 'style="' . $cssStyle . '" ' . 'maxlength="' . $mLgd . '" ' . 'onchange="' . htmlspecialchars($iOnChange) . '"' . $PA['onFocus'] . ' />';
1348 // This is the EDITABLE form field.
1349 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1350 // 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.
1351 $item .= $fieldAppendix . '</span><div style="clear:both;"></div>';
1352 $this->extJSCODE .= 'typo3form.fieldSet(' . $paramsList . ');';
1353 // Going through all custom evaluations configured for this field
1354 foreach ($evalList as $evalData) {
1355 $evalObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$evalData] . ':&' . $evalData);
1356 if (is_object($evalObj) && method_exists($evalObj, 'returnFieldJS')) {
1357 $this->extJSCODE .= '
1358
1359 function ' . $evalData . '(value) {
1360 ' . $evalObj->returnFieldJS() . '
1361 }
1362 ';
1363 }
1364 }
1365 // Creating an alternative item without the JavaScript handlers.
1366 $altItem = '<input type="hidden" name="' . $PA['itemFormElName'] . '_hr" value="" />';
1367 $altItem .= '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1368 // Wrap a wizard around the item?
1369 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'] . '_hr', $specConf);
1370 return $item;
1371 }
1372
1373 /**
1374 * Renders a view widget to handle and activate NULL values.
1375 * The widget is enabled by using 'null' in the 'eval' TCA definition.
1376 *
1377 * @param string $table Name of the table
1378 * @param string $field Name of the field
1379 * @param array $row Accordant data of the record row
1380 * @param array $PA Parameters array with rendering instructions
1381 * @return string Widget (if any).
1382 */
1383 protected function renderNullValueWidget($table, $field, array $row, array $PA) {
1384 $widget = '';
1385
1386 $config = $PA['fieldConf']['config'];
1387 if (!empty($config['eval']) && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($config['eval'], 'null')) {
1388 $isNull = ($PA['itemFormElValue'] === NULL);
1389
1390 $checked = ($isNull ? '' : ' checked="checked"');
1391 $onChange = htmlspecialchars(
1392 'typo3form.fieldSetNull(\'' . $PA['itemFormElName'] . '\', !this.checked)'
1393 );
1394
1395 $widget = '<span class="t3-tceforms-widget-null-wrapper">' .
1396 '<input type="hidden" name="' . $PA['itemFormElNameActive'] . '" value="0" />' .
1397 '<input type="checkbox" name="' . $PA['itemFormElNameActive'] . '" value="1" onchange="' . $onChange . '"' . $checked . ' />' .
1398 '</span>';
1399 }
1400
1401 return $widget;
1402 }
1403
1404 /**
1405 * Determines whether the current field value is considered as NULL value.
1406 * Using NULL values is enabled by using 'null' in the 'eval' TCA definition.
1407 *
1408 * @param string $table Name of the table
1409 * @param string $field Name of the field
1410 * @param array $row Accordant data
1411 * @param array $PA Parameters array with rendering instructions
1412 * @return boolean
1413 */
1414 protected function isNullValue($table, $field, array $row, array $PA) {
1415 $result = FALSE;
1416
1417 $config = $PA['fieldConf']['config'];
1418 if ($PA['itemFormElValue'] === NULL && !empty($config['eval']) && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($config['eval'], 'null')) {
1419 $result = TRUE;
1420 }
1421
1422 return $result;
1423 }
1424
1425 /**
1426 * Generation of TCEform elements of the type "text"
1427 * This will render a <textarea> OR RTE area form field, possibly with various control/validation features
1428 *
1429 * @param string $table The table name of the record
1430 * @param string $field The field name which this element is supposed to edit
1431 * @param array $row The record data array where the value(s) for the field can be found
1432 * @param array $PA An array with additional configuration options.
1433 * @return string The HTML code for the TCEform field
1434 * @todo Define visibility
1435 */
1436 public function getSingleField_typeText($table, $field, $row, &$PA) {
1437 // Init config:
1438 $config = $PA['fieldConf']['config'];
1439 $evalList = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $config['eval'], 1);
1440 if ($this->renderReadonly || $config['readOnly']) {
1441 return $this->getSingleField_typeNone_render($config, $PA['itemFormElValue']);
1442 }
1443 // Setting columns number:
1444 $cols = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
1445 // Setting number of rows:
1446 $origRows = ($rows = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['rows'] ? $config['rows'] : 5, 1, 20));
1447 if (strlen($PA['itemFormElValue']) > $this->charsPerRow * 2) {
1448 $cols = $this->maxTextareaWidth;
1449 $rows = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(round(strlen($PA['itemFormElValue']) / $this->charsPerRow), count(explode(LF, $PA['itemFormElValue'])), 20);
1450 if ($rows < $origRows) {
1451 $rows = $origRows;
1452 }
1453 }
1454 if (in_array('required', $evalList)) {
1455 $this->requiredFields[$table . '_' . $row['uid'] . '_' . $field] = $PA['itemFormElName'];
1456 }
1457 // Init RTE vars:
1458 // Set TRUE, if the RTE is loaded; If not a normal textarea is shown.
1459 $RTEwasLoaded = 0;
1460 // Set TRUE, if the RTE would have been loaded if it wasn't for the disable-RTE flag in the bottom of the page...
1461 $RTEwouldHaveBeenLoaded = 0;
1462 // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. Traditionally, this is where RTE configuration has been found.
1463 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1464 // Setting up the altItem form field, which is a hidden field containing the value
1465 $altItem = '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1466 // If RTE is generally enabled (TYPO3_CONF_VARS and user settings)
1467 if ($this->RTEenabled) {
1468 $p = \TYPO3\CMS\Backend\Utility\BackendUtility::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
1469 // If the field is configured for RTE and if any flag-field is not set to disable it.
1470 if (isset($specConf['richtext']) && (!$p['flag'] || !$row[$p['flag']])) {
1471 \TYPO3\CMS\Backend\Utility\BackendUtility::fixVersioningPid($table, $row);
1472 list($tscPID, $thePidValue) = $this->getTSCpid($table, $row['uid'], $row['pid']);
1473 // If the pid-value is not negative (that is, a pid could NOT be fetched)
1474 if ($thePidValue >= 0) {
1475 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($tscPID));
1476 $RTEtypeVal = \TYPO3\CMS\Backend\Utility\BackendUtility::getTCAtypeValue($table, $row);
1477 $thisConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::RTEsetup($RTEsetup['properties'], $table, $field, $RTEtypeVal);
1478 if (!$thisConfig['disabled']) {
1479 if (!$this->disableRTE) {
1480 $this->RTEcounter++;
1481 // Find alternative relative path for RTE images/links:
1482 $eFile = \TYPO3\CMS\Core\Html\RteHtmlParser::evalWriteFile($specConf['static_write'], $row);
1483 $RTErelPath = is_array($eFile) ? dirname($eFile['relEditFile']) : '';
1484 // Get RTE object, draw form and set flag:
1485 $RTEobj = \TYPO3\CMS\Backend\Utility\BackendUtility::RTEgetObj();
1486 $item = $RTEobj->drawRTE($this, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue);
1487 // Wizard:
1488 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf, 1);
1489 $RTEwasLoaded = 1;
1490 } else {
1491 $RTEwouldHaveBeenLoaded = 1;
1492 $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!)';
1493 }
1494 } else {
1495 $this->commentMessages[] = $PA['itemFormElName'] . ': RTE is disabled by the Page TSconfig, "RTE"-key (eg. by RTE.default.disabled=0 or such)';
1496 }
1497 } else {
1498 $this->commentMessages[] = $PA['itemFormElName'] . ': PID value could NOT be fetched. Rare error, normally with new records.';
1499 }
1500 } else {
1501 if (!isset($specConf['richtext'])) {
1502 $this->commentMessages[] = $PA['itemFormElName'] . ': RTE was not configured for this field in TCA-types';
1503 }
1504 if (!(!$p['flag'] || !$row[$p['flag']])) {
1505 $this->commentMessages[] = $PA['itemFormElName'] . ': Field-flag (' . $PA['flag'] . ') has been set to disable RTE!';
1506 }
1507 }
1508 }
1509 // Display ordinary field if RTE was not loaded.
1510 if (!$RTEwasLoaded) {
1511 // Show message, if no RTE (field can only be edited with RTE!)
1512 if ($specConf['rte_only']) {
1513 $item = '<p><em>' . htmlspecialchars($this->getLL('l_noRTEfound')) . '</em></p>';
1514 } else {
1515 if ($specConf['nowrap']) {
1516 $wrap = 'off';
1517 } else {
1518 $wrap = $config['wrap'] ? $config['wrap'] : 'virtual';
1519 }
1520 $classes = array();
1521 if ($specConf['fixed-font']) {
1522 $classes[] = 'fixed-font';
1523 }
1524 if ($specConf['enable-tab']) {
1525 $classes[] = 'enable-tab';
1526 }
1527 $formWidthText = $this->formWidthText($cols, $wrap);
1528 // Extract class attributes from $formWidthText (otherwise it would be added twice to the output)
1529 $res = array();
1530 if (preg_match('/ class="(.+?)"/', $formWidthText, $res)) {
1531 $formWidthText = str_replace(' class="' . $res[1] . '"', '', $formWidthText);
1532 $classes = array_merge($classes, explode(' ', $res[1]));
1533 }
1534 if (count($classes)) {
1535 $class = ' class="tceforms-textarea ' . implode(' ', $classes) . '"';
1536 } else {
1537 $class = 'tceforms-textarea';
1538 }
1539 $evalList = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $config['eval'], 1);
1540 foreach ($evalList as $func) {
1541 switch ($func) {
1542 case 'required':
1543 $this->registerRequiredProperty('field', $table . '_' . $row['uid'] . '_' . $field, $PA['itemFormElName']);
1544 break;
1545 default:
1546 // Pair hook to the one in t3lib_TCEmain::checkValue_input_Eval() and t3lib_TCEmain::checkValue_text_Eval()
1547 $evalObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
1548 if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue')) {
1549 $_params = array(
1550 'value' => $PA['itemFormElValue']
1551 );
1552 $PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
1553 }
1554 break;
1555 }
1556 }
1557 $iOnChange = implode('', $PA['fieldChangeFunc']);
1558 $item .= '
1559 <textarea ' . 'id="' . uniqid('tceforms-textarea-') . '" ' . 'name="' . $PA['itemFormElName'] . '"' . $formWidthText . $class . ' ' . 'rows="' . $rows . '" ' . 'wrap="' . $wrap . '" ' . 'onchange="' . htmlspecialchars($iOnChange) . '"' . $this->getPlaceholderAttribute($table, $field, $config, $row) . $PA['onFocus'] . '>' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatForTextarea($PA['itemFormElValue']) . '</textarea>';
1560 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf, $RTEwouldHaveBeenLoaded);
1561 }
1562 }
1563 // Return field HTML:
1564 return $item;
1565 }
1566
1567 /**
1568 * Generation of TCEform elements of the type "check"
1569 * This will render a check-box OR an array of checkboxes
1570 *
1571 * @param string $table The table name of the record
1572 * @param string $field The field name which this element is supposed to edit
1573 * @param array $row The record data array where the value(s) for the field can be found
1574 * @param array $PA An array with additional configuration options.
1575 * @return string The HTML code for the TCEform field
1576 * @todo Define visibility
1577 */
1578 public function getSingleField_typeCheck($table, $field, $row, &$PA) {
1579 $config = $PA['fieldConf']['config'];
1580 $item = '';
1581 $disabled = '';
1582 if ($this->renderReadonly || $config['readOnly']) {
1583 $disabled = ' disabled="disabled"';
1584 }
1585 // Traversing the array of items:
1586 $selItems = $this->initItemArray($PA['fieldConf']);
1587 if ($config['itemsProcFunc']) {
1588 $selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
1589 }
1590 if (!count($selItems)) {
1591 $selItems[] = array('', '');
1592 }
1593 $thisValue = intval($PA['itemFormElValue']);
1594 $cols = intval($config['cols']);
1595 $selItemsCount = count($selItems);
1596 if ($cols > 1) {
1597 $item .= '<table border="0" cellspacing="0" cellpadding="0" class="typo3-TCEforms-checkboxArray">';
1598 for ($c = 0; $c < $selItemsCount; $c++) {
1599 $p = $selItems[$c];
1600 if (!($c % $cols)) {
1601 $item .= '<tr>';
1602 }
1603 $cBP = $this->checkBoxParams($PA['itemFormElName'], $thisValue, $c, count($selItems), implode('', $PA['fieldChangeFunc']));
1604 $cBName = $PA['itemFormElName'] . '_' . $c;
1605 $cBID = $PA['itemFormElID'] . '_' . $c;
1606 $item .= '<td nowrap="nowrap">' . '<input type="checkbox"' . $this->insertDefStyle('check') . ' value="1" name="' . $cBName . '"' . $cBP . $disabled . ' id="' . $cBID . '" />' . $this->wrapLabels(('<label for="' . $cBID . '">' . htmlspecialchars($p[0]) . '</label>&nbsp;')) . '</td>';
1607 if ($c % $cols + 1 == $cols) {
1608 $item .= '</tr>';
1609 }
1610 }
1611 if ($c % $cols) {
1612 $rest = $cols - $c % $cols;
1613 for ($c = 0; $c < $rest; $c++) {
1614 $item .= '<td></td>';
1615 }
1616 if ($c > 0) {
1617 $item .= '</tr>';
1618 }
1619 }
1620 $item .= '</table>';
1621 } else {
1622 for ($c = 0; $c < $selItemsCount; $c++) {
1623 $p = $selItems[$c];
1624 $cBP = $this->checkBoxParams($PA['itemFormElName'], $thisValue, $c, count($selItems), implode('', $PA['fieldChangeFunc']));
1625 $cBName = $PA['itemFormElName'] . '_' . $c;
1626 $cBID = $PA['itemFormElID'] . '_' . $c;
1627 $item .= ($c > 0 ? '<br />' : '') . '<input type="checkbox"' . $this->insertDefStyle('check') . ' value="1" name="' . $cBName . '"' . $cBP . $PA['onFocus'] . $disabled . ' id="' . $cBID . '" />' . $this->wrapLabels(('<label for="' . $cBID . '">' . htmlspecialchars($p[0]) . '</label>'));
1628 }
1629 }
1630 if (!$disabled) {
1631 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($thisValue) . '" />';
1632 }
1633 return $item;
1634 }
1635
1636 /**
1637 * Generation of TCEform elements of the type "radio"
1638 * This will render a series of radio buttons.
1639 *
1640 * @param string $table The table name of the record
1641 * @param string $field The field name which this element is supposed to edit
1642 * @param array $row The record data array where the value(s) for the field can be found
1643 * @param array $PA An array with additional configuration options.
1644 * @return string The HTML code for the TCEform field
1645 * @todo Define visibility
1646 */
1647 public function getSingleField_typeRadio($table, $field, $row, &$PA) {
1648 $config = $PA['fieldConf']['config'];
1649 $item = '';
1650 $disabled = '';
1651 if ($this->renderReadonly || $config['readOnly']) {
1652 $disabled = ' disabled="disabled"';
1653 }
1654 // Get items for the array:
1655 $selItems = $this->initItemArray($PA['fieldConf']);
1656 if ($config['itemsProcFunc']) {
1657 $selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
1658 }
1659 // Traverse the items, making the form elements:
1660 $selItemsCount = count($selItems);
1661 for ($c = 0; $c < $selItemsCount; $c++) {
1662 $p = $selItems[$c];
1663 $rID = $PA['itemFormElID'] . '_' . $c;
1664 $rOnClick = implode('', $PA['fieldChangeFunc']);
1665 $rChecked = !strcmp($p[1], $PA['itemFormElValue']) ? ' checked="checked"' : '';
1666 $item .= '<input type="radio"' . $this->insertDefStyle('radio') . ' name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($p[1]) . '" onclick="' . htmlspecialchars($rOnClick) . '"' . $rChecked . $PA['onFocus'] . $disabled . ' id="' . $rID . '" />
1667 <label for="' . $rID . '">' . htmlspecialchars($p[0]) . '</label>
1668 <br />';
1669 }
1670 return $item;
1671 }
1672
1673 /**
1674 * Generation of TCEform elements of the type "select"
1675 * This will render a selector box element, or possibly a special construction with two selector boxes. That depends on configuration.
1676 *
1677 * @param string $table The table name of the record
1678 * @param string $field The field name which this element is supposed to edit
1679 * @param array $row The record data array where the value(s) for the field can be found
1680 * @param array $PA An array with additional configuration options.
1681 * @return string The HTML code for the TCEform field
1682 * @todo Define visibility
1683 */
1684 public function getSingleField_typeSelect($table, $field, $row, &$PA) {
1685 // Field configuration from TCA:
1686 $config = $PA['fieldConf']['config'];
1687 $disabled = '';
1688 if ($this->renderReadonly || $config['readOnly']) {
1689 $disabled = ' disabled="disabled"';
1690 }
1691 // "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/.
1692 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1693 // Getting the selector box items from the system
1694 $selItems = $this->addSelectOptionsToItemArray($this->initItemArray($PA['fieldConf']), $PA['fieldConf'], $this->setTSconfig($table, $row), $field);
1695 // Possibly filter some items:
1696 $keepItemsFunc = create_function('$value', 'return $value[1];');
1697 $selItems = \TYPO3\CMS\Core\Utility\GeneralUtility::keepItemsInArray($selItems, $PA['fieldTSConfig']['keepItems'], $keepItemsFunc);
1698 // Possibly add some items:
1699 $selItems = $this->addItems($selItems, $PA['fieldTSConfig']['addItems.']);
1700 // Process items by a user function:
1701 if (isset($config['itemsProcFunc']) && $config['itemsProcFunc']) {
1702 $selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
1703 }
1704 // Possibly remove some items:
1705 $removeItems = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $PA['fieldTSConfig']['removeItems'], 1);
1706 foreach ($selItems as $tk => $p) {
1707 // Checking languages and authMode:
1708 $languageDeny = $GLOBALS['TCA'][$table]['ctrl']['languageField'] && !strcmp($GLOBALS['TCA'][$table]['ctrl']['languageField'], $field) && !$GLOBALS['BE_USER']->checkLanguageAccess($p[1]);
1709 $authModeDeny = $config['form_type'] == 'select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table, $field, $p[1], $config['authMode']);
1710 if (in_array($p[1], $removeItems) || $languageDeny || $authModeDeny) {
1711 unset($selItems[$tk]);
1712 } elseif (isset($PA['fieldTSConfig']['altLabels.'][$p[1]])) {
1713 $selItems[$tk][0] = htmlspecialchars($this->sL($PA['fieldTSConfig']['altLabels.'][$p[1]]));
1714 }
1715 // Removing doktypes with no access:
1716 if (($table === 'pages' || $table === 'pages_language_overlay') && $field === 'doktype') {
1717 if (!($GLOBALS['BE_USER']->isAdmin() || \TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['BE_USER']->groupData['pagetypes_select'], $p[1]))) {
1718 unset($selItems[$tk]);
1719 }
1720 }
1721 }
1722 // Creating the label for the "No Matching Value" entry.
1723 $nMV_label = isset($PA['fieldTSConfig']['noMatchingValue_label']) ? $this->sL($PA['fieldTSConfig']['noMatchingValue_label']) : '[ ' . $this->getLL('l_noMatchingValue') . ' ]';
1724 // Prepare some values:
1725 $maxitems = intval($config['maxitems']);
1726 // If a SINGLE selector box...
1727 if ($maxitems <= 1 && $config['renderMode'] !== 'tree') {
1728 $item = $this->getSingleField_typeSelect_single($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1729 } elseif (!strcmp($config['renderMode'], 'checkbox')) {
1730 // Checkbox renderMode
1731 $item = $this->getSingleField_typeSelect_checkbox($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1732 } elseif (!strcmp($config['renderMode'], 'singlebox')) {
1733 // Single selector box renderMode
1734 $item = $this->getSingleField_typeSelect_singlebox($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1735 } elseif (!strcmp($config['renderMode'], 'tree')) {
1736 // Tree renderMode
1737 $treeClass = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\Element\\TreeElement', $this);
1738 $item = $treeClass->renderField($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1739 // Register the required number of elements
1740 $minitems = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['minitems'], 0);
1741 $this->registerRequiredProperty('range', $PA['itemFormElName'], array($minitems, $maxitems, 'imgName' => $table . '_' . $row['uid'] . '_' . $field));
1742 } else {
1743 // Traditional multiple selector box:
1744 $item = $this->getSingleField_typeSelect_multiple($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1745 }
1746 // Wizards:
1747 if (!$disabled) {
1748 $altItem = '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1749 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf);
1750 }
1751 return $item;
1752 }
1753
1754 /**
1755 * Creates a single-selector box
1756 * (Render function for getSingleField_typeSelect())
1757 *
1758 * @param string $table See getSingleField_typeSelect()
1759 * @param string $field See getSingleField_typeSelect()
1760 * @param array $row See getSingleField_typeSelect()
1761 * @param array $PA See getSingleField_typeSelect()
1762 * @param array $config (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1763 * @param array $selItems Items available for selection
1764 * @param string $nMV_label Label for no-matching-value
1765 * @return string The HTML code for the item
1766 * @see getSingleField_typeSelect()
1767 * @todo Define visibility
1768 */
1769 public function getSingleField_typeSelect_single($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
1770 // check against inline uniqueness
1771 $inlineParent = $this->inline->getStructureLevel(-1);
1772 if (is_array($inlineParent) && $inlineParent['uid']) {
1773 if ($inlineParent['config']['foreign_table'] == $table && $inlineParent['config']['foreign_unique'] == $field) {
1774 $uniqueIds = $this->inline->inlineData['unique'][$this->inline->inlineNames['object'] . \TYPO3\CMS\Backend\Form\Element\InlineElement::Structure_Separator . $table]['used'];
1775 $PA['fieldChangeFunc']['inlineUnique'] = 'inline.updateUnique(this,\'' . $this->inline->inlineNames['object'] . \TYPO3\CMS\Backend\Form\Element\InlineElement::Structure_Separator . $table . '\',\'' . $this->inline->inlineNames['form'] . '\',\'' . $row['uid'] . '\');';
1776 }
1777 // hide uid of parent record for symmetric relations
1778 if ($inlineParent['config']['foreign_table'] == $table && ($inlineParent['config']['foreign_field'] == $field || $inlineParent['config']['symmetric_field'] == $field)) {
1779 $uniqueIds[] = $inlineParent['uid'];
1780 }
1781 }
1782 // Initialization:
1783 $c = 0;
1784 $sI = 0;
1785 $noMatchingValue = 1;
1786 $opt = array();
1787 $selicons = array();
1788 $onlySelectedIconShown = 0;
1789 $size = intval($config['size']);
1790 // Style set on <select/>
1791 $selectedStyle = '';
1792 $item = '';
1793 $disabled = '';
1794 // TODO: icon is used but never assigned
1795 $onChangeIcon = '';
1796 if ($this->renderReadonly || $config['readOnly']) {
1797 $disabled = ' disabled="disabled"';
1798 $onlySelectedIconShown = 1;
1799 }
1800 // Icon configuration:
1801 if ($config['suppress_icons'] == 'IF_VALUE_FALSE') {
1802 $suppressIcons = !$PA['itemFormElValue'] ? 1 : 0;
1803 } elseif ($config['suppress_icons'] == 'ONLY_SELECTED') {
1804 $suppressIcons = 0;
1805 $onlySelectedIconShown = 1;
1806 } elseif ($config['suppress_icons']) {
1807 $suppressIcons = 1;
1808 } else {
1809 $suppressIcons = 0;
1810 }
1811 // Traverse the Array of selector box items:
1812 $optGroupStart = array();
1813 $optGroupOpen = FALSE;
1814 $classesForSelectTag = array();
1815 foreach ($selItems as $p) {
1816 $sM = !strcmp($PA['itemFormElValue'], $p[1]) ? ' selected="selected"' : '';
1817 if ($sM) {
1818 $sI = $c;
1819 $noMatchingValue = 0;
1820 }
1821 // Getting style attribute value (for icons):
1822 if ($config['iconsInOptionTags']) {
1823 $styleAttrValue = $this->optionTagStyle($p[2]);
1824 if ($sM) {
1825 list($selectIconFile, $selectIconInfo) = $this->getIcon($p[2]);
1826 if (!empty($selectIconInfo)) {
1827 $selectedStyle = ' style="background-image:url(' . $selectIconFile . ');"';
1828 $classesForSelectTag[] = 'typo3-TCEforms-select-selectedItemWithBackgroundImage';
1829 }
1830 }
1831 }
1832 // Compiling the <option> tag:
1833 if (!($p[1] != $PA['itemFormElValue'] && is_array($uniqueIds) && in_array($p[1], $uniqueIds))) {
1834 if (!strcmp($p[1], '--div--')) {
1835 $optGroupStart[0] = $p[0];
1836 if ($config['iconsInOptionTags']) {
1837 $optGroupStart[1] = $this->optgroupTagStyle($p[2]);
1838 } else {
1839 $optGroupStart[1] = $styleAttrValue;
1840 }
1841 } else {
1842 if (count($optGroupStart)) {
1843 // Closing last optgroup before next one starts
1844 if ($optGroupOpen) {
1845 $opt[] = '</optgroup>' . LF;
1846 }
1847 $opt[] = '<optgroup label="' . \TYPO3\CMS\Core\Utility\GeneralUtility::deHSCentities(htmlspecialchars($optGroupStart[0])) . '"' . ($optGroupStart[1] ? ' style="' . htmlspecialchars($optGroupStart[1]) . '"' : '') . ' class="c-divider">' . LF;
1848 $optGroupOpen = TRUE;
1849 $c--;
1850 $optGroupStart = array();
1851 }
1852 $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' . $sM . ($styleAttrValue ? ' style="' . htmlspecialchars($styleAttrValue) . '"' : '') . '>' . \TYPO3\CMS\Core\Utility\GeneralUtility::deHSCentities($p[0]) . '</option>' . LF;
1853 }
1854 }
1855 // If there is an icon for the selector box (rendered in selicon-table below)...:
1856 // if there is an icon ($p[2]), icons should be shown, and, if only selected are visible, is it selected
1857 if ($p[2] && !$suppressIcons && (!$onlySelectedIconShown || $sM)) {
1858 list($selIconFile, $selIconInfo) = $this->getIcon($p[2]);
1859 if (!empty($selIconInfo)) {
1860 $iOnClick = $this->elName($PA['itemFormElName']) . '.selectedIndex=' . $c . '; ' . $this->elName($PA['itemFormElName']) . '.style.backgroundImage=' . $this->elName($PA['itemFormElName']) . '.options[' . $c . '].style.backgroundImage; ' . implode('', $PA['fieldChangeFunc']) . $this->blur() . 'return false;';
1861 } else {
1862 $iOnClick = $this->elName($PA['itemFormElName']) . '.selectedIndex=' . $c . '; ' . $this->elName($PA['itemFormElName']) . '.className=' . $this->elName($PA['itemFormElName']) . '.options[' . $c . '].className; ' . implode('', $PA['fieldChangeFunc']) . $this->blur() . 'return false;';
1863 }
1864 $selicons[] = array(
1865 (!$onlySelectedIconShown ? '<a href="#" onclick="' . htmlspecialchars($iOnClick) . '">' : '') . $this->getIconHtml($p[2], htmlspecialchars($p[0]), htmlspecialchars($p[0])) . (!$onlySelectedIconShown ? '</a>' : ''),
1866 $c,
1867 $sM
1868 );
1869 }
1870 $c++;
1871 }
1872 // Closing optgroup if open
1873 if ($optGroupOpen) {
1874 $opt[] = '</optgroup>';
1875 $optGroupOpen = FALSE;
1876 }
1877 // No-matching-value:
1878 if ($PA['itemFormElValue'] && $noMatchingValue && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1879 $nMV_label = @sprintf($nMV_label, $PA['itemFormElValue']);
1880 $opt[] = '<option value="' . htmlspecialchars($PA['itemFormElValue']) . '" selected="selected">' . htmlspecialchars($nMV_label) . '</option>';
1881 }
1882 // Create item form fields:
1883 $sOnChange = 'if (this.options[this.selectedIndex].value==\'--div--\') {this.selectedIndex=' . $sI . ';} ' . implode('', $PA['fieldChangeFunc']);
1884 if (!$disabled) {
1885 // MUST be inserted before the selector - else is the value of the hiddenfield here mysteriously submitted...
1886 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '_selIconVal" value="' . htmlspecialchars($sI) . '" />';
1887 }
1888 if ($config['iconsInOptionTags']) {
1889 $classesForSelectTag[] = 'icon-select';
1890 }
1891 $item .= '<select' . $selectedStyle . ' id="' . uniqid('tceforms-select-') . '" name="' . $PA['itemFormElName'] . '"' . $this->insertDefStyle('select', implode(' ', $classesForSelectTag)) . ($size ? ' size="' . $size . '"' : '') . ' onchange="' . htmlspecialchars(($onChangeIcon . $sOnChange)) . '"' . $PA['onFocus'] . $disabled . '>';
1892 $item .= implode('', $opt);
1893 $item .= '</select>';
1894 // Create icon table:
1895 if (count($selicons) && !$config['noIconsBelowSelect']) {
1896 $item .= '<table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-selectIcons">';
1897 $selicon_cols = intval($config['selicon_cols']);
1898 if (!$selicon_cols) {
1899 $selicon_cols = count($selicons);
1900 }
1901 $sR = ceil(count($selicons) / $selicon_cols);
1902 $selicons = array_pad($selicons, $sR * $selicon_cols, '');
1903 for ($sa = 0; $sa < $sR; $sa++) {
1904 $item .= '<tr>';
1905 for ($sb = 0; $sb < $selicon_cols; $sb++) {
1906 $sk = $sa * $selicon_cols + $sb;
1907 $imgN = 'selIcon_' . $table . '_' . $row['uid'] . '_' . $field . '_' . $selicons[$sk][1];
1908 $imgS = $selicons[$sk][2] ? $this->backPath . 'gfx/content_selected.gif' : 'clear.gif';
1909 $item .= '<td><img name="' . htmlspecialchars($imgN) . '" src="' . $imgS . '" width="7" height="10" alt="" /></td>';
1910 $item .= '<td>' . $selicons[$sk][0] . '</td>';
1911 }
1912 $item .= '</tr>';
1913 }
1914 $item .= '</table>';
1915 }
1916 return $item;
1917 }
1918
1919 /**
1920 * Creates a checkbox list (renderMode = "checkbox")
1921 * (Render function for getSingleField_typeSelect())
1922 *
1923 * @param string $table See getSingleField_typeSelect()
1924 * @param string $field See getSingleField_typeSelect()
1925 * @param array $row See getSingleField_typeSelect()
1926 * @param array $PA See getSingleField_typeSelect()
1927 * @param array $config (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1928 * @param array $selItems Items available for selection
1929 * @param string $nMV_label Label for no-matching-value
1930 * @return string The HTML code for the item
1931 * @see getSingleField_typeSelect()
1932 * @todo Define visibility
1933 */
1934 public function getSingleField_typeSelect_checkbox($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
1935 if (empty($selItems)) {
1936 return '';
1937 }
1938 // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
1939 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
1940 $item = '';
1941 $disabled = '';
1942 if ($this->renderReadonly || $config['readOnly']) {
1943 $disabled = ' disabled="disabled"';
1944 }
1945 // Traverse the Array of selector box items:
1946 $tRows = array();
1947 $c = 0;
1948 if (!$disabled) {
1949 $sOnChange = implode('', $PA['fieldChangeFunc']);
1950 // Used to accumulate the JS needed to restore the original selection.
1951 $setAll = array();
1952 $unSetAll = array();
1953 foreach ($selItems as $p) {
1954 // Non-selectable element:
1955 if (!strcmp($p[1], '--div--')) {
1956 $selIcon = '';
1957 if (isset($p[2]) && $p[2] != 'empty-emtpy') {
1958 $selIcon = $this->getIconHtml($p[2]);
1959 }
1960 $tRows[] = '
1961 <tr class="c-header">
1962 <td colspan="3">' . $selIcon . htmlspecialchars($p[0]) . '</td>
1963 </tr>';
1964 } else {
1965 // Selected or not by default:
1966 $sM = '';
1967 if (isset($itemArray[$p[1]])) {
1968 $sM = ' checked="checked"';
1969 unset($itemArray[$p[1]]);
1970 }
1971 // Icon:
1972 if ($p[2]) {
1973 $selIcon = $p[2];
1974 } else {
1975 $selIcon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('empty-empty');
1976 }
1977 // Compile row:
1978 $rowId = uniqid('select_checkbox_row_');
1979 $onClickCell = $this->elName(($PA['itemFormElName'] . '[' . $c . ']')) . '.checked=!' . $this->elName(($PA['itemFormElName'] . '[' . $c . ']')) . '.checked;';
1980 $onClick = 'this.attributes.getNamedItem("class").nodeValue = ' . $this->elName(($PA['itemFormElName'] . '[' . $c . ']')) . '.checked ? "c-selectedItem" : "c-unselectedItem";';
1981 $setAll[] = $this->elName(($PA['itemFormElName'] . '[' . $c . ']')) . '.checked=1;';
1982 $setAll[] .= '$(\'' . $rowId . '\').removeClassName(\'c-unselectedItem\');$(\'' . $rowId . '\').addClassName(\'c-selectedItem\');';
1983 $unSetAll[] = $this->elName(($PA['itemFormElName'] . '[' . $c . ']')) . '.checked=0;';
1984 $unSetAll[] .= '$(\'' . $rowId . '\').removeClassName(\'c-selectedItem\');$(\'' . $rowId . '\').addClassName(\'c-unselectedItem\');';
1985 $restoreCmd[] = $this->elName(($PA['itemFormElName'] . '[' . $c . ']')) . '.checked=' . ($sM ? 1 : 0) . ';' . '$(\'' . $rowId . '\').removeClassName(\'c-selectedItem\');$(\'' . $rowId . '\').removeClassName(\'c-unselectedItem\');' . '$(\'' . $rowId . '\').addClassName(\'c-' . ($sM ? '' : 'un') . 'selectedItem\');';
1986 // Check if some help text is available
1987 // Since TYPO3 4.5 help text is expected to be an associative array
1988 // with two key, "title" and "description"
1989 // For the sake of backwards compatibility, we test if the help text
1990 // is a string and use it as a description (this could happen if items
1991 // are modified with an itemProcFunc)
1992 $hasHelp = FALSE;
1993 $help = '';
1994 $helpArray = array();
1995 if (is_array($p[3]) && count($p[3]) > 0 || !empty($p[3])) {
1996 $hasHelp = TRUE;
1997 if (is_array($p[3])) {
1998 $helpArray = $p[3];
1999 } else {
2000 $helpArray['description'] = $p[3];
2001 }
2002 }
2003 $label = \TYPO3\CMS\Core\Utility\GeneralUtility::deHSCentities(htmlspecialchars($p[0]));
2004 if ($hasHelp) {
2005 $help = \TYPO3\CMS\Backend\Utility\BackendUtility::wrapInHelp('', '', '', $helpArray);
2006 }
2007 $tRows[] = '
2008 <tr id="' . $rowId . '" class="' . ($sM ? 'c-selectedItem' : 'c-unselectedItem') . '" onclick="' . htmlspecialchars($onClick) . '" style="cursor: pointer;">
2009 <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>
2010 <td class="c-labelCell" onclick="' . htmlspecialchars($onClickCell) . '">' . $this->getIconHtml($selIcon) . $label . '</td>
2011 <td class="c-descr" onclick="' . htmlspecialchars($onClickCell) . '">' . (empty($help) ? '' : $help) . '</td>
2012 </tr>';
2013 $c++;
2014 }
2015 }
2016 }
2017 // Remaining values (invalid):
2018 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
2019 foreach ($itemArray as $theNoMatchValue => $temp) {
2020 // Compile <checkboxes> tag:
2021 array_unshift($tRows, '
2022 <tr class="c-invalidItem">
2023 <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>
2024 <td class="c-labelCell">' . \TYPO3\CMS\Core\Utility\GeneralUtility::deHSCentities(htmlspecialchars(@sprintf($nMV_label, $theNoMatchValue))) . '</td><td>&nbsp;</td>
2025 </tr>');
2026 $c++;
2027 }
2028 }
2029 // Add an empty hidden field which will send a blank value if all items are unselected.
2030 $item .= '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="" />';
2031 // Remaining checkboxes will get their set-all link:
2032 if (count($setAll)) {
2033 $tableHead = '<thead>
2034 <tr class="c-header-checkbox-controls t3-row-header">
2035 <td class="c-checkbox">
2036 <input type="checkbox" class="checkbox" onclick="if (checked) {' . htmlspecialchars((implode('', $setAll) . '} else {' . implode('', $unSetAll) . '}')) . '">
2037 </td>
2038 <td colspan="2">
2039 </td>
2040 </tr></thead>';
2041 }
2042 // Implode rows in table:
2043 $item .= '
2044 <table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-select-checkbox">' . $tableHead . '<tbody>' . implode('', $tRows) . '</tbody>
2045 </table>
2046 ';
2047 // Add revert icon
2048 if (is_array($restoreCmd)) {
2049 $item .= '<a href="#" onclick="' . implode('', $restoreCmd) . ' return false;' . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-edit-undo', array('title' => htmlspecialchars($this->getLL('l_revertSelection')))) . '</a>';
2050 }
2051 return $item;
2052 }
2053
2054 /**
2055 * Creates a selectorbox list (renderMode = "singlebox")
2056 * (Render function for getSingleField_typeSelect())
2057 *
2058 * @param string $table See getSingleField_typeSelect()
2059 * @param string $field See getSingleField_typeSelect()
2060 * @param array $row See getSingleField_typeSelect()
2061 * @param array $PA See getSingleField_typeSelect()
2062 * @param array $config (Redundant) content of $PA['fieldConf']['config'] (for convenience)
2063 * @param array $selItems Items available for selection
2064 * @param string $nMV_label Label for no-matching-value
2065 * @return string The HTML code for the item
2066 * @see getSingleField_typeSelect()
2067 * @todo Define visibility
2068 */
2069 public function getSingleField_typeSelect_singlebox($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
2070 // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
2071 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
2072 $item = '';
2073 $disabled = '';
2074 if ($this->renderReadonly || $config['readOnly']) {
2075 $disabled = ' disabled="disabled"';
2076 }
2077 // Traverse the Array of selector box items:
2078 $opt = array();
2079 // Used to accumulate the JS needed to restore the original selection.
2080 $restoreCmd = array();
2081 $c = 0;
2082 foreach ($selItems as $p) {
2083 // Selected or not by default:
2084 $sM = '';
2085 if (isset($itemArray[$p[1]])) {
2086 $sM = ' selected="selected"';
2087 $restoreCmd[] = $this->elName(($PA['itemFormElName'] . '[]')) . '.options[' . $c . '].selected=1;';
2088 unset($itemArray[$p[1]]);
2089 }
2090 // Non-selectable element:
2091 $nonSel = '';
2092 if (!strcmp($p[1], '--div--')) {
2093 $nonSel = ' onclick="this.selected=0;" class="c-divider"';
2094 }
2095 // Icon style for option tag:
2096 if ($config['iconsInOptionTags']) {
2097 $styleAttrValue = $this->optionTagStyle($p[2]);
2098 }
2099 // Compile <option> tag:
2100 $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' . $sM . $nonSel . ($styleAttrValue ? ' style="' . htmlspecialchars($styleAttrValue) . '"' : '') . '>' . \TYPO3\CMS\Core\Utility\GeneralUtility::deHSCentities(htmlspecialchars($p[0])) . '</option>';
2101 $c++;
2102 }
2103 // Remaining values:
2104 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
2105 foreach ($itemArray as $theNoMatchValue => $temp) {
2106 // Compile <option> tag:
2107 array_unshift($opt, '<option value="' . htmlspecialchars($theNoMatchValue) . '" selected="selected">' . \TYPO3\CMS\Core\Utility\GeneralUtility::deHSCentities(htmlspecialchars(@sprintf($nMV_label, $theNoMatchValue))) . '</option>');
2108 }
2109 }
2110 // Compile selector box:
2111 $sOnChange = implode('', $PA['fieldChangeFunc']);
2112 $selector_itemListStyle = isset($config['itemListStyle']) ? ' style="' . htmlspecialchars($config['itemListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle . '"';
2113 $size = intval($config['size']);
2114 $cssPrefix = $size === 1 ? 'tceforms-select' : 'tceforms-multiselect';
2115 $size = $config['autoSizeMax'] ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(count($selItems) + 1, \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($size, 1), $config['autoSizeMax']) : $size;
2116 $selectBox = '<select id="' . uniqid($cssPrefix) . '" name="' . $PA['itemFormElName'] . '[]"' . $this->insertDefStyle('select', $cssPrefix) . ($size ? ' size="' . $size . '"' : '') . ' multiple="multiple" onchange="' . htmlspecialchars($sOnChange) . '"' . $PA['onFocus'] . $selector_itemListStyle . $disabled . '>
2117 ' . implode('
2118 ', $opt) . '
2119 </select>';
2120 // Add an empty hidden field which will send a blank value if all items are unselected.
2121 if (!$disabled) {
2122 $item .= '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="" />';
2123 }
2124 // Put it all into a table:
2125 $item .= '
2126 <table border="0" cellspacing="0" cellpadding="0" width="1" class="typo3-TCEforms-select-singlebox">
2127 <tr>
2128 <td>
2129 ' . $selectBox . '
2130 <br/>
2131 <em>' . htmlspecialchars($this->getLL('l_holdDownCTRL')) . '</em>
2132 </td>
2133 <td valign="top">
2134 <a href="#" onclick="' . htmlspecialchars(($this->elName(($PA['itemFormElName'] . '[]')) . '.selectedIndex=-1;' . implode('', $restoreCmd) . ' return false;')) . '" title="' . htmlspecialchars($this->getLL('l_revertSelection')) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-edit-undo') . '</a>
2135 </td>
2136 </tr>
2137 </table>
2138 ';
2139 return $item;
2140 }
2141
2142 /**
2143 * Creates a multiple-selector box (two boxes, side-by-side)
2144 * (Render function for getSingleField_typeSelect())
2145 *
2146 * @param string $table See getSingleField_typeSelect()
2147 * @param string $field See getSingleField_typeSelect()
2148 * @param array $row See getSingleField_typeSelect()
2149 * @param array $PA See getSingleField_typeSelect()
2150 * @param array $config (Redundant) content of $PA['fieldConf']['config'] (for convenience)
2151 * @param array $selItems Items available for selection
2152 * @param string $nMV_label Label for no-matching-value
2153 * @return string The HTML code for the item
2154 * @see getSingleField_typeSelect()
2155 * @todo Define visibility
2156 */
2157 public function getSingleField_typeSelect_multiple($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
2158 $item = '';
2159 $disabled = '';
2160 if ($this->renderReadonly || $config['readOnly']) {
2161 $disabled = ' disabled="disabled"';
2162 }
2163 // Setting this hidden field (as a flag that JavaScript can read out)
2164 if (!$disabled) {
2165 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '_mul" value="' . ($config['multiple'] ? 1 : 0) . '" />';
2166 }
2167 // Set max and min items:
2168 $maxitems = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['maxitems'], 0);
2169 if (!$maxitems) {
2170 $maxitems = 100000;
2171 }
2172 $minitems = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['minitems'], 0);
2173 // Register the required number of elements:
2174 $this->registerRequiredProperty('range', $PA['itemFormElName'], array($minitems, $maxitems, 'imgName' => $table . '_' . $row['uid'] . '_' . $field));
2175 // Get "removeItems":
2176 $removeItems = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $PA['fieldTSConfig']['removeItems'], 1);
2177 // Get the array with selected items:
2178 $itemArray = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $PA['itemFormElValue'], 1);
2179 // Possibly filter some items:
2180 $keepItemsFunc = create_function('$value', '$parts=explode(\'|\',$value,2); return rawurldecode($parts[0]);');
2181 $itemArray = \TYPO3\CMS\Core\Utility\GeneralUtility::keepItemsInArray($itemArray, $PA['fieldTSConfig']['keepItems'], $keepItemsFunc);
2182 // Perform modification of the selected items array:
2183 foreach ($itemArray as $tk => $tv) {
2184 $tvP = explode('|', $tv, 2);
2185 $evalValue = $tvP[0];
2186 $isRemoved = in_array($evalValue, $removeItems) || $config['form_type'] == 'select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table, $field, $evalValue, $config['authMode']);
2187 if ($isRemoved && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
2188 $tvP[1] = rawurlencode(@sprintf($nMV_label, $evalValue));
2189 } elseif (isset($PA['fieldTSConfig']['altLabels.'][$evalValue])) {
2190 $tvP[1] = rawurlencode($this->sL($PA['fieldTSConfig']['altLabels.'][$evalValue]));
2191 }
2192 if ($tvP[1] == '') {
2193 // Case: flexform, default values supplied, no label provided (bug #9795)
2194 foreach ($selItems as $selItem) {
2195 if ($selItem[1] == $tvP[0]) {
2196 $tvP[1] = html_entity_decode($selItem[0]);
2197 break;
2198 }
2199 }
2200 }
2201 $itemArray[$tk] = implode('|', $tvP);
2202 }
2203 $itemsToSelect = '';
2204 if (!$disabled) {
2205 // Create option tags:
2206 $opt = array();
2207 $styleAttrValue = '';
2208 foreach ($selItems as $p) {
2209 if ($config['iconsInOptionTags']) {
2210 $styleAttrValue = $this->optionTagStyle($p[2]);
2211 }
2212 $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' . ($styleAttrValue ? ' style="' . htmlspecialchars($styleAttrValue) . '"' : '') . ' title="' . $p[0] . '">' . $p[0] . '</option>';
2213 }
2214 // Put together the selector box:
2215 $selector_itemListStyle = isset($config['itemListStyle']) ? ' style="' . htmlspecialchars($config['itemListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle . '"';
2216 $size = intval($config['size']);
2217 $size = $config['autoSizeMax'] ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(count($itemArray) + 1, \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($size, 1), $config['autoSizeMax']) : $size;
2218 if ($config['exclusiveKeys']) {
2219 $sOnChange = 'setFormValueFromBrowseWin(\'' . $PA['itemFormElName'] . '\',this.options[this.selectedIndex].value, this.options[this.selectedIndex].text, this.options[this.selectedIndex].title,\'' . $config['exclusiveKeys'] . '\'); ';
2220 } else {
2221 $sOnChange = 'setFormValueFromBrowseWin(\'' . $PA['itemFormElName'] . '\',this.options[this.selectedIndex].value, this.options[this.selectedIndex].text, this.options[this.selectedIndex].title); ';
2222 }
2223 $sOnChange .= implode('', $PA['fieldChangeFunc']);
2224 $itemsToSelect = '
2225 <select id="' . uniqid('tceforms-multiselect-') . '" name="' . $PA['itemFormElName'] . '_sel"' . $this->insertDefStyle('select', 'tceforms-multiselect tceforms-itemstoselect') . ($size ? ' size="' . $size . '"' : '') . ' onchange="' . htmlspecialchars($sOnChange) . '"' . $PA['onFocus'] . $selector_itemListStyle . '>
2226 ' . implode('
2227 ', $opt) . '
2228 </select>';
2229 }
2230 // Pass to "dbFileIcons" function:
2231 $params = array(
2232 'size' => $size,
2233 'autoSizeMax' => \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['autoSizeMax'], 0),
2234 'style' => isset($config['selectedListStyle']) ? ' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle . '"',
2235 'dontShowMoveIcons' => $maxitems <= 1,
2236 'maxitems' => $maxitems,
2237 'info' => '',
2238 'headers' => array(
2239 'selector' => $this->getLL('l_selected') . ':<br />',
2240 'items' => $this->getLL('l_items') . ':<br />'
2241 ),
2242 'noBrowser' => 1,
2243 'thumbnails' => $itemsToSelect,
2244 'readOnly' => $disabled
2245 );
2246 $item .= $this->dbFileIcons($PA['itemFormElName'], '', '', $itemArray, '', $params, $PA['onFocus']);
2247 return $item;
2248 }
2249
2250 /**
2251 * Generation of TCEform elements of the type "group"
2252 * This will render a selectorbox into which elements from either the file system or database can be inserted. Relations.
2253 *
2254 * @param string $table The table name of the record
2255 * @param string $field The field name which this element is supposed to edit
2256 * @param array $row The record data array where the value(s) for the field can be found
2257 * @param array $PA An array with additional configuration options.
2258 * @return string The HTML code for the TCEform field
2259 * @todo Define visibility
2260 */
2261 public function getSingleField_typeGroup($table, $field, $row, &$PA) {
2262 // Init:
2263 $config = $PA['fieldConf']['config'];
2264 $internal_type = $config['internal_type'];
2265 $show_thumbs = $config['show_thumbs'];
2266 $size = intval($config['size']);
2267 $maxitems = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['maxitems'], 0);
2268 if (!$maxitems) {
2269 $maxitems = 100000;
2270 }
2271 $minitems = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['minitems'], 0);
2272 $allowed = trim($config['allowed']);
2273 $disallowed = trim($config['disallowed']);
2274 $item = '';
2275 $disabled = '';
2276 if ($this->renderReadonly || $config['readOnly']) {
2277 $disabled = ' disabled="disabled"';
2278 }
2279 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '_mul" value="' . ($config['multiple'] ? 1 : 0) . '"' . $disabled . ' />';
2280 $this->registerRequiredProperty('range', $PA['itemFormElName'], array($minitems, $maxitems, 'imgName' => $table . '_' . $row['uid'] . '_' . $field));
2281 $info = '';
2282 // "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/.
2283 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
2284 $PA['itemFormElID_file'] = $PA['itemFormElID'] . '_files';
2285 // whether the list and delete controls should be disabled
2286 $noList = isset($config['disable_controls']) && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($config['disable_controls'], 'list');
2287 $noDelete = isset($config['disable_controls']) && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($config['disable_controls'], 'delete');
2288 // if maxitems==1 then automatically replace the current item (in list and file selector)
2289 if ($maxitems === 1) {
2290 $this->additionalJS_post[] = 'TBE_EDITOR.clearBeforeSettingFormValueFromBrowseWin[\'' . $PA['itemFormElName'] . '\'] = {
2291 itemFormElID_file: \'' . $PA['itemFormElID_file'] . '\'
2292 }';
2293 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = 'setFormValueManipulate(\'' . $PA['itemFormElName'] . '\', \'Remove\'); ' . $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'];
2294 } elseif ($noList) {
2295 // If the list controls have been removed and the maximum number is reached, remove the first entry to avoid "write once" field
2296 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = 'setFormValueManipulate(\'' . $PA['itemFormElName'] . '\', \'RemoveFirstIfFull\', \'' . $maxitems . '\'); ' . $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'];
2297 }
2298 // Acting according to either "file" or "db" type:
2299 switch ((string) $config['internal_type']) {
2300 case 'file_reference':
2301 $config['uploadfolder'] = '';
2302 case 'file':
2303 // Creating string showing allowed types:
2304 $tempFT = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $allowed, TRUE);
2305 if (!count($tempFT)) {
2306 $info .= '*';
2307 }
2308 foreach ($tempFT as $ext) {
2309 if ($ext) {
2310 $info .= strtoupper($ext) . ' ';
2311 }
2312 }
2313 // Creating string, showing disallowed types:
2314 $tempFT_dis = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $disallowed, TRUE);
2315 if (count($tempFT_dis)) {
2316 $info .= '<br />';
2317 }
2318 foreach ($tempFT_dis as $ext) {
2319 if ($ext) {
2320 $info .= '-' . strtoupper($ext) . ' ';
2321 }
2322 }
2323 // Making the array of file items:
2324 $itemArray = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $PA['itemFormElValue'], TRUE);
2325 $fileFactory = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance();
2326 // Correct the filename for the FAL items
2327 foreach ($itemArray as &$fileItem) {
2328 list($fileUid, $fileLabel) = explode('|', $fileItem);
2329 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($fileUid)) {
2330 $fileObject = $fileFactory->getFileObject($fileUid);
2331 $fileLabel = $fileObject->getName();
2332 }
2333 $fileItem = $fileUid . '|' . $fileLabel;
2334 }
2335 // Showing thumbnails:
2336 $thumbsnail = '';
2337 if ($show_thumbs) {
2338 $imgs = array();
2339 foreach ($itemArray as $imgRead) {
2340 $imgP = explode('|', $imgRead);
2341 $imgPath = rawurldecode($imgP[0]);
2342 // FAL icon production
2343 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($imgP[0])) {
2344 $fileObject = $fileFactory->getFileObject($imgP[0]);
2345 if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileObject->getExtension())) {
2346 $imageUrl = $fileObject->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW, array())->getPublicUrl(TRUE);
2347 $imgTag = '<img src="' . $imageUrl . '" alt="' . htmlspecialchars($fileObject->getName()) . '" />';
2348 } else {
2349 // Icon
2350 $imgTag = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForFile(strtolower($fileObject->getExtension()), array('title' => $fileObject->getName()));
2351 }
2352 $imgs[] = '<span class="nobr">' . $imgTag . htmlspecialchars($fileObject->getName()) . '</span>';
2353 } else {
2354 $rowCopy = array();
2355 $rowCopy[$field] = $imgPath;
2356 $thumbnailCode = \TYPO3\CMS\Backend\Utility\BackendUtility::thumbCode($rowCopy, $table, $field, $this->backPath, 'thumbs.php', $config['uploadfolder'], 0, ' align="middle"');
2357 $imgs[] = '<span class="nobr">' . $thumbnailCode . $imgPath . '</span>';
2358 }
2359 }
2360 $thumbsnail = implode('<br />', $imgs);
2361 }
2362 // Creating the element:
2363 $params = array(
2364 'size' => $size,
2365 'dontShowMoveIcons' => $maxitems <= 1,
2366 'autoSizeMax' => \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['autoSizeMax'], 0),
2367 'maxitems' => $maxitems,
2368 'style' => isset($config['selectedListStyle']) ? ' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle . '"',
2369 'info' => $info,
2370 'thumbnails' => $thumbsnail,
2371 'readOnly' => $disabled,
2372 'noBrowser' => $noList || isset($config['disable_controls']) && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($config['disable_controls'], 'browser'),
2373 'noList' => $noList,
2374 'noDelete' => $noDelete
2375 );
2376 $item .= $this->dbFileIcons($PA['itemFormElName'], 'file', implode(',', $tempFT), $itemArray, '', $params, $PA['onFocus'], '', '', '', $config);
2377 if (!$disabled && !(isset($config['disable_controls']) && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($config['disable_controls'], 'upload'))) {
2378 // Adding the upload field:
2379 if ($this->edit_docModuleUpload && $config['uploadfolder']) {
2380 // Insert the multiple attribute to enable HTML5 multiple file upload
2381 $multipleAttribute = '';
2382 $multipleFilenameSuffix = '';
2383 if (isset($config['maxitems']) && $config['maxitems'] > 1) {
2384 $multipleAttribute = ' multiple="multiple"';
2385 $multipleFilenameSuffix = '[]';
2386 }
2387 $item .= '<div id="' . $PA['itemFormElID_file'] . '"><input type="file"' . $multipleAttribute . ' name="' . $PA['itemFormElName_file'] . $multipleFilenameSuffix . '" size="35" onchange="' . implode('', $PA['fieldChangeFunc']) . '" /></div>';
2388 }
2389 }
2390 break;
2391 case 'folder':
2392 // If the element is of the internal type "folder":
2393 // Array of folder items:
2394 $itemArray = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $PA['itemFormElValue'], 1);
2395 // Creating the element:
2396 $params = array(
2397 'size' => $size,
2398 'dontShowMoveIcons' => $maxitems <= 1,
2399 'autoSizeMax' => \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['autoSizeMax'], 0),
2400 'maxitems' => $maxitems,
2401 'style' => isset($config['selectedListStyle']) ? ' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle . '"',
2402 'info' => $info,
2403 'readOnly' => $disabled,
2404 'noBrowser' => $noList || isset($config['disable_controls']) && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($config['disable_controls'], 'browser'),
2405 'noList' => $noList
2406 );
2407 $item .= $this->dbFileIcons($PA['itemFormElName'], 'folder', '', $itemArray, '', $params, $PA['onFocus']);
2408 break;
2409 case 'db':
2410 // If the element is of the internal type "db":
2411 // Creating string showing allowed types:
2412 $tempFT = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $allowed, TRUE);
2413 if (!strcmp(trim($tempFT[0]), '*')) {
2414 $onlySingleTableAllowed = FALSE;
2415 $info .= '<span class="nobr">' . htmlspecialchars($this->getLL('l_allTables')) . '</span><br />';
2416 } elseif ($tempFT) {
2417 $onlySingleTableAllowed = count($tempFT) == 1;
2418 foreach ($tempFT as $theT) {
2419 $aOnClick = 'setFormValueOpenBrowser(\'db\', \'' . ($PA['itemFormElName'] . '|||' . $theT) . '\'); return false;';
2420 $info .= '<span class="nobr">
2421 <a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($theT, array()) . htmlspecialchars($this->sL($GLOBALS['TCA'][$theT]['ctrl']['title'])) . '</a></span><br />';
2422 }
2423 }
2424 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
2425 $itemArray = array();
2426 $imgs = array();
2427 // Thumbnails:
2428 $temp_itemArray = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $PA['itemFormElValue'], 1);
2429 foreach ($temp_itemArray as $dbRead) {
2430 $recordParts = explode('|', $dbRead);
2431 list($this_table, $this_uid) = \TYPO3\CMS\Backend\Utility\BackendUtility::splitTable_Uid($recordParts[0]);
2432 // For the case that no table was found and only a single table is defined to be allowed, use that one:
2433 if (!$this_table && $onlySingleTableAllowed) {
2434 $this_table = $allowed;
2435 }
2436 $itemArray[] = array('table' => $this_table, 'id' => $this_uid);
2437 if (!$disabled && $show_thumbs) {
2438 $rr = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL($this_table, $this_uid);
2439 $imgs[] = '<span class="nobr">' . $this->getClickMenu(\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($this_table, $rr, array(
2440 'style' => 'vertical-align:top',
2441 'title' => htmlspecialchars((\TYPO3\CMS\Backend\Utility\BackendUtility::getRecordPath($rr['pid'], $perms_clause, 15) . ' [UID: ' . $rr['uid'] . ']'))
2442 )), $this_table, $this_uid) . '&nbsp;' . \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle($this_table, $rr, TRUE) . ' <span class="typo3-dimmed"><em>[' . $rr['uid'] . ']</em></span>' . '</span>';
2443 }
2444 }
2445 $thumbsnail = '';
2446 if (!$disabled && $show_thumbs) {
2447 $thumbsnail = implode('<br />', $imgs);
2448 }
2449 // Creating the element:
2450 $params = array(
2451 'size' => $size,
2452 'dontShowMoveIcons' => $maxitems <= 1,
2453 'autoSizeMax' => \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['autoSizeMax'], 0),
2454 'maxitems' => $maxitems,
2455 'style' => isset($config['selectedListStyle']) ? ' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle . '"',
2456 'info' => $info,
2457 'thumbnails' => $thumbsnail,
2458 'readOnly' => $disabled,
2459 'noBrowser' => $noList || isset($config['disable_controls']) && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($config['disable_controls'], 'browser'),
2460 'noList' => $noList
2461 );
2462 $item .= $this->dbFileIcons($PA['itemFormElName'], 'db', implode(',', $tempFT), $itemArray, '', $params, $PA['onFocus'], $table, $field, $row['uid'], $config);
2463 break;
2464 }
2465 // Wizards:
2466 $altItem = '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
2467 if (!$disabled) {
2468 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf);
2469 }
2470 return $item;
2471 }
2472
2473 /**
2474 * Generation of TCEform elements of the type "none"
2475 * This will render a non-editable display of the content of the field.
2476 *
2477 * @param string $table The table name of the record
2478 * @param string $field The field name which this element is supposed to edit
2479 * @param array $row The record data array where the value(s) for the field can be found
2480 * @param array $PA An array with additional configuration options.
2481 * @return string The HTML code for the TCEform field
2482 * @todo Define visibility
2483 */
2484 public function getSingleField_typeNone($table, $field, $row, &$PA) {
2485 // Init:
2486 $config = $PA['fieldConf']['config'];
2487 $itemValue = $PA['itemFormElValue'];
2488 return $this->getSingleField_typeNone_render($config, $itemValue);
2489 }
2490
2491 /**
2492 * HTML rendering of a value which is not editable.
2493 *
2494 * @param array $config Configuration for the display
2495 * @param string $itemValue The valu