ebd6c340bc1dabaaeaaf7e3b1f92208898203420
[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-2013 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 \TYPO3\CMS\Core\Utility\GeneralUtility::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 $typeNum = $this->getRTypeNum($table, $row);
664 if ($GLOBALS['TCA'][$table]['types'][$typeNum]) {
665 $itemList = $GLOBALS['TCA'][$table]['types'][$typeNum]['showitem'];
666 if ($itemList) {
667 $fields = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $itemList, 1);
668 $excludeElements = ($this->excludeElements = $this->getExcludeElements($table, $row, $typeNum));
669 foreach ($fields as $fieldInfo) {
670 $parts = explode(';', $fieldInfo);
671 $theField = trim($parts[0]);
672 if (!in_array($theField, $excludeElements) && !strcmp($theField, $theFieldToReturn)) {
673 if ($GLOBALS['TCA'][$table]['columns'][$theField]) {
674 $sField = $this->getSingleField($table, $theField, $row, $parts[1], 1, $parts[3], $parts[2]);
675 return $sField['ITEM'];
676 }
677 }
678 }
679 }
680 }
681 }
682 }
683
684 /**
685 * Based on the $table and $row of content, this displays the complete TCEform for the record.
686 * 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.
687 *
688 * @param string $table The table name
689 * @param array $row The record from the table for which to render a field.
690 * @param integer $depth Depth level
691 * @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'].
692 * @return string HTML output
693 * @see getSoloField()
694 * @todo Define visibility
695 */
696 public function getMainFields($table, array $row, $depth = 0, array $overruleTypesArray = array()) {
697 $this->renderDepth = $depth;
698 // Init vars:
699 $out_array = array(array());
700 $out_array_meta = array(
701 array(
702 'title' => $this->getLL('l_generalTab')
703 )
704 );
705 $out_pointer = 0;
706 $out_sheet = 0;
707 $this->palettesRendered = array();
708 $this->palettesRendered[$this->renderDepth][$table] = array();
709 // Hook: getMainFields_preProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
710 foreach ($this->hookObjectsMainFields as $hookObj) {
711 if (method_exists($hookObj, 'getMainFields_preProcess')) {
712 $hookObj->getMainFields_preProcess($table, $row, $this);
713 }
714 }
715 if ($GLOBALS['TCA'][$table]) {
716 // Get dividers2tabs setting from TCA of the current table:
717 $dividers2tabs = &$GLOBALS['TCA'][$table]['ctrl']['dividers2tabs'];
718 // Load the description content for the table.
719 if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table)) {
720 $GLOBALS['LANG']->loadSingleTableDescription($table);
721 }
722 // Get the current "type" value for the record.
723 $typeNum = $this->getRTypeNum($table, $row);
724 // Find the list of fields to display:
725 if ($GLOBALS['TCA'][$table]['types'][$typeNum]) {
726 $itemList = $GLOBALS['TCA'][$table]['types'][$typeNum]['showitem'];
727 if (is_array($overruleTypesArray) && isset($overruleTypesArray[$typeNum]['showitem'])) {
728 $itemList = $overruleTypesArray[$typeNum]['showitem'];
729 }
730 // If such a list existed...
731 if ($itemList) {
732 // Explode the field list and possibly rearrange the order of the fields, if configured for
733 $fields = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $itemList, 1);
734 if ($this->fieldOrder) {
735 $fields = $this->rearrange($fields);
736 }
737 // Get excluded fields, added fiels and put it together:
738 $excludeElements = ($this->excludeElements = $this->getExcludeElements($table, $row, $typeNum));
739 $fields = $this->mergeFieldsWithAddedFields($fields, $this->getFieldsToAdd($table, $row, $typeNum));
740 // If TCEforms will render a tab menu in the next step, push the name to the tab stack:
741 $tabIdentString = '';
742 $tabIdentStringMD5 = '';
743 if (strstr($itemList, '--div--') !== FALSE && $this->enableTabMenu && $dividers2tabs) {
744 $tabIdentString = 'TCEforms:' . $table . ':' . $row['uid'];
745 $tabIdentStringMD5 = $GLOBALS['TBE_TEMPLATE']->getDynTabMenuId($tabIdentString);
746 // Remember that were currently working on the general tab:
747 if (isset($fields[0]) && strpos($fields[0], '--div--') !== 0) {
748 $this->pushToDynNestedStack('tab', $tabIdentStringMD5 . '-1');
749 }
750 }
751 // Traverse the fields to render:
752 $cc = 0;
753 foreach ($fields as $fieldInfo) {
754 // Exploding subparts of the field configuration:
755 $parts = explode(';', $fieldInfo);
756 // Getting the style information out:
757 $color_style_parts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('-', $parts[4]);
758 if (strcmp($color_style_parts[0], '')) {
759 $this->setColorScheme($GLOBALS['TBE_STYLES']['colorschemes'][intval($color_style_parts[0])]);
760 }
761 if (strcmp($color_style_parts[1], '')) {
762 $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][intval($color_style_parts[1])];
763 if (!isset($this->fieldStyle)) {
764 $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][0];
765 }
766 }
767 if (strcmp($color_style_parts[2], '')) {
768 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
769 $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][intval($color_style_parts[2])];
770 if (!isset($this->borderStyle)) {
771 $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][0];
772 }
773 }
774 // Render the field:
775 $theField = $parts[0];
776 if (!in_array($theField, $excludeElements)) {
777 if ($GLOBALS['TCA'][$table]['columns'][$theField]) {
778 $sFieldPal = '';
779 if ($parts[2] && !isset($this->palettesRendered[$this->renderDepth][$table][$parts[2]])) {
780 $sFieldPal = $this->getPaletteFields($table, $row, $parts[2]);
781 $this->palettesRendered[$this->renderDepth][$table][$parts[2]] = 1;
782 }
783 $sField = $this->getSingleField($table, $theField, $row, $parts[1], 0, $parts[3], $parts[2]);
784 if ($sField) {
785 $sField .= $sFieldPal;
786 }
787 $out_array[$out_sheet][$out_pointer] .= $sField;
788 } elseif ($theField == '--div--') {
789 if ($cc > 0) {
790 $out_array[$out_sheet][$out_pointer] .= $this->getDivider();
791 if ($this->enableTabMenu && $dividers2tabs) {
792 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
793 // Remove last tab entry from the dynNestedStack:
794 $out_sheet++;
795 // Remove the previous sheet from stack (if any):
796 $this->popFromDynNestedStack('tab', $tabIdentStringMD5 . '-' . $out_sheet);
797 // Remember on which sheet we're currently working:
798 $this->pushToDynNestedStack('tab', $tabIdentStringMD5 . '-' . ($out_sheet + 1));
799 $out_array[$out_sheet] = array();
800 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
801 // Register newline for Tab
802 $out_array_meta[$out_sheet]['newline'] = $parts[2] == 'newline';
803 }
804 } else {
805 // Setting alternative title for "General" tab if "--div--" is the very first element.
806 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
807 // Only add the first tab to the dynNestedStack if there are more tabs:
808 if ($tabIdentString && strpos($itemList, '--div--', strlen($fieldInfo))) {
809 $this->pushToDynNestedStack('tab', $tabIdentStringMD5 . '-1');
810 }
811 }
812 } elseif ($theField == '--palette--') {
813 if ($parts[2] && !isset($this->palettesRendered[$this->renderDepth][$table][$parts[2]])) {
814 // Render a 'header' if not collapsed
815 if ($GLOBALS['TCA'][$table]['palettes'][$parts[2]]['canNotCollapse'] && $parts[1]) {
816 $out_array[$out_sheet][$out_pointer] .= $this->getPaletteFields($table, $row, $parts[2], $this->sL($parts[1]));
817 } else {
818 $out_array[$out_sheet][$out_pointer] .= $this->getPaletteFields($table, $row, $parts[2], '', '', $this->sL($parts[1]));
819 }
820 $this->palettesRendered[$this->renderDepth][$table][$parts[2]] = 1;
821 }
822 }
823 }
824 $cc++;
825 }
826 }
827 }
828 }
829 // Hook: getMainFields_postProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
830 foreach ($this->hookObjectsMainFields as $hookObj) {
831 if (method_exists($hookObj, 'getMainFields_postProcess')) {
832 $hookObj->getMainFields_postProcess($table, $row, $this);
833 }
834 }
835 // Wrapping a border around it all:
836 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
837 // Resetting styles:
838 $this->resetSchemes();
839 // Rendering Main palettes, if any
840 $mParr = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['mainpalette']);
841 $i = 0;
842 if (count($mParr)) {
843 foreach ($mParr as $mP) {
844 if (!isset($this->palettesRendered[$this->renderDepth][$table][$mP])) {
845 $temp_palettesCollapsed = $this->palettesCollapsed;
846 $this->palettesCollapsed = 0;
847 $label = $i == 0 ? $this->getLL('l_generalOptions') : $this->getLL('l_generalOptions_more');
848 $out_array[$out_sheet][$out_pointer] .= $this->getPaletteFields($table, $row, $mP, $label);
849 $this->palettesCollapsed = $temp_palettesCollapsed;
850 $this->palettesRendered[$this->renderDepth][$table][$mP] = 1;
851 }
852 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
853 $i++;
854 if ($this->renderDepth) {
855 $this->renderDepth--;
856 }
857 }
858 }
859 // Return the imploded $out_array:
860 // There were --div-- dividers around...
861 if ($out_sheet > 0) {
862 // Create parts array for the tab menu:
863 $parts = array();
864 foreach ($out_array as $idx => $sheetContent) {
865 $content = implode('', $sheetContent);
866 if ($content) {
867 // Wrap content (row) with table-tag, otherwise tab/sheet will be disabled (see getdynTabMenu() )
868 $content = '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . $content . '</table>';
869 }
870 $parts[$idx] = array(
871 'label' => $out_array_meta[$idx]['title'],
872 'content' => $content,
873 'newline' => $out_array_meta[$idx]['newline']
874 );
875 }
876 if (count($parts) > 1) {
877 // Unset the current level of tab menus:
878 $this->popFromDynNestedStack('tab', $tabIdentStringMD5 . '-' . ($out_sheet + 1));
879 $dividersToTabsBehaviour = isset($GLOBALS['TCA'][$table]['ctrl']['dividers2tabs']) ? $GLOBALS['TCA'][$table]['ctrl']['dividers2tabs'] : 1;
880 $output = $this->getDynTabMenu($parts, $tabIdentString, $dividersToTabsBehaviour);
881 } else {
882 // If there is only one tab/part there is no need to wrap it into the dynTab code
883 $output = isset($parts[0]) ? trim($parts[0]['content']) : '';
884 }
885 $output = '
886 <tr>
887 <td colspan="2">
888 ' . $output . '
889 </td>
890 </tr>';
891 } else {
892 // Only one, so just implode:
893 $output = implode('', $out_array[$out_sheet]);
894 }
895 return $output;
896 }
897
898 /**
899 * Will return the TCEform elements for a pre-defined list of fields.
900 * 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.
901 * Used for displaying forms for the frontend edit icons for instance.
902 *
903 * @param string $table The table name
904 * @param array $row The record array.
905 * @param string $list Commalist of fields from the table. These will be shown in the specified order in a form.
906 * @return string TCEform elements in a string.
907 * @todo Define visibility
908 */
909 public function getListedFields($table, $row, $list) {
910 if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table)) {
911 $GLOBALS['LANG']->loadSingleTableDescription($table);
912 }
913 $out = '';
914 $types_fieldConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getTCAtypes($table, $row, 1);
915 $editFieldList = array_unique(\TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $list, 1));
916 foreach ($editFieldList as $theFieldC) {
917 list($theField, $palFields) = preg_split('/\\[|\\]/', $theFieldC);
918 $theField = trim($theField);
919 $palFields = trim($palFields);
920 if ($GLOBALS['TCA'][$table]['columns'][$theField]) {
921 $parts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(';', $types_fieldConfig[$theField]['origString']);
922 // Don't sent palette pointer - there are no options anyways for a field-list.
923 $sField = $this->getSingleField($table, $theField, $row, $parts[1], 0, $parts[3], 0);
924 $out .= $sField;
925 } elseif ($theField == '--div--') {
926 $out .= $this->getDivider();
927 }
928 if ($palFields) {
929 $out .= $this->getPaletteFields($table, $row, '', '', implode(',', \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('|', $palFields, 1)));
930 }
931 }
932 return $out;
933 }
934
935 /**
936 * Creates a palette (collection of secondary options).
937 *
938 * @param string $table The table name
939 * @param array $row The row array
940 * @param string $palette The palette number/pointer
941 * @param string $header Header string for the palette (used when in-form). If not set, no header item is made.
942 * @param string $itemList Optional alternative list of fields for the palette
943 * @param string $collapsedHeader Optional Link text for activating a palette (when palettes does not have another form element to belong to).
944 * @return string HTML code.
945 * @todo Define visibility
946 */
947 public function getPaletteFields($table, $row, $palette, $header = '', $itemList = '', $collapsedHeader = NULL) {
948 if (!$this->doPrintPalette) {
949 return '';
950 }
951 $out = '';
952 $parts = $this->loadPaletteElements($table, $row, $palette, $itemList);
953 // Put palette together if there are fields in it:
954 if (count($parts)) {
955 $realFields = 0;
956 foreach ($parts as $part) {
957 if ($part['NAME'] !== '--linebreak--') {
958 $realFields++;
959 }
960 }
961 if ($realFields > 0) {
962 if ($header) {
963 $out .= $this->intoTemplate(array('HEADER' => htmlspecialchars($header)), $this->palFieldTemplateHeader);
964 }
965 $collapsed = $this->isPalettesCollapsed($table, $palette);
966 // Check if the palette is a hidden palette
967 $isHiddenPalette = !empty($GLOBALS['TCA'][$table]['palettes'][$palette]['isHiddenPalette']);
968 $thePalIcon = '';
969 if ($collapsed && $collapsedHeader !== NULL && !$isHiddenPalette) {
970 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);
971 $thePalIcon = '<span style="margin-left: 20px;">' . $thePalIcon . $collapsedHeader . '</span>';
972 }
973 $paletteHtml = $this->wrapPaletteField($this->printPalette($parts), $table, $row, $palette, $collapsed);
974 $out .= $this->intoTemplate(array('PALETTE' => $thePalIcon . $paletteHtml), $this->palFieldTemplate);
975 }
976 }
977 return $out;
978 }
979
980 /**
981 * Returns the form HTML code for a database table field.
982 *
983 * @param string $table The table name
984 * @param string $field The field name
985 * @param array $row The record to edit from the database table.
986 * @param string $altName Alternative field name label to show.
987 * @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).
988 * @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.
989 * @param integer $pal The palette pointer.
990 * @return mixed String (normal) or array (palettes)
991 * @todo Define visibility
992 */
993 public function getSingleField($table, $field, $row, $altName = '', $palette = 0, $extra = '', $pal = 0) {
994 // Hook: getSingleField_preProcess
995 foreach ($this->hookObjectsSingleField as $hookObj) {
996 if (method_exists($hookObj, 'getSingleField_preProcess')) {
997 $hookObj->getSingleField_preProcess($table, $field, $row, $altName, $palette, $extra, $pal, $this);
998 }
999 }
1000 $out = '';
1001 $PA = array();
1002 $PA['altName'] = $altName;
1003 $PA['palette'] = $palette;
1004 $PA['extra'] = $extra;
1005 $PA['pal'] = $pal;
1006 // Get the TCA configuration for the current field:
1007 $PA['fieldConf'] = $GLOBALS['TCA'][$table]['columns'][$field];
1008 $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ? $PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type'];
1009 // Using "form_type" locally in this script
1010 $skipThisField = $this->inline->skipField($table, $field, $row, $PA['fieldConf']['config']);
1011 // Now, check if this field is configured and editable (according to excludefields + other configuration)
1012 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'])) {
1013 // Fetching the TSconfig for the current table/field. This includes the $row which means that
1014 $PA['fieldTSConfig'] = $this->setTSconfig($table, $row, $field);
1015 // If the field is NOT disabled from TSconfig (which it could have been) then render it
1016 if (!$PA['fieldTSConfig']['disabled']) {
1017 // Override fieldConf by fieldTSconfig:
1018 $PA['fieldConf']['config'] = $this->overrideFieldConf($PA['fieldConf']['config'], $PA['fieldTSConfig']);
1019 // Init variables:
1020 $PA['itemFormElName'] = $this->prependFormFieldNames . '[' . $table . '][' . $row['uid'] . '][' . $field . ']';
1021 // Form field name, in case of file uploads
1022 $PA['itemFormElName_file'] = $this->prependFormFieldNames_file . '[' . $table . '][' . $row['uid'] . '][' . $field . ']';
1023 // Form field name, to activate elements
1024 // If the "eval" list contains "null", elements can be deactivated which results in storing NULL to database
1025 $PA['itemFormElNameActive'] = $this->prependFormFieldNamesActive . '[' . $table . '][' . $row['uid'] . '][' . $field . ']';
1026 // The value to show in the form field.
1027 $PA['itemFormElValue'] = $row[$field];
1028 $PA['itemFormElID'] = $this->prependFormFieldNames . '_' . $table . '_' . $row['uid'] . '_' . $field;
1029 // Set field to read-only if configured for translated records to show default language content as readonly
1030 if ($PA['fieldConf']['l10n_display'] && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly') && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] > 0) {
1031 $PA['fieldConf']['config']['readOnly'] = TRUE;
1032 $PA['itemFormElValue'] = $this->defaultLanguageData[$table . ':' . $row['uid']][$field];
1033 }
1034 if (strpos($GLOBALS['TCA'][$table]['ctrl']['type'], ':') === FALSE) {
1035 $typeField = $GLOBALS['TCA'][$table]['ctrl']['type'];
1036 } else {
1037 $typeField = substr($GLOBALS['TCA'][$table]['ctrl']['type'], 0, strpos($GLOBALS['TCA'][$table]['ctrl']['type'], ':'));
1038 }
1039 // 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"
1040 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)) {
1041 if ($GLOBALS['BE_USER']->jsConfirmation(1)) {
1042 $alertMsgOnChange = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
1043 } else {
1044 $alertMsgOnChange = 'if (TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
1045 }
1046 } else {
1047 $alertMsgOnChange = '';
1048 }
1049 // Render as a hidden field?
1050 if (in_array($field, $this->hiddenFieldListArr)) {
1051 $this->hiddenFieldAccum[] = '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1052 } else {
1053 // Render as a normal field:
1054 // 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.
1055 if (!$PA['palette']) {
1056 $paletteFields = $this->loadPaletteElements($table, $row, $PA['pal']);
1057 if ($PA['pal'] && $this->isPalettesCollapsed($table, $PA['pal']) && count($paletteFields)) {
1058 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);
1059 } else {
1060 $thePalIcon = '';
1061 $palJSfunc = '';
1062 }
1063 }
1064 // onFocus attribute to add to the field:
1065 $PA['onFocus'] = $palJSfunc && !$GLOBALS['BE_USER']->uc['dontShowPalettesOnFocusInAB'] ? ' onfocus="' . htmlspecialchars($palJSfunc) . '"' : '';
1066 // Find item
1067 $item = '';
1068 $PA['label'] = $PA['altName'] ? $PA['altName'] : $PA['fieldConf']['label'];
1069 $PA['label'] = $PA['fieldTSConfig']['label'] ? $PA['fieldTSConfig']['label'] : $PA['label'];
1070 $PA['label'] = $PA['fieldTSConfig']['label.'][$GLOBALS['LANG']->lang] ? $PA['fieldTSConfig']['label.'][$GLOBALS['LANG']->lang] : $PA['label'];
1071 $PA['label'] = $this->sL($PA['label']);
1072 // JavaScript code for event handlers:
1073 $PA['fieldChangeFunc'] = array();
1074 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = 'TBE_EDITOR.fieldChanged(\'' . $table . '\',\'' . $row['uid'] . '\',\'' . $field . '\',\'' . $PA['itemFormElName'] . '\');';
1075 $PA['fieldChangeFunc']['alert'] = $alertMsgOnChange;
1076 // If this is the child of an inline type and it is the field creating the label
1077 if ($this->inline->isInlineChildAndLabelField($table, $field)) {
1078 $inlineObjectId = implode(\TYPO3\CMS\Backend\Form\Element\InlineElement::Structure_Separator, array(
1079 $this->inline->inlineNames['object'],
1080 $table,
1081 $row['uid']
1082 ));
1083 $PA['fieldChangeFunc']['inline'] = 'inline.handleChangedField(\'' . $PA['itemFormElName'] . '\',\'' . $inlineObjectId . '\');';
1084 }
1085 // Based on the type of the item, call a render function:
1086 $item = $this->getSingleField_SW($table, $field, $row, $PA);
1087 // Add language + diff
1088 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'))) {
1089 $renderLanguageDiff = FALSE;
1090 } else {
1091 $renderLanguageDiff = TRUE;
1092 }
1093 if ($renderLanguageDiff) {
1094 $item = $this->renderDefaultLanguageContent($table, $field, $row, $item);
1095 $item = $this->renderDefaultLanguageDiff($table, $field, $row, $item);
1096 }
1097 // 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
1098 $label = \TYPO3\CMS\Core\Utility\GeneralUtility::deHSCentities(htmlspecialchars($PA['label']));
1099 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($row['uid']) && $PA['fieldTSConfig']['linkTitleToSelf'] && !\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('columnsOnly')) {
1100 $lTTS_url = $this->backPath . 'alt_doc.php?edit[' . $table . '][' . $row['uid'] . ']=edit&columnsOnly=' . $field . '&returnUrl=' . rawurlencode($this->thisReturnUrl());
1101 $label = '<a href="' . htmlspecialchars($lTTS_url) . '">' . $label . '</a>';
1102 }
1103 // Wrap the label with help text
1104 $PA['label'] = ($label = \TYPO3\CMS\Backend\Utility\BackendUtility::wrapInHelp($table, $field, $label));
1105 // Create output value:
1106 if ($PA['fieldConf']['config']['form_type'] == 'user' && $PA['fieldConf']['config']['noTableWrapping']) {
1107 $out = $item;
1108 } elseif ($PA['palette']) {
1109 // Array:
1110 $out = array(
1111 'NAME' => $label,
1112 'ID' => $row['uid'],
1113 'FIELD' => $field,
1114 'TABLE' => $table,
1115 'ITEM' => $item,
1116 'ITEM_DISABLED' => ($this->isNullValue($table, $field, $row, $PA) ? ' disabled' : ''),
1117 'ITEM_NULLVALUE' => $this->renderNullValueWidget($table, $field, $row, $PA),
1118 );
1119 $out = $this->addUserTemplateMarkers($out, $table, $field, $row, $PA);
1120 } else {
1121 // String:
1122 $out = array(
1123 'NAME' => $label,
1124 'ITEM' => $item,
1125 'TABLE' => $table,
1126 'ID' => $row['uid'],
1127 'PAL_LINK_ICON' => $thePalIcon,
1128 'FIELD' => $field,
1129 'ITEM_DISABLED' => ($this->isNullValue($table, $field, $row, $PA) ? ' disabled' : ''),
1130 'ITEM_NULLVALUE' => $this->renderNullValueWidget($table, $field, $row, $PA),
1131 );
1132 $out = $this->addUserTemplateMarkers($out, $table, $field, $row, $PA);
1133 // String:
1134 $out = $this->intoTemplate($out);
1135 }
1136 }
1137 } else {
1138 $this->commentMessages[] = $this->prependFormFieldNames . '[' . $table . '][' . $row['uid'] . '][' . $field . ']: Disabled by TSconfig';
1139 }
1140 }
1141 // Hook: getSingleField_postProcess
1142 foreach ($this->hookObjectsSingleField as $hookObj) {
1143 if (method_exists($hookObj, 'getSingleField_postProcess')) {
1144 $hookObj->getSingleField_postProcess($table, $field, $row, $out, $PA, $this);
1145 }
1146 }
1147 // Return value (string or array)
1148 return $out;
1149 }
1150
1151 /**
1152 * Rendering a single item for the form
1153 *
1154 * @param string $table Table name of record
1155 * @param string $field Fieldname to render
1156 * @param array $row The record
1157 * @param array $PA Parameters array containing a lot of stuff. Value by Reference!
1158 * @return string Returns the item as HTML code to insert
1159 * @access private
1160 * @see getSingleField(), getSingleField_typeFlex_draw()
1161 * @todo Define visibility
1162 */
1163 public function getSingleField_SW($table, $field, $row, &$PA) {
1164 $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ? $PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type'];
1165 // Using "form_type" locally in this script
1166 // Hook: getSingleField_beforeRender
1167 foreach ($this->hookObjectsSingleField as $hookObject) {
1168 if (method_exists($hookObject, 'getSingleField_beforeRender')) {
1169 $hookObject->getSingleField_beforeRender($table, $field, $row, $PA);
1170 }
1171 }
1172 switch ($PA['fieldConf']['config']['form_type']) {
1173 case 'input':
1174 $item = $this->getSingleField_typeInput($table, $field, $row, $PA);
1175 break;
1176 case 'text':
1177 $item = $this->getSingleField_typeText($table, $field, $row, $PA);
1178 break;
1179 case 'check':
1180 $item = $this->getSingleField_typeCheck($table, $field, $row, $PA);
1181 break;
1182 case 'radio':
1183 $item = $this->getSingleField_typeRadio($table, $field, $row, $PA);
1184 break;
1185 case 'select':
1186 $item = $this->getSingleField_typeSelect($table, $field, $row, $PA);
1187 break;
1188 case 'group':
1189 $item = $this->getSingleField_typeGroup($table, $field, $row, $PA);
1190 break;
1191 case 'inline':
1192 $item = $this->inline->getSingleField_typeInline($table, $field, $row, $PA);
1193 break;
1194 case 'none':
1195 $item = $this->getSingleField_typeNone($table, $field, $row, $PA);
1196 break;
1197 case 'user':
1198 $item = $this->getSingleField_typeUser($table, $field, $row, $PA);
1199 break;
1200 case 'flex':
1201 $item = $this->getSingleField_typeFlex($table, $field, $row, $PA);
1202 break;
1203 default:
1204 $item = $this->getSingleField_typeUnknown($table, $field, $row, $PA);
1205 break;
1206 }
1207 return $item;
1208 }
1209
1210 /**********************************************************
1211 *
1212 * Rendering of each TCEform field type
1213 *
1214 ************************************************************/
1215 /**
1216 * Generation of TCEform elements of the type "input"
1217 * This will render a single-line input form field, possibly with various control/validation features
1218 *
1219 * @param string $table The table name of the record
1220 * @param string $field The field name which this element is supposed to edit
1221 * @param array $row The record data array where the value(s) for the field can be found
1222 * @param array $PA An array with additional configuration options.
1223 * @return string The HTML code for the TCEform field
1224 * @todo Define visibility
1225 */
1226 public function getSingleField_typeInput($table, $field, $row, &$PA) {
1227 $config = $PA['fieldConf']['config'];
1228 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1229 $size = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['size'] ? $config['size'] : 30, 5, $this->maxInputWidth);
1230 $evalList = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $config['eval'], 1);
1231 $classAndStyleAttributes = $this->formWidthAsArray($size);
1232 $fieldAppendix = '';
1233 $item = '';
1234 $cssClasses = array($classAndStyleAttributes['class']);
1235 $cssStyle = $classAndStyleAttributes['style'];
1236 if (!isset($config['checkbox'])) {
1237 $config['checkbox'] = '0';
1238 $checkboxIsset = FALSE;
1239 } else {
1240 $checkboxIsset = TRUE;
1241 }
1242 if (in_array('date', $evalList) || in_array('datetime', $evalList)) {
1243 if (in_array('datetime', $evalList)) {
1244 $class = 'datetime';
1245 } else {
1246 $class = 'date';
1247 }
1248 $dateRange = '';
1249 if (isset($config['range']['lower'])) {
1250 $dateRange .= ' lower-' . intval($config['range']['lower']);
1251 }
1252 if (isset($config['range']['upper'])) {
1253 $dateRange .= ' upper-' . intval($config['range']['upper']);
1254 }
1255 $inputId = uniqid('tceforms-' . $class . 'field-');
1256 $cssClasses[] = 'tceforms-textfield tceforms-' . $class . 'field' . $dateRange;
1257 $fieldAppendix = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-edit-pick-date', array(
1258 'style' => 'cursor:pointer;',
1259 'id' => 'picker-' . $inputId
1260 ));
1261 } elseif (in_array('timesec', $evalList)) {
1262 $inputId = uniqid('tceforms-timesecfield-');
1263 $cssClasses[] = 'tceforms-textfield tceforms-timesecfield';
1264 } elseif (in_array('year', $evalList)) {
1265 $inputId = uniqid('tceforms-yearfield-');
1266 $cssClasses[] = 'tceforms-textfield tceforms-yearfield';
1267 } elseif (in_array('time', $evalList)) {
1268 $inputId = uniqid('tceforms-timefield-');
1269 $cssClasses[] = 'tceforms-textfield tceforms-timefield';
1270 } elseif (in_array('int', $evalList)) {
1271 $inputId = uniqid('tceforms-intfield-');
1272 $cssClasses[] = 'tceforms-textfield tceforms-intfield';
1273 } elseif (in_array('double2', $evalList)) {
1274 $inputId = uniqid('tceforms-double2field-');
1275 $cssClasses[] = 'tceforms-textfield tceforms-double2field';
1276 } else {
1277 $inputId = uniqid('tceforms-textfield-');
1278 $cssClasses[] = 'tceforms-textfield';
1279 if ($checkboxIsset === FALSE) {
1280 $config['checkbox'] = '';
1281 }
1282 }
1283 if (isset($config['wizards']['link'])) {
1284 $inputId = uniqid('tceforms-linkfield-');
1285 $cssClasses[] = 'tceforms-textfield tceforms-linkfield';
1286 } elseif (isset($config['wizards']['color'])) {
1287 $inputId = uniqid('tceforms-colorfield-');
1288 $cssClasses[] = 'tceforms-textfield tceforms-colorfield';
1289 }
1290 if ($this->renderReadonly || $config['readOnly']) {
1291 $itemFormElValue = $PA['itemFormElValue'];
1292 if (in_array('date', $evalList)) {
1293 $config['format'] = 'date';
1294 } elseif (in_array('datetime', $evalList)) {
1295 $config['format'] = 'datetime';
1296 } elseif (in_array('time', $evalList)) {
1297 $config['format'] = 'time';
1298 }
1299 if (in_array('password', $evalList)) {
1300 $itemFormElValue = $itemFormElValue ? '*********' : '';
1301 }
1302 return $this->getSingleField_typeNone_render($config, $itemFormElValue);
1303 }
1304 foreach ($evalList as $func) {
1305 switch ($func) {
1306 case 'required':
1307 $this->registerRequiredProperty('field', $table . '_' . $row['uid'] . '_' . $field, $PA['itemFormElName']);
1308 // Mark this field for date/time disposal:
1309 if (array_intersect($evalList, array('date', 'datetime', 'time'))) {
1310 $this->requiredAdditional[$PA['itemFormElName']]['isPositiveNumber'] = TRUE;
1311 }
1312 break;
1313 default:
1314 // Pair hook to the one in t3lib_TCEmain::checkValue_input_Eval()
1315 $evalObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
1316 if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue')) {
1317 $_params = array(
1318 'value' => $PA['itemFormElValue']
1319 );
1320 $PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
1321 }
1322 break;
1323 }
1324 }
1325 $paramsList = '\'' . $PA['itemFormElName'] . '\',\'' . implode(',', $evalList) . '\',\'' . trim($config['is_in']) . '\',' . (isset($config['checkbox']) ? 1 : 0) . ',\'' . $config['checkbox'] . '\'';
1326 if (in_array('date', $evalList) || in_array('datetime', $evalList)) {
1327 $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\';">';
1328 // Add server timezone offset to UTC to our stored date
1329 if ($PA['itemFormElValue'] > 0) {
1330 $PA['itemFormElValue'] += date('Z', $PA['itemFormElValue']);
1331 }
1332 } else {
1333 $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\';">';
1334 }
1335 $PA['fieldChangeFunc'] = array_merge(array('typo3form.fieldGet' => 'typo3form.fieldGet(' . $paramsList . ');'), $PA['fieldChangeFunc']);
1336 // Old function "checkbox" now the option to set the date / remove the date
1337 if (isset($config['checkbox'])) {
1338 $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'])));
1339 }
1340 $mLgd = $config['max'] ? $config['max'] : 256;
1341 $iOnChange = implode('', $PA['fieldChangeFunc']);
1342 $cssClasses[] = 'hasDefaultValue';
1343 $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'] . ' />';
1344 // This is the EDITABLE form field.
1345 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1346 // 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.
1347 $item .= $fieldAppendix . '</span><div style="clear:both;"></div>';
1348 $this->extJSCODE .= 'typo3form.fieldSet(' . $paramsList . ');';
1349 // Going through all custom evaluations configured for this field
1350 foreach ($evalList as $evalData) {
1351 $evalObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$evalData] . ':&' . $evalData);
1352 if (is_object($evalObj) && method_exists($evalObj, 'returnFieldJS')) {
1353 $this->extJSCODE .= '
1354
1355 function ' . $evalData . '(value) {
1356 ' . $evalObj->returnFieldJS() . '
1357 }
1358 ';
1359 }
1360 }
1361 // Creating an alternative item without the JavaScript handlers.
1362 $altItem = '<input type="hidden" name="' . $PA['itemFormElName'] . '_hr" value="" />';
1363 $altItem .= '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1364 // Wrap a wizard around the item?
1365 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'] . '_hr', $specConf);
1366 return $item;
1367 }
1368
1369 /**
1370 * Renders a view widget to handle and activate NULL values.
1371 * The widget is enabled by using 'null' in the 'eval' TCA definition.
1372 *
1373 * @param string $table Name of the table
1374 * @param string $field Name of the field
1375 * @param array $row Accordant data of the record row
1376 * @param array $PA Parameters array with rendering instructions
1377 * @return string Widget (if any).
1378 */
1379 protected function renderNullValueWidget($table, $field, array $row, array $PA) {
1380 $widget = '';
1381
1382 $config = $PA['fieldConf']['config'];
1383 if (!empty($config['eval']) && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($config['eval'], 'null')) {
1384 $isNull = ($PA['itemFormElValue'] === NULL);
1385
1386 $checked = ($isNull ? '' : ' checked="checked"');
1387 $onChange = htmlspecialchars(
1388 'typo3form.fieldSetNull(\'' . $PA['itemFormElName'] . '\', !this.checked)'
1389 );
1390
1391 $widget = '<span class="t3-tceforms-widget-null-wrapper">' .
1392 '<input type="hidden" name="' . $PA['itemFormElNameActive'] . '" value="0" />' .
1393 '<input type="checkbox" name="' . $PA['itemFormElNameActive'] . '" value="1" onchange="' . $onChange . '"' . $checked . ' />' .
1394 '</span>';
1395 }
1396
1397 return $widget;
1398 }
1399
1400 /**
1401 * Determines whether the current field value is considered as NULL value.
1402 * Using NULL values is enabled by using 'null' in the 'eval' TCA definition.
1403 *
1404 * @param string $table Name of the table
1405 * @param string $field Name of the field
1406 * @param array $row Accordant data
1407 * @param array $PA Parameters array with rendering instructions
1408 * @return boolean
1409 */
1410 protected function isNullValue($table, $field, array $row, array $PA) {
1411 $result = FALSE;
1412
1413 $config = $PA['fieldConf']['config'];
1414 if ($PA['itemFormElValue'] === NULL && !empty($config['eval']) && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($config['eval'], 'null')) {
1415 $result = TRUE;
1416 }
1417
1418 return $result;
1419 }
1420
1421 /**
1422 * Generation of TCEform elements of the type "text"
1423 * This will render a <textarea> OR RTE area form field, possibly with various control/validation features
1424 *
1425 * @param string $table The table name of the record
1426 * @param string $field The field name which this element is supposed to edit
1427 * @param array $row The record data array where the value(s) for the field can be found
1428 * @param array $PA An array with additional configuration options.
1429 * @return string The HTML code for the TCEform field
1430 * @todo Define visibility
1431 */
1432 public function getSingleField_typeText($table, $field, $row, &$PA) {
1433 // Init config:
1434 $config = $PA['fieldConf']['config'];
1435 $evalList = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $config['eval'], 1);
1436 if ($this->renderReadonly || $config['readOnly']) {
1437 return $this->getSingleField_typeNone_render($config, $PA['itemFormElValue']);
1438 }
1439 // Setting columns number:
1440 $cols = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
1441 // Setting number of rows:
1442 $origRows = ($rows = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['rows'] ? $config['rows'] : 5, 1, 20));
1443 if (strlen($PA['itemFormElValue']) > $this->charsPerRow * 2) {
1444 $cols = $this->maxTextareaWidth;
1445 $rows = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(round(strlen($PA['itemFormElValue']) / $this->charsPerRow), count(explode(LF, $PA['itemFormElValue'])), 20);
1446 if ($rows < $origRows) {
1447 $rows = $origRows;
1448 }
1449 }
1450 if (in_array('required', $evalList)) {
1451 $this->requiredFields[$table . '_' . $row['uid'] . '_' . $field] = $PA['itemFormElName'];
1452 }
1453 // Init RTE vars:
1454 // Set TRUE, if the RTE is loaded; If not a normal textarea is shown.
1455 $RTEwasLoaded = 0;
1456 // Set TRUE, if the RTE would have been loaded if it wasn't for the disable-RTE flag in the bottom of the page...
1457 $RTEwouldHaveBeenLoaded = 0;
1458 // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. Traditionally, this is where RTE configuration has been found.
1459 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1460 // Setting up the altItem form field, which is a hidden field containing the value
1461 $altItem = '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1462 // If RTE is generally enabled (TYPO3_CONF_VARS and user settings)
1463 if ($this->RTEenabled) {
1464 $p = \TYPO3\CMS\Backend\Utility\BackendUtility::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
1465 // If the field is configured for RTE and if any flag-field is not set to disable it.
1466 if (isset($specConf['richtext']) && (!$p['flag'] || !$row[$p['flag']])) {
1467 \TYPO3\CMS\Backend\Utility\BackendUtility::fixVersioningPid($table, $row);
1468 list($tscPID, $thePidValue) = $this->getTSCpid($table, $row['uid'], $row['pid']);
1469 // If the pid-value is not negative (that is, a pid could NOT be fetched)
1470 if ($thePidValue >= 0) {
1471 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($tscPID));
1472 $RTEtypeVal = \TYPO3\CMS\Backend\Utility\BackendUtility::getTCAtypeValue($table, $row);
1473 $thisConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::RTEsetup($RTEsetup['properties'], $table, $field, $RTEtypeVal);
1474 if (!$thisConfig['disabled']) {
1475 if (!$this->disableRTE) {
1476 $this->RTEcounter++;
1477 // Find alternative relative path for RTE images/links:
1478 $eFile = \TYPO3\CMS\Core\Html\RteHtmlParser::evalWriteFile($specConf['static_write'], $row);
1479 $RTErelPath = is_array($eFile) ? dirname($eFile['relEditFile']) : '';
1480 // Get RTE object, draw form and set flag:
1481 $RTEobj = \TYPO3\CMS\Backend\Utility\BackendUtility::RTEgetObj();
1482 $item = $RTEobj->drawRTE($this, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue);
1483 // Wizard:
1484 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf, 1);
1485 $RTEwasLoaded = 1;
1486 } else {
1487 $RTEwouldHaveBeenLoaded = 1;
1488 $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!)';
1489 }
1490 } else {
1491 $this->commentMessages[] = $PA['itemFormElName'] . ': RTE is disabled by the Page TSconfig, "RTE"-key (eg. by RTE.default.disabled=0 or such)';
1492 }
1493 } else {
1494 $this->commentMessages[] = $PA['itemFormElName'] . ': PID value could NOT be fetched. Rare error, normally with new records.';
1495 }
1496 } else {
1497 if (!isset($specConf['richtext'])) {
1498 $this->commentMessages[] = $PA['itemFormElName'] . ': RTE was not configured for this field in TCA-types';
1499 }
1500 if (!(!$p['flag'] || !$row[$p['flag']])) {
1501 $this->commentMessages[] = $PA['itemFormElName'] . ': Field-flag (' . $PA['flag'] . ') has been set to disable RTE!';
1502 }
1503 }
1504 }
1505 // Display ordinary field if RTE was not loaded.
1506 if (!$RTEwasLoaded) {
1507 // Show message, if no RTE (field can only be edited with RTE!)
1508 if ($specConf['rte_only']) {
1509 $item = '<p><em>' . htmlspecialchars($this->getLL('l_noRTEfound')) . '</em></p>';
1510 } else {
1511 if ($specConf['nowrap']) {
1512 $wrap = 'off';
1513 } else {
1514 $wrap = $config['wrap'] ? $config['wrap'] : 'virtual';
1515 }
1516 $classes = array();
1517 if ($specConf['fixed-font']) {
1518 $classes[] = 'fixed-font';
1519 }
1520 if ($specConf['enable-tab']) {
1521 $classes[] = 'enable-tab';
1522 }
1523 $formWidthText = $this->formWidthText($cols, $wrap);
1524 // Extract class attributes from $formWidthText (otherwise it would be added twice to the output)
1525 $res = array();
1526 if (preg_match('/ class="(.+?)"/', $formWidthText, $res)) {
1527 $formWidthText = str_replace(' class="' . $res[1] . '"', '', $formWidthText);
1528 $classes = array_merge($classes, explode(' ', $res[1]));
1529 }
1530 if (count($classes)) {
1531 $class = ' class="tceforms-textarea ' . implode(' ', $classes) . '"';
1532 } else {
1533 $class = 'tceforms-textarea';
1534 }
1535 $evalList = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $config['eval'], 1);
1536 foreach ($evalList as $func) {
1537 switch ($func) {
1538 case 'required':
1539 $this->registerRequiredProperty('field', $table . '_' . $row['uid'] . '_' . $field, $PA['itemFormElName']);
1540 break;
1541 default:
1542 // Pair hook to the one in t3lib_TCEmain::checkValue_input_Eval() and t3lib_TCEmain::checkValue_text_Eval()
1543 $evalObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
1544 if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue')) {
1545 $_params = array(
1546 'value' => $PA['itemFormElValue']
1547 );
1548 $PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
1549 }
1550 break;
1551 }
1552 }
1553 $iOnChange = implode('', $PA['fieldChangeFunc']);
1554 $item .= '
1555 <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>';
1556 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf, $RTEwouldHaveBeenLoaded);
1557 }
1558 }
1559 // Return field HTML:
1560 return $item;
1561 }
1562
1563 /**
1564 * Generation of TCEform elements of the type "check"
1565 * This will render a check-box OR an array of checkboxes
1566 *
1567 * @param string $table The table name of the record
1568 * @param string $field The field name which this element is supposed to edit
1569 * @param array $row The record data array where the value(s) for the field can be found
1570 * @param array $PA An array with additional configuration options.
1571 * @return string The HTML code for the TCEform field
1572 * @todo Define visibility
1573 */
1574 public function getSingleField_typeCheck($table, $field, $row, &$PA) {
1575 $config = $PA['fieldConf']['config'];
1576 $item = '';
1577 $disabled = '';
1578 if ($this->renderReadonly || $config['readOnly']) {
1579 $disabled = ' disabled="disabled"';
1580 }
1581 // Traversing the array of items:
1582 $selItems = $this->initItemArray($PA['fieldConf']);
1583 if ($config['itemsProcFunc']) {
1584 $selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
1585 }
1586 if (!count($selItems)) {
1587 $selItems[] = array('', '');
1588 }
1589 $thisValue = intval($PA['itemFormElValue']);
1590 $cols = intval($config['cols']);
1591 $selItemsCount = count($selItems);
1592 if ($cols > 1) {
1593 $item .= '<table border="0" cellspacing="0" cellpadding="0" class="typo3-TCEforms-checkboxArray">';
1594 for ($c = 0; $c < $selItemsCount; $c++) {
1595 $p = $selItems[$c];
1596 if (!($c % $cols)) {
1597 $item .= '<tr>';
1598 }
1599 $cBP = $this->checkBoxParams($PA['itemFormElName'], $thisValue, $c, count($selItems), implode('', $PA['fieldChangeFunc']));
1600 $cBName = $PA['itemFormElName'] . '_' . $c;
1601 $cBID = $PA['itemFormElID'] . '_' . $c;
1602 $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>';
1603 if ($c % $cols + 1 == $cols) {
1604 $item .= '</tr>';
1605 }
1606 }
1607 if ($c % $cols) {
1608 $rest = $cols - $c % $cols;
1609 for ($c = 0; $c < $rest; $c++) {
1610 $item .= '<td></td>';
1611 }
1612 if ($c > 0) {
1613 $item .= '</tr>';
1614 }
1615 }
1616 $item .= '</table>';
1617 } else {
1618 for ($c = 0; $c < $selItemsCount; $c++) {
1619 $p = $selItems[$c];
1620 $cBP = $this->checkBoxParams($PA['itemFormElName'], $thisValue, $c, count($selItems), implode('', $PA['fieldChangeFunc']));
1621 $cBName = $PA['itemFormElName'] . '_' . $c;
1622 $cBID = $PA['itemFormElID'] . '_' . $c;
1623 $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>'));
1624 }
1625 }
1626 if (!$disabled) {
1627 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($thisValue) . '" />';
1628 }
1629 return $item;
1630 }
1631
1632 /**
1633 * Generation of TCEform elements of the type "radio"
1634 * This will render a series of radio buttons.
1635 *
1636 * @param string $table The table name of the record
1637 * @param string $field The field name which this element is supposed to edit
1638 * @param array $row The record data array where the value(s) for the field can be found
1639 * @param array $PA An array with additional configuration options.
1640 * @return string The HTML code for the TCEform field
1641 * @todo Define visibility
1642 */
1643 public function getSingleField_typeRadio($table, $field, $row, &$PA) {
1644 $config = $PA['fieldConf']['config'];
1645 $item = '';
1646 $disabled = '';
1647 if ($this->renderReadonly || $config['readOnly']) {
1648 $disabled = ' disabled="disabled"';
1649 }
1650 // Get items for the array:
1651 $selItems = $this->initItemArray($PA['fieldConf']);
1652 if ($config['itemsProcFunc']) {
1653 $selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
1654 }
1655 // Traverse the items, making the form elements:
1656 $selItemsCount = count($selItems);
1657 for ($c = 0; $c < $selItemsCount; $c++) {
1658 $p = $selItems[$c];
1659 $rID = $PA['itemFormElID'] . '_' . $c;
1660 $rOnClick = implode('', $PA['fieldChangeFunc']);
1661 $rChecked = !strcmp($p[1], $PA['itemFormElValue']) ? ' checked="checked"' : '';
1662 $item .= '<input type="radio"' . $this->insertDefStyle('radio') . ' name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($p[1]) . '" onclick="' . htmlspecialchars($rOnClick) . '"' . $rChecked . $PA['onFocus'] . $disabled . ' id="' . $rID . '" />
1663 <label for="' . $rID . '">' . htmlspecialchars($p[0]) . '</label>
1664 <br />';
1665 }
1666 return $item;
1667 }
1668
1669 /**
1670 * Generation of TCEform elements of the type "select"
1671 * This will render a selector box element, or possibly a special construction with two selector boxes. That depends on configuration.
1672 *
1673 * @param string $table The table name of the record
1674 * @param string $field The field name which this element is supposed to edit
1675 * @param array $row The record data array where the value(s) for the field can be found
1676 * @param array $PA An array with additional configuration options.
1677 * @return string The HTML code for the TCEform field
1678 * @todo Define visibility
1679 */
1680 public function getSingleField_typeSelect($table, $field, $row, &$PA) {
1681 // Field configuration from TCA:
1682 $config = $PA['fieldConf']['config'];
1683 $disabled = '';
1684 if ($this->renderReadonly || $config['readOnly']) {
1685 $disabled = ' disabled="disabled"';
1686 }
1687 // "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/.
1688 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1689 // Getting the selector box items from the system
1690 $selItems = $this->addSelectOptionsToItemArray($this->initItemArray($PA['fieldConf']), $PA['fieldConf'], $this->setTSconfig($table, $row), $field);
1691 // Possibly filter some items:
1692 $keepItemsFunc = create_function('$value', 'return $value[1];');
1693 $selItems = \TYPO3\CMS\Core\Utility\GeneralUtility::keepItemsInArray($selItems, $PA['fieldTSConfig']['keepItems'], $keepItemsFunc);
1694 // Possibly add some items:
1695 $selItems = $this->addItems($selItems, $PA['fieldTSConfig']['addItems.']);
1696 // Process items by a user function:
1697 if (isset($config['itemsProcFunc']) && $config['itemsProcFunc']) {
1698 $selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
1699 }
1700 // Possibly remove some items:
1701 $removeItems = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $PA['fieldTSConfig']['removeItems'], 1);
1702 foreach ($selItems as $tk => $p) {
1703 // Checking languages and authMode:
1704 $languageDeny = $GLOBALS['TCA'][$table]['ctrl']['languageField'] && !strcmp($GLOBALS['TCA'][$table]['ctrl']['languageField'], $field) && !$GLOBALS['BE_USER']->checkLanguageAccess($p[1]);
1705 $authModeDeny = $config['form_type'] == 'select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table, $field, $p[1], $config['authMode']);
1706 if (in_array($p[1], $removeItems) || $languageDeny || $authModeDeny) {
1707 unset($selItems[$tk]);
1708 } elseif (isset($PA['fieldTSConfig']['altLabels.'][$p[1]])) {
1709 $selItems[$tk][0] = htmlspecialchars($this->sL($PA['fieldTSConfig']['altLabels.'][$p[1]]));
1710 }
1711 // Removing doktypes with no access:
1712 if (($table === 'pages' || $table === 'pages_language_overlay') && $field === 'doktype') {
1713 if (!($GLOBALS['BE_USER']->isAdmin() || \TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['BE_USER']->groupData['pagetypes_select'], $p[1]))) {
1714 unset($selItems[$tk]);
1715 }
1716 }
1717 }
1718 // Creating the label for the "No Matching Value" entry.
1719 $nMV_label = isset($PA['fieldTSConfig']['noMatchingValue_label']) ? $this->sL($PA['fieldTSConfig']['noMatchingValue_label']) : '[ ' . $this->getLL('l_noMatchingValue') . ' ]';
1720 // Prepare some values:
1721 $maxitems = intval($config['maxitems']);
1722 // If a SINGLE selector box...
1723 if ($maxitems <= 1 && $config['renderMode'] !== 'tree') {
1724 $item = $this->getSingleField_typeSelect_single($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1725 } elseif (!strcmp($config['renderMode'], 'checkbox')) {
1726 // Checkbox renderMode
1727 $item = $this->getSingleField_typeSelect_checkbox($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1728 } elseif (!strcmp($config['renderMode'], 'singlebox')) {
1729 // Single selector box renderMode
1730 $item = $this->getSingleField_typeSelect_singlebox($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1731 } elseif (!strcmp($config['renderMode'], 'tree')) {
1732 // Tree renderMode
1733 $treeClass = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\Element\\TreeElement', $this);
1734 $item = $treeClass->renderField($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1735 // Register the required number of elements
1736 $minitems = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['minitems'], 0);
1737 $this->registerRequiredProperty('range', $PA['itemFormElName'], array($minitems, $maxitems, 'imgName' => $table . '_' . $row['uid'] . '_' . $field));
1738 } else {
1739 // Traditional multiple selector box:
1740 $item = $this->getSingleField_typeSelect_multiple($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1741 }
1742 // Wizards:
1743 if (!$disabled) {
1744 $altItem = '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1745 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf);
1746 }
1747 return $item;
1748 }
1749
1750 /**
1751 * Creates a single-selector box
1752 * (Render function for getSingleField_typeSelect())
1753 *
1754 * @param string $table See getSingleField_typeSelect()
1755 * @param string $field See getSingleField_typeSelect()
1756 * @param array $row See getSingleField_typeSelect()
1757 * @param array $PA See getSingleField_typeSelect()
1758 * @param array $config (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1759 * @param array $selItems Items available for selection
1760 * @param string $nMV_label Label for no-matching-value
1761 * @return string The HTML code for the item
1762 * @see getSingleField_typeSelect()
1763 * @todo Define visibility
1764 */
1765 public function getSingleField_typeSelect_single($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
1766 // check against inline uniqueness
1767 $inlineParent = $this->inline->getStructureLevel(-1);
1768 if (is_array($inlineParent) && $inlineParent['uid']) {
1769 if ($inlineParent['config']['foreign_table'] == $table && $inlineParent['config']['foreign_unique'] == $field) {
1770 $uniqueIds = $this->inline->inlineData['unique'][$this->inline->inlineNames['object'] . \TYPO3\CMS\Backend\Form\Element\InlineElement::Structure_Separator . $table]['used'];
1771 $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'] . '\');';
1772 }
1773 // hide uid of parent record for symmetric relations
1774 if ($inlineParent['config']['foreign_table'] == $table && ($inlineParent['config']['foreign_field'] == $field || $inlineParent['config']['symmetric_field'] == $field)) {
1775 $uniqueIds[] = $inlineParent['uid'];
1776 }
1777 }
1778 // Initialization:
1779 $c = 0;
1780 $sI = 0;
1781 $noMatchingValue = 1;
1782 $opt = array();
1783 $selicons = array();
1784 $onlySelectedIconShown = 0;
1785 $size = intval($config['size']);
1786 // Style set on <select/>
1787 $selectedStyle = '';
1788 $item = '';
1789 $disabled = '';
1790 // TODO: icon is used but never assigned
1791 $onChangeIcon = '';
1792 if ($this->renderReadonly || $config['readOnly']) {
1793 $disabled = ' disabled="disabled"';
1794 $onlySelectedIconShown = 1;
1795 }
1796 // Icon configuration:
1797 if ($config['suppress_icons'] == 'IF_VALUE_FALSE') {
1798 $suppressIcons = !$PA['itemFormElValue'] ? 1 : 0;
1799 } elseif ($config['suppress_icons'] == 'ONLY_SELECTED') {
1800 $suppressIcons = 0;
1801 $onlySelectedIconShown = 1;
1802 } elseif ($config['suppress_icons']) {
1803 $suppressIcons = 1;
1804 } else {
1805 $suppressIcons = 0;
1806 }
1807 // Traverse the Array of selector box items:
1808 $optGroupStart = array();
1809 $optGroupOpen = FALSE;
1810 $classesForSelectTag = array();
1811 foreach ($selItems as $p) {
1812 $sM = !strcmp($PA['itemFormElValue'], $p[1]) ? ' selected="selected"' : '';
1813 if ($sM) {
1814 $sI = $c;
1815 $noMatchingValue = 0;
1816 }
1817 // Getting style attribute value (for icons):
1818 if ($config['iconsInOptionTags']) {
1819 $styleAttrValue = $this->optionTagStyle($p[2]);
1820 if ($sM) {
1821 list($selectIconFile, $selectIconInfo) = $this->getIcon($p[2]);
1822 if (!empty($selectIconInfo)) {
1823 $selectedStyle = ' style="background-image:url(' . $selectIconFile . ');"';
1824 $classesForSelectTag[] = 'typo3-TCEforms-select-selectedItemWithBackgroundImage';
1825 }
1826 }
1827 }
1828 // Compiling the <option> tag:
1829 if (!($p[1] != $PA['itemFormElValue'] && is_array($uniqueIds) && in_array($p[1], $uniqueIds))) {
1830 if (!strcmp($p[1], '--div--')) {
1831 $optGroupStart[0] = $p[0];
1832 if ($config['iconsInOptionTags']) {
1833 $optGroupStart[1] = $this->optgroupTagStyle($p[2]);
1834 } else {
1835 $optGroupStart[1] = $styleAttrValue;
1836 }
1837 } else {
1838 if (count($optGroupStart)) {
1839 // Closing last optgroup before next one starts
1840 if ($optGroupOpen) {
1841 $opt[] = '</optgroup>' . LF;
1842 }
1843 $opt[] = '<optgroup label="' . \TYPO3\CMS\Core\Utility\GeneralUtility::deHSCentities(htmlspecialchars($optGroupStart[0])) . '"' . ($optGroupStart[1] ? ' style="' . htmlspecialchars($optGroupStart[1]) . '"' : '') . ' class="c-divider">' . LF;
1844 $optGroupOpen = TRUE;
1845 $c--;
1846 $optGroupStart = array();
1847 }
1848 $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' . $sM . ($styleAttrValue ? ' style="' . htmlspecialchars($styleAttrValue) . '"' : '') . '>' . \TYPO3\CMS\Core\Utility\GeneralUtility::deHSCentities($p[0]) . '</option>' . LF;
1849 }
1850 }
1851 // If there is an icon for the selector box (rendered in selicon-table below)...:
1852 // if there is an icon ($p[2]), icons should be shown, and, if only selected are visible, is it selected
1853 if ($p[2] && !$suppressIcons && (!$onlySelectedIconShown || $sM)) {
1854 list($selIconFile, $selIconInfo) = $this->getIcon($p[2]);
1855 if (!empty($selIconInfo)) {
1856 $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;';
1857 } else {
1858 $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;';
1859 }
1860 $selicons[] = array(
1861 (!$onlySelectedIconShown ? '<a href="#" onclick="' . htmlspecialchars($iOnClick) . '">' : '') . $this->getIconHtml($p[2], htmlspecialchars($p[0]), htmlspecialchars($p[0])) . (!$onlySelectedIconShown ? '</a>' : ''),
1862 $c,
1863 $sM
1864 );
1865 }
1866 $c++;
1867 }
1868 // Closing optgroup if open
1869 if ($optGroupOpen) {
1870 $opt[] = '</optgroup>';
1871 $optGroupOpen = FALSE;
1872 }
1873 // No-matching-value:
1874 if ($PA['itemFormElValue'] && $noMatchingValue && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1875 $nMV_label = @sprintf($nMV_label, $PA['itemFormElValue']);
1876 $opt[] = '<option value="' . htmlspecialchars($PA['itemFormElValue']) . '" selected="selected">' . htmlspecialchars($nMV_label) . '</option>';
1877 }
1878 // Create item form fields:
1879 $sOnChange = 'if (this.options[this.selectedIndex].value==\'--div--\') {this.selectedIndex=' . $sI . ';} ' . implode('', $PA['fieldChangeFunc']);
1880 if (!$disabled) {
1881 // MUST be inserted before the selector - else is the value of the hiddenfield here mysteriously submitted...
1882 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '_selIconVal" value="' . htmlspecialchars($sI) . '" />';
1883 }
1884 if ($config['iconsInOptionTags']) {
1885 $classesForSelectTag[] = 'icon-select';
1886 }
1887 $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 . '>';
1888 $item .= implode('', $opt);
1889 $item .= '</select>';
1890 // Create icon table:
1891 if (count($selicons) && !$config['noIconsBelowSelect']) {
1892 $item .= '<table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-selectIcons">';
1893 $selicon_cols = intval($config['selicon_cols']);
1894 if (!$selicon_cols) {
1895 $selicon_cols = count($selicons);
1896 }
1897 $sR = ceil(count($selicons) / $selicon_cols);
1898 $selicons = array_pad($selicons, $sR * $selicon_cols, '');
1899 for ($sa = 0; $sa < $sR; $sa++) {
1900 $item .= '<tr>';
1901 for ($sb = 0; $sb < $selicon_cols; $sb++) {
1902 $sk = $sa * $selicon_cols + $sb;
1903 $imgN = 'selIcon_' . $table . '_' . $row['uid'] . '_' . $field . '_' . $selicons[$sk][1];
1904 $imgS = $selicons[$sk][2] ? $this->backPath . 'gfx/content_selected.gif' : 'clear.gif';
1905 $item .= '<td><img name="' . htmlspecialchars($imgN) . '" src="' . $imgS . '" width="7" height="10" alt="" /></td>';
1906 $item .= '<td>' . $selicons[$sk][0] . '</td>';
1907 }
1908 $item .= '</tr>';
1909 }
1910 $item .= '</table>';
1911 }
1912 return $item;
1913 }
1914
1915 /**
1916 * Creates a checkbox list (renderMode = "checkbox")
1917 * (Render function for getSingleField_typeSelect())
1918 *
1919 * @param string $table See getSingleField_typeSelect()
1920 * @param string $field See getSingleField_typeSelect()
1921 * @param array $row See getSingleField_typeSelect()
1922 * @param array $PA See getSingleField_typeSelect()
1923 * @param array $config (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1924 * @param array $selItems Items available for selection
1925 * @param string $nMV_label Label for no-matching-value
1926 * @return string The HTML code for the item
1927 * @see getSingleField_typeSelect()
1928 * @todo Define visibility
1929 */
1930 public function getSingleField_typeSelect_checkbox($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
1931 if (empty($selItems)) {
1932 return '';
1933 }
1934 // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
1935 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
1936 $item = '';
1937 $disabled = '';
1938 if ($this->renderReadonly || $config['readOnly']) {
1939 $disabled = ' disabled="disabled"';
1940 }
1941 // Traverse the Array of selector box items:
1942 $tRows = array();
1943 $c = 0;
1944 if (!$disabled) {
1945 $sOnChange = implode('', $PA['fieldChangeFunc']);
1946 // Used to accumulate the JS needed to restore the original selection.
1947 $setAll = array();
1948 $unSetAll = array();
1949 foreach ($selItems as $p) {
1950 // Non-selectable element:
1951 if (!strcmp($p[1], '--div--')) {
1952 $selIcon = '';
1953 if (isset($p[2]) && $p[2] != 'empty-emtpy') {
1954 $selIcon = $this->getIconHtml($p[2]);
1955 }
1956 $tRows[] = '
1957 <tr class="c-header">
1958 <td colspan="3">' . $selIcon . htmlspecialchars($p[0]) . '</td>
1959 </tr>';
1960 } else {
1961 // Selected or not by default:
1962 $sM = '';
1963 if (isset($itemArray[$p[1]])) {
1964 $sM = ' checked="checked"';
1965 unset($itemArray[$p[1]]);
1966 }
1967 // Icon:
1968 if ($p[2]) {
1969 $selIcon = $p[2];
1970 } else {
1971 $selIcon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('empty-empty');
1972 }
1973 // Compile row:
1974 $rowId = uniqid('select_checkbox_row_');
1975 $onClickCell = $this->elName(($PA['itemFormElName'] . '[' . $c . ']')) . '.checked=!' . $this->elName(($PA['itemFormElName'] . '[' . $c . ']')) . '.checked;';
1976 $onClick = 'this.attributes.getNamedItem("class").nodeValue = ' . $this->elName(($PA['itemFormElName'] . '[' . $c . ']')) . '.checked ? "c-selectedItem" : "c-unselectedItem";';
1977 $setAll[] = $this->elName(($PA['itemFormElName'] . '[' . $c . ']')) . '.checked=1;';
1978 $setAll[] .= '$(\'' . $rowId . '\').removeClassName(\'c-unselectedItem\');$(\'' . $rowId . '\').addClassName(\'c-selectedItem\');';
1979 $unSetAll[] = $this->elName(($PA['itemFormElName'] . '[' . $c . ']')) . '.checked=0;';
1980 $unSetAll[] .= '$(\'' . $rowId . '\').removeClassName(\'c-selectedItem\');$(\'' . $rowId . '\').addClassName(\'c-unselectedItem\');';
1981 $restoreCmd[] = $this->elName(($PA['itemFormElName'] . '[' . $c . ']')) . '.checked=' . ($sM ? 1 : 0) . ';' . '$(\'' . $rowId . '\').removeClassName(\'c-selectedItem\');$(\'' . $rowId . '\').removeClassName(\'c-unselectedItem\');' . '$(\'' . $rowId . '\').addClassName(\'c-' . ($sM ? '' : 'un') . 'selectedItem\');';
1982 // Check if some help text is available
1983 // Since TYPO3 4.5 help text is expected to be an associative array
1984 // with two key, "title" and "description"
1985 // For the sake of backwards compatibility, we test if the help text
1986 // is a string and use it as a description (this could happen if items
1987 // are modified with an itemProcFunc)
1988 $hasHelp = FALSE;
1989 $help = '';
1990 $helpArray = array();
1991 if (is_array($p[3]) && count($p[3]) > 0 || !empty($p[3])) {
1992 $hasHelp = TRUE;
1993 if (is_array($p[3])) {
1994 $helpArray = $p[3];
1995 } else {
1996 $helpArray['description'] = $p[3];
1997 }
1998 }
1999 $label = \TYPO3\CMS\Core\Utility\GeneralUtility::deHSCentities(htmlspecialchars($p[0]));
2000 if ($hasHelp) {
2001 $help = \TYPO3\CMS\Backend\Utility\BackendUtility::wrapInHelp('', '', '', $helpArray);
2002 }
2003 $tRows[] = '
2004 <tr id="' . $rowId . '" class="' . ($sM ? 'c-selectedItem' : 'c-unselectedItem') . '" onclick="' . htmlspecialchars($onClick) . '" style="cursor: pointer;">
2005 <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>
2006 <td class="c-labelCell" onclick="' . htmlspecialchars($onClickCell) . '">' . $this->getIconHtml($selIcon) . $label . '</td>
2007 <td class="c-descr" onclick="' . htmlspecialchars($onClickCell) . '">' . (empty($help) ? '' : $help) . '</td>
2008 </tr>';
2009 $c++;
2010 }
2011 }
2012 }
2013 // Remaining values (invalid):
2014 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
2015 foreach ($itemArray as $theNoMatchValue => $temp) {
2016 // Compile <checkboxes> tag:
2017 array_unshift($tRows, '
2018 <tr class="c-invalidItem">
2019 <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>
2020 <td class="c-labelCell">' . \TYPO3\CMS\Core\Utility\GeneralUtility::deHSCentities(htmlspecialchars(@sprintf($nMV_label, $theNoMatchValue))) . '</td><td>&nbsp;</td>
2021 </tr>');
2022 $c++;
2023 }
2024 }
2025 // Add an empty hidden field which will send a blank value if all items are unselected.
2026 $item .= '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="" />';
2027 // Remaining checkboxes will get their set-all link:
2028 if (count($setAll)) {
2029 $tableHead = '<thead>
2030 <tr class="c-header-checkbox-controls t3-row-header">
2031 <td class="c-checkbox">
2032 <input type="checkbox" class="checkbox" onclick="if (checked) {' . htmlspecialchars((implode('', $setAll) . '} else {' . implode('', $unSetAll) . '}')) . '">
2033 </td>
2034 <td colspan="2">
2035 </td>
2036 </tr></thead>';
2037 }
2038 // Implode rows in table:
2039 $item .= '
2040 <table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-select-checkbox">' . $tableHead . '<tbody>' . implode('', $tRows) . '</tbody>
2041 </table>
2042 ';
2043 // Add revert icon
2044 if (is_array($restoreCmd)) {
2045 $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>';
2046 }
2047 return $item;
2048 }
2049
2050 /**
2051 * Creates a selectorbox list (renderMode = "singlebox")
2052 * (Render function for getSingleField_typeSelect())
2053 *
2054 * @param string $table See getSingleField_typeSelect()
2055 * @param string $field See getSingleField_typeSelect()
2056 * @param array $row See getSingleField_typeSelect()
2057 * @param array $PA See getSingleField_typeSelect()
2058 * @param array $config (Redundant) content of $PA['fieldConf']['config'] (for convenience)
2059 * @param array $selItems Items available for selection
2060 * @param string $nMV_label Label for no-matching-value
2061 * @return string The HTML code for the item
2062 * @see getSingleField_typeSelect()
2063 * @todo Define visibility
2064 */
2065 public function getSingleField_typeSelect_singlebox($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
2066 // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
2067 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
2068 $item = '';
2069 $disabled = '';
2070 if ($this->renderReadonly || $config['readOnly']) {
2071 $disabled = ' disabled="disabled"';
2072 }
2073 // Traverse the Array of selector box items:
2074 $opt = array();
2075 // Used to accumulate the JS needed to restore the original selection.
2076 $restoreCmd = array();
2077 $c = 0;
2078 foreach ($selItems as $p) {
2079 // Selected or not by default:
2080 $sM = '';
2081 if (isset($itemArray[$p[1]])) {
2082 $sM = ' selected="selected"';
2083 $restoreCmd[] = $this->elName(($PA['itemFormElName'] . '[]')) . '.options[' . $c . '].selected=1;';
2084 unset($itemArray[$p[1]]);
2085 }
2086 // Non-selectable element:
2087 $nonSel = '';
2088 if (!strcmp($p[1], '--div--')) {
2089 $nonSel = ' onclick="this.selected=0;" class="c-divider"';
2090 }
2091 // Icon style for option tag:
2092 if ($config['iconsInOptionTags']) {
2093 $styleAttrValue = $this->optionTagStyle($p[2]);
2094 }
2095 // Compile <option> tag:
2096 $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' . $sM . $nonSel . ($styleAttrValue ? ' style="' . htmlspecialchars($styleAttrValue) . '"' : '') . '>' . \TYPO3\CMS\Core\Utility\GeneralUtility::deHSCentities(htmlspecialchars($p[0])) . '</option>';
2097 $c++;
2098 }
2099 // Remaining values:
2100 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
2101 foreach ($itemArray as $theNoMatchValue => $temp) {
2102 // Compile <option> tag:
2103 array_unshift($opt, '<option value="' . htmlspecialchars($theNoMatchValue) . '" selected="selected">' . \TYPO3\CMS\Core\Utility\GeneralUtility::deHSCentities(htmlspecialchars(@sprintf($nMV_label, $theNoMatchValue))) . '</option>');
2104 }
2105 }
2106 // Compile selector box:
2107 $sOnChange = implode('', $PA['fieldChangeFunc']);
2108 $selector_itemListStyle = isset($config['itemListStyle']) ? ' style="' . htmlspecialchars($config['itemListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle . '"';
2109 $size = intval($config['size']);
2110 $cssPrefix = $size === 1 ? 'tceforms-select' : 'tceforms-multiselect';
2111 $size = $config['autoSizeMax'] ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(count($selItems) + 1, \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($size, 1), $config['autoSizeMax']) : $size;
2112 $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 . '>
2113 ' . implode('
2114 ', $opt) . '
2115 </select>';
2116 // Add an empty hidden field which will send a blank value if all items are unselected.
2117 if (!$disabled) {
2118 $item .= '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="" />';
2119 }
2120 // Put it all into a table:
2121 $item .= '
2122 <table border="0" cellspacing="0" cellpadding="0" width="1" class="typo3-TCEforms-select-singlebox">
2123 <tr>
2124 <td>
2125 ' . $selectBox . '
2126 <br/>
2127 <em>' . htmlspecialchars($this->getLL('l_holdDownCTRL')) . '</em>
2128 </td>
2129 <td valign="top">
2130 <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>
2131 </td>
2132 </tr>
2133 </table>
2134 ';
2135 return $item;
2136 }
2137
2138 /**
2139 * Creates a multiple-selector box (two boxes, side-by-side)
2140 * (Render function for getSingleField_typeSelect())
2141 *
2142 * @param string $table See getSingleField_typeSelect()
2143 * @param string $field See getSingleField_typeSelect()
2144 * @param array $row See getSingleField_typeSelect()
2145 * @param array $PA See getSingleField_typeSelect()
2146 * @param array $config (Redundant) content of $PA['fieldConf']['config'] (for convenience)
2147 * @param array $selItems Items available for selection
2148 * @param string $nMV_label Label for no-matching-value
2149 * @return string The HTML code for the item
2150 * @see getSingleField_typeSelect()
2151 * @todo Define visibility
2152 */
2153 public function getSingleField_typeSelect_multiple($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
2154 $item = '';
2155 $disabled = '';
2156 if ($this->renderReadonly || $config['readOnly']) {
2157 $disabled = ' disabled="disabled"';
2158 }
2159 // Setting this hidden field (as a flag that JavaScript can read out)
2160 if (!$disabled) {
2161 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '_mul" value="' . ($config['multiple'] ? 1 : 0) . '" />';
2162 }
2163 // Set max and min items:
2164 $maxitems = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['maxitems'], 0);
2165 if (!$maxitems) {
2166 $maxitems = 100000;
2167 }
2168 $minitems = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['minitems'], 0);
2169 // Register the required number of elements:
2170 $this->registerRequiredProperty('range', $PA['itemFormElName'], array($minitems, $maxitems, 'imgName' => $table . '_' . $row['uid'] . '_' . $field));
2171 // Get "removeItems":
2172 $removeItems = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $PA['fieldTSConfig']['removeItems'], 1);
2173 // Get the array with selected items:
2174 $itemArray = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $PA['itemFormElValue'], 1);
2175 // Possibly filter some items:
2176 $keepItemsFunc = create_function('$value', '$parts=explode(\'|\',$value,2); return rawurldecode($parts[0]);');
2177 $itemArray = \TYPO3\CMS\Core\Utility\GeneralUtility::keepItemsInArray($itemArray, $PA['fieldTSConfig']['keepItems'], $keepItemsFunc);
2178 // Perform modification of the selected items array:
2179 foreach ($itemArray as $tk => $tv) {
2180 $tvP = explode('|', $tv, 2);
2181 $evalValue = $tvP[0];
2182 $isRemoved = in_array($evalValue, $removeItems) || $config['form_type'] == 'select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table, $field, $evalValue, $config['authMode']);
2183 if ($isRemoved && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
2184 $tvP[1] = rawurlencode(@sprintf($nMV_label, $evalValue));
2185 } elseif (isset($PA['fieldTSConfig']['altLabels.'][$evalValue])) {
2186 $tvP[1] = rawurlencode($this->sL($PA['fieldTSConfig']['altLabels.'][$evalValue]));
2187 }
2188 if ($tvP[1] == '') {
2189 // Case: flexform, default values supplied, no label provided (bug #9795)
2190 foreach ($selItems as $selItem) {
2191 if ($selItem[1] == $tvP[0]) {
2192 $tvP[1] = html_entity_decode($selItem[0]);
2193 break;
2194 }
2195 }
2196 }
2197 $itemArray[$tk] = implode('|', $tvP);
2198 }
2199 $itemsToSelect = '';
2200 if (!$disabled) {
2201 // Create option tags:
2202 $opt = array();
2203 $styleAttrValue = '';
2204 foreach ($selItems as $p) {
2205 if ($config['iconsInOptionTags']) {
2206 $styleAttrValue = $this->optionTagStyle($p[2]);
2207 }
2208 $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' . ($styleAttrValue ? ' style="' . htmlspecialchars($styleAttrValue) . '"' : '') . ' title="' . $p[0] . '">' . $p[0] . '</option>';
2209 }
2210 // Put together the selector box:
2211 $selector_itemListStyle = isset($config['itemListStyle']) ? ' style="' . htmlspecialchars($config['itemListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle . '"';
2212 $size = intval($config['size']);
2213 $size = $config['autoSizeMax'] ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(count($itemArray) + 1, \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($size, 1), $config['autoSizeMax']) : $size;
2214 if ($config['exclusiveKeys']) {
2215 $sOnChange = 'setFormValueFromBrowseWin(\'' . $PA['itemFormElName'] . '\',this.options[this.selectedIndex].value, this.options[this.selectedIndex].text, this.options[this.selectedIndex].title,\'' . $config['exclusiveKeys'] . '\'); ';
2216 } else {
2217 $sOnChange = 'setFormValueFromBrowseWin(\'' . $PA['itemFormElName'] . '\',this.options[this.selectedIndex].value, this.options[this.selectedIndex].text, this.options[this.selectedIndex].title); ';
2218 }
2219 $sOnChange .= implode('', $PA['fieldChangeFunc']);
2220 $itemsToSelect = '
2221 <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 . '>
2222 ' . implode('
2223 ', $opt) . '
2224 </select>';
2225 }
2226 // Pass to "dbFileIcons" function:
2227 $params = array(
2228 'size' => $size,
2229 'autoSizeMax' => \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['autoSizeMax'], 0),
2230 'style' => isset($config['selectedListStyle']) ? ' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle . '"',
2231 'dontShowMoveIcons' => $maxitems <= 1,
2232 'maxitems' => $maxitems,
2233 'info' => '',
2234 'headers' => array(
2235 'selector' => $this->getLL('l_selected') . ':<br />',
2236 'items' => $this->getLL('l_items') . ':<br />'
2237 ),
2238 'noBrowser' => 1,
2239 'thumbnails' => $itemsToSelect,
2240 'readOnly' => $disabled
2241 );
2242 $item .= $this->dbFileIcons($PA['itemFormElName'], '', '', $itemArray, '', $params, $PA['onFocus']);
2243 return $item;
2244 }
2245
2246 /**
2247 * Generation of TCEform elements of the type "group"
2248 * This will render a selectorbox into which elements from either the file system or database can be inserted. Relations.
2249 *
2250 * @param string $table The table name of the record
2251 * @param string $field The field name which this element is supposed to edit
2252 * @param array $row The record data array where the value(s) for the field can be found
2253 * @param array $PA An array with additional configuration options.
2254 * @return string The HTML code for the TCEform field
2255 * @todo Define visibility
2256 */
2257 public function getSingleField_typeGroup($table, $field, $row, &$PA) {
2258 // Init:
2259 $config = $PA['fieldConf']['config'];
2260 $internal_type = $config['internal_type'];
2261 $show_thumbs = $config['show_thumbs'];
2262 $size = intval($config['size']);
2263 $maxitems = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['maxitems'], 0);
2264 if (!$maxitems) {
2265 $maxitems = 100000;
2266 }
2267 $minitems = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['minitems'], 0);
2268 $allowed = trim($config['allowed']);
2269 $disallowed = trim($config['disallowed']);
2270 $item = '';
2271 $disabled = '';
2272 if ($this->renderReadonly || $config['readOnly']) {
2273 $disabled = ' disabled="disabled"';
2274 }
2275 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '_mul" value="' . ($config['multiple'] ? 1 : 0) . '"' . $disabled . ' />';
2276 $this->registerRequiredProperty('range', $PA['itemFormElName'], array($minitems, $maxitems, 'imgName' => $table . '_' . $row['uid'] . '_' . $field));
2277 $info = '';
2278 // "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/.
2279 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
2280 $PA['itemFormElID_file'] = $PA['itemFormElID'] . '_files';
2281 // whether the list and delete controls should be disabled
2282 $noList = isset($config['disable_controls']) && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($config['disable_controls'], 'list');
2283 $noDelete = isset($config['disable_controls']) && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($config['disable_controls'], 'delete');
2284 // if maxitems==1 then automatically replace the current item (in list and file selector)
2285 if ($maxitems === 1) {
2286 $this->additionalJS_post[] = 'TBE_EDITOR.clearBeforeSettingFormValueFromBrowseWin[\'' . $PA['itemFormElName'] . '\'] = {
2287 itemFormElID_file: \'' . $PA['itemFormElID_file'] . '\'
2288 }';
2289 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = 'setFormValueManipulate(\'' . $PA['itemFormElName'] . '\', \'Remove\'); ' . $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'];
2290 } elseif ($noList) {
2291 // If the list controls have been removed and the maximum number is reached, remove the first entry to avoid "write once" field
2292 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = 'setFormValueManipulate(\'' . $PA['itemFormElName'] . '\', \'RemoveFirstIfFull\', \'' . $maxitems . '\'); ' . $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'];
2293 }
2294 // Acting according to either "file" or "db" type:
2295 switch ((string) $config['internal_type']) {
2296 case 'file_reference':
2297 $config['uploadfolder'] = '';
2298 case 'file':
2299 // Creating string showing allowed types:
2300 $tempFT = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $allowed, TRUE);
2301 if (!count($tempFT)) {
2302 $info .= '*';
2303 }
2304 foreach ($tempFT as $ext) {
2305 if ($ext) {
2306 $info .= strtoupper($ext) . ' ';
2307 }
2308 }
2309 // Creating string, showing disallowed types:
2310 $tempFT_dis = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $disallowed, TRUE);
2311 if (count($tempFT_dis)) {
2312 $info .= '<br />';
2313 }
2314 foreach ($tempFT_dis as $ext) {
2315 if ($ext) {
2316 $info .= '-' . strtoupper($ext) . ' ';
2317 }
2318 }
2319 // Making the array of file items:
2320 $itemArray = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $PA['itemFormElValue'], TRUE);
2321 $fileFactory = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance();
2322 // Correct the filename for the FAL items
2323 foreach ($itemArray as &$fileItem) {
2324 list($fileUid, $fileLabel) = explode('|', $fileItem);
2325 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($fileUid)) {
2326 $fileObject = $fileFactory->getFileObject($fileUid);
2327 $fileLabel = $fileObject->getName();
2328 }
2329 $fileItem = $fileUid . '|' . $fileLabel;
2330 }
2331 // Showing thumbnails:
2332 $thumbsnail = '';
2333 if ($show_thumbs) {
2334 $imgs = array();
2335 foreach ($itemArray as $imgRead) {
2336 $imgP = explode('|', $imgRead);
2337 $imgPath = rawurldecode($imgP[0]);
2338 // FAL icon production
2339 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($imgP[0])) {
2340 $fileObject = $fileFactory->getFileObject($imgP[0]);
2341 if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileObject->getExtension())) {
2342 $imageUrl = $fileObject->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW, array())->getPublicUrl(TRUE);
2343 $imgTag = '<img src="' . $imageUrl . '" alt="' . htmlspecialchars($fileObject->getName()) . '" />';
2344 } else {
2345 // Icon
2346 $imgTag = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForFile(strtolower($fileObject->getExtension()), array('title' => $fileObject->getName()));
2347 }
2348 $imgs[] = '<span class="nobr">' . $imgTag . htmlspecialchars($fileObject->getName()) . '</span>';
2349 } else {
2350 $rowCopy = array();
2351 $rowCopy[$field] = $imgPath;
2352 $thumbnailCode = \TYPO3\CMS\Backend\Utility\BackendUtility::thumbCode($rowCopy, $table, $field, $this->backPath, 'thumbs.php', $config['uploadfolder'], 0, ' align="middle"');
2353 $imgs[] = '<span class="nobr">' . $thumbnailCode . $imgPath . '</span>';
2354 }
2355 }
2356 $thumbsnail = implode('<br />', $imgs);
2357 }
2358 // Creating the element:
2359 $params = array(
2360 'size' => $size,
2361 'dontShowMoveIcons' => $maxitems <= 1,
2362 'autoSizeMax' => \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['autoSizeMax'], 0),
2363 'maxitems' => $maxitems,
2364 'style' => isset($config['selectedListStyle']) ? ' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle . '"',
2365 'info' => $info,
2366 'thumbnails' => $thumbsnail,
2367 'readOnly' => $disabled,
2368 'noBrowser' => $noList || isset($config['disable_controls']) && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($config['disable_controls'], 'browser'),
2369 'noList' => $noList,
2370 'noDelete' => $noDelete
2371 );
2372 $item .= $this->dbFileIcons($PA['itemFormElName'], 'file', implode(',', $tempFT), $itemArray, '', $params, $PA['onFocus'], '', '', '', $config);
2373 if (!$disabled && !(isset($config['disable_controls']) && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($config['disable_controls'], 'upload'))) {
2374 // Adding the upload field:
2375 if ($this->edit_docModuleUpload && $config['uploadfolder']) {
2376 // Insert the multiple attribute to enable HTML5 multiple file upload
2377 $multipleAttribute = '';
2378 $multipleFilenameSuffix = '';
2379 if (isset($config['maxitems']) && $config['maxitems'] > 1) {
2380 $multipleAttribute = ' multiple="multiple"';
2381 $multipleFilenameSuffix = '[]';
2382 }
2383 $item .= '<div id="' . $PA['itemFormElID_file'] . '"><input type="file"' . $multipleAttribute . ' name="' . $PA['itemFormElName_file'] . $multipleFilenameSuffix . '" size="35" onchange="' . implode('', $PA['fieldChangeFunc']) . '" /></div>';
2384 }
2385 }
2386 break;
2387 case 'folder':
2388 // If the element is of the internal type "folder":
2389 // Array of folder items:
2390 $itemArray = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $PA['itemFormElValue'], 1);
2391 // Creating the element:
2392 $params = array(
2393 'size' => $size,
2394 'dontShowMoveIcons' => $maxitems <= 1,
2395 'autoSizeMax' => \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['autoSizeMax'], 0),
2396 'maxitems' => $maxitems,
2397 'style' => isset($config['selectedListStyle']) ? ' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle . '"',
2398 'info' => $info,
2399 'readOnly' => $disabled,
2400 'noBrowser' => $noList || isset($config['disable_controls']) && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($config['disable_controls'], 'browser'),
2401 'noList' => $noList
2402 );
2403 $item .= $this->dbFileIcons($PA['itemFormElName'], 'folder', '', $itemArray, '', $params, $PA['onFocus']);
2404 break;
2405 case 'db':
2406 // If the element is of the internal type "db":
2407 // Creating string showing allowed types:
2408 $tempFT = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $allowed, TRUE);
2409 if (!strcmp(trim($tempFT[0]), '*')) {
2410 $onlySingleTableAllowed = FALSE;
2411 $info .= '<span class="nobr">' . htmlspecialchars($this->getLL('l_allTables')) . '</span><br />';
2412 } elseif ($tempFT) {
2413 $onlySingleTableAllowed = count($tempFT) == 1;
2414 foreach ($tempFT as $theT) {
2415 $aOnClick = 'setFormValueOpenBrowser(\'db\', \'' . ($PA['itemFormElName'] . '|||' . $theT) . '\'); return false;';
2416 $info .= '<span class="nobr">
2417 <a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($theT, array()) . htmlspecialchars($this->sL($GLOBALS['TCA'][$theT]['ctrl']['title'])) . '</a></span><br />';
2418 }
2419 }
2420 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
2421 $itemArray = array();
2422 $imgs = array();
2423 // Thumbnails:
2424 $temp_itemArray = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $PA['itemFormElValue'], 1);
2425 foreach ($temp_itemArray as $dbRead) {
2426 $recordParts = explode('|', $dbRead);
2427 list($this_table, $this_uid) = \TYPO3\CMS\Backend\Utility\BackendUtility::splitTable_Uid($recordParts[0]);
2428 // For the case that no table was found and only a single table is defined to be allowed, use that one:
2429 if (!$this_table && $onlySingleTableAllowed) {
2430 $this_table = $allowed;
2431 }
2432 $itemArray[] = array('table' => $this_table, 'id' => $this_uid);
2433 if (!$disabled && $show_thumbs) {
2434 $rr = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL($this_table, $this_uid);
2435 $imgs[] = '<span class="nobr">' . $this->getClickMenu(\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($this_table, $rr, array(
2436 'style' => 'vertical-align:top',
2437 'title' => htmlspecialchars((\TYPO3\CMS\Backend\Utility\BackendUtility::getRecordPath($rr['pid'], $perms_clause, 15) . ' [UID: ' . $rr['uid'] . ']'))
2438 )), $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>';
2439 }
2440 }
2441 $thumbsnail = '';
2442 if (!$disabled && $show_thumbs) {
2443 $thumbsnail = implode('<br />', $imgs);
2444 }
2445 // Creating the element:
2446 $params = array(
2447 'size' => $size,
2448 'dontShowMoveIcons' => $maxitems <= 1,
2449 'autoSizeMax' => \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['autoSizeMax'], 0),
2450 'maxitems' => $maxitems,
2451 'style' => isset($config['selectedListStyle']) ? ' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle . '"',
2452 'info' => $info,
2453 'thumbnails' => $thumbsnail,
2454 'readOnly' => $disabled,
2455 'noBrowser' => $noList || isset($config['disable_controls']) && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($config['disable_controls'], 'browser'),
2456 'noList' => $noList
2457 );
2458 $item .= $this->dbFileIcons($PA['itemFormElName'], 'db', implode(',', $tempFT), $itemArray, '', $params, $PA['onFocus'], $table, $field, $row['uid'], $config);
2459 break;
2460 }
2461 // Wizards:
2462 $altItem = '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
2463 if (!$disabled) {
2464 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf);
2465 }
2466 return $item;
2467 }
2468
2469 /**
2470 * Generation of TCEform elements of the type "none"
2471 * This will render a non-editable display of the content of the field.
2472 *
2473 * @param string $table The table name of the record
2474 * @param string $field The field name which this element is supposed to edit
2475 * @param array $row The record data array where the value(s) for the field can be found
2476 * @param array $PA An array with additional configuration options.
2477 * @return string The HTML code for the TCEform field
2478 * @todo Define visibility
2479 */
2480 public function getSingleField_typeNone($table, $field, $row, &$PA) {
2481 // Init:
2482 $config = $PA['fieldConf']['config'];
2483 $itemValue = $PA['itemFormElValue'];
2484 return $this->getSingleField_typeNone_render($config, $itemValue);
2485 }
2486
2487 /**
2488 * HTML rendering of a value which is not editable.
2489 *
2490 * @param array $config Configuration for the display
2491 * @param string $itemValue The value to display
2492 * @return string The HTML code for the display
2493 * @see getSingleField_typeNone();
2494 * @todo Define visibility
2495 */
2496 public function getSingleField_typeNone_render($config, $itemValue) {
2497 if ($config['format']) {
2498 $itemValue = $this->formatValue($config, $itemValue);
2499 }
2500 $rows = intval($config['rows']);
2501 if ($rows > 1) {
2502 if (!$config['pass_content']) {
2503 $itemValue = nl2br(htmlspecialchars($itemValue));
2504 }
2505 // Like textarea
2506 $cols = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
2507 if (!$config['fixedRows']) {
2508 $origRows = ($rows = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($rows, 1, 20));
2509 if (strlen($itemValue) > $this->charsPerRow * 2) {
2510 $cols = $this->maxTextareaWidth;
2511 $rows = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(round(strlen($itemValue) / $this->charsPerRow), count(explode(LF, $itemValue)), 20);
2512 if ($rows < $origRows) {
2513 $rows = $origRows;
2514 }
2515 }
2516 }
2517 if ($this->docLarge) {
2518 $cols = round($cols * $this->form_largeComp);
2519 }
2520 $width = ceil($cols * $this->form_rowsToStylewidth);
2521 // Hardcoded: 12 is the height of the font
2522 $height = $rows * 12;
2523 $item = '
2524 <div style="overflow:auto; height:' . $height . 'px; width:' . $width . 'px;" class="t3-tceforms-fieldReadOnly">' . $itemValue . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('status-status-readonly') . '</div>';
2525 } else {
2526 if (!$config['pass_content']) {
2527 $itemValue = htmlspecialchars($itemValue);
2528 }
2529 $cols = $config['cols'] ? $config['cols'] : ($config['size'] ? $config['size'] : $this->maxInputWidth);
2530 if ($this->docLarge) {
2531 $cols = round($cols * $this->form_largeComp);
2532 }