2 /***************************************************************
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Contains TYPO3 Core Form generator - AKA "TCEforms"
30 * Revised for TYPO3 3.6 August/2003 by Kasper Skårhøj
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
36 * [CLASS/FUNCTION INDEX of SCRIPT]
40 * 196: class t3lib_TCEforms
41 * 302: function t3lib_TCEforms()
42 * 338: function initDefaultBEmode()
44 * SECTION: Rendering the forms, fields etc
45 * 385: function getSoloField($table,$row,$theFieldToReturn)
46 * 424: function getMainFields($table,$row,$depth=0)
47 * 618: function getListedFields($table,$row,$list)
48 * 660: function getPaletteFields($table,$row,$palette,$header='',$itemList='',$collapsedHeader='')
49 * 737: function getSingleField($table,$field,$row,$altName='',$palette=0,$extra='',$pal=0)
50 * 900: function getSingleField_SW($table,$field,$row,&$PA)
52 * SECTION: Rendering of each TCEform field type
53 * 976: function getSingleField_typeInput($table,$field,$row,&$PA)
54 * 1057: function getSingleField_typeText($table,$field,$row,&$PA)
55 * 1178: function getSingleField_typeCheck($table,$field,$row,&$PA)
56 * 1244: function getSingleField_typeRadio($table,$field,$row,&$PA)
57 * 1279: function getSingleField_typeSelect($table,$field,$row,&$PA)
58 * 1359: function getSingleField_typeSelect_single($table,$field,$row,&$PA,$config,$selItems,$nMV_label)
59 * 1490: function getSingleField_typeSelect_checkbox($table,$field,$row,&$PA,$config,$selItems,$nMV_label)
60 * 1609: function getSingleField_typeSelect_singlebox($table,$field,$row,&$PA,$config,$selItems,$nMV_label)
61 * 1719: function getSingleField_typeSelect_multiple($table,$field,$row,&$PA,$config,$selItems,$nMV_label)
62 * 1823: function getSingleField_typeGroup($table,$field,$row,&$PA)
63 * 1992: function getSingleField_typeNone($table,$field,$row,&$PA)
64 * 2008: function getSingleField_typeNone_render($config,$itemValue)
65 * 2070: function getSingleField_typeFlex($table,$field,$row,&$PA)
66 * 2205: function getSingleField_typeFlex_langMenu($languages,$elName,$selectedLanguage,$multi=1)
67 * 2224: function getSingleField_typeFlex_sheetMenu($sArr,$elName,$sheetKey)
68 * 2259: function getSingleField_typeFlex_draw($dataStruct,$editData,$cmdData,$table,$field,$row,&$PA,$formPrefix='',$level=0,$tRows=array())
69 * 2452: function getSingleField_typeUnknown($table,$field,$row,&$PA)
70 * 2467: function getSingleField_typeUser($table,$field,$row,&$PA)
72 * SECTION: Field content processing
73 * 2496: function formatValue ($config, $itemValue)
75 * SECTION: "Configuration" fetching/processing functions
76 * 2588: function getRTypeNum($table,$row)
77 * 2614: function rearrange($fields)
78 * 2640: function getExcludeElements($table,$row,$typeNum)
79 * 2688: function getFieldsToAdd($table,$row,$typeNum)
80 * 2713: function mergeFieldsWithAddedFields($fields,$fieldsToAdd)
81 * 2745: function setTSconfig($table,$row,$field='')
82 * 2767: function getSpecConfForField($table,$row,$field)
83 * 2788: function getSpecConfFromString($extraString, $defaultExtras)
84 * 3007: function loadPaletteElements($table, $row, $palette, $itemList='')
86 * SECTION: Display of localized content etc.
87 * 2816: function registerDefaultLanguageData($table,$rec)
88 * 2848: function getLanguageOverlayRawValue($table, $row, $field, $fieldConf)
89 * 2876: function renderDefaultLanguageContent($table,$field,$row,$item)
90 * 2899: function renderDefaultLanguageDiff($table,$field,$row,$item)
92 * SECTION: Form element helper functions
93 * 2955: function dbFileIcons($fName,$mode,$allowed,$itemArray,$selector='',$params=array(),$onFocus='')
94 * 3108: function getClipboardElements($allowed,$mode)
95 * 3157: function getClickMenu($str,$table,$uid='')
96 * 3178: function renderWizards($itemKinds,$wizConf,$table,$row,$field,&$PA,$itemName,$specConf,$RTE=0)
97 * 3382: function getIcon($icon)
98 * 3409: function optionTagStyle($iconString)
99 * 3425: function extractValuesOnlyFromValueLabelList($itemFormElValue)
100 * 3447: function wrapOpenPalette($header,$table,$row,$palette,$retFunc=0)
101 * 3471: function checkBoxParams($itemName,$thisValue,$c,$iCount,$addFunc='')
102 * 3485: function elName($itemName)
103 * 3496: function noTitle($str,$wrapParts=array())
104 * 3505: function blur()
105 * 3514: function thisReturnUrl()
106 * 3527: function getSingleHiddenField($table,$field,$row)
107 * 3549: function formWidth($size=48,$textarea=0)
108 * 3576: function formWidthText($size=48,$wrap='')
109 * 3592: function formElStyle($type)
110 * 3603: function formElClass($type)
111 * 3614: function formElStyleClassValue($type, $class=FALSE)
112 * 3638: function insertDefStyle($type)
113 * 3657: function getDynTabMenu($parts, $idString)
115 * SECTION: Item-array manipulation functions (check/select/radio)
116 * 3696: function initItemArray($fieldValue)
117 * 3714: function addItems($items,$iArray)
118 * 3736: function procItems($items,$iArray,$config,$table,$row,$field)
119 * 3760: function addSelectOptionsToItemArray($items,$fieldValue,$TSconfig,$field)
120 * 3980: function addSelectOptionsToItemArray_makeModuleData($value)
121 * 4002: function foreignTable($items,$fieldValue,$TSconfig,$field,$pFFlag=0)
123 * SECTION: Template functions
124 * 4083: function setNewBEDesign()
125 * 4138: function intoTemplate($inArr,$altTemplate='')
126 * 4162: function addUserTemplateMarkers($marker,$table,$field,$row,&$PA)
127 * 4173: function wrapLabels($str)
128 * 4186: function wrapTotal($c,$rec,$table)
129 * 4199: function replaceTableWrap($arr,$rec,$table)
130 * 4236: function wrapBorder(&$out_array,&$out_pointer)
131 * 4258: function rplColorScheme($inTemplate)
132 * 4278: function getDivider()
133 * 4288: function printPalette($palArr)
134 * 4339: function helpTextIcon($table,$field,$force=0)
135 * 4359: function helpText($table,$field)
136 * 4380: function setColorScheme($scheme)
137 * 4404: function resetSchemes()
138 * 4415: function storeSchemes()
139 * 4427: function restoreSchemes()
141 * SECTION: JavaScript related functions
142 * 4457: function JStop()
143 * 4508: function JSbottom($formname='forms[0]')
144 * 4835: function dbFileCon($formObj='document.forms[0]')
145 * 5053: function printNeededJSFunctions()
146 * 5080: function printNeededJSFunctions_top()
148 * SECTION: Various helper functions
149 * 5128: function getDefaultRecord($table,$pid=0)
150 * 5167: function getRecordPath($table,$rec)
151 * 5181: function readPerms()
152 * 5195: function sL($str)
153 * 5208: function getLL($str)
154 * 5229: function isPalettesCollapsed($table,$palette)
155 * 5245: function isDisplayCondition($displayCond,$row,$ffValueKey='')
156 * 5349: function getTSCpid($table,$uid,$pid)
157 * 5363: function doLoadTableDescr($table)
158 * 5375: function getAvailableLanguages($onlyIsoCoded=1,$setDefault=1)
161 * 5417: class t3lib_TCEforms_FE extends t3lib_TCEforms
162 * 5425: function wrapLabels($str)
163 * 5435: function printPalette($palArr)
164 * 5460: function setFancyDesign()
166 * TOTAL FUNCTIONS: 100
167 * (This index is automatically created/updated by the extension "extdeveval")
173 * 'TCEforms' - Class for creating the backend editing forms.
175 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
176 * @coauthor René Fritz <r.fritz@colorcube.de>
180 class t3lib_TCEforms
{
182 // variables not commented yet.... (do so...)
183 var $palFieldArr = array();
184 var $disableWizards = 0;
185 var $isPalettedoc = 0;
186 var $paletteMargin = 1;
187 var $defStyle = ''; // 'font-family:Verdana;font-size:10px;';
188 var $cachedTSconfig = array();
189 var $cachedTSconfig_fieldLevel = array();
190 var $cachedLanguageFlag = array();
191 var $cachedAdditionalPreviewLanguages = NULL;
192 var $transformedRow = array();
194 var $printNeededJS = array();
195 var $hiddenFieldAccum = array();
196 var $TBE_EDITOR_fieldChanged_func = '';
198 var $prevBorderStyle = '[nothing here...]'; // Something unique...
199 var $allowUpload = 0; // If set direct upload fields will be shown
200 var $titleLen = 15; // @deprecated since TYPO3 4.1: $BE_USER->uc['titleLen'] but what is default??
201 var $defaultLanguageData = array(); // Array where records in the default language is stored. (processed by transferdata)
202 var $defaultLanguageData_diff = array(); // Array where records in the default language is stored (raw without any processing. used for making diff)
203 var $additionalPreviewLanguageData = array();
207 var $backPath = ''; // Set this to the 'backPath' pointing back to the typo3 admin directory from the script where this form is displayed.
208 var $returnUrl = ''; // Alternative return URL path (default is t3lib_div::linkThisScript())
209 var $doSaveFieldName = ''; // Can be set to point to a field name in the form which will be set to '1' when the form is submitted with a *save* button. This way the recipient script can determine that the form was submitted for save and not "close" for example.
210 var $palettesCollapsed = 0; // Can be set true/false to whether palettes (secondary options) are in the topframe or in form. True means they are NOT IN-form. So a collapsed palette is one, which is shown in the top frame, not in the page.
211 var $disableRTE = 0; // If set, the RTE is disabled (from form display, eg. by checkbox in the bottom of the page!)
212 var $globalShowHelp = 1; // If false, then all CSH will be disabled, regardless of settings in $this->edit_showFieldHelp
213 var $localizationMode = ''; // If true, the forms are rendering only localization relevant fields of the records.
214 var $fieldOrder = ''; // Overrule the field order set in TCA[types][showitem], eg for tt_content this value, 'bodytext,image', would make first the 'bodytext' field, then the 'image' field (if set for display)... and then the rest in the old order.
215 var $doPrintPalette = 1; // If set to false, palettes will NEVER be rendered.
218 * Set to initialized clipboard object; Then the element browser will offer a link to paste in records from clipboard.
220 * @var t3lib_clipboard
222 var $clipObj = FALSE;
223 var $enableClickMenu = FALSE; // Enable click menu on reference icons.
224 var $enableTabMenu = FALSE; // Enable Tab Menus.
225 var $renderReadonly = FALSE; // When enabled all fields are rendered non-editable.
227 var $form_rowsToStylewidth = 9.58; // Form field width compensation: Factor from NN4 form field widths to style-aware browsers (like NN6+ and MSIE, with the $CLIENT[FORMSTYLE] value set)
228 var $form_largeComp = 1.33; // Form field width compensation: Compensation for large documents, doc-tab (editing)
229 var $charsPerRow = 40; // The number of chars expected per row when the height of a text area field is automatically calculated based on the number of characters found in the field content.
230 var $maxTextareaWidth = 48; // The maximum abstract value for textareas
231 var $maxInputWidth = 48; // The maximum abstract value for input fields
232 var $defaultMultipleSelectorStyle = 'width:250px;'; // Default style for the selector boxes used for multiple items in "select" and "group" types.
236 var $prependFormFieldNames = 'data'; // The string to prepend formfield names with.
237 var $prependCmdFieldNames = 'cmd'; // The string to prepend commands for tcemain::process_cmdmap with.
238 var $prependFormFieldNames_file = 'data_files'; // The string to prepend FILE form field names with.
239 var $formName = 'editform'; // The name attribute of the form.
240 var $allowOverrideMatrix = array(); // Whitelist that allows TCA field configuration to be overridden by TSconfig, @see overrideFieldConf()
244 var $perms_clause = ''; // Set by readPerms() (caching)
245 var $perms_clause_set = 0; // Set by readPerms() (caching-flag)
246 var $edit_showFieldHelp = ''; // Used to indicate the mode of CSH (Context Sensitive Help), whether it should be icons-only ('icon'), full description ('text') or not at all (blank).
247 var $docLarge = 0; // If set, the forms will be rendered a little wider, more precisely with a factor of $this->form_largeComp.
248 var $clientInfo = array(); // Loaded with info about the browser when class is instantiated.
249 var $RTEenabled = 0; // True, if RTE is possible for the current user (based on result from BE_USER->isRTE())
250 var $RTEenabled_notReasons = ''; // If $this->RTEenabled was false, you can find the reasons listed in this array which is filled with reasons why the RTE could not be loaded)
251 var $RTEcounter = 0; // Counter that is incremented before an RTE is created. Can be used for unique ids etc.
253 var $colorScheme; // Contains current color scheme
254 var $classScheme; // Contains current class scheme
255 var $defColorScheme; // Contains the default color scheme
256 var $defClassScheme; // Contains the default class scheme
257 var $fieldStyle; // Contains field style values
258 var $borderStyle; // Contains border style values.
260 var $commentMessages = array(); // An accumulation of messages from the class.
262 // INTERNAL, templates
263 var $totalWrap = '<hr />|<hr />'; // Total wrapping for the table rows.
264 var $fieldTemplate = '<strong>###FIELD_NAME###</strong><br />###FIELD_ITEM###<hr />'; // Field template
265 var $sectionWrap = ''; // Wrapping template code for a section
266 var $palFieldTemplateHeader = ''; // Template for palette headers
267 var $palFieldTemplate = ''; // Template for palettes
269 // INTERNAL, working memory
270 var $excludeElements = ''; // Set to the fields NOT to display, if any.
271 var $palettesRendered = array(); // During rendering of forms this will keep track of which palettes has already been rendered (so they are not rendered twice by mistake)
272 var $hiddenFieldListArr = array(); // This array of fields will be set as hidden-fields instead of rendered normally! For instance palette fields edited in the top frame are set as hidden fields since the main form has to submit the values. The top frame actually just sets the value in the main form!
273 var $requiredFields = array(); // Used to register input-field names, which are required. (Done during rendering of the fields). This information is then used later when the JavaScript is made.
274 var $requiredAdditional = array(); // Used to register input-field names, which are required an have additional requirements (e.g. like a date/time must be positive integer). The information of this array is merged with $this->requiredFields later.
275 var $requiredElements = array(); // Used to register the min and max number of elements for selectorboxes where that apply (in the "group" type for instance)
276 var $requiredNested = array(); // Used to determine where $requiredFields or $requiredElements are nested (in Tabs or IRRE)
277 var $renderDepth = 0; // Keeps track of the rendering depth of nested records.
278 var $savedSchemes = array(); // Color scheme buffer.
279 var $dynNestedStack = array(); // holds the path an element is nested in (e.g. required for RTEhtmlarea)
281 // Internal, registers for user defined functions etc.
282 var $additionalCode_pre = array(); // Additional HTML code, printed before the form.
283 var $additionalJS_pre = array(); // Additional JavaScript, printed before the form
284 var $additionalJS_post = array(); // Additional JavaScript printed after the form
285 var $additionalJS_submit = array(); // Additional JavaScript executed on submit; If you set "OK" variable it will raise an error about RTEs not being loaded and offer to block further submission.
286 var $additionalJS_delete = array(); // Additional JavaScript executed when section element is deleted. This is neceessary, for example, to correctly clean up HTMLArea RTE (bug #8232)
289 * Instance of t3lib_tceforms_inline
291 * @var t3lib_TCEforms_inline
294 var $hookObjectsMainFields = array(); // Array containing hook class instances called once for a form
295 var $hookObjectsSingleField = array(); // Array containing hook class instances called for each field
296 var $extraFormHeaders = array(); // Rows gettings inserted into the alt_doc headers (when called from alt_doc.php)
298 public $templateFile = ''; // Form templates, relative to typo3 directory
302 * Constructor function, setting internal variables, loading the styles used.
306 function t3lib_TCEforms() {
307 global $CLIENT, $TYPO3_CONF_VARS;
309 $this->clientInfo
= t3lib_div
::clientInfo();
311 $this->RTEenabled
= $GLOBALS['BE_USER']->isRTE();
312 if (!$this->RTEenabled
) {
313 $this->RTEenabled_notReasons
= implode(LF
, $GLOBALS['BE_USER']->RTE_errors
);
314 $this->commentMessages
[] = 'RTE NOT ENABLED IN SYSTEM due to:' . LF
. $this->RTEenabled_notReasons
;
317 // Default color+class scheme
318 $this->defColorScheme
= array(
319 $GLOBALS['SOBE']->doc
->bgColor
, // Background for the field AND palette
320 t3lib_div
::modifyHTMLColorAll($GLOBALS['SOBE']->doc
->bgColor
, -20), // Background for the field header
321 t3lib_div
::modifyHTMLColorAll($GLOBALS['SOBE']->doc
->bgColor
, -10), // Background for the palette field header
322 'black', // Field header font color
323 '#666666' // Palette field header font color
325 $this->defColorScheme
= array();
327 // Override / Setting defaults from TBE_STYLES array
328 $this->resetSchemes();
330 // Setting the current colorScheme to default.
331 $this->defColorScheme
= $this->colorScheme
;
332 $this->defClassScheme
= $this->classScheme
;
334 // Define whitelist that allows TCA field configuration to be overridden by TSconfig, @see overrideFieldConf():
335 $this->allowOverrideMatrix
= array(
336 'input' => array('size', 'max'),
337 'text' => array('cols', 'rows', 'wrap'),
338 'check' => array('cols', 'showIfRTE'),
339 'select' => array('size', 'autoSizeMax', 'maxitems', 'minitems'),
340 'group' => array('size', 'autoSizeMax', 'max_size', 'show_thumbs', 'maxitems', 'minitems', 'disable_controls'),
341 'inline' => array('appearance', 'behaviour', 'foreign_label', 'foreign_selector', 'foreign_unique', 'maxitems', 'minitems', 'size', 'autoSizeMax', 'symmetric_label'),
344 // Create instance of t3lib_TCEforms_inline only if this a non-IRRE-AJAX call:
345 if (!isset($GLOBALS['ajaxID']) ||
strpos($GLOBALS['ajaxID'], 't3lib_TCEforms_inline::') !== 0) {
346 $this->inline
= t3lib_div
::makeInstance('t3lib_TCEforms_inline');
348 // Create instance of t3lib_TCEforms_suggest only if this a non-Suggest-AJAX call:
349 if (!isset($GLOBALS['ajaxID']) ||
strpos($GLOBALS['ajaxID'], 't3lib_TCEforms_suggest::') !== 0) {
350 $this->suggest
= t3lib_div
::makeInstance('t3lib_TCEforms_suggest');
353 // Prepare user defined objects (if any) for hooks which extend this function:
354 $this->hookObjectsMainFields
= array();
355 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'])) {
356 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'] as $classRef) {
357 $this->hookObjectsMainFields
[] = t3lib_div
::getUserObj($classRef);
360 $this->hookObjectsSingleField
= array();
361 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getSingleFieldClass'])) {
362 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getSingleFieldClass'] as $classRef) {
363 $this->hookObjectsSingleField
[] = t3lib_div
::getUserObj($classRef);
367 $this->templateFile
= 'templates/tceforms.html';
372 * Initialize various internal variables.
376 function initDefaultBEmode() {
378 $this->prependFormFieldNames
= 'data';
379 $this->formName
= 'editform';
380 $this->setNewBEDesign();
381 $this->docLarge
= $BE_USER->uc
['edit_wideDocument'] ?
1 : 0;
382 $this->edit_showFieldHelp
= $BE_USER->uc
['edit_showFieldHelp'];
384 $this->edit_docModuleUpload
= $BE_USER->uc
['edit_docModuleUpload'];
385 $this->titleLen
= $BE_USER->uc
['titleLen']; // @deprecated since TYPO3 4.1
387 $this->inline
->init($this);
388 $this->suggest
->init($this);
392 /*******************************************************
394 * Rendering the forms, fields etc
396 *******************************************************/
399 * Will return the TCEform element for just a single field from a record.
400 * The field must be listed in the currently displayed fields (as found in [types][showitem]) for the record.
401 * This also means that the $table/$row supplied must be complete so the list of fields to show can be found correctly
403 * @param string The table name
404 * @param array The record from the table for which to render a field.
405 * @param string The field name to return the TCEform element for.
406 * @return string HTML output
407 * @see getMainFields()
409 function getSoloField($table, $row, $theFieldToReturn) {
413 t3lib_div
::loadTCA($table);
414 $typeNum = $this->getRTypeNum($table, $row);
415 if ($TCA[$table]['types'][$typeNum]) {
416 $itemList = $TCA[$table]['types'][$typeNum]['showitem'];
418 $fields = t3lib_div
::trimExplode(',', $itemList, 1);
419 $excludeElements = $this->excludeElements
= $this->getExcludeElements($table, $row, $typeNum);
421 foreach ($fields as $fieldInfo) {
422 $parts = explode(';', $fieldInfo);
424 $theField = trim($parts[0]);
425 if (!in_array($theField, $excludeElements) && !strcmp($theField, $theFieldToReturn)) {
426 if ($TCA[$table]['columns'][$theField]) {
427 $sField = $this->getSingleField($table, $theField, $row, $parts[1], 1, $parts[3], $parts[2]);
428 return $sField['ITEM'];
438 * Based on the $table and $row of content, this displays the complete TCEform for the record.
439 * The input-$row is required to be preprocessed if necessary by eg. the t3lib_transferdata class. For instance the RTE content should be transformed through this class first.
441 * @param string The table name
442 * @param array The record from the table for which to render a field.
443 * @param integer Depth level
444 * @return string HTML output
445 * @see getSoloField()
447 function getMainFields($table, $row, $depth = 0) {
448 global $TCA, $TYPO3_CONF_VARS;
450 $this->renderDepth
= $depth;
453 $out_array = array(array());
454 $out_array_meta = array(array(
455 'title' => $this->getLL('l_generalTab')
460 $this->palettesRendered
= array();
461 $this->palettesRendered
[$this->renderDepth
][$table] = array();
463 // Hook: getMainFields_preProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
464 foreach ($this->hookObjectsMainFields
as $hookObj) {
465 if (method_exists($hookObj, 'getMainFields_preProcess')) {
466 $hookObj->getMainFields_preProcess($table, $row, $this);
472 // Load the full TCA for the table.
473 t3lib_div
::loadTCA($table);
475 // Get dividers2tabs setting from TCA of the current table:
476 $dividers2tabs =& $TCA[$table]['ctrl']['dividers2tabs'];
478 // Load the description content for the table.
479 if ($this->edit_showFieldHelp ||
$this->doLoadTableDescr($table)) {
480 $GLOBALS['LANG']->loadSingleTableDescription($table);
482 // Get the current "type" value for the record.
483 $typeNum = $this->getRTypeNum($table, $row);
485 // Find the list of fields to display:
486 if ($TCA[$table]['types'][$typeNum]) {
487 $itemList = $TCA[$table]['types'][$typeNum]['showitem'];
488 if ($itemList) { // If such a list existed...
489 // Explode the field list and possibly rearrange the order of the fields, if configured for
490 $fields = t3lib_div
::trimExplode(',', $itemList, 1);
491 if ($this->fieldOrder
) {
492 $fields = $this->rearrange($fields);
495 // Get excluded fields, added fiels and put it together:
496 $excludeElements = $this->excludeElements
= $this->getExcludeElements($table, $row, $typeNum);
497 $fields = $this->mergeFieldsWithAddedFields($fields, $this->getFieldsToAdd($table, $row, $typeNum));
499 // If TCEforms will render a tab menu in the next step, push the name to the tab stack:
500 $tabIdentString = '';
501 $tabIdentStringMD5 = '';
502 if (strstr($itemList, '--div--') !== false && $this->enableTabMenu
&& $dividers2tabs) {
503 $tabIdentString = 'TCEforms:' . $table . ':' . $row['uid'];
504 $tabIdentStringMD5 = $GLOBALS['TBE_TEMPLATE']->getDynTabMenuId($tabIdentString);
505 // Remember that were currently working on the general tab:
506 if (isset($fields[0]) && strpos($fields[0], '--div--') !== 0) {
507 $this->pushToDynNestedStack('tab', $tabIdentStringMD5 . '-1');
511 // Traverse the fields to render:
513 foreach ($fields as $fieldInfo) {
514 // Exploding subparts of the field configuration:
515 $parts = explode(';', $fieldInfo);
517 // Getting the style information out:
518 $color_style_parts = t3lib_div
::trimExplode('-', $parts[4]);
519 if (strcmp($color_style_parts[0], '')) {
520 $this->setColorScheme($GLOBALS['TBE_STYLES']['colorschemes'][intval($color_style_parts[0])]);
522 if (strcmp($color_style_parts[1], '')) {
523 $this->fieldStyle
= $GLOBALS['TBE_STYLES']['styleschemes'][intval($color_style_parts[1])];
524 if (!isset($this->fieldStyle
)) {
525 $this->fieldStyle
= $GLOBALS['TBE_STYLES']['styleschemes'][0];
528 if (strcmp($color_style_parts[2], '')) {
529 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
530 $this->borderStyle
= $GLOBALS['TBE_STYLES']['borderschemes'][intval($color_style_parts[2])];
531 if (!isset($this->borderStyle
)) {
532 $this->borderStyle
= $GLOBALS['TBE_STYLES']['borderschemes'][0];
537 $theField = $parts[0];
538 if (!in_array($theField, $excludeElements)) {
539 if ($TCA[$table]['columns'][$theField]) {
542 if ($parts[2] && !isset($this->palettesRendered
[$this->renderDepth
][$table][$parts[2]])) {
543 $sFieldPal = $this->getPaletteFields($table, $row, $parts[2]);
544 $this->palettesRendered
[$this->renderDepth
][$table][$parts[2]] = 1;
546 $sField = $this->getSingleField($table, $theField, $row, $parts[1], 0, $parts[3], $parts[2]);
548 $sField .= $sFieldPal;
551 $out_array[$out_sheet][$out_pointer] .= $sField;
552 } elseif ($theField == '--div--') {
554 $out_array[$out_sheet][$out_pointer] .= $this->getDivider();
556 if ($this->enableTabMenu
&& $dividers2tabs) {
557 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
558 // Remove last tab entry from the dynNestedStack:
560 // Remove the previous sheet from stack (if any):
561 $this->popFromDynNestedStack('tab', $tabIdentStringMD5 . '-' . ($out_sheet));
562 // Remember on which sheet we're currently working:
563 $this->pushToDynNestedStack('tab', $tabIdentStringMD5 . '-' . ($out_sheet +
1));
564 $out_array[$out_sheet] = array();
565 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
566 // Register newline for Tab
567 $out_array_meta[$out_sheet]['newline'] = ($parts[2] == "newline");
569 } else { // Setting alternative title for "General" tab if "--div--" is the very first element.
570 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
571 // Only add the first tab to the dynNestedStack if there are more tabs:
572 if ($tabIdentString && strpos($itemList, '--div--', strlen($fieldInfo))) {
573 $this->pushToDynNestedStack('tab', $tabIdentStringMD5 . '-1');
576 } elseif ($theField == '--palette--') {
577 if ($parts[2] && !isset($this->palettesRendered
[$this->renderDepth
][$table][$parts[2]])) {
578 // render a 'header' if not collapsed
579 if ($TCA[$table]['palettes'][$parts[2]]['canNotCollapse'] AND $parts[1]) {
580 $out_array[$out_sheet][$out_pointer] .= $this->getPaletteFields($table, $row, $parts[2], $this->sL($parts[1]));
582 $out_array[$out_sheet][$out_pointer] .= $this->getPaletteFields($table, $row, $parts[2], '', '', $this->sL($parts[1]));
584 $this->palettesRendered
[$this->renderDepth
][$table][$parts[2]] = 1;
595 // Hook: getMainFields_postProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
596 foreach ($this->hookObjectsMainFields
as $hookObj) {
597 if (method_exists($hookObj, 'getMainFields_postProcess')) {
598 $hookObj->getMainFields_postProcess($table, $row, $this);
602 // Wrapping a border around it all:
603 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
606 $this->resetSchemes();
608 // Rendering Main palettes, if any
609 $mParr = t3lib_div
::trimExplode(',', $TCA[$table]['ctrl']['mainpalette']);
612 foreach ($mParr as $mP) {
613 if (!isset($this->palettesRendered
[$this->renderDepth
][$table][$mP])) {
614 $temp_palettesCollapsed = $this->palettesCollapsed
;
615 $this->palettesCollapsed
= 0;
616 $label = ($i == 0 ?
$this->getLL('l_generalOptions') : $this->getLL('l_generalOptions_more'));
617 $out_array[$out_sheet][$out_pointer] .= $this->getPaletteFields($table, $row, $mP, $label);
618 $this->palettesCollapsed
= $temp_palettesCollapsed;
619 $this->palettesRendered
[$this->renderDepth
][$table][$mP] = 1;
621 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
623 if ($this->renderDepth
) {
624 $this->renderDepth
--;
629 // Return the imploded $out_array:
630 if ($out_sheet > 0) { // There were --div-- dividers around...
632 // Create parts array for the tab menu:
634 foreach ($out_array as $idx => $sheetContent) {
635 $content = implode('', $sheetContent);
637 // Wrap content (row) with table-tag, otherwise tab/sheet will be disabled (see getdynTabMenu() )
638 $content = '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . $content . '</table>';
640 $parts[$idx] = array(
641 'label' => $out_array_meta[$idx]['title'],
642 'content' => $content,
643 'newline' => $out_array_meta[$idx]['newline'], // Newline for this tab/sheet
647 if (count($parts) > 1) {
648 // Unset the current level of tab menus:
649 $this->popFromDynNestedStack('tab', $tabIdentStringMD5 . '-' . ($out_sheet +
1));
650 $dividersToTabsBehaviour = (isset($TCA[$table]['ctrl']['dividers2tabs']) ?
$TCA[$table]['ctrl']['dividers2tabs'] : 1);
651 $output = $this->getDynTabMenu($parts, $tabIdentString, $dividersToTabsBehaviour);
654 // If there is only one tab/part there is no need to wrap it into the dynTab code
655 $output = isset($parts[0]) ?
trim($parts[0]['content']) : '';
666 // Only one, so just implode:
667 $output = implode('', $out_array[$out_sheet]);
674 * Will return the TCEform elements for a pre-defined list of fields.
675 * 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.
676 * Used for displaying forms for the frontend edit icons for instance.
678 * @param string The table name
679 * @param array The record array.
680 * @param string Commalist of fields from the table. These will be shown in the specified order in a form.
681 * @return string TCEform elements in a string.
683 function getListedFields($table, $row, $list) {
686 t3lib_div
::loadTCA($table);
687 if ($this->edit_showFieldHelp ||
$this->doLoadTableDescr($table)) {
688 $GLOBALS['LANG']->loadSingleTableDescription($table);
692 $types_fieldConfig = t3lib_BEfunc
::getTCAtypes($table, $row, 1);
694 $editFieldList = array_unique(t3lib_div
::trimExplode(',', $list, 1));
695 foreach ($editFieldList as $theFieldC) {
696 list($theField, $palFields) = preg_split('/\[|\]/', $theFieldC);
697 $theField = trim($theField);
698 $palFields = trim($palFields);
699 if ($TCA[$table]['columns'][$theField]) {
700 $parts = t3lib_div
::trimExplode(';', $types_fieldConfig[$theField]['origString']);
701 $sField = $this->getSingleField($table, $theField, $row, $parts[1], 0, $parts[3], 0); // Don't sent palette pointer - there are no options anyways for a field-list.
703 } elseif ($theField == '--div--') {
704 $out .= $this->getDivider();
707 $out .= $this->getPaletteFields($table, $row, '', '', implode(',', t3lib_div
::trimExplode('|', $palFields, 1)));
715 * Creates a palette (collection of secondary options).
717 * @param string The table name
718 * @param array The row array
719 * @param string The palette number/pointer
720 * @param string Header string for the palette (used when in-form). If not set, no header item is made.
721 * @param string Optional alternative list of fields for the palette
722 * @param string Optional Link text for activating a palette (when palettes does not have another form element to belong to).
723 * @return string HTML code.
725 function getPaletteFields($table, $row, $palette, $header = '', $itemList = '', $collapsedHeader = NULL) {
726 if (!$this->doPrintPalette
) {
731 $parts = $this->loadPaletteElements($table, $row, $palette, $itemList);
733 // Put palette together if there are fields in it:
738 foreach ($parts as $part) {
739 if ($part['NAME'] !== '--linebreak--') {
744 if ($realFields > 0) {
747 $out .= $this->intoTemplate(
748 array('HEADER' => htmlspecialchars($header)),
749 $this->palFieldTemplateHeader
753 $collapsed = $this->isPalettesCollapsed($table, $palette);
756 if ($collapsed && $collapsedHeader !== NULL) {
757 list($thePalIcon,) = $this->wrapOpenPalette(
758 t3lib_iconWorks
::getSpriteIcon(
759 'actions-system-options-view',
760 array('title' => htmlspecialchars($this->getLL('l_moreOptions')))
761 ), $table, $row, $palette, 1);
762 $thePalIcon = '<span style="margin-left: 20px;">' . $thePalIcon . $collapsedHeader . '</span>';
765 $paletteHtml = $this->wrapPaletteField($this->printPalette($parts), $table, $row, $palette, $collapsed);
767 $out .= $this->intoTemplate(
768 array('PALETTE' => $thePalIcon . $paletteHtml),
769 $this->palFieldTemplate
777 * Returns the form HTML code for a database table field.
779 * @param string The table name
780 * @param string The field name
781 * @param array The record to edit from the database table.
782 * @param string Alternative field name label to show.
783 * @param boolean Set this if the field is on a palette (in top frame), otherwise not. (if set, field will render as a hidden field).
784 * @param string The "extra" options from "Part 4" of the field configurations found in the "types" "showitem" list. Typically parsed by $this->getSpecConfFromString() in order to get the options as an associative array.
785 * @param integer The palette pointer.
786 * @return mixed String (normal) or array (palettes)
788 function getSingleField($table, $field, $row, $altName = '', $palette = 0, $extra = '', $pal = 0) {
789 global $TCA, $BE_USER;
791 // Hook: getSingleField_preProcess
792 foreach ($this->hookObjectsSingleField
as $hookObj) {
793 if (method_exists($hookObj, 'getSingleField_preProcess')) {
794 $hookObj->getSingleField_preProcess($table, $field, $row, $altName, $palette, $extra, $pal, $this);
800 $PA['altName'] = $altName;
801 $PA['palette'] = $palette;
802 $PA['extra'] = $extra;
805 // Make sure to load full $TCA array for the table:
806 t3lib_div
::loadTCA($table);
808 // Get the TCA configuration for the current field:
809 $PA['fieldConf'] = $TCA[$table]['columns'][$field];
810 $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ?
$PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type']; // Using "form_type" locally in this script
812 $skipThisField = $this->inline
->skipField($table, $field, $row, $PA['fieldConf']['config']);
814 // Now, check if this field is configured and editable (according to excludefields + other configuration)
815 if (is_array($PA['fieldConf']) &&
817 (!$PA['fieldConf']['exclude'] ||
$BE_USER->check('non_exclude_fields', $table . ':' . $field)) &&
818 $PA['fieldConf']['config']['form_type'] != 'passthrough' &&
819 ($this->RTEenabled ||
!$PA['fieldConf']['config']['showIfRTE']) &&
820 (!$PA['fieldConf']['displayCond'] ||
$this->isDisplayCondition($PA['fieldConf']['displayCond'], $row)) &&
821 (!$TCA[$table]['ctrl']['languageField'] ||
$PA['fieldConf']['l10n_display'] ||
strcmp($PA['fieldConf']['l10n_mode'], 'exclude') ||
$row[$TCA[$table]['ctrl']['languageField']] <= 0) &&
822 (!$TCA[$table]['ctrl']['languageField'] ||
!$this->localizationMode ||
$this->localizationMode
=== $PA['fieldConf']['l10n_cat'])
826 // Fetching the TSconfig for the current table/field. This includes the $row which means that
827 $PA['fieldTSConfig'] = $this->setTSconfig($table, $row, $field);
829 // If the field is NOT disabled from TSconfig (which it could have been) then render it
830 if (!$PA['fieldTSConfig']['disabled']) {
831 // Override fieldConf by fieldTSconfig:
832 $PA['fieldConf']['config'] = $this->overrideFieldConf($PA['fieldConf']['config'], $PA['fieldTSConfig']);
835 $PA['itemFormElName'] = $this->prependFormFieldNames
. '[' . $table . '][' . $row['uid'] . '][' . $field . ']'; // Form field name
836 $PA['itemFormElName_file'] = $this->prependFormFieldNames_file
. '[' . $table . '][' . $row['uid'] . '][' . $field . ']'; // Form field name, in case of file uploads
837 $PA['itemFormElValue'] = $row[$field]; // The value to show in the form field.
838 $PA['itemFormElID'] = $this->prependFormFieldNames
. '_' . $table . '_' . $row['uid'] . '_' . $field;
840 // set field to read-only if configured for translated records to show default language content as readonly
841 if ($PA['fieldConf']['l10n_display'] && t3lib_div
::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly') && $row[$TCA[$table]['ctrl']['languageField']] > 0) {
842 $PA['fieldConf']['config']['readOnly'] = true;
843 $PA['itemFormElValue'] = $this->defaultLanguageData
[$table . ':' . $row['uid']][$field];
846 // 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"
848 ($TCA[$table]['ctrl']['type'] && !strcmp($field, $TCA[$table]['ctrl']['type'])) ||
849 ($TCA[$table]['ctrl']['requestUpdate'] && t3lib_div
::inList($TCA[$table]['ctrl']['requestUpdate'], $field))) {
850 if ($GLOBALS['BE_USER']->jsConfirmation(1)) {
851 $alertMsgOnChange = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
853 $alertMsgOnChange = 'if (TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
856 $alertMsgOnChange = '';
859 // Render as a hidden field?
860 if (in_array($field, $this->hiddenFieldListArr
)) {
861 $this->hiddenFieldAccum
[] = '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
862 } else { // Render as a normal field:
864 // 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.
865 if (!$PA['palette']) {
866 $paletteFields = $this->loadPaletteElements($table, $row, $PA['pal']);
867 if ($PA['pal'] && $this->isPalettesCollapsed($table, $PA['pal']) && count($paletteFields)) {
868 list($thePalIcon, $palJSfunc) = $this->wrapOpenPalette(t3lib_iconWorks
::getSpriteIcon('actions-system-options-view', array('title' => htmlspecialchars($this->getLL('l_moreOptions')))), $table, $row, $PA['pal'], 1);
874 // onFocus attribute to add to the field:
875 $PA['onFocus'] = ($palJSfunc && !$BE_USER->uc
['dontShowPalettesOnFocusInAB']) ?
' onfocus="' . htmlspecialchars($palJSfunc) . '"' : '';
879 $PA['label'] = ($PA['altName'] ?
$PA['altName'] : $PA['fieldConf']['label']);
880 $PA['label'] = ($PA['fieldTSConfig']['label'] ?
$PA['fieldTSConfig']['label'] : $PA['label']);
881 $PA['label'] = ($PA['fieldTSConfig']['label.'][$GLOBALS['LANG']->lang
] ?
$PA['fieldTSConfig']['label.'][$GLOBALS['LANG']->lang
] : $PA['label']);
882 $PA['label'] = $this->sL($PA['label']);
883 // JavaScript code for event handlers:
884 $PA['fieldChangeFunc'] = array();
885 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = "TBE_EDITOR.fieldChanged('" . $table . "','" . $row['uid'] . "','" . $field . "','" . $PA['itemFormElName'] . "');";
886 $PA['fieldChangeFunc']['alert'] = $alertMsgOnChange;
887 // if this is the child of an inline type and it is the field creating the label
888 if ($this->inline
->isInlineChildAndLabelField($table, $field)) {
889 $inlineObjectId = implode(
890 t3lib_TCEforms_inline
::Structure_Separator
,
892 $this->inline
->inlineNames
['object'],
897 $PA['fieldChangeFunc']['inline'] = "inline.handleChangedField('" . $PA['itemFormElName'] . "','" . $inlineObjectId . "');";
900 // Based on the type of the item, call a render function:
901 $item = $this->getSingleField_SW($table, $field, $row, $PA);
903 // Add language + diff
904 if ($PA['fieldConf']['l10n_display'] && (t3lib_div
::inList($PA['fieldConf']['l10n_display'], 'hideDiff') || t3lib_div
::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly'))) {
905 $renderLanguageDiff = false;
907 $renderLanguageDiff = true;
910 if ($renderLanguageDiff) {
911 $item = $this->renderDefaultLanguageContent($table, $field, $row, $item);
912 $item = $this->renderDefaultLanguageDiff($table, $field, $row, $item);
915 // 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
916 $label = t3lib_div
::deHSCentities(htmlspecialchars($PA['label']));
917 if (t3lib_div
::testInt($row['uid']) && $PA['fieldTSConfig']['linkTitleToSelf'] && !t3lib_div
::_GP('columnsOnly')) {
918 $lTTS_url = $this->backPath
. 'alt_doc.php?edit[' . $table . '][' . $row['uid'] . ']=edit&columnsOnly=' . $field . '&returnUrl=' . rawurlencode($this->thisReturnUrl());
919 $label = '<a href="' . htmlspecialchars($lTTS_url) . '">' . $label . '</a>';
922 // wrap the label with help text
923 $PA['label'] = $label = t3lib_BEfunc
::wrapInHelp($table, $field, $label);
925 // Create output value:
926 if ($PA['fieldConf']['config']['form_type'] == 'user' && $PA['fieldConf']['config']['noTableWrapping']) {
928 } elseif ($PA['palette']) {
937 $out = $this->addUserTemplateMarkers($out, $table, $field, $row, $PA);
945 'PAL_LINK_ICON' => $thePalIcon,
948 $out = $this->addUserTemplateMarkers($out, $table, $field, $row, $PA);
950 $out = $this->intoTemplate($out);
954 $this->commentMessages
[] = $this->prependFormFieldNames
. '[' . $table . '][' . $row['uid'] . '][' . $field . ']: Disabled by TSconfig';
957 // Hook: getSingleField_postProcess
958 foreach ($this->hookObjectsSingleField
as $hookObj) {
959 if (method_exists($hookObj, 'getSingleField_postProcess')) {
960 $hookObj->getSingleField_postProcess($table, $field, $row, $out, $PA, $this);
963 // Return value (string or array)
968 * Rendering a single item for the form
970 * @param string Table name of record
971 * @param string Fieldname to render
972 * @param array The record
973 * @param array parameters array containing a lot of stuff. Value by Reference!
974 * @return string Returns the item as HTML code to insert
976 * @see getSingleField(), getSingleField_typeFlex_draw()
978 function getSingleField_SW($table, $field, $row, &$PA) {
979 $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ?
$PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type']; // Using "form_type" locally in this script
981 // Hook: getSingleField_beforeRender
982 foreach ($this->hookObjectsSingleField
as $hookObject) {
983 if (method_exists($hookObject, 'getSingleField_beforeRender')) {
984 $hookObject->getSingleField_beforeRender($table, $field, $row, $PA);
988 switch ($PA['fieldConf']['config']['form_type']) {
990 $item = $this->getSingleField_typeInput($table, $field, $row, $PA);
993 $item = $this->getSingleField_typeText($table, $field, $row, $PA);
996 $item = $this->getSingleField_typeCheck($table, $field, $row, $PA);
999 $item = $this->getSingleField_typeRadio($table, $field, $row, $PA);
1002 $item = $this->getSingleField_typeSelect($table, $field, $row, $PA);
1005 $item = $this->getSingleField_typeGroup($table, $field, $row, $PA);
1008 $item = $this->inline
->getSingleField_typeInline($table, $field, $row, $PA);
1011 $item = $this->getSingleField_typeNone($table, $field, $row, $PA);
1014 $item = $this->getSingleField_typeUser($table, $field, $row, $PA);
1017 $item = $this->getSingleField_typeFlex($table, $field, $row, $PA);
1020 $item = $this->getSingleField_typeUnknown($table, $field, $row, $PA);
1028 /**********************************************************
1030 * Rendering of each TCEform field type
1032 ************************************************************/
1035 * Generation of TCEform elements of the type "input"
1036 * This will render a single-line input form field, possibly with various control/validation features
1038 * @param string The table name of the record
1039 * @param string The field name which this element is supposed to edit
1040 * @param array The record data array where the value(s) for the field can be found
1041 * @param array An array with additional configuration options.
1042 * @return string The HTML code for the TCEform field
1044 function getSingleField_typeInput($table, $field, $row, &$PA) {
1045 $config = $PA['fieldConf']['config'];
1047 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1048 $size = t3lib_div
::intInRange($config['size'] ?
$config['size'] : 30, 5, $this->maxInputWidth
);
1049 $evalList = t3lib_div
::trimExplode(',', $config['eval'], 1);
1050 $classAndStyleAttributes = $this->formWidthAsArray($size);
1052 $fieldAppendix = '';
1054 $cssClasses = array($classAndStyleAttributes['class']);
1055 $cssStyle = $classAndStyleAttributes['style'];
1057 if (!isset($config['checkbox'])) {
1058 $config['checkbox'] = '0';
1059 $checkboxIsset = FALSE;
1061 $checkboxIsset = TRUE;
1064 if (in_array('date', $evalList) ||
in_array('datetime', $evalList)) {
1065 if (in_array('datetime', $evalList)) {
1066 $class = 'datetime';
1071 if (isset($config['range']['lower'])) {
1072 $dateRange .= ' lower-' . intval($config['range']['lower']);
1074 if (isset($config['range']['upper'])) {
1075 $dateRange .= ' upper-' . intval($config['range']['upper']);
1077 $inputId = uniqid('tceforms-' . $class . 'field-');
1078 $cssClasses[] = 'tceforms-textfield tceforms-' . $class . 'field' . $dateRange;
1079 $fieldAppendix = t3lib_iconWorks
::getSpriteIcon(
1080 'actions-edit-pick-date',
1082 'style' => 'cursor:pointer;',
1083 'id' => 'picker-' . $inputId
1086 } elseif (in_array('timesec', $evalList)) {
1087 $inputId = uniqid('tceforms-timesecfield-');
1088 $cssClasses[] = 'tceforms-textfield tceforms-timesecfield';
1089 } elseif (in_array('year', $evalList)) {
1090 $inputId = uniqid('tceforms-yearfield-');
1091 $cssClasses[] = 'tceforms-textfield tceforms-yearfield';
1092 } elseif (in_array('time', $evalList)) {
1093 $inputId = uniqid('tceforms-timefield-');
1094 $cssClasses[] = 'tceforms-textfield tceforms-timefield';
1095 } elseif (in_array('int', $evalList)) {
1096 $inputId = uniqid('tceforms-intfield-');
1097 $cssClasses[] = 'tceforms-textfield tceforms-intfield';
1098 } elseif (in_array('double2', $evalList)) {
1099 $inputId = uniqid('tceforms-double2field-');
1100 $cssClasses[] = 'tceforms-textfield tceforms-double2field';
1102 $inputId = uniqid('tceforms-textfield-');
1103 $cssClasses[] = 'tceforms-textfield';
1104 if ($checkboxIsset === FALSE) {
1105 $config['checkbox'] = '';
1108 if (isset($config['wizards']['link'])) {
1109 $inputId = uniqid('tceforms-linkfield-');
1110 $cssClasses[] = 'tceforms-textfield tceforms-linkfield';
1112 } elseif (isset($config['wizards']['color'])) {
1113 $inputId = uniqid('tceforms-colorfield-');
1114 $cssClasses[] = 'tceforms-textfield tceforms-colorfield';
1117 if ($this->renderReadonly ||
$config['readOnly']) {
1118 $itemFormElValue = $PA['itemFormElValue'];
1119 if (in_array('date', $evalList)) {
1120 $config['format'] = 'date';
1121 } elseif (in_array('datetime', $evalList)) {
1122 $config['format'] = 'datetime';
1123 } elseif (in_array('time', $evalList)) {
1124 $config['format'] = 'time';
1126 if (in_array('password', $evalList)) {
1127 $itemFormElValue = $itemFormElValue ?
'*********' : '';
1129 return $this->getSingleField_typeNone_render($config, $itemFormElValue);
1132 foreach ($evalList as $func) {
1135 $this->registerRequiredProperty('field', $table . '_' . $row['uid'] . '_' . $field, $PA['itemFormElName']);
1136 // Mark this field for date/time disposal:
1137 if (array_intersect($evalList, array('date', 'datetime', 'time'))) {
1138 $this->requiredAdditional
[$PA['itemFormElName']]['isPositiveNumber'] = true;
1142 if (substr($func, 0, 3) == 'tx_') {
1143 // Pair hook to the one in t3lib_TCEmain::checkValue_input_Eval()
1144 $evalObj = t3lib_div
::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
1145 if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue')) {
1147 'value' => $PA['itemFormElValue']
1149 $PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
1156 $paramsList = "'" . $PA['itemFormElName'] . "','" . implode(',', $evalList) . "','" . trim($config['is_in']) . "'," . (isset($config['checkbox']) ?
1 : 0) . ",'" . $config['checkbox'] . "'";
1157 if ((in_array('date', $evalList) ||
in_array('datetime', $evalList))) {
1158 $item .= '<span class="t3-tceforms-input-wrapper-datetime" onmouseOver="if (document.getElementById(\'' .
1159 $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\';">';
1161 // Add server timezone offset to UTC to our stored date
1162 if ($PA['itemFormElValue'] > 0) {
1163 $PA['itemFormElValue'] +
= date('Z', $PA['itemFormElValue']);
1166 $item .= '<span class="t3-tceforms-input-wrapper" onmouseOver="if (document.getElementById(\'' . $inputId .
1167 '\').value) {this.className=\'t3-tceforms-input-wrapper-hover\';} else {this.className=\'t3-tceforms-input-wrapper\';};" onmouseOut="this.className=\'t3-tceforms-input-wrapper\';">';
1170 $PA['fieldChangeFunc'] = array_merge(
1171 array('typo3form.fieldGet' => 'typo3form.fieldGet(' . $paramsList . ');'),
1172 $PA['fieldChangeFunc']
1174 // old function "checkbox" now the option to set the date / remove the date
1175 if (isset($config['checkbox'])) {
1176 $item .= t3lib_iconWorks
::getSpriteIcon('actions-input-clear', array('tag' => 'a', 'class' => 't3-tceforms-input-clearer', 'onclick' => 'document.getElementById(\'' . $inputId . '\').value=\'\';document.getElementById(\'' . $inputId . '\').focus();' . implode('', $PA['fieldChangeFunc'])));
1178 $mLgd = ($config['max'] ?
$config['max'] : 256);
1179 $iOnChange = implode('', $PA['fieldChangeFunc']);
1181 $item .= '<input type="text" id="' . $inputId .
1182 '" class="' . implode(' ', $cssClasses) . '" name="' . $PA['itemFormElName'] .
1183 '_hr" value="" style="' . $cssStyle . '" maxlength="' . $mLgd . '" onchange="' .
1184 htmlspecialchars($iOnChange) . '"' . $PA['onFocus'] . ' />'; // This is the EDITABLE form field.
1185 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' .
1186 htmlspecialchars($PA['itemFormElValue']) . '" />'; // This is the ACTUAL form field - values from the EDITABLE field must be transferred to this field which is the one that is written to the database.
1187 $item .= $fieldAppendix . '</span><div style="clear:both;"></div>';
1188 $this->extJSCODE
.= 'typo3form.fieldSet(' . $paramsList . ');';
1190 // going through all custom evaluations configured for this field
1191 foreach ($evalList as $evalData) {
1192 if (substr($evalData, 0, 3) == 'tx_') {
1193 $evalObj = t3lib_div
::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$evalData] . ':&' . $evalData);
1194 if (is_object($evalObj) && method_exists($evalObj, 'returnFieldJS')) {
1195 $this->extJSCODE
.= "\n\nfunction " . $evalData . "(value) {\n" . $evalObj->returnFieldJS() . "\n}\n";
1200 // Creating an alternative item without the JavaScript handlers.
1201 $altItem = '<input type="hidden" name="' . $PA['itemFormElName'] . '_hr" value="" />';
1202 $altItem .= '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1204 // Wrap a wizard around the item?
1205 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'] . '_hr', $specConf);
1211 * Generation of TCEform elements of the type "text"
1212 * This will render a <textarea> OR RTE area form field, possibly with various control/validation features
1214 * @param string The table name of the record
1215 * @param string The field name which this element is supposed to edit
1216 * @param array The record data array where the value(s) for the field can be found
1217 * @param array An array with additional configuration options.
1218 * @return string The HTML code for the TCEform field
1220 function getSingleField_typeText($table, $field, $row, &$PA) {
1223 $config = $PA['fieldConf']['config'];
1224 $evalList = t3lib_div
::trimExplode(',', $config['eval'], 1);
1226 if ($this->renderReadonly ||
$config['readOnly']) {
1227 return $this->getSingleField_typeNone_render($config, $PA['itemFormElValue']);
1230 // Setting columns number:
1231 $cols = t3lib_div
::intInRange($config['cols'] ?
$config['cols'] : 30, 5, $this->maxTextareaWidth
);
1233 // Setting number of rows:
1234 $origRows = $rows = t3lib_div
::intInRange($config['rows'] ?
$config['rows'] : 5, 1, 20);
1235 if (strlen($PA['itemFormElValue']) > $this->charsPerRow
* 2) {
1236 $cols = $this->maxTextareaWidth
;
1237 $rows = t3lib_div
::intInRange(round(strlen($PA['itemFormElValue']) / $this->charsPerRow
), count(explode(LF
, $PA['itemFormElValue'])), 20);
1238 if ($rows < $origRows) {
1243 if (in_array('required', $evalList)) {
1244 $this->requiredFields
[$table . '_' . $row['uid'] . '_' . $field] = $PA['itemFormElName'];
1248 $RTEwasLoaded = 0; // Set true, if the RTE is loaded; If not a normal textarea is shown.
1249 $RTEwouldHaveBeenLoaded = 0; // Set true, if the RTE would have been loaded if it wasn't for the disable-RTE flag in the bottom of the page...
1251 // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. Traditionally, this is where RTE configuration has been found.
1252 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1254 // Setting up the altItem form field, which is a hidden field containing the value
1255 $altItem = '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1257 // If RTE is generally enabled (TYPO3_CONF_VARS and user settings)
1258 if ($this->RTEenabled
) {
1259 $p = t3lib_BEfunc
::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
1260 if (isset($specConf['richtext']) && (!$p['flag'] ||
!$row[$p['flag']])) { // If the field is configured for RTE and if any flag-field is not set to disable it.
1261 t3lib_BEfunc
::fixVersioningPid($table, $row);
1262 list($tscPID, $thePidValue) = $this->getTSCpid($table, $row['uid'], $row['pid']);
1264 // If the pid-value is not negative (that is, a pid could NOT be fetched)
1265 if ($thePidValue >= 0) {
1266 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', t3lib_BEfunc
::getPagesTSconfig($tscPID));
1267 $RTEtypeVal = t3lib_BEfunc
::getTCAtypeValue($table, $row);
1268 $thisConfig = t3lib_BEfunc
::RTEsetup($RTEsetup['properties'], $table, $field, $RTEtypeVal);
1270 if (!$thisConfig['disabled']) {
1271 if (!$this->disableRTE
) {
1272 $this->RTEcounter++
;
1274 // Find alternative relative path for RTE images/links:
1275 $eFile = t3lib_parsehtml_proc
::evalWriteFile($specConf['static_write'], $row);
1276 $RTErelPath = is_array($eFile) ?
dirname($eFile['relEditFile']) : '';
1278 // Get RTE object, draw form and set flag:
1279 $RTEobj = t3lib_BEfunc
::RTEgetObj();
1280 $item = $RTEobj->drawRTE($this, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue);
1283 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf, 1);
1287 $RTEwouldHaveBeenLoaded = 1;
1288 $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!)';
1291 $this->commentMessages
[] = $PA['itemFormElName'] . ': RTE is disabled by the Page TSconfig, "RTE"-key (eg. by RTE.default.disabled=0 or such)';
1294 $this->commentMessages
[] = $PA['itemFormElName'] . ': PID value could NOT be fetched. Rare error, normally with new records.';
1297 if (!isset($specConf['richtext'])) {
1298 $this->commentMessages
[] = $PA['itemFormElName'] . ': RTE was not configured for this field in TCA-types';
1300 if (!(!$p['flag'] ||
!$row[$p['flag']])) {
1301 $this->commentMessages
[] = $PA['itemFormElName'] . ': Field-flag (' . $PA['flag'] . ') has been set to disable RTE!';
1306 // Display ordinary field if RTE was not loaded.
1307 if (!$RTEwasLoaded) {
1308 if ($specConf['rte_only']) { // Show message, if no RTE (field can only be edited with RTE!)
1309 $item = '<p><em>' . htmlspecialchars($this->getLL('l_noRTEfound')) . '</em></p>';
1311 if ($specConf['nowrap']) {
1314 $wrap = ($config['wrap'] ?
$config['wrap'] : 'virtual');
1318 if ($specConf['fixed-font']) {
1319 $classes[] = 'fixed-font';
1321 if ($specConf['enable-tab']) {
1322 $classes[] = 'enable-tab';
1325 $formWidthText = $this->formWidthText($cols, $wrap);
1327 // Extract class attributes from $formWidthText (otherwise it would be added twice to the output)
1329 if (preg_match('/ class="(.+?)"/', $formWidthText, $res)) {
1330 $formWidthText = str_replace(' class="' . $res[1] . '"', '', $formWidthText);
1331 $classes = array_merge($classes, explode(' ', $res[1]));
1334 if (count($classes)) {
1335 $class = ' class="tceforms-textarea ' . implode(' ', $classes) . '"';
1337 $class = 'tceforms-textarea';
1340 $evalList = t3lib_div
::trimExplode(',', $config['eval'], 1);
1341 foreach ($evalList as $func) {
1344 $this->registerRequiredProperty('field', $table . '_' . $row['uid'] . '_' . $field, $PA['itemFormElName']);
1347 if (substr($func, 0, 3) == 'tx_') {
1348 // Pair hook to the one in t3lib_TCEmain::checkValue_input_Eval() and t3lib_TCEmain::checkValue_text_Eval()
1349 $evalObj = t3lib_div
::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
1350 if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue')) {
1352 'value' => $PA['itemFormElValue']
1354 $PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
1361 $iOnChange = implode('', $PA['fieldChangeFunc']);
1363 <textarea id="' . uniqid('tceforms-textarea-') . '" name="' . $PA['itemFormElName'] . '"' . $formWidthText . $class . ' rows="' . $rows . '" wrap="' . $wrap . '" onchange="' . htmlspecialchars($iOnChange) . '"' . $PA['onFocus'] . '>' .
1364 t3lib_div
::formatForTextarea($PA['itemFormElValue']) .
1366 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf, $RTEwouldHaveBeenLoaded);
1370 // Return field HTML:
1375 * Generation of TCEform elements of the type "check"
1376 * This will render a check-box OR an array of checkboxes
1378 * @param string The table name of the record
1379 * @param string The field name which this element is supposed to edit
1380 * @param array The record data array where the value(s) for the field can be found
1381 * @param array An array with additional configuration options.
1382 * @return string The HTML code for the TCEform field
1384 function getSingleField_typeCheck($table, $field, $row, &$PA) {
1385 $config = $PA['fieldConf']['config'];
1389 if ($this->renderReadonly ||
$config['readOnly']) {
1390 $disabled = ' disabled="disabled"';
1393 // Traversing the array of items:
1394 $selItems = $this->initItemArray($PA['fieldConf']);
1395 if ($config['itemsProcFunc']) {
1396 $selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
1399 if (!count($selItems)) {
1400 $selItems[] = array('', '');
1402 $thisValue = intval($PA['itemFormElValue']);
1404 $cols = intval($config['cols']);
1406 $item .= '<table border="0" cellspacing="0" cellpadding="0" class="typo3-TCEforms-checkboxArray">';
1407 for ($c = 0; $c < count($selItems); $c++
) {
1409 if (!($c %
$cols)) {
1412 $cBP = $this->checkBoxParams($PA['itemFormElName'], $thisValue, $c, count($selItems), implode('', $PA['fieldChangeFunc']));
1413 $cBName = $PA['itemFormElName'] . '_' . $c;
1414 $cBID = $PA['itemFormElID'] . '_' . $c;
1415 $item .= '<td nowrap="nowrap">' .
1416 '<input type="checkbox"' . $this->insertDefStyle('check') . ' value="1" name="' . $cBName . '"' . $cBP . $disabled . ' id="' . $cBID . '" />' .
1417 $this->wrapLabels('<label for="' . $cBID . '">' . htmlspecialchars($p[0]) . '</label> ') .
1419 if (($c %
$cols) +
1 == $cols) {
1424 $rest = $cols - ($c %
$cols);
1425 for ($c = 0; $c < $rest; $c++
) {
1426 $item .= '<td></td>';
1432 $item .= '</table>';
1434 for ($c = 0; $c < count($selItems); $c++
) {
1436 $cBP = $this->checkBoxParams($PA['itemFormElName'], $thisValue, $c, count($selItems), implode('', $PA['fieldChangeFunc']));
1437 $cBName = $PA['itemFormElName'] . '_' . $c;
1438 $cBID = $PA['itemFormElID'] . '_' . $c;
1439 $item .= ($c > 0 ?
'<br />' : '') .
1440 '<input type="checkbox"' . $this->insertDefStyle('check') . ' value="1" name="' . $cBName . '"' . $cBP . $PA['onFocus'] . $disabled . ' id="' . $cBID . '" />' .
1441 $this->wrapLabels('<label for="' . $cBID . '">' . htmlspecialchars($p[0]) . '</label>');
1445 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($thisValue) . '" />';
1452 * Generation of TCEform elements of the type "radio"
1453 * This will render a series of radio buttons.
1455 * @param string The table name of the record
1456 * @param string The field name which this element is supposed to edit
1457 * @param array The record data array where the value(s) for the field can be found
1458 * @param array An array with additional configuration options.
1459 * @return string The HTML code for the TCEform field
1461 function getSingleField_typeRadio($table, $field, $row, &$PA) {
1462 $config = $PA['fieldConf']['config'];
1466 if ($this->renderReadonly ||
$config['readOnly']) {
1467 $disabled = ' disabled="disabled"';
1470 // Get items for the array:
1471 $selItems = $this->initItemArray($PA['fieldConf']);
1472 if ($config['itemsProcFunc']) {
1473 $selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
1476 // Traverse the items, making the form elements:
1477 for ($c = 0; $c < count($selItems); $c++
) {
1479 $rID = $PA['itemFormElID'] . '_' . $c;
1480 $rOnClick = implode('', $PA['fieldChangeFunc']);
1481 $rChecked = (!strcmp($p[1], $PA['itemFormElValue']) ?
' checked="checked"' : '');
1482 $item .= '<input type="radio"' . $this->insertDefStyle('radio') . ' name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($p[1]) . '" onclick="' . htmlspecialchars($rOnClick) . '"' . $rChecked . $PA['onFocus'] . $disabled . ' id="' . $rID . '" />
1483 <label for="' . $rID . '">' . htmlspecialchars($p[0]) . '</label>
1491 * Generation of TCEform elements of the type "select"
1492 * This will render a selector box element, or possibly a special construction with two selector boxes. That depends on configuration.
1494 * @param string The table name of the record
1495 * @param string The field name which this element is supposed to edit
1496 * @param array The record data array where the value(s) for the field can be found
1497 * @param array An array with additional configuration options.
1498 * @return string The HTML code for the TCEform field
1500 function getSingleField_typeSelect($table, $field, $row, &$PA) {
1503 // Field configuration from TCA:
1504 $config = $PA['fieldConf']['config'];
1507 if ($this->renderReadonly ||
$config['readOnly']) {
1508 $disabled = ' disabled="disabled"';
1511 // "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/.
1512 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1514 // Getting the selector box items from the system
1515 $selItems = $this->addSelectOptionsToItemArray(
1516 $this->initItemArray($PA['fieldConf']),
1518 $this->setTSconfig($table, $row),
1521 // Possibly filter some items:
1522 $keepItemsFunc = create_function('$value', 'return $value[1];');
1523 $selItems = t3lib_div
::keepItemsInArray($selItems, $PA['fieldTSConfig']['keepItems'], $keepItemsFunc);
1524 // Possibly add some items:
1525 $selItems = $this->addItems($selItems, $PA['fieldTSConfig']['addItems.']);
1526 // Process items by a user function:
1527 if (isset($config['itemsProcFunc']) && $config['itemsProcFunc']) {
1528 $selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
1531 // Possibly remove some items:
1532 $removeItems = t3lib_div
::trimExplode(',', $PA['fieldTSConfig']['removeItems'], 1);
1533 foreach ($selItems as $tk => $p) {
1535 // Checking languages and authMode:
1536 $languageDeny = $TCA[$table]['ctrl']['languageField'] && !strcmp($TCA[$table]['ctrl']['languageField'], $field) && !$GLOBALS['BE_USER']->checkLanguageAccess($p[1]);
1537 $authModeDeny = $config['form_type'] == 'select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table, $field, $p[1], $config['authMode']);
1538 if (in_array($p[1], $removeItems) ||
$languageDeny ||
$authModeDeny) {
1539 unset($selItems[$tk]);
1540 } elseif (isset($PA['fieldTSConfig']['altLabels.'][$p[1]])) {
1541 $selItems[$tk][0] = $this->sL($PA['fieldTSConfig']['altLabels.'][$p[1]]);
1544 // Removing doktypes with no access:
1545 if (($table === 'pages' ||
$table === 'pages_language_overlay') && $field === 'doktype') {
1546 if (!($GLOBALS['BE_USER']->isAdmin() || t3lib_div
::inList($GLOBALS['BE_USER']->groupData
['pagetypes_select'], $p[1]))) {
1547 unset($selItems[$tk]);
1552 // Creating the label for the "No Matching Value" entry.
1553 $nMV_label = isset($PA['fieldTSConfig']['noMatchingValue_label']) ?
$this->sL($PA['fieldTSConfig']['noMatchingValue_label']) : '[ ' . $this->getLL('l_noMatchingValue') . ' ]';
1555 // Prepare some values:
1556 $maxitems = intval($config['maxitems']);
1558 // If a SINGLE selector box...
1559 if ($maxitems <= 1 && $config['renderMode'] !== 'tree') {
1560 $item = $this->getSingleField_typeSelect_single($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1561 } elseif (!strcmp($config['renderMode'], 'checkbox')) { // Checkbox renderMode
1562 $item = $this->getSingleField_typeSelect_checkbox($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1563 } elseif (!strcmp($config['renderMode'], 'singlebox')) { // Single selector box renderMode
1564 $item = $this->getSingleField_typeSelect_singlebox($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1565 } elseif (!strcmp($config['renderMode'], 'tree')) { // Tree renderMode
1566 $treeClass = t3lib_div
::makeInstance('t3lib_TCEforms_Tree', $this);
1567 $item = $treeClass->renderField($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1568 } else { // Traditional multiple selector box:
1569 $item = $this->getSingleField_typeSelect_multiple($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1574 $altItem = '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1575 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf);
1582 * Creates a single-selector box
1583 * (Render function for getSingleField_typeSelect())
1585 * @param string See getSingleField_typeSelect()
1586 * @param string See getSingleField_typeSelect()
1587 * @param array See getSingleField_typeSelect()
1588 * @param array See getSingleField_typeSelect()
1589 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1590 * @param array Items available for selection
1591 * @param string Label for no-matching-value
1592 * @return string The HTML code for the item
1593 * @see getSingleField_typeSelect()
1595 function getSingleField_typeSelect_single($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
1596 // check against inline uniqueness
1597 $inlineParent = $this->inline
->getStructureLevel(-1);
1598 if (is_array($inlineParent) && $inlineParent['uid']) {
1599 if ($inlineParent['config']['foreign_table'] == $table && $inlineParent['config']['foreign_unique'] == $field) {
1600 $uniqueIds = $this->inline
->inlineData
['unique'][$this->inline
->inlineNames
['object'] . '[' . $table . ']']['used'];
1601 $PA['fieldChangeFunc']['inlineUnique'] = "inline.updateUnique(this,'" . $this->inline
->inlineNames
['object'] . '[' . $table . "]','" . $this->inline
->inlineNames
['form'] . "','" . $row['uid'] . "');";
1603 // hide uid of parent record for symmetric relations
1604 if ($inlineParent['config']['foreign_table'] == $table && ($inlineParent['config']['foreign_field'] == $field ||
$inlineParent['config']['symmetric_field'] == $field)) {
1605 $uniqueIds[] = $inlineParent['uid'];
1612 $noMatchingValue = 1;
1614 $selicons = array();
1615 $onlySelectedIconShown = 0;
1616 $size = intval($config['size']);
1617 $selectedStyle = ''; // Style set on <select/>
1621 $onChangeIcon = ''; // TODO: icon is used but never assigned
1623 if ($this->renderReadonly ||
$config['readOnly']) {
1624 $disabled = ' disabled="disabled"';
1625 $onlySelectedIconShown = 1;
1628 // Icon configuration:
1629 if ($config['suppress_icons'] == 'IF_VALUE_FALSE') {
1630 $suppressIcons = !$PA['itemFormElValue'] ?
1 : 0;
1631 } elseif ($config['suppress_icons'] == 'ONLY_SELECTED') {
1633 $onlySelectedIconShown = 1;
1634 } elseif ($config['suppress_icons']) {
1640 // Traverse the Array of selector box items:
1641 $optGroupStart = array();
1642 $optGroupOpen = FALSE;
1643 $classesForSelectTag = array();
1644 foreach ($selItems as $p) {
1645 $sM = (!strcmp($PA['itemFormElValue'], $p[1]) ?
' selected="selected"' : '');
1648 $noMatchingValue = 0;
1651 // Getting style attribute value (for icons):
1652 if ($config['iconsInOptionTags']) {
1653 $styleAttrValue = $this->optionTagStyle($p[2]);
1655 list($selectIconFile, $selectIconInfo) = $this->getIcon($p[2]);
1656 if (!empty($selectIconInfo)) {
1657 $selectedStyle = ' style="background-image:url(' . $selectIconFile . ');"';
1658 $classesForSelectTag[] = 'typo3-TCEforms-select-selectedItemWithBackgroundImage';
1663 // Compiling the <option> tag:
1664 if (!($p[1] != $PA['itemFormElValue'] && is_array($uniqueIds) && in_array($p[1], $uniqueIds))) {
1665 if (!strcmp($p[1], '--div--')) {
1666 $optGroupStart[0] = $p[0];
1667 if ($config['iconsInOptionTags']) {
1668 $optGroupStart[1] = $this->optgroupTagStyle($p[2]);
1670 $optGroupStart[1] = $styleAttrValue;
1674 if (count($optGroupStart)) {
1675 if ($optGroupOpen) { // Closing last optgroup before next one starts
1676 $opt[] = '</optgroup>' . LF
;
1678 $opt[] = '<optgroup label="' . t3lib_div
::deHSCentities(htmlspecialchars($optGroupStart[0])) . '"' .
1679 ($optGroupStart[1] ?
' style="' . htmlspecialchars($optGroupStart[1]) . '"' : '') .
1680 ' class="c-divider">' . LF
;
1681 $optGroupOpen = TRUE;
1683 $optGroupStart = array();
1685 $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' .
1687 ($styleAttrValue ?
' style="' . htmlspecialchars($styleAttrValue) . '"' : '') .
1688 '>' . t3lib_div
::deHSCentities(($p[0])) . '</option>' . LF
;
1692 // If there is an icon for the selector box (rendered in selicon-table below)...:
1693 // if there is an icon ($p[2]), icons should be shown, and, if only selected are visible, is it selected
1694 if ($p[2] && !$suppressIcons && (!$onlySelectedIconShown ||
$sM)) {
1695 list($selIconFile, $selIconInfo) = $this->getIcon($p[2]);
1696 if (!empty($selIconInfo)) {
1697 $iOnClick = $this->elName($PA['itemFormElName']) . '.selectedIndex=' . $c . '; ' .
1698 $this->elName($PA['itemFormElName']) . '.style.backgroundImage=' . $this->elName($PA['itemFormElName']) . '.options[' . $c . '].style.backgroundImage; ' .
1699 implode('', $PA['fieldChangeFunc']) . $this->blur() . 'return false;';
1701 $iOnClick = $this->elName($PA['itemFormElName']) . '.selectedIndex=' . $c . '; ' .
1702 $this->elName($PA['itemFormElName']) . '.className=' . $this->elName($PA['itemFormElName']) . '.options[' . $c . '].className; ' .
1703 implode('', $PA['fieldChangeFunc']) . $this->blur() . 'return false;';
1705 $selicons[] = array(
1706 (!$onlySelectedIconShown ?
'<a href="#" onclick="' . htmlspecialchars($iOnClick) . '">' : '') .
1707 $this->getIconHtml($p[2], htmlspecialchars($p[0]), htmlspecialchars($p[0])) .
1708 (!$onlySelectedIconShown ?
'</a>' : ''),
1714 if ($optGroupOpen) { // Closing optgroup if open
1715 $opt[] = '</optgroup>';
1716 $optGroupOpen = false;
1719 // No-matching-value:
1720 if ($PA['itemFormElValue'] && $noMatchingValue && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1721 $nMV_label = @sprintf
($nMV_label, $PA['itemFormElValue']);
1722 $opt[] = '<option value="' . htmlspecialchars($PA['itemFormElValue']) . '" selected="selected">' . htmlspecialchars($nMV_label) . '</option>';
1725 // Create item form fields:
1726 $sOnChange = 'if (this.options[this.selectedIndex].value==\'--div--\') {this.selectedIndex=' . $sI . ';} ' . implode('', $PA['fieldChangeFunc']);
1728 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '_selIconVal" value="' . htmlspecialchars($sI) . '" />'; // MUST be inserted before the selector - else is the value of the hiddenfield here mysteriously submitted...
1730 if ($config['iconsInOptionTags']) {
1731 $classesForSelectTag[] = 'icon-select';
1733 $item .= '<select' . $selectedStyle . ' id="' . uniqid('tceforms-select-') . '" name="' . $PA['itemFormElName'] . '"' .
1734 $this->insertDefStyle('select', implode(' ', $classesForSelectTag)) .
1735 ($size ?
' size="' . $size . '"' : '') .
1736 ' onchange="' . htmlspecialchars($onChangeIcon . $sOnChange) . '"' .
1737 $PA['onFocus'] . $disabled . '>';
1738 $item .= implode('', $opt);
1739 $item .= '</select>';
1741 // Create icon table:
1742 if (count($selicons) && !$config['noIconsBelowSelect']) {
1743 $item .= '<table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-selectIcons">';
1744 $selicon_cols = intval($config['selicon_cols']);
1745 if (!$selicon_cols) {
1746 $selicon_cols = count($selicons);
1748 $sR = ceil(count($selicons) / $selicon_cols);
1749 $selicons = array_pad($selicons, $sR * $selicon_cols, '');
1750 for ($sa = 0; $sa < $sR; $sa++
) {
1752 for ($sb = 0; $sb < $selicon_cols; $sb++
) {
1753 $sk = ($sa * $selicon_cols +
$sb);
1754 $imgN = 'selIcon_' . $table . '_' . $row['uid'] . '_' . $field . '_' . $selicons[$sk][1];
1755 $imgS = ($selicons[$sk][2] ?
$this->backPath
. 'gfx/content_selected.gif' : 'clear.gif');
1756 $item .= '<td><img name="' . htmlspecialchars($imgN) . '" src="' . $imgS . '" width="7" height="10" alt="" /></td>';
1757 $item .= '<td>' . $selicons[$sk][0] . '</td>';
1761 $item .= '</table>';
1768 * Creates a checkbox list (renderMode = "checkbox")
1769 * (Render function for getSingleField_typeSelect())
1771 * @param string See getSingleField_typeSelect()
1772 * @param string See getSingleField_typeSelect()
1773 * @param array See getSingleField_typeSelect()
1774 * @param array See getSingleField_typeSelect()
1775 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1776 * @param array Items available for selection
1777 * @param string Label for no-matching-value
1778 * @return string The HTML code for the item
1779 * @see getSingleField_typeSelect()
1781 function getSingleField_typeSelect_checkbox($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
1783 if (empty($selItems)) {
1787 // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
1788 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
1792 if ($this->renderReadonly ||
$config['readOnly']) {
1793 $disabled = ' disabled="disabled"';
1796 // Traverse the Array of selector box items:
1800 $sOnChange = implode('', $PA['fieldChangeFunc']);
1801 $setAll = array(); // Used to accumulate the JS needed to restore the original selection.
1802 $unSetAll = array();
1803 foreach ($selItems as $p) {
1804 // Non-selectable element:
1805 if (!strcmp($p[1], '--div--')) {
1807 <tr class="c-header">
1808 <td colspan="3">' . htmlspecialchars($p[0]) . '</td>
1811 // Selected or not by default:
1813 if (isset($itemArray[$p[1]])) {
1814 $sM = ' checked="checked"';
1815 unset($itemArray[$p[1]]);
1822 $selIcon = t3lib_iconWorks
::getSpriteIcon('empty-empty');
1826 $rowId = uniqid('select_checkbox_row_');
1827 $onClickCell = $this->elName($PA['itemFormElName'] . '[' . $c . ']') . '.checked=!' . $this->elName($PA['itemFormElName'] . '[' . $c . ']') . '.checked;';
1828 $onClick = 'this.attributes.getNamedItem("class").nodeValue = ' . $this->elName($PA['itemFormElName'] . '[' . $c . ']') . '.checked ? "c-selectedItem" : "c-unselectedItem";';
1829 $setAll[] = $this->elName($PA['itemFormElName'] . '[' . $c . ']') . '.checked=1;';
1830 $setAll[] .= '$(\'' . $rowId . '\').removeClassName(\'c-unselectedItem\');$(\'' . $rowId . '\').addClassName(\'c-selectedItem\');';
1831 $unSetAll[] = $this->elName($PA['itemFormElName'] . '[' . $c . ']') . '.checked=0;';
1832 $unSetAll[] .= '$(\'' . $rowId . '\').removeClassName(\'c-selectedItem\');$(\'' . $rowId . '\').addClassName(\'c-unselectedItem\');';
1833 $restoreCmd[] = $this->elName($PA['itemFormElName'] . '[' . $c . ']') . '.checked=' . ($sM ?
1 : 0) . ';' .
1834 '$(\'' . $rowId . '\').removeClassName(\'c-selectedItem\');$(\'' . $rowId . '\').removeClassName(\'c-unselectedItem\');' .
1835 '$(\'' . $rowId . '\').addClassName(\'c-' . ($sM ?
'' : 'un') . 'selectedItem\');';
1837 // Check if some help text is available
1838 // Since TYPO3 4.5 help text is expected to be an associative array
1839 // with two key, "title" and "description"
1840 // For the sake of backwards compatibility, we test if the help text
1841 // is a string and use it as a description (this could happen if items
1842 // are modified with an itemProcFunc)
1845 $helpArray = array();
1846 if ((is_array($p[3]) && count($p[3]) > 0) ||
!empty($p[3])) {
1848 if (is_array($p[3])) {
1851 $helpArray['description'] = $p[3];
1855 $label = t3lib_div
::deHSCentities(htmlspecialchars($p[0]));
1857 $help = t3lib_BEfunc
::wrapInHelp('', '', '', $helpArray);
1861 <tr id="' . $rowId . '" class="' . ($sM ?
'c-selectedItem' : 'c-unselectedItem') . '" onclick="' . htmlspecialchars($onClick) . '" style="cursor: pointer;">
1862 <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>
1863 <td class="c-labelCell" onclick="' . htmlspecialchars($onClickCell) . '">' .
1864 $this->getIconHtml($selIcon) .
1867 <td class="c-descr" onclick="' . htmlspecialchars($onClickCell) . '">' . ((empty($help)) ?
'' : $help) . '</td>
1874 // Remaining values (invalid):
1875 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1876 foreach ($itemArray as $theNoMatchValue => $temp) {
1877 // Compile <checkboxes> tag:
1878 array_unshift($tRows, '
1879 <tr class="c-invalidItem">
1880 <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>
1881 <td class="c-labelCell">' .
1882 t3lib_div
::deHSCentities(htmlspecialchars(@sprintf
($nMV_label, $theNoMatchValue))) .
1883 '</td><td> </td>
1889 // Add an empty hidden field which will send a blank value if all items are unselected.
1890 $item .= '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="" />';
1892 // Remaining checkboxes will get their set-all link:
1893 if (count($setAll)) {
1894 $tableHead = '<thead>
1895 <tr class="c-header-checkbox-controls t3-row-header">
1896 <td class="c-checkbox">
1897 <input type="checkbox" class="checkbox" onclick="if (checked) {' . htmlspecialchars(implode('', $setAll) . '} else {' . implode('', $unSetAll) . '}') . '">
1903 // Implode rows in table:
1905 <table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-select-checkbox">' .
1907 '<tbody>' . implode('', $tRows) . '</tbody>
1912 if (is_array($restoreCmd)) {
1913 $item .= '<a href="#" onclick="' . implode('', $restoreCmd) . ' return false;' . '">' .
1914 t3lib_iconWorks
::getSpriteIcon('actions-edit-undo', array('title' => htmlspecialchars($this->getLL('l_revertSelection')))) . '</a>';
1921 * Creates a selectorbox list (renderMode = "singlebox")
1922 * (Render function for getSingleField_typeSelect())
1924 * @param string See getSingleField_typeSelect()
1925 * @param string See getSingleField_typeSelect()
1926 * @param array See getSingleField_typeSelect()
1927 * @param array See getSingleField_typeSelect()
1928 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1929 * @param array Items available for selection
1930 * @param string Label for no-matching-value
1931 * @return string The HTML code for the item
1932 * @see getSingleField_typeSelect()
1934 function getSingleField_typeSelect_singlebox($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
1936 // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
1937 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
1941 if ($this->renderReadonly ||
$config['readOnly']) {
1942 $disabled = ' disabled="disabled"';
1945 // Traverse the Array of selector box items:
1947 $restoreCmd = array(); // Used to accumulate the JS needed to restore the original selection.
1949 foreach ($selItems as $p) {
1950 // Selected or not by default:
1952 if (isset($itemArray[$p[1]])) {
1953 $sM = ' selected="selected"';
1954 $restoreCmd[] = $this->elName($PA['itemFormElName'] . '[]') . '.options[' . $c . '].selected=1;';
1955 unset($itemArray[$p[1]]);
1958 // Non-selectable element:
1960 if (!strcmp($p[1], '--div--')) {
1961 $nonSel = ' onclick="this.selected=0;" class="c-divider"';
1964 // Icon style for option tag:
1965 if ($config['iconsInOptionTags']) {
1966 $styleAttrValue = $this->optionTagStyle($p[2]);
1969 // Compile <option> tag:
1970 $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' .
1973 ($styleAttrValue ?
' style="' . htmlspecialchars($styleAttrValue) . '"' : '') .
1974 '>' . t3lib_div
::deHSCentities(htmlspecialchars($p[0])) . '</option>';
1978 // Remaining values:
1979 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1980 foreach ($itemArray as $theNoMatchValue => $temp) {
1981 // Compile <option> tag:
1982 array_unshift($opt, '<option value="' . htmlspecialchars($theNoMatchValue) . '" selected="selected">' . t3lib_div
::deHSCentities(htmlspecialchars(@sprintf
($nMV_label, $theNoMatchValue))) . '</option>');
1986 // Compile selector box:
1987 $sOnChange = implode('', $PA['fieldChangeFunc']);
1988 $selector_itemListStyle = isset($config['itemListStyle']) ?
' style="' . htmlspecialchars($config['itemListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle
. '"';
1989 $size = intval($config['size']);
1990 $cssPrefix = ($size === 1) ?
'tceforms-select' : 'tceforms-multiselect';
1991 $size = $config['autoSizeMax'] ? t3lib_div
::intInRange(count($selItems) +
1, t3lib_div
::intInRange($size, 1), $config['autoSizeMax']) : $size;
1992 $selectBox = '<select id="' . uniqid($cssPrefix) . '" name="' . $PA['itemFormElName'] . '[]"' .
1993 $this->insertDefStyle('select', $cssPrefix) .
1994 ($size ?
' size="' . $size . '"' : '') .
1995 ' multiple="multiple" onchange="' . htmlspecialchars($sOnChange) . '"' .
1997 $selector_itemListStyle .
2004 // Add an empty hidden field which will send a blank value if all items are unselected.
2006 $item .= '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="" />';
2009 // Put it all into a table:
2011 <table border="0" cellspacing="0" cellpadding="0" width="1" class="typo3-TCEforms-select-singlebox">
2017 htmlspecialchars($this->getLL('l_holdDownCTRL')) .
2021 <a href="#" onclick="' . htmlspecialchars($this->elName($PA['itemFormElName'] . '[]') . '.selectedIndex=-1;' . implode('', $restoreCmd) . ' return false;') . '" title="' . htmlspecialchars($this->getLL('l_revertSelection')) . '">' .
2022 t3lib_iconWorks
::getSpriteIcon('actions-edit-undo') .
2033 * Creates a multiple-selector box (two boxes, side-by-side)
2034 * (Render function for getSingleField_typeSelect())
2036 * @param string See getSingleField_typeSelect()
2037 * @param string See getSingleField_typeSelect()
2038 * @param array See getSingleField_typeSelect()
2039 * @param array See getSingleField_typeSelect()
2040 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
2041 * @param array Items available for selection
2042 * @param string Label for no-matching-value
2043 * @return string The HTML code for the item
2044 * @see getSingleField_typeSelect()
2046 function getSingleField_typeSelect_multiple($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
2050 if ($this->renderReadonly ||
$config['readOnly']) {
2051 $disabled = ' disabled="disabled"';
2054 // Setting this hidden field (as a flag that JavaScript can read out)
2056 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '_mul" value="' . ($config['multiple'] ?
1 : 0) . '" />';
2059 // Set max and min items:
2060 $maxitems = t3lib_div
::intInRange($config['maxitems'], 0);
2064 $minitems = t3lib_div
::intInRange($config['minitems'], 0);
2066 // Register the required number of elements:
2067 $this->registerRequiredProperty('range', $PA['itemFormElName'], array($minitems, $maxitems, 'imgName' => $table . '_' . $row['uid'] . '_' . $field));
2069 // Get "removeItems":
2070 $removeItems = t3lib_div
::trimExplode(',', $PA['fieldTSConfig']['removeItems'], 1);
2072 // Get the array with selected items:
2073 $itemArray = t3lib_div
::trimExplode(',', $PA['itemFormElValue'], 1);
2075 // Possibly filter some items:
2076 $keepItemsFunc = create_function('$value', '$parts=explode(\'|\',$value,2); return rawurldecode($parts[0]);');
2077 $itemArray = t3lib_div
::keepItemsInArray($itemArray, $PA['fieldTSConfig']['keepItems'], $keepItemsFunc);
2079 // Perform modification of the selected items array:
2080 foreach ($itemArray as $tk => $tv) {
2081 $tvP = explode('|', $tv, 2);
2082 $evalValue = $tvP[0];
2083 $isRemoved = in_array($evalValue, $removeItems) ||
($config['form_type'] == 'select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table, $field, $evalValue, $config['authMode']));
2084 if ($isRemoved && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
2085 $tvP[1] = rawurlencode(@sprintf
($nMV_label, $evalValue));
2086 } elseif (isset($PA['fieldTSConfig']['altLabels.'][$evalValue])) {
2087 $tvP[1] = rawurlencode($this->sL($PA['fieldTSConfig']['altLabels.'][$evalValue]));
2089 if ($tvP[1] == '') {
2090 // Case: flexform, default values supplied, no label provided (bug #9795)
2091 foreach ($selItems as $selItem) {
2092 if ($selItem[1] == $tvP[0]) {
2093 $tvP[1] = html_entity_decode($selItem[0]);
2098 $itemArray[$tk] = implode('|', $tvP);
2100 $itemsToSelect = '';
2103 // Create option tags:
2105 $styleAttrValue = '';
2106 foreach ($selItems as $p) {
2107 if ($config['iconsInOptionTags']) {
2108 $styleAttrValue = $this->optionTagStyle($p[2]);
2110 $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' .
2111 ($styleAttrValue ?
' style="' . htmlspecialchars($styleAttrValue) . '"' : '') .
2112 '>' . $p[0] . '</option>';
2115 // Put together the selector box:
2116 $selector_itemListStyle = isset($config['itemListStyle']) ?
' style="' . htmlspecialchars($config['itemListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle
. '"';
2117 $size = intval($config['size']);
2118 $size = $config['autoSizeMax'] ? t3lib_div
::intInRange(count($itemArray) +
1, t3lib_div
::intInRange($size, 1), $config['autoSizeMax']) : $size;
2119 if ($config['exclusiveKeys']) {
2120 $sOnChange = 'setFormValueFromBrowseWin(\'' . $PA['itemFormElName'] . '\',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text,\'' . $config['exclusiveKeys'] . '\'); ';
2122 $sOnChange = 'setFormValueFromBrowseWin(\'' . $PA['itemFormElName'] . '\',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text); ';
2124 $sOnChange .= implode('', $PA['fieldChangeFunc']);
2126 <select id="' . uniqid('tceforms-multiselect-') . '" name="' . $PA['itemFormElName'] . '_sel"' .
2127 $this->insertDefStyle('select', 'tceforms-multiselect tceforms-itemstoselect') .
2128 ($size ?
' size="' . $size . '"' : '') .
2129 ' onchange="' . htmlspecialchars($sOnChange) . '"' .
2131 $selector_itemListStyle . '>
2137 // Pass to "dbFileIcons" function:
2140 'autoSizeMax' => t3lib_div
::intInRange($config['autoSizeMax'], 0),
2141 'style' => isset($config['selectedListStyle']) ?
' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle
. '"',
2142 'dontShowMoveIcons' => ($maxitems <= 1),
2143 'maxitems' => $maxitems,
2146 'selector' => $this->getLL('l_selected') . ':<br />',
2147 'items' => $this->getLL('l_items') . ':<br />'
2150 'thumbnails' => $itemsToSelect,
2151 'readOnly' => $disabled
2153 $item .= $this->dbFileIcons($PA['itemFormElName'], '', '', $itemArray, '', $params, $PA['onFocus']);
2159 * Generation of TCEform elements of the type "group"
2160 * This will render a selectorbox into which elements from either the file system or database can be inserted. Relations.
2162 * @param string The table name of the record
2163 * @param string The field name which this element is supposed to edit
2164 * @param array The record data array where the value(s) for the field can be found
2165 * @param array An array with additional configuration options.
2166 * @return string The HTML code for the TCEform field
2168 function getSingleField_typeGroup($table, $field, $row, &$PA) {
2170 $config = $PA['fieldConf']['config'];
2171 $internal_type = $config['internal_type'];
2172 $show_thumbs = $config['show_thumbs'];
2173 $size = intval($config['size']);
2174 $maxitems = t3lib_div
::intInRange($config['maxitems'], 0);
2178 $minitems = t3lib_div
::intInRange($config['minitems'], 0);
2179 $allowed = trim($config['allowed']);
2180 $disallowed = trim($config['disallowed']);
2184 if ($this->renderReadonly ||
$config['readOnly']) {
2185 $disabled = ' disabled="disabled"';
2188 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '_mul" value="' . ($config['multiple'] ?
1 : 0) . '"' . $disabled . ' />';
2189 $this->registerRequiredProperty('range', $PA['itemFormElName'], array($minitems, $maxitems, 'imgName' => $table . '_' . $row['uid'] . '_' . $field));
2192 // "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/.
2193 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
2195 $PA['itemFormElID_file'] = $PA['itemFormElID'] . '_files';
2197 // whether the list controls should be disabled
2198 $noList = isset($config['disable_controls']) && t3lib_div
::inList($config['disable_controls'], 'list');
2200 // if maxitems==1 then automatically replace the current item (in list and file selector)
2201 if ($maxitems === 1) {
2202 $this->additionalJS_post
[] = "TBE_EDITOR.clearBeforeSettingFormValueFromBrowseWin['" . $PA['itemFormElName'] . "'] = {
2203 itemFormElID_file: '" . $PA['itemFormElID_file'] . "'
2205 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = "setFormValueManipulate('" . $PA['itemFormElName'] . "', 'Remove'); " . $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'];
2206 } elseif ($noList) {
2207 // if the list controls have been removed and the maximum number is reached, remove the first entry to avoid "write once" field
2208 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = "setFormValueManipulate('" . $PA['itemFormElName'] . "', 'RemoveFirstIfFull', '" . $maxitems . "'); " . $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'];
2211 // Acting according to either "file" or "db" type:
2212 switch ((string) $config['internal_type']) {
2213 case 'file_reference':
2214 $config['uploadfolder'] = '';
2216 case 'file': // If the element is of the internal type "file":
2218 // Creating string showing allowed types:
2219 $tempFT = t3lib_div
::trimExplode(',', $allowed, TRUE);
2220 if (!count($tempFT)) {
2223 foreach ($tempFT as $ext) {
2225 $info .= strtoupper($ext) . ' ';
2228 // Creating string, showing disallowed types:
2229 $tempFT_dis = t3lib_div
::trimExplode(',', $disallowed, TRUE);
2230 if (count($tempFT_dis)) {
2233 foreach ($tempFT_dis as $ext) {
2235 $info .= '-' . strtoupper($ext) . ' ';
2239 // Making the array of file items:
2240 $itemArray = t3lib_div
::trimExplode(',', $PA['itemFormElValue'], TRUE);
2242 // Showing thumbnails:
2246 foreach ($itemArray as $imgRead) {
2247 $imgP = explode('|', $imgRead);
2248 $imgPath = rawurldecode($imgP[0]);
2251 $rowCopy[$field] = $imgPath;
2253 $imgs[] = '<span class="nobr">' . t3lib_BEfunc
::thumbCode($rowCopy, $table, $field, $this->backPath
, 'thumbs.php', $config['uploadfolder'], 0, ' align="middle"') .
2257 $thumbsnail = implode('<br />', $imgs);
2260 // Creating the element:
2263 'dontShowMoveIcons' => ($maxitems <= 1),
2264 'autoSizeMax' => t3lib_div
::intInRange($config['autoSizeMax'], 0),
2265 'maxitems' => $maxitems,
2266 'style' => isset($config['selectedListStyle']) ?
' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle
. '"',
2268 'thumbnails' => $thumbsnail,
2269 'readOnly' => $disabled,
2270 'noBrowser' => $noList ||
(isset($config['disable_controls']) && t3lib_div
::inList($config['disable_controls'], 'browser')),
2271 'noList' => $noList,
2273 $item .= $this->dbFileIcons($PA['itemFormElName'], 'file', implode(',', $tempFT), $itemArray, '', $params, $PA['onFocus']);
2275 if (!$disabled && !(isset($config['disable_controls']) && t3lib_div
::inList($config['disable_controls'], 'upload'))) {
2276 // Adding the upload field:
2277 if ($this->edit_docModuleUpload
&& $config['uploadfolder']) {
2278 $item .= '<div id="' . $PA['itemFormElID_file'] . '"><input type="file" name="' . $PA['itemFormElName_file'] . '" size="35" onchange="' . implode('', $PA['fieldChangeFunc']) . '" /></div>';
2282 case 'folder': // If the element is of the internal type "folder":
2284 // array of folder items:
2285 $itemArray = t3lib_div
::trimExplode(',', $PA['itemFormElValue'], 1);
2287 // Creating the element:
2290 'dontShowMoveIcons' => ($maxitems <= 1),
2291 'autoSizeMax' => t3lib_div
::intInRange($config['autoSizeMax'], 0),
2292 'maxitems' => $maxitems,
2293 'style' => isset($config['selectedListStyle']) ?
2294 ' style="' . htmlspecialchars($config['selectedListStyle']) . '"'
2295 : ' style="' . $this->defaultMultipleSelectorStyle
. '"',
2297 'readOnly' => $disabled,
2298 'noBrowser' => $noList ||
(isset($config['disable_controls']) && t3lib_div
::inList($config['disable_controls'], 'browser')),
2299 'noList' => $noList,
2302 $item .= $this->dbFileIcons(
2303 $PA['itemFormElName'],
2312 case 'db': // If the element is of the internal type "db":
2314 // Creating string showing allowed types:
2315 $tempFT = t3lib_div
::trimExplode(',', $allowed, TRUE);
2316 if (!strcmp(trim($tempFT[0]), '*')) {
2317 $onlySingleTableAllowed = false;
2318 $info .= '<span class="nobr">' .
2319 htmlspecialchars($this->getLL('l_allTables')) .
2321 } elseif ($tempFT) {
2322 $onlySingleTableAllowed = (count($tempFT) == 1);
2323 foreach ($tempFT as $theT) {
2324 $info .= '<span class="nobr">' .
2325 t3lib_iconWorks
::getSpriteIconForRecord($theT, array()) .
2326 htmlspecialchars($this->sL($GLOBALS['TCA'][$theT]['ctrl']['title'])) .
2331 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
2332 $itemArray = array();
2336 $temp_itemArray = t3lib_div
::trimExplode(',', $PA['itemFormElValue'], 1);
2337 foreach ($temp_itemArray as $dbRead) {
2338 $recordParts = explode('|', $dbRead);
2339 list($this_table, $this_uid) = t3lib_BEfunc
::splitTable_Uid($recordParts[0]);
2340 // For the case that no table was found and only a single table is defined to be allowed, use that one:
2341 if (!$this_table && $onlySingleTableAllowed) {
2342 $this_table = $allowed;
2344 $itemArray[] = array('table' => $this_table, 'id' => $this_uid);
2345 if (!$disabled && $show_thumbs) {
2346 $rr = t3lib_BEfunc
::getRecordWSOL($this_table, $this_uid);
2347 $imgs[] = '<span class="nobr">' .
2348 $this->getClickMenu(
2349 t3lib_iconWorks
::getSpriteIconForRecord(
2353 'style' => 'vertical-align:top',
2354 'title' => htmlspecialchars(t3lib_BEfunc
::getRecordPath($rr['pid'], $perms_clause, 15) . ' [UID: ' . $rr['uid'] . ']')
2361 t3lib_BEfunc
::getRecordTitle($this_table, $rr, TRUE) . ' <span class="typo3-dimmed"><em>[' . $rr['uid'] . ']</em></span>' .
2366 if (!$disabled && $show_thumbs) {
2367 $thumbsnail = implode('<br />', $imgs);
2370 // Creating the element:
2373 'dontShowMoveIcons' => ($maxitems <= 1),
2374 'autoSizeMax' => t3lib_div
::intInRange($config['autoSizeMax'], 0),
2375 'maxitems' => $maxitems,
2376 'style' => isset($config['selectedListStyle']) ?
' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle
. '"',
2378 'thumbnails' => $thumbsnail,
2379 'readOnly' => $disabled,
2380 'noBrowser' => $noList ||
(isset($config['disable_controls']) && t3lib_div
::inList($config['disable_controls'], 'browser')),
2381 'noList' => $noList,
2383 $item .= $this->dbFileIcons($PA['itemFormElName'], 'db', implode(',', $tempFT), $itemArray, '', $params, $PA['onFocus'], $table, $field, $row['uid']);
2389 $altItem = '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
2391 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf);
2398 * Generation of TCEform elements of the type "none"
2399 * This will render a non-editable display of the content of the field.
2401 * @param string The table name of the record
2402 * @param string The field name which this element is supposed to edit
2403 * @param array The record data array where the value(s) for the field can be found
2404 * @param array An array with additional configuration options.
2405 * @return string The HTML code for the TCEform field
2407 function getSingleField_typeNone($table, $field, $row, &$PA) {
2409 $config = $PA['fieldConf']['config'];
2410 $itemValue = $PA['itemFormElValue'];
2412 return $this->getSingleField_typeNone_render($config, $itemValue);
2416 * HTML rendering of a value which is not editable.
2418 * @param array Configuration for the display
2419 * @param string The value to display
2420 * @return string The HTML code for the display
2421 * @see getSingleField_typeNone();
2423 function getSingleField_typeNone_render($config, $itemValue) {
2425 // is colorScheme[0] the right value?
2426 $divStyle = 'border:solid 1px ' . t3lib_div
::modifyHTMLColorAll($this->colorScheme
[0], -30) . ';' . $this->defStyle
. $this->formElStyle('none') . ' background-color: ' . $this->colorScheme
[0] . '; padding-left:1px;color:#555;';
2428 if ($config['format']) {
2429 $itemValue = $this->formatValue($config, $itemValue);
2432 $rows = intval($config['rows']);
2434 if (!$config['pass_content']) {
2435 $itemValue = nl2br(htmlspecialchars($itemValue));
2438 $cols = t3lib_div
::intInRange($config['cols'] ?
$config['cols'] : 30, 5, $this->maxTextareaWidth
);
2439 if (!$config['fixedRows']) {
2440 $origRows = $rows = t3lib_div
::intInRange($rows, 1, 20);
2441 if (strlen($itemValue) > $this->charsPerRow
* 2) {
2442 $cols = $this->maxTextareaWidth
;
2443 $rows = t3lib_div
::intInRange(round(strlen($itemValue) / $this->charsPerRow
), count(explode(LF
, $itemValue)), 20);
2444 if ($rows < $origRows) {
2450 if ($this->docLarge
) {
2451 $cols = round($cols * $this->form_largeComp
);
2453 $width = ceil($cols * $this->form_rowsToStylewidth
);
2454 // hardcoded: 12 is the height of the font
2455 $height = $rows * 12;
2458 <div style="' . htmlspecialchars($divStyle . ' overflow:auto; height:' . $height . 'px; width:' . $width . 'px;') . '" class="' . htmlspecialchars($this->formElClass('none')) . '">' .
2462 if (!$config['pass_content']) {
2463 $itemValue = htmlspecialchars($itemValue);
2466 $cols = $config['cols'] ?
$config['cols'] : ($config['size'] ?
$config['size'] : $this->maxInputWidth
);
2467 if ($this->docLarge
) {
2468 $cols = round($cols * $this->form_largeComp
);
2470 $width = ceil($cols * $this->form_rowsToStylewidth
);
2472 // overflow:auto crashes mozilla here. Title tag is usefull when text is longer than the div box (overflow:hidden).
2474 <div style="' . htmlspecialchars($divStyle . ' overflow:hidden; width:' . $width . 'px;') . '" class="' . htmlspecialchars($this->formElClass('none')) . '" title="' . $itemValue . '">' .
2475 '<span class="nobr">' . (strcmp($itemValue, '') ?
$itemValue : ' ') . '</span>' .
2483 * Handler for Flex Forms
2485 * @param string The table name of the record
2486 * @param string The field name which this element is supposed to edit
2487 * @param array The record data array where the value(s) for the field can be found
2488 * @param array An array with additional configuration options.
2489 * @return string The HTML code for the TCEform field
2491 function getSingleField_typeFlex($table, $field, $row, &$PA) {
2494 $dataStructArray = t3lib_BEfunc
::getFlexFormDS($PA['fieldConf']['config'], $row, $table);
2497 // Manipulate Flexform DS via TSConfig and group access lists
2498 if (is_array($dataStructArray)) {
2499 $flexFormHelper = t3lib_div
::makeInstance('t3lib_TCEforms_Flexforms');
2500 $dataStructArray = $flexFormHelper->modifyFlexFormDS($dataStructArray, $table, $field, $row, $PA['fieldConf']['config']);
2501 unset($flexFormHelper);
2504 // Get data structure:
2505 if (is_array($dataStructArray)) {
2508 $xmlData = $PA['itemFormElValue'];
2509 $xmlHeaderAttributes = t3lib_div
::xmlGetHeaderAttribs($xmlData);
2510 $storeInCharset = strtolower($xmlHeaderAttributes['encoding']);
2511 if ($storeInCharset) {
2512 $currentCharset = $GLOBALS['LANG']->charSet
;
2513 $xmlData = $GLOBALS['LANG']->csConvObj
->conv($xmlData, $storeInCharset, $currentCharset, 1);
2515 $editData = t3lib_div
::xml2array($xmlData);
2516 if (!is_array($editData)) { // Must be XML parsing error...
2517 $editData = array();
2518 } elseif (!isset($editData['meta']) ||
!is_array($editData['meta'])) {
2519 $editData['meta'] = array();
2522 // Find the data structure if sheets are found:
2523 $sheet = $editData['meta']['currentSheetId'] ?
$editData['meta']['currentSheetId'] : 'sDEF'; // Sheet to display
2525 // Create sheet menu:
2526 //TODO; Why is this commented out?
2527 // if (is_array($dataStructArray['sheets'])) {
2528 // #$item.=$this->getSingleField_typeFlex_sheetMenu($dataStructArray['sheets'], $PA['itemFormElName'].'[meta][currentSheetId]', $sheet).'<br />';
2531 // Create language menu:
2532 $langChildren = $dataStructArray['meta']['langChildren'] ?
1 : 0;
2533 $langDisabled = $dataStructArray['meta']['langDisable'] ?
1 : 0;
2535 $editData['meta']['currentLangId'] = array();
2537 // Look up page overlays:
2538 $checkPageLanguageOverlay = $GLOBALS['BE_USER']->getTSConfigVal('options.checkPageLanguageOverlay') ?
TRUE : FALSE;
2539 if ($checkPageLanguageOverlay) {
2540 $pageOverlays = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
2542 'pages_language_overlay',
2543 'pid=' . intval($row['pid']) .
2544 t3lib_BEfunc
::deleteClause('pages_language_overlay') .
2545 t3lib_BEfunc
::versioningPlaceholderClause('pages_language_overlay'),
2552 $languages = $this->getAvailableLanguages();
2554 foreach ($languages as $lInfo) {
2555 if ($GLOBALS['BE_USER']->checkLanguageAccess($lInfo['uid']) && (!$checkPageLanguageOverlay ||
$lInfo['uid'] <= 0 ||
is_array($pageOverlays[$lInfo['uid']]))) {
2556 $editData['meta']['currentLangId'][] = $lInfo['ISOcode'];
2559 if (!is_array($editData['meta']['currentLangId']) ||
!count($editData['meta']['currentLangId'])) {
2560 $editData['meta']['currentLangId'] = array('DEF');
2563 $editData['meta']['currentLangId'] = array_unique($editData['meta']['currentLangId']);
2565 //TODO: Why is this commented out?
2566 // if (!$langDisabled && count($languages) > 1) {
2567 // $item.=$this->getSingleField_typeFlex_langMenu($languages, $PA['itemFormElName'].'[meta][currentLangId]', $editData['meta']['currentLangId']).'<br />';
2570 $PA['_noEditDEF'] = FALSE;
2571 if ($langChildren ||
$langDisabled) {
2572 $rotateLang = array('DEF');
2574 if (!in_array('DEF', $editData['meta']['currentLangId'])) {
2575 array_unshift($editData['meta']['currentLangId'], 'DEF');
2576 $PA['_noEditDEF'] = TRUE;
2578 $rotateLang = $editData['meta']['currentLangId'];
2582 if (is_array($dataStructArray['sheets'])) {
2583 $tabsToTraverse = array_keys($dataStructArray['sheets']);
2585 $tabsToTraverse = array($sheet);
2588 foreach ($rotateLang as $lKey) {
2589 if (!$langChildren && !$langDisabled) {
2590 $item .= '<strong>' . $this->getLanguageIcon($table, $row, 'v' . $lKey) . $lKey . ':</strong>';
2593 $tabParts = array();
2594 foreach ($tabsToTraverse as $sheet) {
2595 list ($dataStruct, $sheet) = t3lib_div
::resolveSheetDefInDS($dataStructArray, $sheet);
2598 if (is_array($dataStruct['ROOT']) && is_array($dataStruct['ROOT']['el'])) {
2599 $lang = 'l' . $lKey; // Default language, other options are "lUK" or whatever country code (independant of system!!!)
2600 $PA['_valLang'] = $langChildren && !$langDisabled ?
$editData['meta']['currentLangId'] : 'DEF'; // Default language, other options are "lUK" or whatever country code (independant of system!!!)
2601 $PA['_lang'] = $lang;
2602 // Assemble key for loading the correct CSH file
2603 $dsPointerFields = t3lib_div
::trimExplode(',', $GLOBALS['TCA'][$table]['columns'][$field]['config']['ds_pointerField'], TRUE);
2604 $PA['_cshKey'] = $table . '.' . $field;
2605 foreach ($dsPointerFields as $key) {
2606 $PA['_cshKey'] .= '.' . $row[$key];
2609 // Push the sheet level tab to DynNestedStack
2610 if (is_array($dataStructArray['sheets'])) {
2611 $tabIdentString = $GLOBALS['TBE_TEMPLATE']->getDynTabMenuId('TCEFORMS:flexform:' . $PA['itemFormElName'] . $PA['_lang']);
2612 $this->pushToDynNestedStack('tab', $tabIdentString . '-' . (count($tabParts) +
1));
2615 $tRows = $this->getSingleField_typeFlex_draw(
2616 $dataStruct['ROOT']['el'],
2617 $editData['data'][$sheet][$lang],
2622 '[data][' . $sheet . '][' . $lang . ']'
2624 $sheetContent = '<div class="typo3-TCEforms-flexForm">' . $tRows . '</div>';
2627 // Pop the sheet level tab from DynNestedStack
2628 if (is_array($dataStructArray['sheets'])) {
2629 $this->popFromDynNestedStack('tab', $tabIdentString . '-' . (count($tabParts) +
1));
2632 $sheetContent = 'Data Structure ERROR: No ROOT element found for sheet "' . $sheet . '".';
2636 $tabParts[] = array(
2637 'label' => ($dataStruct['ROOT']['TCEforms']['sheetTitle'] ?
$this->sL($dataStruct['ROOT']['TCEforms']['sheetTitle']) : $sheet),
2638 'description' => ($dataStruct['ROOT']['TCEforms']['sheetDescription'] ?
$this->sL($dataStruct['ROOT']['TCEforms']['sheetDescription']) : ''),
2639 'linkTitle' => ($dataStruct['ROOT']['TCEforms']['sheetShortDescr'] ?
$this->sL($dataStruct['ROOT']['TCEforms']['sheetShortDescr']) : ''),
2640 'content' => $sheetContent
2644 if (is_array($dataStructArray['sheets'])) {