2 namespace TYPO3\CMS\Backend\Form
;
5 * This file is part of the TYPO3 CMS project.
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
17 use TYPO3\CMS\Backend\Form\Element\InlineElement
;
18 use TYPO3\CMS\Backend\Template\DocumentTemplate
;
19 use TYPO3\CMS\Backend\Utility\BackendUtility
;
20 use TYPO3\CMS\Backend\Utility\IconUtility
;
21 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication
;
22 use TYPO3\CMS\Core\Database\DatabaseConnection
;
23 use TYPO3\CMS\Core\Html\HtmlParser
;
24 use TYPO3\CMS\Core\Html\RteHtmlParser
;
25 use TYPO3\CMS\Core\Messaging\FlashMessage
;
26 use TYPO3\CMS\Core\Messaging\FlashMessageQueue
;
27 use TYPO3\CMS\Core\Messaging\FlashMessageService
;
28 use TYPO3\CMS\Core\
Resource\ProcessedFile
;
29 use TYPO3\CMS\Core\
Resource\ResourceFactory
;
30 use TYPO3\CMS\Core\Utility\ArrayUtility
;
31 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility
;
32 use TYPO3\CMS\Core\Utility\GeneralUtility
;
33 use TYPO3\CMS\Core\Utility\MathUtility
;
34 use TYPO3\CMS\Core\Utility\PathUtility
;
35 use TYPO3\CMS\Lang\LanguageService
;
38 * 'TCEforms' - Class for creating the backend editing forms.
40 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
41 * @coauthor René Fritz <r.fritz@colorcube.de>
46 * @todo Define visibility
49 public $palFieldArr = array();
52 * @todo Define visibility
55 public $disableWizards = FALSE;
58 * @todo Define visibility
61 public $isPalettedoc = FALSE;
64 * @todo Define visibility
67 public $paletteMargin = 1;
70 * @todo Define visibility
73 public $defStyle = '';
76 * @todo Define visibility
79 public $cachedTSconfig = array();
82 * @todo Define visibility
85 public $cachedTSconfig_fieldLevel = array();
88 * @todo Define visibility
91 public $cachedLanguageFlag = array();
94 * @todo Define visibility
97 public $cachedAdditionalPreviewLanguages = NULL;
100 * Cache for the real PID of a record. The array key consists for a combined string "<table>:<uid>:<pid>".
101 * The value is an array with two values: first is the real PID of a record, second is the PID value for TSconfig.
105 protected $cache_getTSCpid = array();
108 * @todo Define visibility
111 public $transformedRow = array();
114 * @todo Define visibility
117 public $extJSCODE = '';
120 * @todo Define visibility
123 public $printNeededJS = array();
126 * @todo Define visibility
129 public $hiddenFieldAccum = array();
132 * @todo Define visibility
135 public $TBE_EDITOR_fieldChanged_func = '';
138 * @todo Define visibility
141 public $loadMD5_JS = TRUE;
144 * Array where records in the default language is stored. (processed by transferdata)
146 * @todo Define visibility
149 public $defaultLanguageData = array();
152 * Array where records in the default language is stored (raw without any processing. used for making diff)
154 * @todo Define visibility
157 public $defaultLanguageData_diff = array();
160 * @todo Define visibility
163 public $additionalPreviewLanguageData = array();
167 * Set this to the 'backPath' pointing back to the typo3 admin directory
168 * from the script where this form is displayed.
170 * @todo Define visibility
173 public $backPath = '';
176 * Alternative return URL path (default is \TYPO3\CMS\Core\Utility\GeneralUtility::linkThisScript())
178 * @todo Define visibility
181 public $returnUrl = '';
184 * Can be set to point to a field name in the form which will be set to '1' when the form
185 * is submitted with a *save* button. This way the recipient script can determine that
186 * the form was submitted for save and not "close" for example.
188 * @todo Define visibility
191 public $doSaveFieldName = '';
194 * Can be set TRUE/FALSE to whether palettes (secondary options) are in the topframe or in form.
195 * TRUE means they are NOT IN-form. So a collapsed palette is one, which is shown in the top frame, not in the page.
197 * @todo Define visibility
200 public $palettesCollapsed = FALSE;
203 * If set, the RTE is disabled (from form display, eg. by checkbox in the bottom of the page!)
205 * @todo Define visibility
208 public $disableRTE = FALSE;
211 * If FALSE, then all CSH will be disabled, regardless of settings in $this->edit_showFieldHelp
213 * @todo Define visibility
216 public $globalShowHelp = TRUE;
219 * If this evaluates to TRUE, the forms are rendering only localization relevant fields of the records.
221 * @todo Define visibility
224 public $localizationMode = '';
227 * Overrule the field order set in TCA[types][showitem], eg for tt_content this value,
228 * 'bodytext,image', would make first the 'bodytext' field, then the 'image' field (if set for display)...
229 * and then the rest in the old order.
231 * @todo Define visibility
234 public $fieldOrder = '';
237 * If set to FALSE, palettes will NEVER be rendered.
239 * @todo Define visibility
242 public $doPrintPalette = TRUE;
245 * Set to initialized clipboard object;
246 * Then the element browser will offer a link to paste in records from clipboard.
248 * @var \TYPO3\CMS\Backend\Clipboard\Clipboard|NULL
249 * @todo Define visibility
251 public $clipObj = NULL;
254 * Enable click menu on reference icons.
256 * @todo Define visibility
259 public $enableClickMenu = FALSE;
262 * @todo Define visibility
265 public $enableTabMenu = FALSE;
268 * When enabled all fields are rendered non-editable
270 * @todo Define visibility
273 public $renderReadonly = FALSE;
276 * Form field width compensation: Factor of "size=12" to "style="width: 12*9.58px"
277 * for form field widths of style-aware browsers
279 * @todo Define visibility
282 public $form_rowsToStylewidth = 9.58;
285 * Value that gets added for style="width: ...px" for textareas compared to input fields.
289 protected $form_additionalTextareaStyleWidth = 23;
292 * Form field width compensation: Compensation for large documents, doc-tab (editing)
294 * @todo Define visibility
297 public $form_largeComp = 1.33;
300 * The number of chars expected per row when the height of a text area field is
301 * automatically calculated based on the number of characters found in the field content.
303 * @todo Define visibility
306 public $charsPerRow = 40;
309 * The maximum abstract value for textareas
311 * @todo Define visibility
314 public $maxTextareaWidth = 48;
317 * The maximum abstract value for input fields
318 * @todo Define visibility
322 public $maxInputWidth = 48;
325 * Default style for the selector boxes used for multiple items in "select" and "group" types.
327 * @todo Define visibility
330 public $defaultMultipleSelectorStyle = 'width:310px;';
334 * The string to prepend formfield names with.
335 * @todo Define visibility
339 public $prependFormFieldNames = 'data';
342 * The string to prepend commands for tcemain::process_cmdmap with
344 * @todo Define visibility
347 public $prependCmdFieldNames = 'cmd';
350 * The string to prepend FILE form field names with
352 * @todo Define visibility
355 public $prependFormFieldNames_file = 'data_files';
358 * The string to prepend form field names that are active (not NULL)
362 protected $prependFormFieldNamesActive = 'control[active]';
365 * The name attribute of the form
367 * @todo Define visibility
370 public $formName = 'editform';
373 * Whitelist that allows TCA field configuration to be overridden by TSconfig
375 * @todo Define visibility
376 * @see overrideFieldConf()
379 public $allowOverrideMatrix = array();
383 * Set by readPerms() (caching)
385 * @todo Define visibility
388 public $perms_clause = '';
391 * Set by readPerms() (caching-flag)
393 * @todo Define visibility
396 public $perms_clause_set = FALSE;
399 * Used to indicate the mode of CSH (Context Sensitive Help),
400 * whether it should be icons-only ('icon') or not at all (blank).
402 * @todo Define visibility
405 public $edit_showFieldHelp = FALSE;
410 public $edit_docModuleUpload = FALSE;
413 * Loaded with info about the browser when class is instantiated
415 * @todo Define visibility
418 public $clientInfo = array();
421 * TRUE, if RTE is possible for the current user (based on result from BE_USER->isRTE())
423 * @todo Define visibility
426 public $RTEenabled = FALSE;
429 * If $this->RTEenabled was FALSE, you can find the reasons listed in this array
430 * which is filled with reasons why the RTE could not be loaded)
431 * @todo Define visibility
435 public $RTEenabled_notReasons = '';
438 * Counter that is incremented before an RTE is created. Can be used for unique ids etc.
440 * @todo Define visibility
443 public $RTEcounter = 0;
446 * Contains current color scheme
448 * @todo Define visibility
451 public $colorScheme = array();
454 * Contains current class scheme
456 * @todo Define visibility
459 public $classScheme = array();
462 * Contains the default color scheme
464 * @todo Define visibility
467 public $defColorScheme = array();
470 * Contains the default class scheme
472 * @todo Define visibility
475 public $defClassScheme = array();
478 * Contains field style values
480 * @todo Define visibility
483 public $fieldStyle = NULL;
486 * Contains border style values
488 * @todo Define visibility
491 public $borderStyle = NULL;
494 * An accumulation of messages from the class
496 * @todo Define visibility
499 public $commentMessages = array();
501 // INTERNAL, templates
503 * Total wrapping for the table rows
505 * @todo Define visibility
508 public $totalWrap = '<hr />|<hr />';
513 * @todo Define visibility
516 public $fieldTemplate = '<strong>###FIELD_NAME###</strong><br />###FIELD_ITEM###<hr />';
519 * Template subpart for palette fields
523 protected $paletteFieldTemplate = '';
526 * Wrapping template code for a section
528 * @todo Define visibility
531 public $sectionWrap = '';
534 * Template for palette headers
536 * @todo Define visibility
539 public $palFieldTemplateHeader = '';
542 * Template for palettes
544 * @todo Define visibility
547 public $palFieldTemplate = '';
549 // INTERNAL, working memory
551 * Set to the fields NOT to display, if any
553 * @todo Define visibility
556 public $excludeElements = NULL;
559 * During rendering of forms this will keep track of which palettes
560 * has already been rendered (so they are not rendered twice by mistake)
562 * @todo Define visibility
565 public $palettesRendered = array();
568 * This array of fields will be set as hidden-fields instead of rendered normally!
569 * For instance palette fields edited in the top frame are set as hidden fields
570 * since the main form has to submit the values.
571 * The top frame actually just sets the value in the main form!
573 * @todo Define visibility
576 public $hiddenFieldListArr = array();
579 * Used to register input-field names, which are required. (Done during rendering of the fields).
580 * This information is then used later when the JavaScript is made.
582 * @todo Define visibility
585 public $requiredFields = array();
588 * Used to register input-field names, which are required an have additional requirements.
589 * (e.g. like a date/time must be positive integer)
590 * The information of this array is merged with $this->requiredFields later.
592 * @todo Define visibility
595 public $requiredAdditional = array();
598 * Used to register the min and max number of elements
599 * for selector boxes where that apply (in the "group" type for instance)
601 * @todo Define visibility
604 public $requiredElements = array();
607 * Used to determine where $requiredFields or $requiredElements are nested (in Tabs or IRRE)
609 * @todo Define visibility
612 public $requiredNested = array();
615 * Keeps track of the rendering depth of nested records
617 * @todo Define visibility
620 public $renderDepth = 0;
623 * Color scheme buffer
625 * @todo Define visibility
628 public $savedSchemes = array();
631 * holds the path an element is nested in (e.g. required for RTEhtmlarea)
632 * @todo Define visibility
636 public $dynNestedStack = array();
638 // Internal, registers for user defined functions etc.
640 * Additional HTML code, printed before the form
642 * @todo Define visibility
645 public $additionalCode_pre = array();
648 * Additional JavaScript, printed before the form
650 * @todo Define visibility
653 public $additionalJS_pre = array();
656 * Additional JavaScript printed after the form
658 * @todo Define visibility
661 public $additionalJS_post = array();
664 * Additional JavaScript executed on submit; If you set "OK" variable it will raise an error
665 * about RTEs not being loaded and offer to block further submission.
667 * @todo Define visibility
670 public $additionalJS_submit = array();
673 * Additional JavaScript executed when section element is deleted.
674 * This is necessary, for example, to correctly clean up HTMLArea RTE (bug #8232)
676 * @todo Define visibility
679 public $additionalJS_delete = array();
682 * @var \TYPO3\CMS\Backend\Form\Element\InlineElement
683 * @todo Define visibility
688 * Array containing hook class instances called once for a form
690 * @todo Define visibility
693 public $hookObjectsMainFields = array();
696 * Array containing hook class instances called for each field
698 * @todo Define visibility
701 public $hookObjectsSingleField = array();
704 * Rows getting inserted into the alt_doc headers (when called from alt_doc.php)
706 * @todo Define visibility
709 public $extraFormHeaders = array();
712 * Form template, relative to typo3 directory
716 public $templateFile = '';
721 protected $multiSelectFilterCount = 0;
724 * @var \TYPO3\CMS\Backend\Form\Element\SuggestElement
729 * Constructor function, setting internal variables, loading the styles used.
731 * @todo Define visibility
733 public function __construct() {
734 $this->clientInfo
= GeneralUtility
::clientInfo();
735 $this->RTEenabled
= $this->getBackendUserAuthentication()->isRTE();
736 if (!$this->RTEenabled
) {
737 $this->RTEenabled_notReasons
= implode(LF
, $this->getBackendUserAuthentication()->RTE_errors
);
738 $this->commentMessages
[] = 'RTE NOT ENABLED IN SYSTEM due to:' . LF
. $this->RTEenabled_notReasons
;
740 // Default color+class scheme
741 $docTemplate = $this->getControllerDocumentTemplate();
742 $this->defColorScheme
= array(
743 $docTemplate->bgColor
,
744 // Background for the field AND palette
745 GeneralUtility
::modifyHTMLColorAll($docTemplate->bgColor
, -20),
746 // Background for the field header
747 GeneralUtility
::modifyHTMLColorAll($docTemplate->bgColor
, -10),
748 // Background for the palette field header
750 // Field header font color
753 $this->defColorScheme
= array();
754 // Override / Setting defaults from TBE_STYLES array
755 $this->resetSchemes();
756 // Setting the current colorScheme to default.
757 $this->defColorScheme
= $this->colorScheme
;
758 $this->defClassScheme
= $this->classScheme
;
759 // Define whitelist that allows TCA field configuration to be overridden by TSconfig, @see overrideFieldConf():
760 $this->allowOverrideMatrix
= array(
761 'input' => array('size', 'max', 'readOnly'),
762 'text' => array('cols', 'rows', 'wrap', 'readOnly'),
763 'check' => array('cols', 'showIfRTE', 'readOnly'),
764 'select' => array('size', 'autoSizeMax', 'maxitems', 'minitems', 'readOnly', 'treeConfig'),
765 'group' => array('size', 'autoSizeMax', 'max_size', 'show_thumbs', 'maxitems', 'minitems', 'disable_controls', 'readOnly'),
766 'inline' => array('appearance', 'behaviour', 'foreign_label', 'foreign_selector', 'foreign_unique', 'maxitems', 'minitems', 'size', 'autoSizeMax', 'symmetric_label', 'readOnly')
768 // Create instance of InlineElement only if this a non-IRRE-AJAX call:
769 if (!isset($GLOBALS['ajaxID']) ||
strpos($GLOBALS['ajaxID'], 'TYPO3\\CMS\\Backend\\Form\\Element\\InlineElement::') !== 0) {
770 $this->inline
= GeneralUtility
::makeInstance('TYPO3\\CMS\\Backend\\Form\\Element\\InlineElement');
772 // Create instance of \TYPO3\CMS\Backend\Form\Element\SuggestElement only if this a non-Suggest-AJAX call:
773 if (!isset($GLOBALS['ajaxID']) ||
strpos($GLOBALS['ajaxID'], 'TYPO3\\CMS\\Backend\\Form\\Element\\SuggestElement::') !== 0) {
774 $this->suggest
= GeneralUtility
::makeInstance('TYPO3\\CMS\\Backend\\Form\\Element\\SuggestElement');
776 // Prepare user defined objects (if any) for hooks which extend this function:
777 $this->hookObjectsMainFields
= array();
778 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'])) {
779 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'] as $classRef) {
780 $this->hookObjectsMainFields
[] = GeneralUtility
::getUserObj($classRef);
783 $this->hookObjectsSingleField
= array();
784 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getSingleFieldClass'])) {
785 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getSingleFieldClass'] as $classRef) {
786 $this->hookObjectsSingleField
[] = GeneralUtility
::getUserObj($classRef);
789 $this->templateFile
= 'sysext/backend/Resources/Private/Templates/FormEngine.html';
793 * Initialize various internal variables.
796 * @todo Define visibility
798 public function initDefaultBEmode() {
799 $this->prependFormFieldNames
= 'data';
800 $this->formName
= 'editform';
801 $this->setNewBEDesign();
802 $this->edit_showFieldHelp
= (bool)$this->getBackendUserAuthentication()->uc
['edit_showFieldHelp'];
803 $this->edit_docModuleUpload
= (bool)$this->getBackendUserAuthentication()->uc
['edit_docModuleUpload'];
804 $this->inline
->init($this);
805 $this->suggest
->init($this);
808 /*******************************************************
810 * Rendering the forms, fields etc
812 *******************************************************/
814 * Will return the TCEform element for just a single field from a record.
815 * The field must be listed in the currently displayed fields (as found in [types][showitem]) for the record.
816 * This also means that the $table/$row supplied must be complete so the list of fields to show can be found correctly
818 * @param string $table The table name
819 * @param array $row The record from the table for which to render a field.
820 * @param string $theFieldToReturn The field name to return the TCEform element for.
821 * @return string HTML output
822 * @see getMainFields()
823 * @todo Define visibility
825 public function getSoloField($table, $row, $theFieldToReturn) {
826 if ($GLOBALS['TCA'][$table]) {
827 $typeNum = $this->getRTypeNum($table, $row);
828 if ($GLOBALS['TCA'][$table]['types'][$typeNum]) {
829 $itemList = $GLOBALS['TCA'][$table]['types'][$typeNum]['showitem'];
831 $fields = GeneralUtility
::trimExplode(',', $itemList, TRUE);
832 $excludeElements = ($this->excludeElements
= $this->getExcludeElements($table, $row, $typeNum));
833 foreach ($fields as $fieldInfo) {
834 $parts = explode(';', $fieldInfo);
835 $theField = trim($parts[0]);
836 if (!in_array($theField, $excludeElements) && (string)$theField === (string)$theFieldToReturn) {
837 if ($GLOBALS['TCA'][$table]['columns'][$theField]) {
838 $sField = $this->getSingleField($table, $theField, $row, $parts[1], 1, $parts[3], $parts[2]);
839 return $sField['ITEM'];
849 * Based on the $table and $row of content, this displays the complete TCEform for the record.
850 * The input-$row is required to be preprocessed if necessary by eg.
851 * the \TYPO3\CMS\Backend\Form\DataPreprocessor class. For instance the RTE content
852 * should be transformed through this class first.
854 * @param string $table The table name
855 * @param array $row The record from the table for which to render a field.
856 * @param integer $depth Depth level
857 * @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'].
858 * @return string HTML output
859 * @see getSoloField()
860 * @todo Define visibility
862 public function getMainFields($table, array $row, $depth = 0, array $overruleTypesArray = array()) {
863 $this->renderDepth
= $depth;
865 $out_array = array(array());
866 $out_array_meta = array(
868 'title' => $this->getLL('l_generalTab')
873 $this->palettesRendered
= array();
874 $this->palettesRendered
[$this->renderDepth
][$table] = array();
875 // Hook: getMainFields_preProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
876 foreach ($this->hookObjectsMainFields
as $hookObj) {
877 if (method_exists($hookObj, 'getMainFields_preProcess')) {
878 $hookObj->getMainFields_preProcess($table, $row, $this);
881 if ($GLOBALS['TCA'][$table]) {
882 // Get dividers2tabs setting from TCA of the current table:
883 $dividers2tabs = &$GLOBALS['TCA'][$table]['ctrl']['dividers2tabs'];
884 // Load the description content for the table.
885 if ($this->edit_showFieldHelp ||
$this->doLoadTableDescr($table)) {
886 $this->getLanguageService()->loadSingleTableDescription($table);
888 // Get the current "type" value for the record.
889 $typeNum = $this->getRTypeNum($table, $row);
890 // Find the list of fields to display:
891 if ($GLOBALS['TCA'][$table]['types'][$typeNum]) {
892 $itemList = $GLOBALS['TCA'][$table]['types'][$typeNum]['showitem'];
893 if (is_array($overruleTypesArray) && isset($overruleTypesArray[$typeNum]['showitem'])) {
894 $itemList = $overruleTypesArray[$typeNum]['showitem'];
896 // If such a list existed...
898 // Explode the field list and possibly rearrange the order of the fields, if configured for
899 $fields = GeneralUtility
::trimExplode(',', $itemList, TRUE);
900 if ($this->fieldOrder
) {
901 $fields = $this->rearrange($fields);
903 // Get excluded fields, added fiels and put it together:
904 $excludeElements = ($this->excludeElements
= $this->getExcludeElements($table, $row, $typeNum));
905 $fields = $this->mergeFieldsWithAddedFields($fields, $this->getFieldsToAdd($table, $row, $typeNum), $table);
906 // If TCEforms will render a tab menu in the next step, push the name to the tab stack:
907 $tabIdentString = '';
908 $tabIdentStringMD5 = '';
909 if (strstr($itemList, '--div--') !== FALSE && $this->enableTabMenu
&& $dividers2tabs) {
910 $tabIdentString = 'TCEforms:' . $table . ':' . $row['uid'];
911 $tabIdentStringMD5 = $this->getDocumentTemplate()->getDynTabMenuId($tabIdentString);
912 // Remember that were currently working on the general tab:
913 if (isset($fields[0]) && strpos($fields[0], '--div--') !== 0) {
914 $this->pushToDynNestedStack('tab', $tabIdentStringMD5 . '-1');
917 // Traverse the fields to render:
919 foreach ($fields as $fieldInfo) {
920 // Exploding subparts of the field configuration:
921 $parts = explode(';', $fieldInfo);
922 // Getting the style information out:
923 $color_style_parts = GeneralUtility
::trimExplode('-', $parts[4]);
924 if ($color_style_parts[0] !== '') {
925 $this->setColorScheme($GLOBALS['TBE_STYLES']['colorschemes'][(int)$color_style_parts[0]]);
927 if ($color_style_parts[1] !== '') {
928 $this->fieldStyle
= $GLOBALS['TBE_STYLES']['styleschemes'][(int)$color_style_parts[1]];
929 if (!isset($this->fieldStyle
)) {
930 $this->fieldStyle
= $GLOBALS['TBE_STYLES']['styleschemes'][0];
933 if ($color_style_parts[2] !== '') {
934 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
935 $this->borderStyle
= $GLOBALS['TBE_STYLES']['borderschemes'][(int)$color_style_parts[2]];
936 if (!isset($this->borderStyle
)) {
937 $this->borderStyle
= $GLOBALS['TBE_STYLES']['borderschemes'][0];
941 $theField = $parts[0];
942 if (!in_array($theField, $excludeElements)) {
943 if ($GLOBALS['TCA'][$table]['columns'][$theField]) {
945 if ($parts[2] && !isset($this->palettesRendered
[$this->renderDepth
][$table][$parts[2]])) {
946 $sFieldPal = $this->getPaletteFields($table, $row, $parts[2]);
947 $this->palettesRendered
[$this->renderDepth
][$table][$parts[2]] = 1;
949 $sField = $this->getSingleField($table, $theField, $row, $parts[1], 0, $parts[3], $parts[2]);
951 $sField .= $sFieldPal;
953 $out_array[$out_sheet][$out_pointer] .= $sField;
954 } elseif ($theField == '--div--') {
956 $out_array[$out_sheet][$out_pointer] .= $this->getDivider();
957 if ($this->enableTabMenu
&& $dividers2tabs) {
958 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
959 // Remove last tab entry from the dynNestedStack:
961 // Remove the previous sheet from stack (if any):
962 $this->popFromDynNestedStack('tab', $tabIdentStringMD5 . '-' . $out_sheet);
963 // Remember on which sheet we're currently working:
964 $this->pushToDynNestedStack('tab', $tabIdentStringMD5 . '-' . ($out_sheet +
1));
965 $out_array[$out_sheet] = array();
966 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
967 // Register newline for Tab
968 $out_array_meta[$out_sheet]['newline'] = $parts[2] == 'newline';
971 // Setting alternative title for "General" tab if "--div--" is the very first element.
972 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
973 // Only add the first tab to the dynNestedStack if there are more tabs:
974 if ($tabIdentString && strpos($itemList, '--div--', strlen($fieldInfo))) {
975 $this->pushToDynNestedStack('tab', $tabIdentStringMD5 . '-1');
978 } elseif ($theField == '--palette--') {
979 if ($parts[2] && !isset($this->palettesRendered
[$this->renderDepth
][$table][$parts[2]])) {
980 // Render a 'header' if not collapsed
981 if ($GLOBALS['TCA'][$table]['palettes'][$parts[2]]['canNotCollapse'] && $parts[1]) {
982 $out_array[$out_sheet][$out_pointer] .= $this->getPaletteFields($table, $row, $parts[2], $this->sL($parts[1]));
984 $out_array[$out_sheet][$out_pointer] .= $this->getPaletteFields($table, $row, $parts[2], '', '', $this->sL($parts[1]));
986 $this->palettesRendered
[$this->renderDepth
][$table][$parts[2]] = 1;
995 // Hook: getMainFields_postProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
996 foreach ($this->hookObjectsMainFields
as $hookObj) {
997 if (method_exists($hookObj, 'getMainFields_postProcess')) {
998 $hookObj->getMainFields_postProcess($table, $row, $this);
1001 // Wrapping a border around it all:
1002 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
1003 // Resetting styles:
1004 $this->resetSchemes();
1005 // Rendering Main palettes, if any
1006 $mParr = GeneralUtility
::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['mainpalette']);
1008 if (count($mParr)) {
1009 foreach ($mParr as $mP) {
1010 if (!isset($this->palettesRendered
[$this->renderDepth
][$table][$mP])) {
1011 $temp_palettesCollapsed = $this->palettesCollapsed
;
1012 $this->palettesCollapsed
= FALSE;
1013 $label = $i == 0 ?
$this->getLL('l_generalOptions') : $this->getLL('l_generalOptions_more');
1014 $out_array[$out_sheet][$out_pointer] .= $this->getPaletteFields($table, $row, $mP, $label);
1015 $this->palettesCollapsed
= $temp_palettesCollapsed;
1016 $this->palettesRendered
[$this->renderDepth
][$table][$mP] = 1;
1018 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
1020 if ($this->renderDepth
) {
1021 $this->renderDepth
--;
1025 // Return the imploded $out_array:
1026 // There were --div-- dividers around...
1027 if ($out_sheet > 0) {
1028 // Create parts array for the tab menu:
1030 foreach ($out_array as $idx => $sheetContent) {
1031 $content = implode('', $sheetContent);
1033 // Wrap content (row) with table-tag, otherwise tab/sheet will be disabled (see getdynTabMenu() )
1034 $content = '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . $content . '</table>';
1036 $parts[$idx] = array(
1037 'label' => $out_array_meta[$idx]['title'],
1038 'content' => $content,
1039 'newline' => $out_array_meta[$idx]['newline']
1042 if (count($parts) > 1) {
1043 // Unset the current level of tab menus:
1044 $this->popFromDynNestedStack('tab', $tabIdentStringMD5 . '-' . ($out_sheet +
1));
1045 $dividersToTabsBehaviour = isset($GLOBALS['TCA'][$table]['ctrl']['dividers2tabs']) ?
$GLOBALS['TCA'][$table]['ctrl']['dividers2tabs'] : 1;
1046 $output = $this->getDynTabMenu($parts, $tabIdentString, $dividersToTabsBehaviour);
1048 // If there is only one tab/part there is no need to wrap it into the dynTab code
1049 $output = isset($parts[0]) ?
trim($parts[0]['content']) : '';
1058 // Only one tab, so just implode and wrap the background image (= tab container) around:
1059 $output = implode('', $out_array[$out_sheet]);
1060 $output = '<div class="typo3-dyntabmenu-divs">' . $output . '</div>';
1067 * Will return the TCEform elements for a pre-defined list of fields.
1068 * 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.
1069 * Used for displaying forms for the frontend edit icons for instance.
1071 * @param string $table The table name
1072 * @param array $row The record array.
1073 * @param string $list Commalist of fields from the table. These will be shown in the specified order in a form.
1074 * @return string TCEform elements in a string.
1075 * @todo Define visibility
1077 public function getListedFields($table, $row, $list) {
1078 if ($this->edit_showFieldHelp ||
$this->doLoadTableDescr($table)) {
1079 $this->getLanguageService()->loadSingleTableDescription($table);
1082 $types_fieldConfig = BackendUtility
::getTCAtypes($table, $row, 1);
1083 $editFieldList = array_unique(GeneralUtility
::trimExplode(',', $list, TRUE));
1084 foreach ($editFieldList as $theFieldC) {
1085 list($theField, $palFields) = preg_split('/\\[|\\]/', $theFieldC);
1086 $theField = trim($theField);
1087 $palFields = trim($palFields);
1088 if ($GLOBALS['TCA'][$table]['columns'][$theField]) {
1089 $parts = GeneralUtility
::trimExplode(';', $types_fieldConfig[$theField]['origString']);
1090 // Don't sent palette pointer - there are no options anyways for a field-list.
1091 $sField = $this->getSingleField($table, $theField, $row, $parts[1], 0, $parts[3], 0);
1093 } elseif ($theField == '--div--') {
1094 $out .= $this->getDivider();
1097 $out .= $this->getPaletteFields($table, $row, '', '', implode(',', GeneralUtility
::trimExplode('|', $palFields, TRUE)));
1104 * Creates a palette (collection of secondary options).
1106 * @param string $table The table name
1107 * @param array $row The row array
1108 * @param string $palette The palette number/pointer
1109 * @param string $header Header string for the palette (used when in-form). If not set, no header item is made.
1110 * @param string $itemList Optional alternative list of fields for the palette
1111 * @param string $collapsedHeader Optional Link text for activating a palette (when palettes does not have another form element to belong to).
1112 * @return string HTML code.
1113 * @todo Define visibility
1115 public function getPaletteFields($table, $row, $palette, $header = '', $itemList = '', $collapsedHeader = NULL) {
1116 if (!$this->doPrintPalette
) {
1120 $parts = $this->loadPaletteElements($table, $row, $palette, $itemList);
1121 // Put palette together if there are fields in it:
1122 if (count($parts)) {
1124 foreach ($parts as $part) {
1125 if ($part['NAME'] !== '--linebreak--') {
1129 if ($realFields > 0) {
1131 $out .= $this->intoTemplate(array('HEADER' => htmlspecialchars($header)), $this->palFieldTemplateHeader
);
1133 $collapsed = $this->isPalettesCollapsed($table, $palette);
1134 // Check if the palette is a hidden palette
1135 $isHiddenPalette = !empty($GLOBALS['TCA'][$table]['palettes'][$palette]['isHiddenPalette']);
1137 if ($collapsed && $collapsedHeader !== NULL && !$isHiddenPalette) {
1138 list($thePalIcon, ) = $this->wrapOpenPalette(IconUtility
::getSpriteIcon('actions-system-options-view', array('title' => htmlspecialchars($this->getLL('l_moreOptions')))), $table, $row, $palette, 1);
1139 $thePalIcon = '<span style="margin-left: 20px;">' . $thePalIcon . $collapsedHeader . '</span>';
1141 $paletteHtml = $this->wrapPaletteField($this->printPalette($parts), $table, $row, $palette, $collapsed);
1142 $out .= $this->intoTemplate(array('PALETTE' => $thePalIcon . $paletteHtml), $this->palFieldTemplate
);
1149 * Returns the form HTML code for a database table field.
1151 * @param string $table The table name
1152 * @param string $field The field name
1153 * @param array $row The record to edit from the database table.
1154 * @param string $altName Alternative field name label to show.
1155 * @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).
1156 * @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.
1157 * @param integer $pal The palette pointer.
1158 * @return mixed String (normal) or array (palettes)
1159 * @todo Define visibility
1161 public function getSingleField($table, $field, $row, $altName = '', $palette = FALSE, $extra = '', $pal = 0) {
1162 // Hook: getSingleField_preProcess
1163 foreach ($this->hookObjectsSingleField
as $hookObj) {
1164 if (method_exists($hookObj, 'getSingleField_preProcess')) {
1165 $hookObj->getSingleField_preProcess($table, $field, $row, $altName, $palette, $extra, $pal, $this);
1170 $PA['altName'] = $altName;
1171 $PA['palette'] = $palette;
1172 $PA['extra'] = $extra;
1174 // Get the TCA configuration for the current field:
1175 $PA['fieldConf'] = $GLOBALS['TCA'][$table]['columns'][$field];
1176 $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ?
: $PA['fieldConf']['config']['type'];
1178 // Using "form_type" locally in this script
1179 $skipThisField = $this->inline
->skipField($table, $field, $row, $PA['fieldConf']['config']);
1181 // Evaluate display condition
1182 $displayConditionResult = TRUE;
1183 if (is_array($PA['fieldConf']) && $PA['fieldConf']['displayCond'] && is_array($row)) {
1184 /** @var $elementConditionMatcher \TYPO3\CMS\Backend\Form\ElementConditionMatcher */
1185 $elementConditionMatcher = GeneralUtility
::makeInstance('TYPO3\\CMS\\Backend\\Form\\ElementConditionMatcher');
1186 $displayConditionResult = $elementConditionMatcher->match($PA['fieldConf']['displayCond'], $row);
1188 // Check if this field is configured and editable (according to excludefields + other configuration)
1190 is_array($PA['fieldConf'])
1192 && (!$PA['fieldConf']['exclude'] ||
$this->getBackendUserAuthentication()->check('non_exclude_fields', $table . ':' . $field))
1193 && $PA['fieldConf']['config']['form_type'] != 'passthrough'
1194 && ($this->RTEenabled ||
!$PA['fieldConf']['config']['showIfRTE'])
1195 && $displayConditionResult
1196 && (!$GLOBALS['TCA'][$table]['ctrl']['languageField'] ||
$PA['fieldConf']['l10n_display'] ||
($PA['fieldConf']['l10n_mode'] !== 'exclude') ||
$row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] <= 0)
1197 && (!$GLOBALS['TCA'][$table]['ctrl']['languageField'] ||
!$this->localizationMode ||
$this->localizationMode
=== $PA['fieldConf']['l10n_cat'])
1199 // Fetching the TSconfig for the current table/field. This includes the $row which means that
1200 $PA['fieldTSConfig'] = $this->setTSconfig($table, $row, $field);
1201 // If the field is NOT disabled from TSconfig (which it could have been) then render it
1202 if (!$PA['fieldTSConfig']['disabled']) {
1203 // Override fieldConf by fieldTSconfig:
1204 $PA['fieldConf']['config'] = $this->overrideFieldConf($PA['fieldConf']['config'], $PA['fieldTSConfig']);
1206 $PA['itemFormElName'] = $this->prependFormFieldNames
. '[' . $table . '][' . $row['uid'] . '][' . $field . ']';
1207 // Form field name, in case of file uploads
1208 $PA['itemFormElName_file'] = $this->prependFormFieldNames_file
. '[' . $table . '][' . $row['uid'] . '][' . $field . ']';
1209 // Form field name, to activate elements
1210 // If the "eval" list contains "null", elements can be deactivated which results in storing NULL to database
1211 $PA['itemFormElNameActive'] = $this->prependFormFieldNamesActive
. '[' . $table . '][' . $row['uid'] . '][' . $field . ']';
1212 // The value to show in the form field.
1213 $PA['itemFormElValue'] = $row[$field];
1214 $PA['itemFormElID'] = $this->prependFormFieldNames
. '_' . $table . '_' . $row['uid'] . '_' . $field;
1215 // Set field to read-only if configured for translated records to show default language content as readonly
1216 if ($PA['fieldConf']['l10n_display'] && GeneralUtility
::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly') && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] > 0) {
1217 $PA['fieldConf']['config']['readOnly'] = TRUE;
1218 $PA['itemFormElValue'] = $this->defaultLanguageData
[$table . ':' . $row['uid']][$field];
1220 if (strpos($GLOBALS['TCA'][$table]['ctrl']['type'], ':') === FALSE) {
1221 $typeField = $GLOBALS['TCA'][$table]['ctrl']['type'];
1223 $typeField = substr($GLOBALS['TCA'][$table]['ctrl']['type'], 0, strpos($GLOBALS['TCA'][$table]['ctrl']['type'], ':'));
1225 // 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"
1227 !empty($GLOBALS['TCA'][$table]['ctrl']['type'])
1228 && $field === $typeField
1229 ||
!empty($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'])
1230 && GeneralUtility
::inList(str_replace(' ', '', $GLOBALS['TCA'][$table]['ctrl']['requestUpdate']), $field)
1232 if ($this->getBackendUserAuthentication()->jsConfirmation(1)) {
1233 $alertMsgOnChange = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
1235 $alertMsgOnChange = 'if (TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
1238 $alertMsgOnChange = '';
1240 // Render as a hidden field?
1241 if (in_array($field, $this->hiddenFieldListArr
)) {
1242 $this->hiddenFieldAccum
[] = '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1244 // Render as a normal field:
1245 // 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.
1246 if (!$PA['palette']) {
1247 $paletteFields = $this->loadPaletteElements($table, $row, $PA['pal']);
1248 if ($PA['pal'] && $this->isPalettesCollapsed($table, $PA['pal']) && count($paletteFields)) {
1249 list($thePalIcon, $palJSfunc) = $this->wrapOpenPalette(IconUtility
::getSpriteIcon('actions-system-options-view', array('title' => htmlspecialchars($this->getLL('l_moreOptions')))), $table, $row, $PA['pal'], 1);
1255 // onFocus attribute to add to the field:
1256 $PA['onFocus'] = $palJSfunc && !$this->getBackendUserAuthentication()->uc
['dontShowPalettesOnFocusInAB'] ?
' onfocus="' . htmlspecialchars($palJSfunc) . '"' : '';
1257 $PA['label'] = $PA['altName'] ?
: $PA['fieldConf']['label'];
1258 $PA['label'] = $PA['fieldTSConfig']['label'] ?
: $PA['label'];
1259 $PA['label'] = $PA['fieldTSConfig']['label.'][$this->getLanguageService()->lang
] ?
: $PA['label'];
1260 $PA['label'] = $this->sL($PA['label']);
1261 // JavaScript code for event handlers:
1262 $PA['fieldChangeFunc'] = array();
1263 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = 'TBE_EDITOR.fieldChanged(\'' . $table . '\',\'' . $row['uid'] . '\',\'' . $field . '\',\'' . $PA['itemFormElName'] . '\');';
1264 $PA['fieldChangeFunc']['alert'] = $alertMsgOnChange;
1265 // If this is the child of an inline type and it is the field creating the label
1266 if ($this->inline
->isInlineChildAndLabelField($table, $field)) {
1267 $inlineObjectId = implode(InlineElement
::Structure_Separator
, array(
1268 $this->inline
->inlineNames
['object'],
1272 $PA['fieldChangeFunc']['inline'] = 'inline.handleChangedField(\'' . $PA['itemFormElName'] . '\',\'' . $inlineObjectId . '\');';
1274 // Based on the type of the item, call a render function:
1275 $item = $this->getSingleField_SW($table, $field, $row, $PA);
1276 // Add language + diff
1277 if ($PA['fieldConf']['l10n_display'] && (GeneralUtility
::inList($PA['fieldConf']['l10n_display'], 'hideDiff') || GeneralUtility
::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly'))) {
1278 $renderLanguageDiff = FALSE;
1280 $renderLanguageDiff = TRUE;
1282 if ($renderLanguageDiff) {
1283 $item = $this->renderDefaultLanguageContent($table, $field, $row, $item);
1284 $item = $this->renderDefaultLanguageDiff($table, $field, $row, $item);
1286 // 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
1287 $label = htmlspecialchars($PA['label'], ENT_COMPAT
, 'UTF-8', FALSE);
1288 if (MathUtility
::canBeInterpretedAsInteger($row['uid']) && $PA['fieldTSConfig']['linkTitleToSelf'] && !GeneralUtility
::_GP('columnsOnly')) {
1289 $lTTS_url = $this->backPath
. 'alt_doc.php?edit[' . $table . '][' . $row['uid'] . ']=edit&columnsOnly=' . $field . '&returnUrl=' . rawurlencode($this->thisReturnUrl());
1290 $label = '<a href="' . htmlspecialchars($lTTS_url) . '">' . $label . '</a>';
1293 if (isset($PA['fieldConf']['config']['mode']) && $PA['fieldConf']['config']['mode'] == 'useOrOverridePlaceholder') {
1294 $placeholder = $this->getPlaceholderValue($table, $field, $PA['fieldConf']['config'], $row);
1295 $onChange = 'typo3form.fieldTogglePlaceholder(' . GeneralUtility
::quoteJSvalue($PA['itemFormElName']) . ', !this.checked)';
1296 $checked = $PA['itemFormElValue'] === NULL ?
'' : ' checked="checked"';
1298 $this->additionalJS_post
[] = 'typo3form.fieldTogglePlaceholder('
1299 . GeneralUtility
::quoteJSvalue($PA['itemFormElName']) . ', ' . ($checked ?
'false' : 'true') . ');';
1301 $item = '<div class="t3-form-field-placeholder-override">'
1302 . '<span class="t3-tceforms-placeholder-override-checkbox">' .
1303 '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElNameActive']) . '" value="0" />' .
1304 '<input type="checkbox" name="' . htmlspecialchars($PA['itemFormElNameActive']) . '" value="1" id="tce-forms-textfield-use-override-' . $field . '-' . $row['uid'] . '" onchange="' . htmlspecialchars($onChange) . '"' . $checked . ' />' .
1305 '<label for="tce-forms-textfield-use-override-' . $field . '-' . $row['uid'] . '">' .
1306 sprintf($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.placeholder.override'),
1307 BackendUtility
::getRecordTitlePrep($placeholder, 20)) . '</label>' .
1309 . '<div class="t3-form-placeholder-placeholder">' . $this->getSingleField_typeNone_render(
1310 $PA['fieldConf']['config'], GeneralUtility
::fixed_lgd_cs($placeholder, 30)
1312 . '<div class="t3-form-placeholder-formfield">' . $item . '</div>'
1316 // Wrap the label with help text
1317 $PA['label'] = ($label = BackendUtility
::wrapInHelp($table, $field, $label));
1318 // Create output value:
1319 if ($PA['fieldConf']['config']['form_type'] == 'user' && $PA['fieldConf']['config']['noTableWrapping']) {
1321 } elseif ($PA['palette']) {
1325 'ID' => $row['uid'],
1329 'ITEM_DISABLED' => ($this->isDisabledNullValueField($table, $field, $row, $PA) ?
' disabled' : ''),
1330 'ITEM_NULLVALUE' => $this->renderNullValueWidget($table, $field, $row, $PA),
1332 $out = $this->addUserTemplateMarkers($out, $table, $field, $row, $PA);
1339 'ID' => $row['uid'],
1340 'PAL_LINK_ICON' => $thePalIcon,
1342 'ITEM_DISABLED' => ($this->isDisabledNullValueField($table, $field, $row, $PA) ?
' disabled' : ''),
1343 'ITEM_NULLVALUE' => $this->renderNullValueWidget($table, $field, $row, $PA),
1345 $out = $this->addUserTemplateMarkers($out, $table, $field, $row, $PA);
1347 $out = $this->intoTemplate($out);
1351 $this->commentMessages
[] = $this->prependFormFieldNames
. '[' . $table . '][' . $row['uid'] . '][' . $field . ']: Disabled by TSconfig';
1354 // Hook: getSingleField_postProcess
1355 foreach ($this->hookObjectsSingleField
as $hookObj) {
1356 if (method_exists($hookObj, 'getSingleField_postProcess')) {
1357 $hookObj->getSingleField_postProcess($table, $field, $row, $out, $PA, $this);
1360 // Return value (string or array)
1365 * Rendering a single item for the form
1367 * @param string $table Table name of record
1368 * @param string $field Fieldname to render
1369 * @param array $row The record
1370 * @param array $PA Parameters array containing a lot of stuff. Value by Reference!
1371 * @return string Returns the item as HTML code to insert
1373 * @see getSingleField(), getSingleField_typeFlex_draw()
1374 * @todo Define visibility
1376 public function getSingleField_SW($table, $field, $row, &$PA) {
1377 $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ?
: $PA['fieldConf']['config']['type'];
1378 // Using "form_type" locally in this script
1379 // Hook: getSingleField_beforeRender
1380 foreach ($this->hookObjectsSingleField
as $hookObject) {
1381 if (method_exists($hookObject, 'getSingleField_beforeRender')) {
1382 $hookObject->getSingleField_beforeRender($table, $field, $row, $PA);
1385 switch ($PA['fieldConf']['config']['form_type']) {
1387 $item = $this->getSingleField_typeInput($table, $field, $row, $PA);
1390 $item = $this->getSingleField_typeText($table, $field, $row, $PA);
1393 $item = $this->getSingleField_typeCheck($table, $field, $row, $PA);
1396 $item = $this->getSingleField_typeRadio($table, $field, $row, $PA);
1399 $item = $this->getSingleField_typeSelect($table, $field, $row, $PA);
1402 $item = $this->getSingleField_typeGroup($table, $field, $row, $PA);
1405 $item = $this->inline
->getSingleField_typeInline($table, $field, $row, $PA);
1408 $item = $this->getSingleField_typeNone($table, $field, $row, $PA);
1411 $item = $this->getSingleField_typeUser($table, $field, $row, $PA);
1414 $item = $this->getSingleField_typeFlex($table, $field, $row, $PA);
1417 $item = $this->getSingleField_typeUnknown($table, $field, $row, $PA);
1422 /**********************************************************
1424 * Rendering of each TCEform field type
1426 ************************************************************/
1428 * Generation of TCEform elements of the type "input"
1429 * This will render a single-line input form field, possibly with various control/validation features
1431 * @param string $table The table name of the record
1432 * @param string $field The field name which this element is supposed to edit
1433 * @param array $row The record data array where the value(s) for the field can be found
1434 * @param array $PA An array with additional configuration options.
1435 * @return string The HTML code for the TCEform field
1436 * @todo Define visibility
1438 public function getSingleField_typeInput($table, $field, $row, &$PA) {
1439 $config = $PA['fieldConf']['config'];
1440 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1441 $size = MathUtility
::forceIntegerInRange($config['size'] ?
$config['size'] : 30, 5, $this->maxInputWidth
);
1442 $evalList = GeneralUtility
::trimExplode(',', $config['eval'], TRUE);
1443 $classAndStyleAttributes = $this->formWidthAsArray($size);
1444 $fieldAppendix = '';
1446 $cssClasses = array($classAndStyleAttributes['class']);
1447 $cssStyle = $classAndStyleAttributes['style'];
1448 if (!isset($config['checkbox'])) {
1449 $config['checkbox'] = '0';
1450 $checkboxIsset = FALSE;
1452 $checkboxIsset = TRUE;
1454 if (in_array('date', $evalList) ||
in_array('datetime', $evalList)) {
1455 if (in_array('datetime', $evalList)) {
1456 $class = 'datetime';
1461 if (isset($config['range']['lower'])) {
1462 $dateRange .= ' lower-' . (int)$config['range']['lower'];
1464 if (isset($config['range']['upper'])) {
1465 $dateRange .= ' upper-' . (int)$config['range']['upper'];
1467 $inputId = uniqid('tceforms-' . $class . 'field-');
1468 $cssClasses[] = 'tceforms-textfield tceforms-' . $class . 'field' . $dateRange;
1469 $fieldAppendix = IconUtility
::getSpriteIcon('actions-edit-pick-date', array(
1470 'style' => 'cursor:pointer;',
1471 'id' => 'picker-' . $inputId
1473 } elseif (in_array('timesec', $evalList)) {
1474 $inputId = uniqid('tceforms-timesecfield-');
1475 $cssClasses[] = 'tceforms-textfield tceforms-timesecfield';
1476 } elseif (in_array('year', $evalList)) {
1477 $inputId = uniqid('tceforms-yearfield-');
1478 $cssClasses[] = 'tceforms-textfield tceforms-yearfield';
1479 } elseif (in_array('time', $evalList)) {
1480 $inputId = uniqid('tceforms-timefield-');
1481 $cssClasses[] = 'tceforms-textfield tceforms-timefield';
1482 } elseif (in_array('int', $evalList)) {
1483 $inputId = uniqid('tceforms-intfield-');
1484 $cssClasses[] = 'tceforms-textfield tceforms-intfield';
1485 } elseif (in_array('double2', $evalList)) {
1486 $inputId = uniqid('tceforms-double2field-');
1487 $cssClasses[] = 'tceforms-textfield tceforms-double2field';
1489 $inputId = uniqid('tceforms-textfield-');
1490 $cssClasses[] = 'tceforms-textfield';
1491 if ($checkboxIsset === FALSE) {
1492 $config['checkbox'] = '';
1495 if (isset($config['wizards']['link'])) {
1496 $inputId = uniqid('tceforms-linkfield-');
1497 $cssClasses[] = 'tceforms-textfield tceforms-linkfield';
1498 } elseif (isset($config['wizards']['color'])) {
1499 $inputId = uniqid('tceforms-colorfield-');
1500 $cssClasses[] = 'tceforms-textfield tceforms-colorfield';
1502 if ($this->renderReadonly ||
$config['readOnly']) {
1503 $itemFormElValue = $PA['itemFormElValue'];
1504 if (in_array('date', $evalList)) {
1505 $config['format'] = 'date';
1506 } elseif (in_array('datetime', $evalList)) {
1507 $config['format'] = 'datetime';
1508 } elseif (in_array('time', $evalList)) {
1509 $config['format'] = 'time';
1511 if (in_array('password', $evalList)) {
1512 $itemFormElValue = $itemFormElValue ?
'*********' : '';
1514 return $this->getSingleField_typeNone_render($config, $itemFormElValue);
1516 foreach ($evalList as $func) {
1519 $this->registerRequiredProperty('field', $table . '_' . $row['uid'] . '_' . $field, $PA['itemFormElName']);
1520 // Mark this field for date/time disposal:
1521 if (array_intersect($evalList, array('date', 'datetime', 'time'))) {
1522 $this->requiredAdditional
[$PA['itemFormElName']]['isPositiveNumber'] = TRUE;
1526 // Pair hook to the one in \TYPO3\CMS\Core\DataHandling\DataHandler::checkValue_input_Eval()
1527 $evalObj = GeneralUtility
::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
1528 if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue')) {
1530 'value' => $PA['itemFormElValue']
1532 $PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
1536 $paramsList = '\'' . $PA['itemFormElName'] . '\',\'' . implode(',', $evalList) . '\',\'' . trim($config['is_in']) . '\',' . (isset($config['checkbox']) ?
1 : 0) . ',\'' . $config['checkbox'] . '\'';
1537 if (in_array('date', $evalList) ||
in_array('datetime', $evalList)) {
1538 $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\';">';
1539 // Add server timezone offset to UTC to our stored date
1540 if ($PA['itemFormElValue'] > 0) {
1541 $PA['itemFormElValue'] +
= date('Z', $PA['itemFormElValue']);
1544 $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\';">';
1546 $PA['fieldChangeFunc'] = array_merge(array('typo3form.fieldGet' => 'typo3form.fieldGet(' . $paramsList . ');'), $PA['fieldChangeFunc']);
1547 // Old function "checkbox" now the option to set the date / remove the date
1548 if (isset($config['checkbox'])) {
1549 $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'])));
1551 $mLgd = $config['max'] ?
: 256;
1552 $iOnChange = implode('', $PA['fieldChangeFunc']);
1553 $cssClasses[] = 'hasDefaultValue';
1554 $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'] . ' />';
1555 // This is the EDITABLE form field.
1556 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1557 // 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.
1558 $item .= $fieldAppendix . '</span><div style="clear:both;"></div>';
1559 $this->extJSCODE
.= 'typo3form.fieldSet(' . $paramsList . ');';
1560 // Going through all custom evaluations configured for this field
1561 foreach ($evalList as $evalData) {
1562 $evalObj = GeneralUtility
::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$evalData] . ':&' . $evalData);
1563 if (is_object($evalObj) && method_exists($evalObj, 'returnFieldJS')) {
1564 $this->extJSCODE
.= '
1565 TBE_EDITOR.customEvalFunctions[\'' . $evalData . '\'] = function(value) {
1566 ' . $evalObj->returnFieldJS() . '
1571 // Creating an alternative item without the JavaScript handlers.
1572 $altItem = '<input type="hidden" name="' . $PA['itemFormElName'] . '_hr" value="" />';
1573 $altItem .= '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1574 // Wrap a wizard around the item?
1575 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'] . '_hr', $specConf);
1581 * Renders a view widget to handle and activate NULL values.
1582 * The widget is enabled by using 'null' in the 'eval' TCA definition.
1584 * @param string $table Name of the table
1585 * @param string $field Name of the field
1586 * @param array $row Accordant data of the record row
1587 * @param array $PA Parameters array with rendering instructions
1588 * @return string Widget (if any).
1590 protected function renderNullValueWidget($table, $field, array $row, array $PA) {
1593 $config = $PA['fieldConf']['config'];
1594 if (!empty($config['eval']) && GeneralUtility
::inList($config['eval'], 'null') && (empty($config['mode']) ||
$config['mode'] !== 'useOrOverridePlaceholder')) {
1595 $isNull = ($PA['itemFormElValue'] === NULL);
1597 $checked = ($isNull ?
'' : ' checked="checked"');
1598 $onChange = htmlspecialchars(
1599 'typo3form.fieldSetNull(\'' . $PA['itemFormElName'] . '\', !this.checked)'
1602 $widget = '<span class="t3-tceforms-widget-null-wrapper">' .
1603 '<input type="hidden" name="' . $PA['itemFormElNameActive'] . '" value="0" />' .
1604 '<input type="checkbox" name="' . $PA['itemFormElNameActive'] . '" value="1" onchange="' . $onChange . '"' . $checked . ' />' .
1612 * Determines whether the current field value is considered as NULL value.
1613 * Using NULL values is enabled by using 'null' in the 'eval' TCA definition.
1615 * @param string $table Name of the table
1616 * @param string $field Name of the field
1617 * @param array $row Accordant data
1618 * @param array $PA Parameters array with rendering instructions
1621 protected function isDisabledNullValueField($table, $field, array $row, array $PA) {
1624 $config = $PA['fieldConf']['config'];
1625 if ($PA['itemFormElValue'] === NULL && !empty($config['eval'])
1626 && GeneralUtility
::inList($config['eval'], 'null')
1627 && (empty($config['mode']) ||
$config['mode'] !== 'useOrOverridePlaceholder')) {
1636 * Generation of TCEform elements of the type "text"
1637 * This will render a <textarea> OR RTE area form field, possibly with various control/validation features
1639 * @param string $table The table name of the record
1640 * @param string $field The field name which this element is supposed to edit
1641 * @param array $row The record data array where the value(s) for the field can be found
1642 * @param array $PA An array with additional configuration options.
1643 * @return string The HTML code for the TCEform field
1644 * @todo Define visibility
1646 public function getSingleField_typeText($table, $field, $row, &$PA) {
1648 $config = $PA['fieldConf']['config'];
1649 $evalList = GeneralUtility
::trimExplode(',', $config['eval'], TRUE);
1650 if ($this->renderReadonly ||
$config['readOnly']) {
1651 return $this->getSingleField_typeNone_render($config, $PA['itemFormElValue']);
1653 // Setting columns number:
1654 $cols = MathUtility
::forceIntegerInRange($config['cols'] ?
$config['cols'] : 30, 5, $this->maxTextareaWidth
);
1655 // Setting number of rows:
1656 $origRows = ($rows = MathUtility
::forceIntegerInRange($config['rows'] ?
$config['rows'] : 5, 1, 20));
1657 if (strlen($PA['itemFormElValue']) > $this->charsPerRow
* 2) {
1658 $cols = $this->maxTextareaWidth
;
1659 $rows = MathUtility
::forceIntegerInRange(round(strlen($PA['itemFormElValue']) / $this->charsPerRow
), count(explode(LF
, $PA['itemFormElValue'])), 20);
1660 if ($rows < $origRows) {
1664 if (in_array('required', $evalList)) {
1665 $this->requiredFields
[$table . '_' . $row['uid'] . '_' . $field] = $PA['itemFormElName'];
1668 // Set TRUE, if the RTE is loaded; If not a normal textarea is shown.
1670 // Set TRUE, if the RTE would have been loaded if it wasn't for the disable-RTE flag in the bottom of the page...
1671 $RTEwouldHaveBeenLoaded = 0;
1672 // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. Traditionally, this is where RTE configuration has been found.
1673 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1674 // Setting up the altItem form field, which is a hidden field containing the value
1675 $altItem = '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1676 // If RTE is generally enabled (TYPO3_CONF_VARS and user settings)
1677 if ($this->RTEenabled
) {
1678 $p = BackendUtility
::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
1679 // If the field is configured for RTE and if any flag-field is not set to disable it.
1680 if (isset($specConf['richtext']) && (!$p['flag'] ||
!$row[$p['flag']])) {
1681 BackendUtility
::fixVersioningPid($table, $row);
1682 list($tscPID, $thePidValue) = $this->getTSCpid($table, $row['uid'], $row['pid']);
1683 // If the pid-value is not negative (that is, a pid could NOT be fetched)
1684 if ($thePidValue >= 0) {
1685 $RTEsetup = $this->getBackendUserAuthentication()->getTSConfig('RTE', BackendUtility
::getPagesTSconfig($tscPID));
1686 $RTEtypeVal = BackendUtility
::getTCAtypeValue($table, $row);
1687 $thisConfig = BackendUtility
::RTEsetup($RTEsetup['properties'], $table, $field, $RTEtypeVal);
1688 if (!$thisConfig['disabled']) {
1689 if (!$this->disableRTE
) {
1690 $this->RTEcounter++
;
1691 // Find alternative relative path for RTE images/links:
1692 $eFile = RteHtmlParser
::evalWriteFile($specConf['static_write'], $row);
1693 $RTErelPath = is_array($eFile) ?
dirname($eFile['relEditFile']) : '';
1694 // Get RTE object, draw form and set flag:
1695 $RTEobj = BackendUtility
::RTEgetObj();
1696 $item = $RTEobj->drawRTE($this, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue);
1698 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf, 1);
1701 $RTEwouldHaveBeenLoaded = 1;
1702 $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!)';
1705 $this->commentMessages
[] = $PA['itemFormElName'] . ': RTE is disabled by the Page TSconfig, "RTE"-key (eg. by RTE.default.disabled=0 or such)';
1708 $this->commentMessages
[] = $PA['itemFormElName'] . ': PID value could NOT be fetched. Rare error, normally with new records.';
1711 if (!isset($specConf['richtext'])) {
1712 $this->commentMessages
[] = $PA['itemFormElName'] . ': RTE was not configured for this field in TCA-types';
1714 if (!(!$p['flag'] ||
!$row[$p['flag']])) {
1715 $this->commentMessages
[] = $PA['itemFormElName'] . ': Field-flag (' . $PA['flag'] . ') has been set to disable RTE!';
1719 // Display ordinary field if RTE was not loaded.
1720 if (!$RTEwasLoaded) {
1721 // Show message, if no RTE (field can only be edited with RTE!)
1722 if ($specConf['rte_only']) {
1723 $item = '<p><em>' . htmlspecialchars($this->getLL('l_noRTEfound')) . '</em></p>';
1725 if ($specConf['nowrap']) {
1728 $wrap = $config['wrap'] ?
: 'virtual';
1731 if ($specConf['fixed-font']) {
1732 $classes[] = 'fixed-font';
1734 if ($specConf['enable-tab']) {
1735 $classes[] = 'enable-tab';
1737 $formWidthText = $this->formWidthText($cols, $wrap);
1738 // Extract class attributes from $formWidthText (otherwise it would be added twice to the output)
1740 if (preg_match('/ class="(.+?)"/', $formWidthText, $res)) {
1741 $formWidthText = str_replace(' class="' . $res[1] . '"', '', $formWidthText);
1742 $classes = array_merge($classes, explode(' ', $res[1]));
1744 if (count($classes)) {
1745 $class = ' class="tceforms-textarea ' . implode(' ', $classes) . '"';
1747 $class = 'tceforms-textarea';
1749 $evalList = GeneralUtility
::trimExplode(',', $config['eval'], TRUE);
1750 foreach ($evalList as $func) {
1753 $this->registerRequiredProperty('field', $table . '_' . $row['uid'] . '_' . $field, $PA['itemFormElName']);
1756 // Pair hook to the one in \TYPO3\CMS\Core\DataHandling\DataHandler::checkValue_input_Eval() and \TYPO3\CMS\Core\DataHandling\DataHandler::checkValue_text_Eval()
1757 $evalObj = GeneralUtility
::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
1758 if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue')) {
1760 'value' => $PA['itemFormElValue']
1762 $PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
1766 $iOnChange = implode('', $PA['fieldChangeFunc']);
1768 <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>';
1769 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf, $RTEwouldHaveBeenLoaded);
1772 // Return field HTML:
1777 * Generation of TCEform elements of the type "check"
1778 * This will render a check-box OR an array of checkboxes
1780 * @param string $table The table name of the record
1781 * @param string $field The field name which this element is supposed to edit
1782 * @param array $row The record data array where the value(s) for the field can be found
1783 * @param array $PA An array with additional configuration options.
1784 * @return string The HTML code for the TCEform field
1785 * @todo Define visibility
1787 public function getSingleField_typeCheck($table, $field, $row, &$PA) {
1788 $config = $PA['fieldConf']['config'];
1791 if ($this->renderReadonly ||
$config['readOnly']) {
1792 $disabled = ' disabled="disabled"';
1794 // Traversing the array of items:
1795 $selItems = $this->initItemArray($PA['fieldConf']);
1796 if ($config['itemsProcFunc']) {
1797 $selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
1799 if (!count($selItems)) {
1800 $selItems[] = array('', '');
1802 $thisValue = (int)$PA['itemFormElValue'];
1803 $cols = (int)$config['cols'];
1804 $selItemsCount = count($selItems);
1806 $item .= '<table border="0" cellspacing="0" cellpadding="0" class="typo3-TCEforms-checkboxArray">';
1807 for ($c = 0; $c < $selItemsCount; $c++
) {
1809 if (!($c %
$cols)) {
1812 $cBP = $this->checkBoxParams($PA['itemFormElName'], $thisValue, $c, count($selItems), implode('', $PA['fieldChangeFunc']));
1813 $cBName = $PA['itemFormElName'] . '_' . $c;
1814 $cBID = $PA['itemFormElID'] . '_' . $c;
1815 $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> ')) . '</td>';
1816 if ($c %
$cols +
1 == $cols) {
1821 $rest = $cols - $c %
$cols;
1822 for ($c = 0; $c < $rest; $c++
) {
1823 $item .= '<td></td>';
1829 $item .= '</table>';
1831 for ($c = 0; $c < $selItemsCount; $c++
) {
1833 $cBP = $this->checkBoxParams($PA['itemFormElName'], $thisValue, $c, count($selItems), implode('', $PA['fieldChangeFunc']));
1834 $cBName = $PA['itemFormElName'] . '_' . $c;
1835 $cBID = $PA['itemFormElID'] . '_' . $c;
1836 $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>'));
1840 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($thisValue) . '" />';
1846 * Generation of TCEform elements of the type "radio"
1847 * This will render a series of radio buttons.
1849 * @param string $table The table name of the record
1850 * @param string $field The field name which this element is supposed to edit
1851 * @param array $row The record data array where the value(s) for the field can be found
1852 * @param array $PA An array with additional configuration options.
1853 * @return string The HTML code for the TCEform field
1854 * @todo Define visibility
1856 public function getSingleField_typeRadio($table, $field, $row, &$PA) {
1857 $config = $PA['fieldConf']['config'];
1860 if ($this->renderReadonly ||
$config['readOnly']) {
1861 $disabled = ' disabled="disabled"';
1863 // Get items for the array:
1864 $selItems = $this->initItemArray($PA['fieldConf']);
1865 if ($config['itemsProcFunc']) {
1866 $selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
1868 // Traverse the items, making the form elements:
1869 $selItemsCount = count($selItems);
1870 for ($c = 0; $c < $selItemsCount; $c++
) {
1872 $rID = $PA['itemFormElID'] . '_' . $c;
1873 $rOnClick = implode('', $PA['fieldChangeFunc']);
1874 $rChecked = (string)$p[1] === (string)$PA['itemFormElValue'] ?
' checked="checked"' : '';
1875 $item .= '<input type="radio"' . $this->insertDefStyle('radio') . ' name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($p[1]) . '" onclick="' . htmlspecialchars($rOnClick) . '"' . $rChecked . $PA['onFocus'] . $disabled . ' id="' . $rID . '" />
1876 <label for="' . $rID . '">' . htmlspecialchars($p[0]) . '</label>
1883 * Generation of TCEform elements of the type "select"
1884 * This will render a selector box element, or possibly a special construction with two selector boxes. That depends on configuration.
1886 * @param string $table The table name of the record
1887 * @param string $field The field name which this element is supposed to edit
1888 * @param array $row The record data array where the value(s) for the field can be found
1889 * @param array $PA An array with additional configuration options.
1890 * @return string The HTML code for the TCEform field
1891 * @todo Define visibility
1893 public function getSingleField_typeSelect($table, $field, $row, &$PA) {
1894 // Field configuration from TCA:
1895 $config = $PA['fieldConf']['config'];
1897 if ($this->renderReadonly ||
$config['readOnly']) {
1898 $disabled = ' disabled="disabled"';
1900 // "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/.
1901 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1902 $selItems = $this->getSelectItems($table, $field, $row, $PA);
1904 // Creating the label for the "No Matching Value" entry.
1905 $nMV_label = isset($PA['fieldTSConfig']['noMatchingValue_label']) ?
$this->sL($PA['fieldTSConfig']['noMatchingValue_label']) : '[ ' . $this->getLL('l_noMatchingValue') . ' ]';
1906 // Prepare some values:
1907 $maxitems = (int)$config['maxitems'];
1908 // If a SINGLE selector box...
1909 if ($maxitems <= 1 && $config['renderMode'] !== 'tree') {
1910 $item = $this->getSingleField_typeSelect_single($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1911 } elseif ($config['renderMode'] === 'checkbox') {
1912 // Checkbox renderMode
1913 $item = $this->getSingleField_typeSelect_checkbox($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1914 } elseif ($config['renderMode'] === 'singlebox') {
1915 // Single selector box renderMode
1916 $item = $this->getSingleField_typeSelect_singlebox($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1917 } elseif ($config['renderMode'] === 'tree') {
1919 $treeClass = GeneralUtility
::makeInstance('TYPO3\\CMS\\Backend\\Form\\Element\\TreeElement', $this);
1920 $item = $treeClass->renderField($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1921 // Register the required number of elements
1922 $minitems = MathUtility
::forceIntegerInRange($config['minitems'], 0);
1923 $this->registerRequiredProperty('range', $PA['itemFormElName'], array($minitems, $maxitems, 'imgName' => $table . '_' . $row['uid'] . '_' . $field));
1925 // Traditional multiple selector box:
1926 $item = $this->getSingleField_typeSelect_multiple($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1930 $altItem = '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1931 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf);
1937 * Collects the items for a select field by reading the configured
1938 * select items from the configuration and / or by collecting them
1939 * from a foreign table.
1941 * @param string $table The table name of the record
1942 * @param string $fieldName The select field name
1943 * @param array $row The record data array where the value(s) for the field can be found
1944 * @param array $PA An array with additional configuration options.
1947 public function getSelectItems($table, $fieldName, array $row, array $PA) {
1948 $config = $PA['fieldConf']['config'];
1950 // Getting the selector box items from the system
1951 $selectItems = $this->addSelectOptionsToItemArray(
1952 $this->initItemArray($PA['fieldConf']),
1954 $this->setTSconfig($table, $row),
1958 // Possibly filter some items:
1959 $selectItems = GeneralUtility
::keepItemsInArray(
1961 $PA['fieldTSConfig']['keepItems'],
1967 // Possibly add some items:
1968 $selectItems = $this->addItems($selectItems, $PA['fieldTSConfig']['addItems.']);
1970 // Process items by a user function:
1971 if (isset($config['itemsProcFunc']) && $config['itemsProcFunc']) {
1972 $selectItems = $this->procItems($selectItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $fieldName);
1975 // Possibly remove some items:
1976 $removeItems = GeneralUtility
::trimExplode(',', $PA['fieldTSConfig']['removeItems'], TRUE);
1977 foreach ($selectItems as $selectItemIndex => $selectItem) {
1979 // Checking languages and authMode:
1980 $languageDeny = FALSE;
1981 $beUserAuth = $this->getBackendUserAuthentication();
1983 !empty($GLOBALS['TCA'][$table]['ctrl']['languageField'])
1984 && $GLOBALS['TCA'][$table]['ctrl']['languageField'] === $fieldName
1985 && !$beUserAuth->checkLanguageAccess($selectItem[1])
1987 $languageDeny = TRUE;
1990 $authModeDeny = FALSE;
1992 ($config['form_type'] === 'select')
1993 && $config['authMode']
1994 && !$beUserAuth->checkAuthMode($table, $fieldName, $selectItem[1], $config['authMode'])
1996 $authModeDeny = TRUE;
1999 if (in_array($selectItem[1], $removeItems) ||
$languageDeny ||
$authModeDeny) {
2000 unset($selectItems[$selectItemIndex]);
2001 } elseif (isset($PA['fieldTSConfig']['altLabels.'][$selectItem[1]])) {
2002 $selectItems[$selectItemIndex][0] = htmlspecialchars($this->sL($PA['fieldTSConfig']['altLabels.'][$selectItem[1]]));
2005 // Removing doktypes with no access:
2006 if (($table === 'pages' ||
$table === 'pages_language_overlay') && $fieldName === 'doktype') {
2007 if (!($beUserAuth->isAdmin() || GeneralUtility
::inList($beUserAuth->groupData
['pagetypes_select'], $selectItem[1]))) {
2008 unset($selectItems[$selectItemIndex]);
2013 return $selectItems;
2017 * Creates a single-selector box
2018 * (Render function for getSingleField_typeSelect())
2020 * @param string $table See getSingleField_typeSelect()
2021 * @param string $field See getSingleField_typeSelect()
2022 * @param array $row See getSingleField_typeSelect()
2023 * @param array $PA See getSingleField_typeSelect()
2024 * @param array $config (Redundant) content of $PA['fieldConf']['config'] (for convenience)
2025 * @param array $selItems Items available for selection
2026 * @param string $nMV_label Label for no-matching-value
2027 * @return string The HTML code for the item
2028 * @see getSingleField_typeSelect()
2029 * @todo Define visibility
2031 public function getSingleField_typeSelect_single($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
2032 // check against inline uniqueness
2033 $inlineParent = $this->inline
->getStructureLevel(-1);
2034 if (is_array($inlineParent) && $inlineParent['uid']) {
2035 if ($inlineParent['config']['foreign_table'] == $table && $inlineParent['config']['foreign_unique'] == $field) {
2036 $uniqueIds = $this->inline
->inlineData
['unique'][$this->inline
->inlineNames
['object'] . InlineElement
::Structure_Separator
. $table]['used'];
2037 $PA['fieldChangeFunc']['inlineUnique'] = 'inline.updateUnique(this,\'' . $this->inline
->inlineNames
['object'] . InlineElement
::Structure_Separator
. $table . '\',\'' . $this->inline
->inlineNames
['form'] . '\',\'' . $row['uid'] . '\');';
2039 // hide uid of parent record for symmetric relations
2040 if ($inlineParent['config']['foreign_table'] == $table && ($inlineParent['config']['foreign_field'] == $field ||
$inlineParent['config']['symmetric_field'] == $field)) {
2041 $uniqueIds[] = $inlineParent['uid'];
2047 $noMatchingValue = 1;
2049 $selicons = array();
2050 $onlySelectedIconShown = 0;
2051 $size = (int)$config['size'];
2052 // Style set on <select/>
2053 $selectedStyle = '';
2056 // TODO: icon is used but never assigned
2058 if ($this->renderReadonly ||
$config['readOnly']) {
2059 $disabled = ' disabled="disabled"';
2060 $onlySelectedIconShown = 1;
2062 // Register as required if minitems is greater than zero
2063 if (($minItems = MathUtility
::forceIntegerInRange($config['minitems'], 0)) > 0) {
2064 $this->registerRequiredProperty('field', $table . '_' . $row['uid'] . '_' . $field, $PA['itemFormElName']);
2067 // Icon configuration:
2068 if ($config['suppress_icons'] == 'IF_VALUE_FALSE') {
2069 $suppressIcons = !$PA['itemFormElValue'] ?
1 : 0;
2070 } elseif ($config['suppress_icons'] == 'ONLY_SELECTED') {
2072 $onlySelectedIconShown = 1;
2073 } elseif ($config['suppress_icons']) {
2078 // Traverse the Array of selector box items:
2079 $optGroupStart = array();
2080 $optGroupOpen = FALSE;
2081 $classesForSelectTag = array();
2082 foreach ($selItems as $p) {
2083 $sM = (string)$PA['itemFormElValue'] === (string)$p[1] ?
' selected="selected"' : '';
2086 $noMatchingValue = 0;
2088 // Getting style attribute value (for icons):
2089 if ($config['iconsInOptionTags']) {
2090 $styleAttrValue = $this->optionTagStyle($p[2]);
2092 list($selectIconFile, $selectIconInfo) = $this->getIcon($p[2]);
2093 if (!empty($selectIconInfo)) {
2094 $selectedStyle = ' style="background-image:url(' . $selectIconFile . ');"';
2095 $classesForSelectTag[] = 'typo3-TCEforms-select-selectedItemWithBackgroundImage';
2099 // Compiling the <option> tag:
2100 if (!($p[1] != $PA['itemFormElValue'] && is_array($uniqueIds) && in_array($p[1], $uniqueIds))) {
2101 if ($p[1] === '--div--') {
2102 $optGroupStart[0] = $p[0];
2103 if ($config['iconsInOptionTags']) {
2104 $optGroupStart[1] = $this->optgroupTagStyle($p[2]);
2106 $optGroupStart[1] = $styleAttrValue;
2109 if (count($optGroupStart)) {
2110 // Closing last optgroup before next one starts
2111 if ($optGroupOpen) {
2112 $opt[] = '</optgroup>' . LF
;
2114 $opt[] = '<optgroup label="' . htmlspecialchars($optGroupStart[0], ENT_COMPAT
, 'UTF-8', FALSE) . '"' . ($optGroupStart[1] ?
' style="' . htmlspecialchars($optGroupStart[1]) . '"' : '') . ' class="c-divider">' . LF
;
2115 $optGroupOpen = TRUE;
2117 $optGroupStart = array();
2119 $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' . $sM . ($styleAttrValue ?
' style="' . htmlspecialchars($styleAttrValue) . '"' : '') . '>' . htmlspecialchars($p[0], ENT_COMPAT
, 'UTF-8', FALSE) . '</option>' . LF
;
2122 // If there is an icon for the selector box (rendered in selicon-table below)...:
2123 // if there is an icon ($p[2]), icons should be shown, and, if only selected are visible, is it selected
2124 if ($p[2] && !$suppressIcons && (!$onlySelectedIconShown ||
$sM)) {
2125 list($selIconFile, $selIconInfo) = $this->getIcon($p[2]);
2126 if (!empty($selIconInfo)) {
2127 $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;';
2129 $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;';
2131 $selicons[] = array(
2132 (!$onlySelectedIconShown ?
'<a href="#" onclick="' . htmlspecialchars($iOnClick) . '">' : '') . $this->getIconHtml($p[2], htmlspecialchars($p[0]), htmlspecialchars($p[0])) . (!$onlySelectedIconShown ?
'</a>' : ''),
2139 // Closing optgroup if open
2140 if ($optGroupOpen) {
2141 $opt[] = '</optgroup>';
2143 // No-matching-value:
2144 if ($PA['itemFormElValue'] && $noMatchingValue && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
2145 $nMV_label = @sprintf
($nMV_label, $PA['itemFormElValue']);
2146 $opt[] = '<option value="' . htmlspecialchars($PA['itemFormElValue']) . '" selected="selected">' . htmlspecialchars($nMV_label) . '</option>';
2148 // Create item form fields:
2149 $sOnChange = 'if (this.options[this.selectedIndex].value==\'--div--\') {this.selectedIndex=' . $sI . ';} ' . implode('', $PA['fieldChangeFunc']);
2151 // MUST be inserted before the selector - else is the value of the hiddenfield here mysteriously submitted...
2152 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '_selIconVal" value="' . htmlspecialchars($sI) . '" />';
2154 if ($config['iconsInOptionTags']) {
2155 $classesForSelectTag[] = 'icon-select';
2157 $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 . '>';
2158 $item .= implode('', $opt);
2159 $item .= '</select>';
2160 // Create icon table:
2161 if (count($selicons) && !$config['noIconsBelowSelect']) {
2162 $item .= '<table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-selectIcons">';
2163 $selicon_cols = (int)$config['selicon_cols'];
2164 if (!$selicon_cols) {
2165 $selicon_cols = count($selicons);
2167 $sR = ceil(count($selicons) / $selicon_cols);
2168 $selicons = array_pad($selicons, $sR * $selicon_cols, '');
2169 for ($sa = 0; $sa < $sR; $sa++
) {
2171 for ($sb = 0; $sb < $selicon_cols; $sb++
) {
2172 $sk = $sa * $selicon_cols +
$sb;
2173 $imgN = 'selIcon_' . $table . '_' . $row['uid'] . '_' . $field . '_' . $selicons[$sk][1];
2174 $imgS = $selicons[$sk][2] ?
$this->backPath
. 'gfx/content_selected.gif' : 'clear.gif';
2175 $item .= '<td><img name="' . htmlspecialchars($imgN) . '" src="' . $imgS . '" width="7" height="10" alt="" /></td>';
2176 $item .= '<td>' . $selicons[$sk][0] . '</td>';
2180 $item .= '</table>';
2186 * Creates a checkbox list (renderMode = "checkbox")
2187 * (Render function for getSingleField_typeSelect())
2189 * @param string $table See getSingleField_typeSelect()
2190 * @param string $field See getSingleField_typeSelect()
2191 * @param array $row See getSingleField_typeSelect()
2192 * @param array $PA See getSingleField_typeSelect()
2193 * @param array $config (Redundant) content of $PA['fieldConf']['config'] (for convenience)
2194 * @param array $selItems Items available for selection
2195 * @param string $nMV_label Label for no-matching-value
2196 * @return string The HTML code for the item
2197 * @see getSingleField_typeSelect()
2198 * @todo Define visibility
2200 public function getSingleField_typeSelect_checkbox($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
2201 if (empty($selItems)) {
2204 // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
2205 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
2208 if ($this->renderReadonly ||
$config['readOnly']) {
2209 $disabled = ' disabled="disabled"';
2211 // Traverse the Array of selector box items:
2215 $sOnChange = implode('', $PA['fieldChangeFunc']);
2216 // Used to accumulate the JS needed to restore the original selection.
2218 $unSetAll = array();
2219 foreach ($selItems as $p) {
2220 // Non-selectable element:
2221 if ($p[1] === '--div--') {
2223 if (isset($p[2]) && $p[2] != 'empty-emtpy') {
2224 $selIcon = $this->getIconHtml($p[2]);
2227 <tr class="c-header">
2228 <td colspan="3">' . $selIcon . htmlspecialchars($p[0]) . '</td>
2231 // Selected or not by default:
2233 if (isset($itemArray[$p[1]])) {
2234 $sM = ' checked="checked"';
2235 unset($itemArray[$p[1]]);
2241 $selIcon = IconUtility
::getSpriteIcon('empty-empty');
2244 $rowId = uniqid('select_checkbox_row_');
2245 $onClickCell = $this->elName(($PA['itemFormElName'] . '[' . $c . ']')) . '.checked=!' . $this->elName(($PA['itemFormElName'] . '[' . $c . ']')) . '.checked;';
2246 $onClick = 'this.attributes.getNamedItem("class").nodeValue = ' . $this->elName(($PA['itemFormElName'] . '[' . $c . ']')) . '.checked ? "c-selectedItem" : "c-unselectedItem";';
2247 $setAll[] = $this->elName(($PA['itemFormElName'] . '[' . $c . ']')) . '.checked=1;';
2248 $setAll[] .= '$(\'' . $rowId . '\').removeClassName(\'c-unselectedItem\');$(\'' . $rowId . '\').addClassName(\'c-selectedItem\');';
2249 $unSetAll[] = $this->elName(($PA['itemFormElName'] . '[' . $c . ']')) . '.checked=0;';
2250 $unSetAll[] .= '$(\'' . $rowId . '\').removeClassName(\'c-selectedItem\');$(\'' . $rowId . '\').addClassName(\'c-unselectedItem\');';
2251 $restoreCmd[] = $this->elName(($PA['itemFormElName'] . '[' . $c . ']')) . '.checked=' . ($sM ?
1 : 0) . ';' . '$(\'' . $rowId . '\').removeClassName(\'c-selectedItem\');$(\'' . $rowId . '\').removeClassName(\'c-unselectedItem\');' . '$(\'' . $rowId . '\').addClassName(\'c-' . ($sM ?
'' : 'un') . 'selectedItem\');';
2252 // Check if some help text is available
2253 // Since TYPO3 4.5 help text is expected to be an associative array
2254 // with two key, "title" and "description"
2255 // For the sake of backwards compatibility, we test if the help text
2256 // is a string and use it as a description (this could happen if items
2257 // are modified with an itemProcFunc)
2260 $helpArray = array();
2261 if (is_array($p[3]) && count($p[3]) > 0 ||
!empty($p[3])) {
2263 if (is_array($p[3])) {
2266 $helpArray['description'] = $p[3];
2269 $label = htmlspecialchars($p[0], ENT_COMPAT
, 'UTF-8', FALSE);
2271 $help = BackendUtility
::wrapInHelp('', '', '', $helpArray);
2274 <tr id="' . $rowId . '" class="' . ($sM ?
'c-selectedItem' : 'c-unselectedItem') . '" onclick="' . htmlspecialchars($onClick) . '" style="cursor: pointer;">
2275 <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>
2276 <td class="c-labelCell" onclick="' . htmlspecialchars($onClickCell) . '">' . $this->getIconHtml($selIcon) . $label . '</td>
2277 <td class="c-descr" onclick="' . htmlspecialchars($onClickCell) . '">' . (empty($help) ?
'' : $help) . '</td>
2283 // Remaining values (invalid):
2284 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
2285 foreach ($itemArray as $theNoMatchValue => $temp) {
2286 // Compile <checkboxes> tag:
2287 array_unshift($tRows, '
2288 <tr class="c-invalidItem">
2289 <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>
2290 <td class="c-labelCell">' . htmlspecialchars(@sprintf
($nMV_label, $theNoMatchValue), ENT_COMPAT
, 'UTF-8', FALSE) . '</td><td> </td>
2295 // Add an empty hidden field which will send a blank value if all items are unselected.
2296 $item .= '<input type="hidden" class="select-checkbox" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="" />';
2297 // Remaining checkboxes will get their set-all link:
2298 if (count($setAll)) {
2299 $tableHead = '<thead>
2300 <tr class="c-header-checkbox-controls t3-row-header">
2301 <td class="c-checkbox">
2302 <input type="checkbox" class="checkbox" onclick="if (checked) {' . htmlspecialchars((implode('', $setAll) . '} else {' . implode('', $unSetAll) . '}')) . '">
2308 // Implode rows in table:
2310 <table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-select-checkbox">' . $tableHead . '<tbody>' . implode('', $tRows) . '</tbody>
2314 if (is_array($restoreCmd)) {
2315 $item .= '<a href="#" onclick="' . implode('', $restoreCmd) . ' return false;' . '">' . IconUtility
::getSpriteIcon('actions-edit-undo', array('title' => htmlspecialchars($this->getLL('l_revertSelection')))) . '</a>';
2321 * Creates a selectorbox list (renderMode = "singlebox")
2322 * (Render function for getSingleField_typeSelect())
2324 * @param string $table See getSingleField_typeSelect()
2325 * @param string $field See getSingleField_typeSelect()
2326 * @param array $row See getSingleField_typeSelect()
2327 * @param array $PA See getSingleField_typeSelect()
2328 * @param array $config (Redundant) content of $PA['fieldConf']['config'] (for convenience)
2329 * @param array $selItems Items available for selection
2330 * @param string $nMV_label Label for no-matching-value
2331 * @return string The HTML code for the item
2332 * @see getSingleField_typeSelect()
2333 * @todo Define visibility
2335 public function getSingleField_typeSelect_singlebox($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
2336 // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
2337 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
2340 if ($this->renderReadonly ||
$config['readOnly']) {
2341 $disabled = ' disabled="disabled"';
2343 // Traverse the Array of selector box items:
2345 // Used to accumulate the JS needed to restore the original selection.
2346 $restoreCmd = array();
2348 foreach ($selItems as $p) {
2349 // Selected or not by default:
2351 if (isset($itemArray[$p[1]])) {
2352 $sM = ' selected="selected"';
2353 $restoreCmd[] = $this->elName(($PA['itemFormElName'] . '[]')) . '.options[' . $c . '].selected=1;';
2354 unset($itemArray[$p[1]]);
2356 // Non-selectable element:
2358 if ((string) $p[1] === '--div--') {
2359 $nonSel = ' onclick="this.selected=0;" class="c-divider"';
2361 // Icon style for option tag:
2362 if ($config['iconsInOptionTags']) {
2363 $styleAttrValue = $this->optionTagStyle($p[2]);
2365 // Compile <option> tag:
2366 $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' . $sM . $nonSel . ($styleAttrValue ?
' style="' . htmlspecialchars($styleAttrValue) . '"' : '') . '>' . htmlspecialchars($p[0], ENT_COMPAT
, 'UTF-8', FALSE) . '</option>';
2369 // Remaining values:
2370 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
2371 foreach ($itemArray as $theNoMatchValue => $temp) {
2372 // Compile <option> tag:
2373 array_unshift($opt, '<option value="' . htmlspecialchars($theNoMatchValue) . '" selected="selected">' . htmlspecialchars(@sprintf
($nMV_label, $theNoMatchValue), ENT_COMPAT
, 'UTF-8', FALSE) . '</option>');
2376 // Compile selector box:
2377 $sOnChange = implode('', $PA['fieldChangeFunc']);
2378 $selector_itemListStyle = isset($config['itemListStyle']) ?
' style="' . htmlspecialchars($config['itemListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle
. '"';
2379 $size = (int)$config['size'];
2380 $cssPrefix = $size === 1 ?
'tceforms-select' : 'tceforms-multiselect';
2381 $size = $config['autoSizeMax'] ? MathUtility
::forceIntegerInRange(count($selItems) +
1, MathUtility
::forceIntegerInRange($size, 1), $config['autoSizeMax']) : $size;
2382 $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 . '>
2386 // Add an empty hidden field which will send a blank value if all items are unselected.
2388 $item .= '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="" />';
2390 // Put it all into a table:
2392 <table border="0" cellspacing="0" cellpadding="0" width="1" class="typo3-TCEforms-select-singlebox">
2397 <em>' . htmlspecialchars($this->getLL('l_holdDownCTRL')) . '</em>
2400 <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>
2409 * Creates a multiple-selector box (two boxes, side-by-side)
2410 * (Render function for getSingleField_typeSelect())
2412 * @param string $table See getSingleField_typeSelect()
2413 * @param string $field See getSingleField_typeSelect()
2414 * @param array $row See getSingleField_typeSelect()
2415 * @param array $PA See getSingleField_typeSelect()
2416 * @param array $config (Redundant) content of $PA['fieldConf']['config'] (for convenience)
2417 * @param array $selItems Items available for selection
2418 * @param string $nMV_label Label for no-matching-value
2419 * @return string The HTML code for the item
2420 * @see getSingleField_typeSelect()
2421 * @todo Define visibility
2423 public function getSingleField_typeSelect_multiple($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
2426 if ($this->renderReadonly ||
$config['readOnly']) {
2427 $disabled = ' disabled="disabled"';
2429 // Setting this hidden field (as a flag that JavaScript can read out)
2431 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '_mul" value="' . ($config['multiple'] ?
1 : 0) . '" />';
2433 // Set max and min items:
2434 $maxitems = MathUtility
::forceIntegerInRange($config['maxitems'], 0);
2438 $minitems = MathUtility
::forceIntegerInRange($config['minitems'], 0);
2439 // Register the required number of elements:
2440 $this->registerRequiredProperty('range', $PA['itemFormElName'], array($minitems, $maxitems, 'imgName' => $table . '_' . $row['uid'] . '_' . $field));
2441 // Get "removeItems":
2442 $removeItems = GeneralUtility
::trimExplode(',', $PA['fieldTSConfig']['removeItems'], TRUE);
2443 // Get the array with selected items:
2444 $itemArray = GeneralUtility
::trimExplode(',', $PA['itemFormElValue'], TRUE);
2446 // Possibly filter some items:
2447 $itemArray = GeneralUtility
::keepItemsInArray(
2449 $PA['fieldTSConfig']['keepItems'],
2451 $parts = explode('|', $value, 2);
2452 return rawurldecode($parts[0]);
2456 // Perform modification of the selected items array:
2457 foreach ($itemArray as $tk => $tv) {
2458 $tvP = explode('|', $tv, 2);
2459 $evalValue = $tvP[0];
2460 $isRemoved = in_array($evalValue, $removeItems) ||
$config['form_type'] == 'select' && $config['authMode'] && !$this->getBackendUserAuthentication()->checkAuthMode($table, $field, $evalValue, $config['authMode']);
2461 if ($isRemoved && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
2462 $tvP[1] = rawurlencode(@sprintf
($nMV_label, $evalValue));
2463 } elseif (isset($PA['fieldTSConfig']['altLabels.'][$evalValue])) {
2464 $tvP[1] = rawurlencode($this->sL($PA['fieldTSConfig']['altLabels.'][$evalValue]));
2466 if ($tvP[1] == '') {
2467 // Case: flexform, default values supplied, no label provided (bug #9795)
2468 foreach ($selItems as $selItem) {
2469 if ($selItem[1] == $tvP[0]) {
2470 $tvP[1] = html_entity_decode($selItem[0]);
2475 $itemArray[$tk] = implode('|', $tvP);
2477 $itemsToSelect = '';
2478 $filterTextfield = '';
2479 $filterSelectbox = '';
2481 // Create option tags:
2483 $styleAttrValue = '';
2484 foreach ($selItems as $p) {
2485 if ($config['iconsInOptionTags']) {
2486 $styleAttrValue = $this->optionTagStyle($p[2]);
2488 $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' . ($styleAttrValue ?
' style="' . htmlspecialchars($styleAttrValue) . '"' : '') . ' title="' . $p[0] . '">' . $p[0] . '</option>';
2490 // Put together the selector box:
2491 $selector_itemListStyle = isset($config['itemListStyle']) ?
' style="' . htmlspecialchars($config['itemListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle
. '"';
2492 $size = (int)$config['size'];
2493 $size = $config['autoSizeMax'] ? MathUtility
::forceIntegerInRange(count($itemArray) +
1, MathUtility
::forceIntegerInRange($size, 1), $config['autoSizeMax']) : $size;
2494 $sOnChange = implode('', $PA['fieldChangeFunc']);
2496 $multiSelectId = uniqid('tceforms-multiselect-');
2498 <select data-relatedfieldname="' . htmlspecialchars($PA['itemFormElName']) . '" data-exclusivevalues="' . htmlspecialchars($config['exclusiveKeys']) . '" id="' . $multiSelectId . '" name="' . $PA['itemFormElName'] . '_sel"' . $this->insertDefStyle('select', 'tceforms-multiselect tceforms-itemstoselect t3-form-select-itemstoselect') . ($size ?
' size="' . $size . '"' : '') . ' onchange="' . htmlspecialchars($sOnChange) . '"' . $PA['onFocus'] . $selector_itemListStyle . '>
2503 if ($config['enableMultiSelectFilterTextfield'] ||
$config['multiSelectFilterItems']) {
2504 $this->multiSelectFilterCount++
;
2505 $jsSelectBoxFilterName = str_replace(' ', '', ucwords(str_replace('-', ' ', GeneralUtility
::strtolower($multiSelectId))));
2506 $this->additionalJS_post
[] = '
2507 var '. $jsSelectBoxFilterName . ' = new TCEForms.SelectBoxFilter("' . $multiSelectId . '");
2511 if ($config['enableMultiSelectFilterTextfield']) {
2512 // add input field for filter
2513 $filterTextfield = '<input class="typo3-TCEforms-suggest-search typo3-TCEforms-multiselect-filter" id="' . $multiSelectId . '_filtertextfield" value="" style="width: 104px;" />';
2516 if (isset($config['multiSelectFilterItems']) && is_array($config['multiSelectFilterItems']) && count($config['multiSelectFilterItems']) > 1) {
2517 $filterDropDownOptions = array();
2518 foreach ($config['multiSelectFilterItems'] as $optionElement) {
2519 $filterDropDownOptions[] = '<option value="' . htmlspecialchars($this->sL($optionElement[0])) . '">' . htmlspecialchars((isset($optionElement[1]) && $optionElement[1] != '') ?
$this->sL($optionElement[1]) : $this->sL($optionElement[0])) . '</option>';
2521 $filterSelectbox = '
2522 <select id="' . $multiSelectId . '_filterdropdown">
2524 ', $filterDropDownOptions) . '
2528 // Pass to "dbFileIcons" function:
2531 'autoSizeMax' => MathUtility
::forceIntegerInRange($config['autoSizeMax'], 0),
2532 'style' => isset($config['selectedListStyle']) ?
' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle
. '"',
2533 'dontShowMoveIcons' => $maxitems <= 1,
2534 'maxitems' => $maxitems,
2537 'selector' => $this->getLL('l_selected') . ':<br />',
2538 'items' => $this->getLL('l_items') . ': ' . $filterSelectbox . $filterTextfield . '<br />'
2541 'thumbnails' => $itemsToSelect,
2542 'readOnly' => $disabled
2544 $item .= $this->dbFileIcons($PA['itemFormElName'], '', '', $itemArray, '', $params, $PA['onFocus']);
2549 * Generation of TCEform elements of the type "group"
2550 * This will render a selectorbox into which elements from either the file system or database can be inserted. Relations.
2552 * @param string $table The table name of the record
2553 * @param string $field The field name which this element is supposed to edit
2554 * @param array $row The record data array where the value(s) for the field can be found
2555 * @param array $PA An array with additional configuration options.
2556 * @return string The HTML code for the TCEform field
2557 * @todo Define visibility
2559 public function getSingleField_typeGroup($table, $field, $row, &$PA) {
2561 $config = $PA['fieldConf']['config'];
2562 $show_thumbs = $config['show_thumbs'];
2563 $size = isset($config['size']) ?
(int)$config['size'] : 5;
2564 $maxitems = MathUtility
::forceIntegerInRange($config['maxitems'], 1);
2565 $minitems = MathUtility
::forceIntegerInRange($config['minitems'], 0);
2566 $allowed = trim($config['allowed']);
2567 $disallowed = trim($config['disallowed']);
2570 if ($this->renderReadonly ||
$config['readOnly']) {
2571 $disabled = ' disabled="disabled"';
2573 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '_mul" value="' . ($config['multiple'] ?
1 : 0) . '"' . $disabled . ' />';
2574 $this->registerRequiredProperty('range', $PA['itemFormElName'], array($minitems, $maxitems, 'imgName' => $table . '_' . $row['uid'] . '_' . $field));
2576 // "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/.
2577 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
2578 $PA['itemFormElID_file'] = $PA['itemFormElID'] . '_files';
2579 // whether the list and delete controls should be disabled
2580 $noList = isset($config['disable_controls']) && GeneralUtility
::inList($config['disable_controls'], 'list');
2581 $noDelete = isset($config['disable_controls']) && GeneralUtility
::inList($config['disable_controls'], 'delete');
2582 // if maxitems==1 then automatically replace the current item (in list and file selector)
2583 if ($maxitems === 1) {
2584 $this->additionalJS_post
[] = 'TBE_EDITOR.clearBeforeSettingFormValueFromBrowseWin[\'' . $PA['itemFormElName'] . '\'] = {
2585 itemFormElID_file: \'' . $PA['itemFormElID_file'] . '\'
2587 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = 'setFormValueManipulate(\'' . $PA['itemFormElName'] . '\', \'Remove\'); ' . $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'];
2588 } elseif ($noList) {
2589 // If the list controls have been removed and the maximum number is reached, remove the first entry to avoid "write once" field
2590 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = 'setFormValueManipulate(\'' . $PA['itemFormElName'] . '\', \'RemoveFirstIfFull\', \'' . $maxitems . '\'); ' . $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'];
2592 // Acting according to either "file" or "db" type:
2593 switch ((string) $config['internal_type']) {
2594 case 'file_reference':
2595 $config['uploadfolder'] = '';
2598 // Creating string showing allowed types:
2599 $tempFT = GeneralUtility
::trimExplode(',', $allowed, TRUE);
2600 if (!count($tempFT)) {
2603 foreach ($tempFT as $ext) {
2605 $info .= strtoupper($ext) . ' ';