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