[TASK] Change "false" into "FALSE"
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_tceforms.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
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.
13 *
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.
18 *
19 *
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.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Contains TYPO3 Core Form generator - AKA "TCEforms"
29 *
30 * Revised for TYPO3 3.6 August/2003 by Kasper Skårhøj
31 * XHTML compliant
32 *
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
34 */
35 /**
36 * [CLASS/FUNCTION INDEX of SCRIPT]
37 *
38 *
39 *
40 * 196: class t3lib_TCEforms
41 * 302: function t3lib_TCEforms()
42 * 338: function initDefaultBEmode()
43 *
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)
51 *
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)
71 *
72 * SECTION: Field content processing
73 * 2496: function formatValue ($config, $itemValue)
74 *
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='')
85 *
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)
91 *
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)
114 *
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)
122 *
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()
140 *
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()
147 *
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)
159 *
160 *
161 * 5417: class t3lib_TCEforms_FE extends t3lib_TCEforms
162 * 5425: function wrapLabels($str)
163 * 5435: function printPalette($palArr)
164 * 5460: function setFancyDesign()
165 *
166 * TOTAL FUNCTIONS: 100
167 * (This index is automatically created/updated by the extension "extdeveval")
168 *
169 */
170
171
172 /**
173 * 'TCEforms' - Class for creating the backend editing forms.
174 *
175 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
176 * @coauthor René Fritz <r.fritz@colorcube.de>
177 * @package TYPO3
178 * @subpackage t3lib
179 */
180 class t3lib_TCEforms {
181
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();
193 var $extJSCODE = '';
194 var $printNeededJS = array();
195 var $hiddenFieldAccum = array();
196 var $TBE_EDITOR_fieldChanged_func = '';
197 var $loadMD5_JS = 1;
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: $GLOBALS['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();
204
205
206 // EXTERNAL, static
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.
216
217 /**
218 * Set to initialized clipboard object; Then the element browser will offer a link to paste in records from clipboard.
219 *
220 * @var t3lib_clipboard
221 */
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.
226
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.
233
234
235 // INTERNAL, static
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()
241
242
243 // INTERNAL, dynamic
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.
252
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.
259
260 var $commentMessages = array(); // An accumulation of messages from the class.
261
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
268
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)
280
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)
287
288 /**
289 * Instance of t3lib_tceforms_inline
290 *
291 * @var t3lib_TCEforms_inline
292 */
293 var $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)
297
298 public $templateFile = ''; // Form templates, relative to typo3 directory
299
300
301 /**
302 * Constructor function, setting internal variables, loading the styles used.
303 *
304 * @return void
305 */
306 function t3lib_TCEforms() {
307 global $CLIENT, $TYPO3_CONF_VARS;
308
309 $this->clientInfo = t3lib_div::clientInfo();
310
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;
315 }
316
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
324 );
325 $this->defColorScheme = array();
326
327 // Override / Setting defaults from TBE_STYLES array
328 $this->resetSchemes();
329
330 // Setting the current colorScheme to default.
331 $this->defColorScheme = $this->colorScheme;
332 $this->defClassScheme = $this->classScheme;
333
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'),
342 );
343
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');
347 }
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');
351 }
352
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);
358 }
359 }
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);
364 }
365 }
366
367 $this->templateFile = 'templates/tceforms.html';
368
369 }
370
371 /**
372 * Initialize various internal variables.
373 *
374 * @return void
375 */
376 function initDefaultBEmode() {
377 $this->prependFormFieldNames = 'data';
378 $this->formName = 'editform';
379 $this->setNewBEDesign();
380 $this->docLarge = ($GLOBALS['BE_USER']->uc['edit_wideDocument'] ? 1 : 0);
381 $this->edit_showFieldHelp = $GLOBALS['BE_USER']->uc['edit_showFieldHelp'];
382
383 $this->edit_docModuleUpload = $GLOBALS['BE_USER']->uc['edit_docModuleUpload'];
384 $this->titleLen = $GLOBALS['BE_USER']->uc['titleLen']; // @deprecated since TYPO3 4.1
385
386 $this->inline->init($this);
387 $this->suggest->init($this);
388 }
389
390
391 /*******************************************************
392 *
393 * Rendering the forms, fields etc
394 *
395 *******************************************************/
396
397 /**
398 * Will return the TCEform element for just a single field from a record.
399 * The field must be listed in the currently displayed fields (as found in [types][showitem]) for the record.
400 * This also means that the $table/$row supplied must be complete so the list of fields to show can be found correctly
401 *
402 * @param string The table name
403 * @param array The record from the table for which to render a field.
404 * @param string The field name to return the TCEform element for.
405 * @return string HTML output
406 * @see getMainFields()
407 */
408 function getSoloField($table, $row, $theFieldToReturn) {
409 if ($GLOBALS['TCA'][$table]) {
410 t3lib_div::loadTCA($table);
411 $typeNum = $this->getRTypeNum($table, $row);
412 if ($GLOBALS['TCA'][$table]['types'][$typeNum]) {
413 $itemList = $GLOBALS['TCA'][$table]['types'][$typeNum]['showitem'];
414 if ($itemList) {
415 $fields = t3lib_div::trimExplode(',', $itemList, 1);
416 $excludeElements = $this->excludeElements = $this->getExcludeElements($table, $row, $typeNum);
417
418 foreach ($fields as $fieldInfo) {
419 $parts = explode(';', $fieldInfo);
420
421 $theField = trim($parts[0]);
422 if (!in_array($theField, $excludeElements) && !strcmp($theField, $theFieldToReturn)) {
423 if ($GLOBALS['TCA'][$table]['columns'][$theField]) {
424 $sField = $this->getSingleField($table, $theField, $row, $parts[1], 1, $parts[3], $parts[2]);
425 return $sField['ITEM'];
426 }
427 }
428 }
429 }
430 }
431 }
432 }
433
434 /**
435 * Based on the $table and $row of content, this displays the complete TCEform for the record.
436 * 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.
437 *
438 * @param string The table name
439 * @param array The record from the table for which to render a field.
440 * @param integer Depth level
441 * @return string HTML output
442 * @see getSoloField()
443 */
444 function getMainFields($table, $row, $depth = 0) {
445 $this->renderDepth = $depth;
446
447 // Init vars:
448 $out_array = array(array());
449 $out_array_meta = array(array(
450 'title' => $this->getLL('l_generalTab')
451 ));
452
453 $out_pointer = 0;
454 $out_sheet = 0;
455 $this->palettesRendered = array();
456 $this->palettesRendered[$this->renderDepth][$table] = array();
457
458 // Hook: getMainFields_preProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
459 foreach ($this->hookObjectsMainFields as $hookObj) {
460 if (method_exists($hookObj, 'getMainFields_preProcess')) {
461 $hookObj->getMainFields_preProcess($table, $row, $this);
462 }
463 }
464
465 if ($GLOBALS['TCA'][$table]) {
466
467 // Load the full TCA for the table.
468 t3lib_div::loadTCA($table);
469
470 // Get dividers2tabs setting from TCA of the current table:
471 $dividers2tabs =& $GLOBALS['TCA'][$table]['ctrl']['dividers2tabs'];
472
473 // Load the description content for the table.
474 if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table)) {
475 $GLOBALS['LANG']->loadSingleTableDescription($table);
476 }
477 // Get the current "type" value for the record.
478 $typeNum = $this->getRTypeNum($table, $row);
479
480 // Find the list of fields to display:
481 if ($GLOBALS['TCA'][$table]['types'][$typeNum]) {
482 $itemList = $GLOBALS['TCA'][$table]['types'][$typeNum]['showitem'];
483 if ($itemList) { // If such a list existed...
484 // Explode the field list and possibly rearrange the order of the fields, if configured for
485 $fields = t3lib_div::trimExplode(',', $itemList, 1);
486 if ($this->fieldOrder) {
487 $fields = $this->rearrange($fields);
488 }
489
490 // Get excluded fields, added fiels and put it together:
491 $excludeElements = $this->excludeElements = $this->getExcludeElements($table, $row, $typeNum);
492 $fields = $this->mergeFieldsWithAddedFields($fields, $this->getFieldsToAdd($table, $row, $typeNum));
493
494 // If TCEforms will render a tab menu in the next step, push the name to the tab stack:
495 $tabIdentString = '';
496 $tabIdentStringMD5 = '';
497 if (strstr($itemList, '--div--') !== FALSE && $this->enableTabMenu && $dividers2tabs) {
498 $tabIdentString = 'TCEforms:' . $table . ':' . $row['uid'];
499 $tabIdentStringMD5 = $GLOBALS['TBE_TEMPLATE']->getDynTabMenuId($tabIdentString);
500 // Remember that were currently working on the general tab:
501 if (isset($fields[0]) && strpos($fields[0], '--div--') !== 0) {
502 $this->pushToDynNestedStack('tab', $tabIdentStringMD5 . '-1');
503 }
504 }
505
506 // Traverse the fields to render:
507 $cc = 0;
508 foreach ($fields as $fieldInfo) {
509 // Exploding subparts of the field configuration:
510 $parts = explode(';', $fieldInfo);
511
512 // Getting the style information out:
513 $color_style_parts = t3lib_div::trimExplode('-', $parts[4]);
514 if (strcmp($color_style_parts[0], '')) {
515 $this->setColorScheme($GLOBALS['TBE_STYLES']['colorschemes'][intval($color_style_parts[0])]);
516 }
517 if (strcmp($color_style_parts[1], '')) {
518 $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][intval($color_style_parts[1])];
519 if (!isset($this->fieldStyle)) {
520 $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][0];
521 }
522 }
523 if (strcmp($color_style_parts[2], '')) {
524 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
525 $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][intval($color_style_parts[2])];
526 if (!isset($this->borderStyle)) {
527 $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][0];
528 }
529 }
530
531 // Render the field:
532 $theField = $parts[0];
533 if (!in_array($theField, $excludeElements)) {
534 if ($GLOBALS['TCA'][$table]['columns'][$theField]) {
535 $sFieldPal = '';
536
537 if ($parts[2] && !isset($this->palettesRendered[$this->renderDepth][$table][$parts[2]])) {
538 $sFieldPal = $this->getPaletteFields($table, $row, $parts[2]);
539 $this->palettesRendered[$this->renderDepth][$table][$parts[2]] = 1;
540 }
541 $sField = $this->getSingleField($table, $theField, $row, $parts[1], 0, $parts[3], $parts[2]);
542 if ($sField) {
543 $sField .= $sFieldPal;
544 }
545
546 $out_array[$out_sheet][$out_pointer] .= $sField;
547 } elseif ($theField == '--div--') {
548 if ($cc > 0) {
549 $out_array[$out_sheet][$out_pointer] .= $this->getDivider();
550
551 if ($this->enableTabMenu && $dividers2tabs) {
552 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
553 // Remove last tab entry from the dynNestedStack:
554 $out_sheet++;
555 // Remove the previous sheet from stack (if any):
556 $this->popFromDynNestedStack('tab', $tabIdentStringMD5 . '-' . ($out_sheet));
557 // Remember on which sheet we're currently working:
558 $this->pushToDynNestedStack('tab', $tabIdentStringMD5 . '-' . ($out_sheet + 1));
559 $out_array[$out_sheet] = array();
560 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
561 // Register newline for Tab
562 $out_array_meta[$out_sheet]['newline'] = ($parts[2] == "newline");
563 }
564 } else { // Setting alternative title for "General" tab if "--div--" is the very first element.
565 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
566 // Only add the first tab to the dynNestedStack if there are more tabs:
567 if ($tabIdentString && strpos($itemList, '--div--', strlen($fieldInfo))) {
568 $this->pushToDynNestedStack('tab', $tabIdentStringMD5 . '-1');
569 }
570 }
571 } elseif ($theField == '--palette--') {
572 if ($parts[2] && !isset($this->palettesRendered[$this->renderDepth][$table][$parts[2]])) {
573 // render a 'header' if not collapsed
574 if ($GLOBALS['TCA'][$table]['palettes'][$parts[2]]['canNotCollapse'] && $parts[1]) {
575 $out_array[$out_sheet][$out_pointer] .= $this->getPaletteFields($table, $row, $parts[2], $this->sL($parts[1]));
576 } else {
577 $out_array[$out_sheet][$out_pointer] .= $this->getPaletteFields($table, $row, $parts[2], '', '', $this->sL($parts[1]));
578 }
579 $this->palettesRendered[$this->renderDepth][$table][$parts[2]] = 1;
580 }
581 }
582 }
583
584 $cc++;
585 }
586 }
587 }
588 }
589
590 // Hook: getMainFields_postProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
591 foreach ($this->hookObjectsMainFields as $hookObj) {
592 if (method_exists($hookObj, 'getMainFields_postProcess')) {
593 $hookObj->getMainFields_postProcess($table, $row, $this);
594 }
595 }
596
597 // Wrapping a border around it all:
598 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
599
600 // Resetting styles:
601 $this->resetSchemes();
602
603 // Rendering Main palettes, if any
604 $mParr = t3lib_div::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['mainpalette']);
605 $i = 0;
606 if (count($mParr)) {
607 foreach ($mParr as $mP) {
608 if (!isset($this->palettesRendered[$this->renderDepth][$table][$mP])) {
609 $temp_palettesCollapsed = $this->palettesCollapsed;
610 $this->palettesCollapsed = 0;
611 $label = ($i == 0 ? $this->getLL('l_generalOptions') : $this->getLL('l_generalOptions_more'));
612 $out_array[$out_sheet][$out_pointer] .= $this->getPaletteFields($table, $row, $mP, $label);
613 $this->palettesCollapsed = $temp_palettesCollapsed;
614 $this->palettesRendered[$this->renderDepth][$table][$mP] = 1;
615 }
616 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
617 $i++;
618 if ($this->renderDepth) {
619 $this->renderDepth--;
620 }
621 }
622 }
623
624 // Return the imploded $out_array:
625 if ($out_sheet > 0) { // There were --div-- dividers around...
626
627 // Create parts array for the tab menu:
628 $parts = array();
629 foreach ($out_array as $idx => $sheetContent) {
630 $content = implode('', $sheetContent);
631 if ($content) {
632 // Wrap content (row) with table-tag, otherwise tab/sheet will be disabled (see getdynTabMenu() )
633 $content = '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . $content . '</table>';
634 }
635 $parts[$idx] = array(
636 'label' => $out_array_meta[$idx]['title'],
637 'content' => $content,
638 'newline' => $out_array_meta[$idx]['newline'], // Newline for this tab/sheet
639 );
640 }
641
642 if (count($parts) > 1) {
643 // Unset the current level of tab menus:
644 $this->popFromDynNestedStack('tab', $tabIdentStringMD5 . '-' . ($out_sheet + 1));
645 $dividersToTabsBehaviour = (isset($GLOBALS['TCA'][$table]['ctrl']['dividers2tabs'])
646 ? $GLOBALS['TCA'][$table]['ctrl']['dividers2tabs']
647 : 1);
648 $output = $this->getDynTabMenu($parts, $tabIdentString, $dividersToTabsBehaviour);
649
650 } else {
651 // If there is only one tab/part there is no need to wrap it into the dynTab code
652 $output = isset($parts[0]) ? trim($parts[0]['content']) : '';
653 }
654
655 $output = '
656 <tr>
657 <td colspan="2">
658 ' . $output . '
659 </td>
660 </tr>';
661
662 } else {
663 // Only one, so just implode:
664 $output = implode('', $out_array[$out_sheet]);
665 }
666
667 return $output;
668 }
669
670 /**
671 * Will return the TCEform elements for a pre-defined list of fields.
672 * 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.
673 * Used for displaying forms for the frontend edit icons for instance.
674 *
675 * @param string The table name
676 * @param array The record array.
677 * @param string Commalist of fields from the table. These will be shown in the specified order in a form.
678 * @return string TCEform elements in a string.
679 */
680 function getListedFields($table, $row, $list) {
681 t3lib_div::loadTCA($table);
682 if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table)) {
683 $GLOBALS['LANG']->loadSingleTableDescription($table);
684 }
685
686 $out = '';
687 $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table, $row, 1);
688
689 $editFieldList = array_unique(t3lib_div::trimExplode(',', $list, 1));
690 foreach ($editFieldList as $theFieldC) {
691 list($theField, $palFields) = preg_split('/\[|\]/', $theFieldC);
692 $theField = trim($theField);
693 $palFields = trim($palFields);
694 if ($GLOBALS['TCA'][$table]['columns'][$theField]) {
695 $parts = t3lib_div::trimExplode(';', $types_fieldConfig[$theField]['origString']);
696 $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.
697 $out .= $sField;
698 } elseif ($theField == '--div--') {
699 $out .= $this->getDivider();
700 }
701 if ($palFields) {
702 $out .= $this->getPaletteFields($table, $row, '', '', implode(',', t3lib_div::trimExplode('|', $palFields, 1)));
703 }
704 }
705
706 return $out;
707 }
708
709 /**
710 * Creates a palette (collection of secondary options).
711 *
712 * @param string The table name
713 * @param array The row array
714 * @param string The palette number/pointer
715 * @param string Header string for the palette (used when in-form). If not set, no header item is made.
716 * @param string Optional alternative list of fields for the palette
717 * @param string Optional Link text for activating a palette (when palettes does not have another form element to belong to).
718 * @return string HTML code.
719 */
720 function getPaletteFields($table, $row, $palette, $header = '', $itemList = '', $collapsedHeader = NULL) {
721 if (!$this->doPrintPalette) {
722 return '';
723 }
724
725 $out = '';
726 $parts = $this->loadPaletteElements($table, $row, $palette, $itemList);
727
728 // Put palette together if there are fields in it:
729 if (count($parts)) {
730
731 $realFields = 0;
732
733 foreach ($parts as $part) {
734 if ($part['NAME'] !== '--linebreak--') {
735 $realFields++;
736 }
737 }
738
739 if ($realFields > 0) {
740
741 if ($header) {
742 $out .= $this->intoTemplate(
743 array('HEADER' => htmlspecialchars($header)),
744 $this->palFieldTemplateHeader
745 );
746 }
747
748 $collapsed = $this->isPalettesCollapsed($table, $palette);
749
750 $thePalIcon = '';
751 if ($collapsed && $collapsedHeader !== NULL) {
752 list($thePalIcon,) = $this->wrapOpenPalette(
753 t3lib_iconWorks::getSpriteIcon(
754 'actions-system-options-view',
755 array('title' => htmlspecialchars($this->getLL('l_moreOptions')))
756 ), $table, $row, $palette, 1);
757 $thePalIcon = '<span style="margin-left: 20px;">' . $thePalIcon . $collapsedHeader . '</span>';
758 }
759
760 $paletteHtml = $this->wrapPaletteField($this->printPalette($parts), $table, $row, $palette, $collapsed);
761
762 $out .= $this->intoTemplate(
763 array('PALETTE' => $thePalIcon . $paletteHtml),
764 $this->palFieldTemplate
765 );
766 }
767 }
768 return $out;
769 }
770
771 /**
772 * Returns the form HTML code for a database table field.
773 *
774 * @param string The table name
775 * @param string The field name
776 * @param array The record to edit from the database table.
777 * @param string Alternative field name label to show.
778 * @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).
779 * @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.
780 * @param integer The palette pointer.
781 * @return mixed String (normal) or array (palettes)
782 */
783 function getSingleField($table, $field, $row, $altName = '', $palette = 0, $extra = '', $pal = 0) {
784
785 // Hook: getSingleField_preProcess
786 foreach ($this->hookObjectsSingleField as $hookObj) {
787 if (method_exists($hookObj, 'getSingleField_preProcess')) {
788 $hookObj->getSingleField_preProcess($table, $field, $row, $altName, $palette, $extra, $pal, $this);
789 }
790 }
791
792 $out = '';
793 $PA = array();
794 $PA['altName'] = $altName;
795 $PA['palette'] = $palette;
796 $PA['extra'] = $extra;
797 $PA['pal'] = $pal;
798
799 // Make sure to load full $GLOBALS['TCA'] array for the table:
800 t3lib_div::loadTCA($table);
801
802 // Get the TCA configuration for the current field:
803 $PA['fieldConf'] = $GLOBALS['TCA'][$table]['columns'][$field];
804 $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
805
806 $skipThisField = $this->inline->skipField($table, $field, $row, $PA['fieldConf']['config']);
807
808 // Now, check if this field is configured and editable (according to excludefields + other configuration)
809 if (is_array($PA['fieldConf']) &&
810 !$skipThisField &&
811 (!$PA['fieldConf']['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $table . ':' . $field)) &&
812 $PA['fieldConf']['config']['form_type'] != 'passthrough' &&
813 ($this->RTEenabled || !$PA['fieldConf']['config']['showIfRTE']) &&
814 (!$PA['fieldConf']['displayCond'] || $this->isDisplayCondition($PA['fieldConf']['displayCond'], $row)) &&
815 (!$GLOBALS['TCA'][$table]['ctrl']['languageField'] || $PA['fieldConf']['l10n_display'] || strcmp($PA['fieldConf']['l10n_mode'], 'exclude') || $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] <= 0) &&
816 (!$GLOBALS['TCA'][$table]['ctrl']['languageField'] || !$this->localizationMode || $this->localizationMode === $PA['fieldConf']['l10n_cat'])
817 ) {
818
819
820 // Fetching the TSconfig for the current table/field. This includes the $row which means that
821 $PA['fieldTSConfig'] = $this->setTSconfig($table, $row, $field);
822
823 // If the field is NOT disabled from TSconfig (which it could have been) then render it
824 if (!$PA['fieldTSConfig']['disabled']) {
825 // Override fieldConf by fieldTSconfig:
826 $PA['fieldConf']['config'] = $this->overrideFieldConf($PA['fieldConf']['config'], $PA['fieldTSConfig']);
827
828 // Init variables:
829 $PA['itemFormElName'] = $this->prependFormFieldNames . '[' . $table . '][' . $row['uid'] . '][' . $field . ']'; // Form field name
830 $PA['itemFormElName_file'] = $this->prependFormFieldNames_file . '[' . $table . '][' . $row['uid'] . '][' . $field . ']'; // Form field name, in case of file uploads
831 $PA['itemFormElValue'] = $row[$field]; // The value to show in the form field.
832 $PA['itemFormElID'] = $this->prependFormFieldNames . '_' . $table . '_' . $row['uid'] . '_' . $field;
833
834 // set field to read-only if configured for translated records to show default language content as readonly
835 if ($PA['fieldConf']['l10n_display']
836 && t3lib_div::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly')
837 && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] > 0) {
838 $PA['fieldConf']['config']['readOnly'] = TRUE;
839 $PA['itemFormElValue'] = $this->defaultLanguageData[$table . ':' . $row['uid']][$field];
840 }
841
842 // 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"
843 if (
844 ($GLOBALS['TCA'][$table]['ctrl']['type'] && !strcmp($field, $GLOBALS['TCA'][$table]['ctrl']['type']))
845 || ($GLOBALS['TCA'][$table]['ctrl']['requestUpdate']
846 && t3lib_div::inList($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'], $field))) {
847 if ($GLOBALS['BE_USER']->jsConfirmation(1)) {
848 $alertMsgOnChange = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
849 } else {
850 $alertMsgOnChange = 'if (TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
851 }
852 } else {
853 $alertMsgOnChange = '';
854 }
855
856 // Render as a hidden field?
857 if (in_array($field, $this->hiddenFieldListArr)) {
858 $this->hiddenFieldAccum[] = '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
859 } else { // Render as a normal field:
860
861 // 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.
862 if (!$PA['palette']) {
863 $paletteFields = $this->loadPaletteElements($table, $row, $PA['pal']);
864 if ($PA['pal'] && $this->isPalettesCollapsed($table, $PA['pal']) && count($paletteFields)) {
865 list($thePalIcon, $palJSfunc) = $this->wrapOpenPalette(t3lib_iconWorks::getSpriteIcon('actions-system-options-view', array('title' => htmlspecialchars($this->getLL('l_moreOptions')))), $table, $row, $PA['pal'], 1);
866 } else {
867 $thePalIcon = '';
868 $palJSfunc = '';
869 }
870 }
871 // onFocus attribute to add to the field:
872 $PA['onFocus'] = (($palJSfunc && !$GLOBALS['BE_USER']->uc['dontShowPalettesOnFocusInAB'])
873 ? ' onfocus="' . htmlspecialchars($palJSfunc) . '"'
874 : '');
875
876 // Find item
877 $item = '';
878 $PA['label'] = ($PA['altName'] ? $PA['altName'] : $PA['fieldConf']['label']);
879 $PA['label'] = ($PA['fieldTSConfig']['label'] ? $PA['fieldTSConfig']['label'] : $PA['label']);
880 $PA['label'] = ($PA['fieldTSConfig']['label.'][$GLOBALS['LANG']->lang] ? $PA['fieldTSConfig']['label.'][$GLOBALS['LANG']->lang] : $PA['label']);
881 $PA['label'] = $this->sL($PA['label']);
882 // JavaScript code for event handlers:
883 $PA['fieldChangeFunc'] = array();
884 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = "TBE_EDITOR.fieldChanged('" . $table . "','" . $row['uid'] . "','" . $field . "','" . $PA['itemFormElName'] . "');";
885 $PA['fieldChangeFunc']['alert'] = $alertMsgOnChange;
886 // if this is the child of an inline type and it is the field creating the label
887 if ($this->inline->isInlineChildAndLabelField($table, $field)) {
888 $inlineObjectId = implode(
889 t3lib_TCEforms_inline::Structure_Separator,
890 array(
891 $this->inline->inlineNames['object'],
892 $table,
893 $row['uid']
894 )
895 );
896 $PA['fieldChangeFunc']['inline'] = "inline.handleChangedField('" . $PA['itemFormElName'] . "','" . $inlineObjectId . "');";
897 }
898
899 // Based on the type of the item, call a render function:
900 $item = $this->getSingleField_SW($table, $field, $row, $PA);
901
902 // Add language + diff
903 if ($PA['fieldConf']['l10n_display'] && (t3lib_div::inList($PA['fieldConf']['l10n_display'], 'hideDiff') || t3lib_div::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly'))) {
904 $renderLanguageDiff = FALSE;
905 } else {
906 $renderLanguageDiff = TRUE;
907 }
908
909 if ($renderLanguageDiff) {
910 $item = $this->renderDefaultLanguageContent($table, $field, $row, $item);
911 $item = $this->renderDefaultLanguageDiff($table, $field, $row, $item);
912 }
913
914 // 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
915 $label = t3lib_div::deHSCentities(htmlspecialchars($PA['label']));
916 if (t3lib_div::testInt($row['uid']) && $PA['fieldTSConfig']['linkTitleToSelf'] && !t3lib_div::_GP('columnsOnly')) {
917 $lTTS_url = $this->backPath . 'alt_doc.php?edit[' . $table . '][' . $row['uid'] . ']=edit&columnsOnly=' . $field . '&returnUrl=' . rawurlencode($this->thisReturnUrl());
918 $label = '<a href="' . htmlspecialchars($lTTS_url) . '">' . $label . '</a>';
919 }
920
921 // wrap the label with help text
922 $PA['label'] = $label = t3lib_BEfunc::wrapInHelp($table, $field, $label);
923
924 // Create output value:
925 if ($PA['fieldConf']['config']['form_type'] == 'user' && $PA['fieldConf']['config']['noTableWrapping']) {
926 $out = $item;
927 } elseif ($PA['palette']) {
928 // Array:
929 $out = array(
930 'NAME' => $label,
931 'ID' => $row['uid'],
932 'FIELD' => $field,
933 'TABLE' => $table,
934 'ITEM' => $item
935 );
936 $out = $this->addUserTemplateMarkers($out, $table, $field, $row, $PA);
937 } else {
938 // String:
939 $out = array(
940 'NAME' => $label,
941 'ITEM' => $item,
942 'TABLE' => $table,
943 'ID' => $row['uid'],
944 'PAL_LINK_ICON' => $thePalIcon,
945 'FIELD' => $field
946 );
947 $out = $this->addUserTemplateMarkers($out, $table, $field, $row, $PA);
948 // String:
949 $out = $this->intoTemplate($out);
950 }
951 }
952 } else {
953 $this->commentMessages[] = $this->prependFormFieldNames . '[' . $table . '][' . $row['uid'] . '][' . $field . ']: Disabled by TSconfig';
954 }
955 }
956 // Hook: getSingleField_postProcess
957 foreach ($this->hookObjectsSingleField as $hookObj) {
958 if (method_exists($hookObj, 'getSingleField_postProcess')) {
959 $hookObj->getSingleField_postProcess($table, $field, $row, $out, $PA, $this);
960 }
961 }
962 // Return value (string or array)
963 return $out;
964 }
965
966 /**
967 * Rendering a single item for the form
968 *
969 * @param string Table name of record
970 * @param string Fieldname to render
971 * @param array The record
972 * @param array parameters array containing a lot of stuff. Value by Reference!
973 * @return string Returns the item as HTML code to insert
974 * @access private
975 * @see getSingleField(), getSingleField_typeFlex_draw()
976 */
977 function getSingleField_SW($table, $field, $row, &$PA) {
978 $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
979
980 // Hook: getSingleField_beforeRender
981 foreach ($this->hookObjectsSingleField as $hookObject) {
982 if (method_exists($hookObject, 'getSingleField_beforeRender')) {
983 $hookObject->getSingleField_beforeRender($table, $field, $row, $PA);
984 }
985 }
986
987 switch ($PA['fieldConf']['config']['form_type']) {
988 case 'input':
989 $item = $this->getSingleField_typeInput($table, $field, $row, $PA);
990 break;
991 case 'text':
992 $item = $this->getSingleField_typeText($table, $field, $row, $PA);
993 break;
994 case 'check':
995 $item = $this->getSingleField_typeCheck($table, $field, $row, $PA);
996 break;
997 case 'radio':
998 $item = $this->getSingleField_typeRadio($table, $field, $row, $PA);
999 break;
1000 case 'select':
1001 $item = $this->getSingleField_typeSelect($table, $field, $row, $PA);
1002 break;
1003 case 'group':
1004 $item = $this->getSingleField_typeGroup($table, $field, $row, $PA);
1005 break;
1006 case 'inline':
1007 $item = $this->inline->getSingleField_typeInline($table, $field, $row, $PA);
1008 break;
1009 case 'none':
1010 $item = $this->getSingleField_typeNone($table, $field, $row, $PA);
1011 break;
1012 case 'user':
1013 $item = $this->getSingleField_typeUser($table, $field, $row, $PA);
1014 break;
1015 case 'flex':
1016 $item = $this->getSingleField_typeFlex($table, $field, $row, $PA);
1017 break;
1018 default:
1019 $item = $this->getSingleField_typeUnknown($table, $field, $row, $PA);
1020 break;
1021 }
1022
1023 return $item;
1024 }
1025
1026
1027 /**********************************************************
1028 *
1029 * Rendering of each TCEform field type
1030 *
1031 ************************************************************/
1032
1033 /**
1034 * Generation of TCEform elements of the type "input"
1035 * This will render a single-line input form field, possibly with various control/validation features
1036 *
1037 * @param string The table name of the record
1038 * @param string The field name which this element is supposed to edit
1039 * @param array The record data array where the value(s) for the field can be found
1040 * @param array An array with additional configuration options.
1041 * @return string The HTML code for the TCEform field
1042 */
1043 function getSingleField_typeInput($table, $field, $row, &$PA) {
1044 $config = $PA['fieldConf']['config'];
1045
1046 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1047 $size = t3lib_div::intInRange($config['size'] ? $config['size'] : 30, 5, $this->maxInputWidth);
1048 $evalList = t3lib_div::trimExplode(',', $config['eval'], 1);
1049 $classAndStyleAttributes = $this->formWidthAsArray($size);
1050
1051 $fieldAppendix = '';
1052 $item = '';
1053 $cssClasses = array($classAndStyleAttributes['class']);
1054 $cssStyle = $classAndStyleAttributes['style'];
1055
1056 if (!isset($config['checkbox'])) {
1057 $config['checkbox'] = '0';
1058 $checkboxIsset = FALSE;
1059 } else {
1060 $checkboxIsset = TRUE;
1061 }
1062
1063 if (in_array('date', $evalList) || in_array('datetime', $evalList)) {
1064 if (in_array('datetime', $evalList)) {
1065 $class = 'datetime';
1066 } else {
1067 $class = 'date';
1068 }
1069 $dateRange = '';
1070 if (isset($config['range']['lower'])) {
1071 $dateRange .= ' lower-' . intval($config['range']['lower']);
1072 }
1073 if (isset($config['range']['upper'])) {
1074 $dateRange .= ' upper-' . intval($config['range']['upper']);
1075 }
1076 $inputId = uniqid('tceforms-' . $class . 'field-');
1077 $cssClasses[] = 'tceforms-textfield tceforms-' . $class . 'field' . $dateRange;
1078 $fieldAppendix = t3lib_iconWorks::getSpriteIcon(
1079 'actions-edit-pick-date',
1080 array(
1081 'style' => 'cursor:pointer;',
1082 'id' => 'picker-' . $inputId
1083 )
1084 );
1085 } elseif (in_array('timesec', $evalList)) {
1086 $inputId = uniqid('tceforms-timesecfield-');
1087 $cssClasses[] = 'tceforms-textfield tceforms-timesecfield';
1088 } elseif (in_array('year', $evalList)) {
1089 $inputId = uniqid('tceforms-yearfield-');
1090 $cssClasses[] = 'tceforms-textfield tceforms-yearfield';
1091 } elseif (in_array('time', $evalList)) {
1092 $inputId = uniqid('tceforms-timefield-');
1093 $cssClasses[] = 'tceforms-textfield tceforms-timefield';
1094 } elseif (in_array('int', $evalList)) {
1095 $inputId = uniqid('tceforms-intfield-');
1096 $cssClasses[] = 'tceforms-textfield tceforms-intfield';
1097 } elseif (in_array('double2', $evalList)) {
1098 $inputId = uniqid('tceforms-double2field-');
1099 $cssClasses[] = 'tceforms-textfield tceforms-double2field';
1100 } else {
1101 $inputId = uniqid('tceforms-textfield-');
1102 $cssClasses[] = 'tceforms-textfield';
1103 if ($checkboxIsset === FALSE) {
1104 $config['checkbox'] = '';
1105 }
1106 }
1107 if (isset($config['wizards']['link'])) {
1108 $inputId = uniqid('tceforms-linkfield-');
1109 $cssClasses[] = 'tceforms-textfield tceforms-linkfield';
1110
1111 } elseif (isset($config['wizards']['color'])) {
1112 $inputId = uniqid('tceforms-colorfield-');
1113 $cssClasses[] = 'tceforms-textfield tceforms-colorfield';
1114 }
1115
1116 if ($this->renderReadonly || $config['readOnly']) {
1117 $itemFormElValue = $PA['itemFormElValue'];
1118 if (in_array('date', $evalList)) {
1119 $config['format'] = 'date';
1120 } elseif (in_array('datetime', $evalList)) {
1121 $config['format'] = 'datetime';
1122 } elseif (in_array('time', $evalList)) {
1123 $config['format'] = 'time';
1124 }
1125 if (in_array('password', $evalList)) {
1126 $itemFormElValue = $itemFormElValue ? '*********' : '';
1127 }
1128 return $this->getSingleField_typeNone_render($config, $itemFormElValue);
1129 }
1130
1131 foreach ($evalList as $func) {
1132 switch ($func) {
1133 case 'required':
1134 $this->registerRequiredProperty('field', $table . '_' . $row['uid'] . '_' . $field, $PA['itemFormElName']);
1135 // Mark this field for date/time disposal:
1136 if (array_intersect($evalList, array('date', 'datetime', 'time'))) {
1137 $this->requiredAdditional[$PA['itemFormElName']]['isPositiveNumber'] = TRUE;
1138 }
1139 break;
1140 default:
1141 if (substr($func, 0, 3) == 'tx_') {
1142 // Pair hook to the one in t3lib_TCEmain::checkValue_input_Eval()
1143 $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
1144 if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue')) {
1145 $_params = array(
1146 'value' => $PA['itemFormElValue']
1147 );
1148 $PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
1149 }
1150 }
1151 break;
1152 }
1153 }
1154
1155 $paramsList = "'" . $PA['itemFormElName'] . "','" . implode(',', $evalList) . "','" . trim($config['is_in']) . "'," . (isset($config['checkbox']) ? 1 : 0) . ",'" . $config['checkbox'] . "'";
1156 if ((in_array('date', $evalList) || in_array('datetime', $evalList))) {
1157 $item .= '<span class="t3-tceforms-input-wrapper-datetime" onmouseOver="if (document.getElementById(\'' .
1158 $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\';">';
1159
1160 // Add server timezone offset to UTC to our stored date
1161 if ($PA['itemFormElValue'] > 0) {
1162 $PA['itemFormElValue'] += date('Z', $PA['itemFormElValue']);
1163 }
1164 } else {
1165 $item .= '<span class="t3-tceforms-input-wrapper" onmouseOver="if (document.getElementById(\'' . $inputId .
1166 '\').value) {this.className=\'t3-tceforms-input-wrapper-hover\';} else {this.className=\'t3-tceforms-input-wrapper\';};" onmouseOut="this.className=\'t3-tceforms-input-wrapper\';">';
1167 }
1168
1169 $PA['fieldChangeFunc'] = array_merge(
1170 array('typo3form.fieldGet' => 'typo3form.fieldGet(' . $paramsList . ');'),
1171 $PA['fieldChangeFunc']
1172 );
1173 // old function "checkbox" now the option to set the date / remove the date
1174 if (isset($config['checkbox'])) {
1175 $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'])));
1176 }
1177 $mLgd = ($config['max'] ? $config['max'] : 256);
1178 $iOnChange = implode('', $PA['fieldChangeFunc']);
1179
1180 $item .= '<input type="text" id="' . $inputId .
1181 '" class="' . implode(' ', $cssClasses) . '" name="' . $PA['itemFormElName'] .
1182 '_hr" value="" style="' . $cssStyle . '" maxlength="' . $mLgd . '" onchange="' .
1183 htmlspecialchars($iOnChange) . '"' . $PA['onFocus'] . ' />'; // This is the EDITABLE form field.
1184 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' .
1185 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.
1186 $item .= $fieldAppendix . '</span><div style="clear:both;"></div>';
1187 $this->extJSCODE .= 'typo3form.fieldSet(' . $paramsList . ');';
1188
1189 // going through all custom evaluations configured for this field
1190 foreach ($evalList as $evalData) {
1191 if (substr($evalData, 0, 3) == 'tx_') {
1192 $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$evalData] . ':&' . $evalData);
1193 if (is_object($evalObj) && method_exists($evalObj, 'returnFieldJS')) {
1194 $this->extJSCODE .= "\n\nfunction " . $evalData . "(value) {\n" . $evalObj->returnFieldJS() . "\n}\n";
1195 }
1196 }
1197 }
1198
1199 // Creating an alternative item without the JavaScript handlers.
1200 $altItem = '<input type="hidden" name="' . $PA['itemFormElName'] . '_hr" value="" />';
1201 $altItem .= '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1202
1203 // Wrap a wizard around the item?
1204 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'] . '_hr', $specConf);
1205
1206 return $item;
1207 }
1208
1209 /**
1210 * Generation of TCEform elements of the type "text"
1211 * This will render a <textarea> OR RTE area form field, possibly with various control/validation features
1212 *
1213 * @param string The table name of the record
1214 * @param string The field name which this element is supposed to edit
1215 * @param array The record data array where the value(s) for the field can be found
1216 * @param array An array with additional configuration options.
1217 * @return string The HTML code for the TCEform field
1218 */
1219 function getSingleField_typeText($table, $field, $row, &$PA) {
1220
1221 // Init config:
1222 $config = $PA['fieldConf']['config'];
1223 $evalList = t3lib_div::trimExplode(',', $config['eval'], 1);
1224
1225 if ($this->renderReadonly || $config['readOnly']) {
1226 return $this->getSingleField_typeNone_render($config, $PA['itemFormElValue']);
1227 }
1228
1229 // Setting columns number:
1230 $cols = t3lib_div::intInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
1231
1232 // Setting number of rows:
1233 $origRows = $rows = t3lib_div::intInRange($config['rows'] ? $config['rows'] : 5, 1, 20);
1234 if (strlen($PA['itemFormElValue']) > $this->charsPerRow * 2) {
1235 $cols = $this->maxTextareaWidth;
1236 $rows = t3lib_div::intInRange(round(strlen($PA['itemFormElValue']) / $this->charsPerRow), count(explode(LF, $PA['itemFormElValue'])), 20);
1237 if ($rows < $origRows) {
1238 $rows = $origRows;
1239 }
1240 }
1241
1242 if (in_array('required', $evalList)) {
1243 $this->requiredFields[$table . '_' . $row['uid'] . '_' . $field] = $PA['itemFormElName'];
1244 }
1245
1246 // Init RTE vars:
1247 $RTEwasLoaded = 0; // Set TRUE, if the RTE is loaded; If not a normal textarea is shown.
1248 $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...
1249
1250 // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. Traditionally, this is where RTE configuration has been found.
1251 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1252
1253 // Setting up the altItem form field, which is a hidden field containing the value
1254 $altItem = '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1255
1256 // If RTE is generally enabled (TYPO3_CONF_VARS and user settings)
1257 if ($this->RTEenabled) {
1258 $p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
1259 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.
1260 t3lib_BEfunc::fixVersioningPid($table, $row);
1261 list($tscPID, $thePidValue) = $this->getTSCpid($table, $row['uid'], $row['pid']);
1262
1263 // If the pid-value is not negative (that is, a pid could NOT be fetched)
1264 if ($thePidValue >= 0) {
1265 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($tscPID));
1266 $RTEtypeVal = t3lib_BEfunc::getTCAtypeValue($table, $row);
1267 $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'], $table, $field, $RTEtypeVal);
1268
1269 if (!$thisConfig['disabled']) {
1270 if (!$this->disableRTE) {
1271 $this->RTEcounter++;
1272
1273 // Find alternative relative path for RTE images/links:
1274 $eFile = t3lib_parsehtml_proc::evalWriteFile($specConf['static_write'], $row);
1275 $RTErelPath = is_array($eFile) ? dirname($eFile['relEditFile']) : '';
1276
1277 // Get RTE object, draw form and set flag:
1278 $RTEobj = t3lib_BEfunc::RTEgetObj();
1279 $item = $RTEobj->drawRTE($this, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue);
1280
1281 // Wizard:
1282 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf, 1);
1283
1284 $RTEwasLoaded = 1;
1285 } else {
1286 $RTEwouldHaveBeenLoaded = 1;
1287 $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!)';
1288 }
1289 } else {
1290 $this->commentMessages[] = $PA['itemFormElName'] . ': RTE is disabled by the Page TSconfig, "RTE"-key (eg. by RTE.default.disabled=0 or such)';
1291 }
1292 } else {
1293 $this->commentMessages[] = $PA['itemFormElName'] . ': PID value could NOT be fetched. Rare error, normally with new records.';
1294 }
1295 } else {
1296 if (!isset($specConf['richtext'])) {
1297 $this->commentMessages[] = $PA['itemFormElName'] . ': RTE was not configured for this field in TCA-types';
1298 }
1299 if (!(!$p['flag'] || !$row[$p['flag']])) {
1300 $this->commentMessages[] = $PA['itemFormElName'] . ': Field-flag (' . $PA['flag'] . ') has been set to disable RTE!';
1301 }
1302 }
1303 }
1304
1305 // Display ordinary field if RTE was not loaded.
1306 if (!$RTEwasLoaded) {
1307 if ($specConf['rte_only']) { // Show message, if no RTE (field can only be edited with RTE!)
1308 $item = '<p><em>' . htmlspecialchars($this->getLL('l_noRTEfound')) . '</em></p>';
1309 } else {
1310 if ($specConf['nowrap']) {
1311 $wrap = 'off';
1312 } else {
1313 $wrap = ($config['wrap'] ? $config['wrap'] : 'virtual');
1314 }
1315
1316 $classes = array();
1317 if ($specConf['fixed-font']) {
1318 $classes[] = 'fixed-font';
1319 }
1320 if ($specConf['enable-tab']) {
1321 $classes[] = 'enable-tab';
1322 }
1323
1324 $formWidthText = $this->formWidthText($cols, $wrap);
1325
1326 // Extract class attributes from $formWidthText (otherwise it would be added twice to the output)
1327 $res = array();
1328 if (preg_match('/ class="(.+?)"/', $formWidthText, $res)) {
1329 $formWidthText = str_replace(' class="' . $res[1] . '"', '', $formWidthText);
1330 $classes = array_merge($classes, explode(' ', $res[1]));
1331 }
1332
1333 if (count($classes)) {
1334 $class = ' class="tceforms-textarea ' . implode(' ', $classes) . '"';
1335 } else {
1336 $class = 'tceforms-textarea';
1337 }
1338
1339 $evalList = t3lib_div::trimExplode(',', $config['eval'], 1);
1340 foreach ($evalList as $func) {
1341 switch ($func) {
1342 case 'required':
1343 $this->registerRequiredProperty('field', $table . '_' . $row['uid'] . '_' . $field, $PA['itemFormElName']);
1344 break;
1345 default:
1346 if (substr($func, 0, 3) == 'tx_') {
1347 // Pair hook to the one in t3lib_TCEmain::checkValue_input_Eval() and t3lib_TCEmain::checkValue_text_Eval()
1348 $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
1349 if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue')) {
1350 $_params = array(
1351 'value' => $PA['itemFormElValue']
1352 );
1353 $PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
1354 }
1355 }
1356 break;
1357 }
1358 }
1359
1360 $iOnChange = implode('', $PA['fieldChangeFunc']);
1361 $item .= '
1362 <textarea id="' . uniqid('tceforms-textarea-') . '" name="' . $PA['itemFormElName'] . '"' . $formWidthText . $class . ' rows="' . $rows . '" wrap="' . $wrap . '" onchange="' . htmlspecialchars($iOnChange) . '"' . $PA['onFocus'] . '>' .
1363 t3lib_div::formatForTextarea($PA['itemFormElValue']) .
1364 '</textarea>';
1365 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf, $RTEwouldHaveBeenLoaded);
1366 }
1367 }
1368
1369 // Return field HTML:
1370 return $item;
1371 }
1372
1373 /**
1374 * Generation of TCEform elements of the type "check"
1375 * This will render a check-box OR an array of checkboxes
1376 *
1377 * @param string The table name of the record
1378 * @param string The field name which this element is supposed to edit
1379 * @param array The record data array where the value(s) for the field can be found
1380 * @param array An array with additional configuration options.
1381 * @return string The HTML code for the TCEform field
1382 */
1383 function getSingleField_typeCheck($table, $field, $row, &$PA) {
1384 $config = $PA['fieldConf']['config'];
1385
1386 $item = '';
1387 $disabled = '';
1388 if ($this->renderReadonly || $config['readOnly']) {
1389 $disabled = ' disabled="disabled"';
1390 }
1391
1392 // Traversing the array of items:
1393 $selItems = $this->initItemArray($PA['fieldConf']);
1394 if ($config['itemsProcFunc']) {
1395 $selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
1396 }
1397
1398 if (!count($selItems)) {
1399 $selItems[] = array('', '');
1400 }
1401 $thisValue = intval($PA['itemFormElValue']);
1402
1403 $cols = intval($config['cols']);
1404 if ($cols > 1) {
1405 $item .= '<table border="0" cellspacing="0" cellpadding="0" class="typo3-TCEforms-checkboxArray">';
1406 for ($c = 0; $c < count($selItems); $c++) {
1407 $p = $selItems[$c];
1408 if (!($c % $cols)) {
1409 $item .= '<tr>';
1410 }
1411 $cBP = $this->checkBoxParams($PA['itemFormElName'], $thisValue, $c, count($selItems), implode('', $PA['fieldChangeFunc']));
1412 $cBName = $PA['itemFormElName'] . '_' . $c;
1413 $cBID = $PA['itemFormElID'] . '_' . $c;
1414 $item .= '<td nowrap="nowrap">' .
1415 '<input type="checkbox"' . $this->insertDefStyle('check') . ' value="1" name="' . $cBName . '"' . $cBP . $disabled . ' id="' . $cBID . '" />' .
1416 $this->wrapLabels('<label for="' . $cBID . '">' . htmlspecialchars($p[0]) . '</label>&nbsp;') .
1417 '</td>';
1418 if (($c % $cols) + 1 == $cols) {
1419 $item .= '</tr>';
1420 }
1421 }
1422 if ($c % $cols) {
1423 $rest = $cols - ($c % $cols);
1424 for ($c = 0; $c < $rest; $c++) {
1425 $item .= '<td></td>';
1426 }
1427 if ($c > 0) {
1428 $item .= '</tr>';
1429 }
1430 }
1431 $item .= '</table>';
1432 } else {
1433 for ($c = 0; $c < count($selItems); $c++) {
1434 $p = $selItems[$c];
1435 $cBP = $this->checkBoxParams($PA['itemFormElName'], $thisValue, $c, count($selItems), implode('', $PA['fieldChangeFunc']));
1436 $cBName = $PA['itemFormElName'] . '_' . $c;
1437 $cBID = $PA['itemFormElID'] . '_' . $c;
1438 $item .= ($c > 0 ? '<br />' : '') .
1439 '<input type="checkbox"' . $this->insertDefStyle('check') . ' value="1" name="' . $cBName . '"' . $cBP . $PA['onFocus'] . $disabled . ' id="' . $cBID . '" />' .
1440 $this->wrapLabels('<label for="' . $cBID . '">' . htmlspecialchars($p[0]) . '</label>');
1441 }
1442 }
1443 if (!$disabled) {
1444 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($thisValue) . '" />';
1445 }
1446
1447 return $item;
1448 }
1449
1450 /**
1451 * Generation of TCEform elements of the type "radio"
1452 * This will render a series of radio buttons.
1453 *
1454 * @param string The table name of the record
1455 * @param string The field name which this element is supposed to edit
1456 * @param array The record data array where the value(s) for the field can be found
1457 * @param array An array with additional configuration options.
1458 * @return string The HTML code for the TCEform field
1459 */
1460 function getSingleField_typeRadio($table, $field, $row, &$PA) {
1461 $config = $PA['fieldConf']['config'];
1462
1463 $item = '';
1464 $disabled = '';
1465 if ($this->renderReadonly || $config['readOnly']) {
1466 $disabled = ' disabled="disabled"';
1467 }
1468
1469 // Get items for the array:
1470 $selItems = $this->initItemArray($PA['fieldConf']);
1471 if ($config['itemsProcFunc']) {
1472 $selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
1473 }
1474
1475 // Traverse the items, making the form elements:
1476 for ($c = 0; $c < count($selItems); $c++) {
1477 $p = $selItems[$c];
1478 $rID = $PA['itemFormElID'] . '_' . $c;
1479 $rOnClick = implode('', $PA['fieldChangeFunc']);
1480 $rChecked = (!strcmp($p[1], $PA['itemFormElValue']) ? ' checked="checked"' : '');
1481 $item .= '<input type="radio"' . $this->insertDefStyle('radio') . ' name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($p[1]) . '" onclick="' . htmlspecialchars($rOnClick) . '"' . $rChecked . $PA['onFocus'] . $disabled . ' id="' . $rID . '" />
1482 <label for="' . $rID . '">' . htmlspecialchars($p[0]) . '</label>
1483 <br />';
1484 }
1485
1486 return $item;
1487 }
1488
1489 /**
1490 * Generation of TCEform elements of the type "select"
1491 * This will render a selector box element, or possibly a special construction with two selector boxes. That depends on configuration.
1492 *
1493 * @param string The table name of the record
1494 * @param string The field name which this element is supposed to edit
1495 * @param array The record data array where the value(s) for the field can be found
1496 * @param array An array with additional configuration options.
1497 * @return string The HTML code for the TCEform field
1498 */
1499 function getSingleField_typeSelect($table, $field, $row, &$PA) {
1500
1501 // Field configuration from TCA:
1502 $config = $PA['fieldConf']['config'];
1503
1504 $disabled = '';
1505 if ($this->renderReadonly || $config['readOnly']) {
1506 $disabled = ' disabled="disabled"';
1507 }
1508
1509 // "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/.
1510 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1511
1512 // Getting the selector box items from the system
1513 $selItems = $this->addSelectOptionsToItemArray(
1514 $this->initItemArray($PA['fieldConf']),
1515 $PA['fieldConf'],
1516 $this->setTSconfig($table, $row),
1517 $field
1518 );
1519 // Possibly filter some items:
1520 $keepItemsFunc = create_function('$value', 'return $value[1];');
1521 $selItems = t3lib_div::keepItemsInArray($selItems, $PA['fieldTSConfig']['keepItems'], $keepItemsFunc);
1522 // Possibly add some items:
1523 $selItems = $this->addItems($selItems, $PA['fieldTSConfig']['addItems.']);
1524 // Process items by a user function:
1525 if (isset($config['itemsProcFunc']) && $config['itemsProcFunc']) {
1526 $selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
1527 }
1528
1529 // Possibly remove some items:
1530 $removeItems = t3lib_div::trimExplode(',', $PA['fieldTSConfig']['removeItems'], 1);
1531 foreach ($selItems as $tk => $p) {
1532
1533 // Checking languages and authMode:
1534 $languageDeny = $GLOBALS['TCA'][$table]['ctrl']['languageField']
1535 && !strcmp($GLOBALS['TCA'][$table]['ctrl']['languageField'], $field)
1536 && !$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]]);
1542 }
1543
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]);
1548 }
1549 }
1550 }
1551
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') . ' ]';
1554
1555 // Prepare some values:
1556 $maxitems = intval($config['maxitems']);
1557
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);
1570 }
1571
1572 // Wizards:
1573 if (!$disabled) {
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);
1576 }
1577
1578 return $item;
1579 }
1580
1581 /**
1582 * Creates a single-selector box
1583 * (Render function for getSingleField_typeSelect())
1584 *
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()
1594 */
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'] . "');";
1602 }
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'];
1606 }
1607 }
1608
1609 // Initialization:
1610 $c = 0;
1611 $sI = 0;
1612 $noMatchingValue = 1;
1613 $opt = array();
1614 $selicons = array();
1615 $onlySelectedIconShown = 0;
1616 $size = intval($config['size']);
1617 $selectedStyle = ''; // Style set on <select/>
1618
1619 $item = '';
1620 $disabled = '';
1621 $onChangeIcon = ''; // TODO: icon is used but never assigned
1622
1623 if ($this->renderReadonly || $config['readOnly']) {
1624 $disabled = ' disabled="disabled"';
1625 $onlySelectedIconShown = 1;
1626 }
1627
1628 // Icon configuration:
1629 if ($config['suppress_icons'] == 'IF_VALUE_FALSE') {
1630 $suppressIcons = !$PA['itemFormElValue'] ? 1 : 0;
1631 } elseif ($config['suppress_icons'] == 'ONLY_SELECTED') {
1632 $suppressIcons = 0;
1633 $onlySelectedIconShown = 1;
1634 } elseif ($config['suppress_icons']) {
1635 $suppressIcons = 1;
1636 } else {
1637 $suppressIcons = 0;
1638 }
1639
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"' : '');
1646 if ($sM) {
1647 $sI = $c;
1648 $noMatchingValue = 0;
1649 }
1650
1651 // Getting style attribute value (for icons):
1652 if ($config['iconsInOptionTags']) {
1653 $styleAttrValue = $this->optionTagStyle($p[2]);
1654 if ($sM) {
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';
1659 }
1660 }
1661 }
1662
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]);
1669 } else {
1670 $optGroupStart[1] = $styleAttrValue;
1671 }
1672
1673 } else {
1674 if (count($optGroupStart)) {
1675 if ($optGroupOpen) { // Closing last optgroup before next one starts
1676 $opt[] = '</optgroup>' . LF;
1677 }
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;
1682 $c--;
1683 $optGroupStart = array();
1684 }
1685 $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' .
1686 $sM .
1687 ($styleAttrValue ? ' style="' . htmlspecialchars($styleAttrValue) . '"' : '') .
1688 '>' . t3lib_div::deHSCentities(($p[0])) . '</option>' . LF;
1689 }
1690 }
1691
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;';
1700 } else {
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;';
1704 }
1705 $selicons[] = array(
1706 (!$onlySelectedIconShown ? '<a href="#" onclick="' . htmlspecialchars($iOnClick) . '">' : '') .
1707 $this->getIconHtml($p[2], htmlspecialchars($p[0]), htmlspecialchars($p[0])) .
1708 (!$onlySelectedIconShown ? '</a>' : ''),
1709 $c, $sM);
1710 }
1711 $c++;
1712 }
1713
1714 if ($optGroupOpen) { // Closing optgroup if open
1715 $opt[] = '</optgroup>';
1716 $optGroupOpen = FALSE;
1717 }
1718
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>';
1723 }
1724
1725 // Create item form fields:
1726 $sOnChange = 'if (this.options[this.selectedIndex].value==\'--div--\') {this.selectedIndex=' . $sI . ';} ' . implode('', $PA['fieldChangeFunc']);
1727 if (!$disabled) {
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...
1729 }
1730 if ($config['iconsInOptionTags']) {
1731 $classesForSelectTag[] = 'icon-select';
1732 }
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>';
1740
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);
1747 }
1748 $sR = ceil(count($selicons) / $selicon_cols);
1749 $selicons = array_pad($selicons, $sR * $selicon_cols, '');
1750 for ($sa = 0; $sa < $sR; $sa++) {
1751 $item .= '<tr>';
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>';
1758 }
1759 $item .= '</tr>';
1760 }
1761 $item .= '</table>';
1762 }
1763
1764 return $item;
1765 }
1766
1767 /**
1768 * Creates a checkbox list (renderMode = "checkbox")
1769 * (Render function for getSingleField_typeSelect())
1770 *
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()
1780 */
1781 function getSingleField_typeSelect_checkbox($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
1782
1783 if (empty($selItems)) {
1784 return '';
1785 }
1786
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']));
1789
1790 $item = '';
1791 $disabled = '';
1792 if ($this->renderReadonly || $config['readOnly']) {
1793 $disabled = ' disabled="disabled"';
1794 }
1795
1796 // Traverse the Array of selector box items:
1797 $tRows = array();
1798 $c = 0;
1799 if (!$disabled) {
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--')) {
1806 $tRows[] = '
1807 <tr class="c-header">
1808 <td colspan="3">' . htmlspecialchars($p[0]) . '</td>
1809 </tr>';
1810 } else {
1811 // Selected or not by default:
1812 $sM = '';
1813 if (isset($itemArray[$p[1]])) {
1814 $sM = ' checked="checked"';
1815 unset($itemArray[$p[1]]);
1816 }
1817
1818 // Icon:
1819 if ($p[2]) {
1820 $selIcon = $p[2];
1821 } else {
1822 $selIcon = t3lib_iconWorks::getSpriteIcon('empty-empty');
1823 }
1824
1825 // Compile row:
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\');';
1836
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)
1843 $hasHelp = FALSE;
1844 $help = '';
1845 $helpArray = array();
1846 if ((is_array($p[3]) && count($p[3]) > 0) || !empty($p[3])) {
1847 $hasHelp = TRUE;
1848 if (is_array($p[3])) {
1849 $helpArray = $p[3];
1850 } else {
1851 $helpArray['description'] = $p[3];
1852 }
1853 }
1854
1855 $label = t3lib_div::deHSCentities(htmlspecialchars($p[0]));
1856 if ($hasHelp) {
1857 $help = t3lib_BEfunc::wrapInHelp('', '', '', $helpArray);
1858 }
1859
1860 $tRows[] = '
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) .
1865 $label .
1866 '</td>
1867 <td class="c-descr" onclick="' . htmlspecialchars($onClickCell) . '">' . ((empty($help)) ? '' : $help) . '</td>
1868 </tr>';
1869 $c++;
1870 }
1871 }
1872 }
1873
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>&nbsp;</td>
1884 </tr>');
1885 $c++;
1886 }
1887 }
1888
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="" />';
1891
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) . '}') . '">
1898 </td>
1899 <td colspan="2">
1900 </td>
1901 </tr></thead>';
1902 }
1903 // Implode rows in table:
1904 $item .= '
1905 <table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-select-checkbox">' .
1906 $tableHead .
1907 '<tbody>' . implode('', $tRows) . '</tbody>
1908 </table>
1909 ';
1910
1911 // Add revert icon
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>';
1915 }
1916
1917 return $item;
1918 }
1919
1920 /**
1921 * Creates a selectorbox list (renderMode = "singlebox")
1922 * (Render function for getSingleField_typeSelect())
1923 *
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()
1933 */
1934 function getSingleField_typeSelect_singlebox($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
1935
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']));
1938
1939 $item = '';
1940 $disabled = '';
1941 if ($this->renderReadonly || $config['readOnly']) {
1942 $disabled = ' disabled="disabled"';
1943 }
1944
1945 // Traverse the Array of selector box items:
1946 $opt = array();
1947 $restoreCmd = array(); // Used to accumulate the JS needed to restore the original selection.
1948 $c = 0;
1949 foreach ($selItems as $p) {
1950 // Selected or not by default:
1951 $sM = '';
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]]);
1956 }
1957
1958 // Non-selectable element:
1959 $nonSel = '';
1960 if (!strcmp($p[1], '--div--')) {
1961 $nonSel = ' onclick="this.selected=0;" class="c-divider"';
1962 }
1963
1964 // Icon style for option tag:
1965 if ($config['iconsInOptionTags']) {
1966 $styleAttrValue = $this->optionTagStyle($p[2]);
1967 }
1968
1969 // Compile <option> tag:
1970 $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' .
1971 $sM .
1972 $nonSel .
1973 ($styleAttrValue ? ' style="' . htmlspecialchars($styleAttrValue) . '"' : '') .
1974 '>' . t3lib_div::deHSCentities(htmlspecialchars($p[0])) . '</option>';
1975 $c++;
1976 }
1977
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>');
1983 }
1984 }
1985
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) . '"' .
1996 $PA['onFocus'] .
1997 $selector_itemListStyle .
1998 $disabled . '>
1999 ' .
2000 implode('
2001 ', $opt) . '
2002 </select>';
2003
2004 // Add an empty hidden field which will send a blank value if all items are unselected.
2005 if (!$disabled) {
2006 $item .= '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="" />';
2007 }
2008
2009 // Put it all into a table:
2010 $item .= '
2011 <table border="0" cellspacing="0" cellpadding="0" width="1" class="typo3-TCEforms-select-singlebox">
2012 <tr>
2013 <td>
2014 ' . $selectBox . '
2015 <br/>
2016 <em>' .
2017 htmlspecialchars($this->getLL('l_holdDownCTRL')) .
2018 '</em>
2019 </td>
2020 <td valign="top">
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') .
2023 '</a>
2024 </td>
2025 </tr>
2026 </table>
2027 ';
2028
2029 return $item;
2030 }
2031
2032 /**
2033 * Creates a multiple-selector box (two boxes, side-by-side)
2034 * (Render function for getSingleField_typeSelect())
2035 *
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()
2045 */
2046 function getSingleField_typeSelect_multiple($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
2047
2048 $item = '';
2049 $disabled = '';
2050 if ($this->renderReadonly || $config['readOnly']) {
2051 $disabled = ' disabled="disabled"';
2052 }
2053
2054 // Setting this hidden field (as a flag that JavaScript can read out)
2055 if (!$disabled) {
2056 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '_mul" value="' . ($config['multiple'] ? 1 : 0) . '" />';
2057 }
2058
2059 // Set max and min items:
2060 $maxitems = t3lib_div::intInRange($config['maxitems'], 0);
2061 if (!$maxitems) {
2062 $maxitems = 100000;
2063 }
2064 $minitems = t3lib_div::intInRange($config['minitems'], 0);
2065
2066 // Register the required number of elements:
2067 $this->registerRequiredProperty('range', $PA['itemFormElName'], array($minitems, $maxitems, 'imgName' => $table . '_' . $row['uid'] . '_' . $field));
2068
2069 // Get "removeItems":
2070 $removeItems = t3lib_div::trimExplode(',', $PA['fieldTSConfig']['removeItems'], 1);
2071
2072 // Get the array with selected items:
2073 $itemArray = t3lib_div::trimExplode(',', $PA['itemFormElValue'], 1);
2074
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);
2078
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]));
2088 }
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]);
2094 break;
2095 }
2096 }
2097 }
2098 $itemArray[$tk] = implode('|', $tvP);
2099 }
2100 $itemsToSelect = '';
2101
2102 if (!$disabled) {
2103 // Create option tags:
2104 $opt = array();
2105 $styleAttrValue = '';
2106 foreach ($selItems as $p) {
2107 if ($config['iconsInOptionTags']) {
2108 $styleAttrValue = $this->optionTagStyle($p[2]);
2109 }
2110 $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' .
2111 ($styleAttrValue ? ' style="' . htmlspecialchars($styleAttrValue) . '"' : '') .
2112 '>' . $p[0] . '</option>';
2113 }
2114
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'] . '\'); ';
2121 } else {
2122 $sOnChange = 'setFormValueFromBrowseWin(\'' . $PA['itemFormElName'] . '\',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text); ';
2123 }
2124 $sOnChange .= implode('', $PA['fieldChangeFunc']);
2125 $itemsToSelect = '
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) . '"' .
2130 $PA['onFocus'] .
2131 $selector_itemListStyle . '>
2132 ' . implode('
2133 ', $opt) . '
2134 </select>';
2135 }
2136
2137 // Pass to "dbFileIcons" function:
2138 $params = array(
2139 'size' => $size,
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,
2144 'info' => '',
2145 'headers' => array(
2146 'selector' => $this->getLL('l_selected') . ':<br />',
2147 'items' => $this->getLL('l_items') . ':<br />'
2148 ),
2149 'noBrowser' => 1,
2150 'thumbnails' => $itemsToSelect,
2151 'readOnly' => $disabled
2152 );
2153 $item .= $this->dbFileIcons($PA['itemFormElName'], '', '', $itemArray, '', $params, $PA['onFocus']);
2154
2155 return $item;
2156 }
2157
2158 /**
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.
2161 *
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
2167 */
2168 function getSingleField_typeGroup($table, $field, $row, &$PA) {
2169 // Init:
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);
2175 if (!$maxitems) {
2176 $maxitems = 100000;
2177 }
2178 $minitems = t3lib_div::intInRange($config['minitems'], 0);
2179 $allowed = trim($config['allowed']);
2180 $disallowed = trim($config['disallowed']);
2181
2182 $item = '';
2183 $disabled = '';
2184 if ($this->renderReadonly || $config['readOnly']) {
2185 $disabled = ' disabled="disabled"';
2186 }
2187
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));
2190 $info = '';
2191
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']);
2194
2195 $PA['itemFormElID_file'] = $PA['itemFormElID'] . '_files';
2196
2197 // whether the list controls should be disabled
2198 $noList = isset($config['disable_controls']) && t3lib_div::inList($config['disable_controls'], 'list');
2199
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'] . "'
2204 }";
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'];
2209 }
2210
2211 // Acting according to either "file" or "db" type:
2212 switch ((string) $config['internal_type']) {
2213 case 'file_reference':
2214 $config['uploadfolder'] = '';
2215 // Fall through
2216 case 'file': // If the element is of the internal type "file":
2217
2218 // Creating string showing allowed types:
2219 $tempFT = t3lib_div::trimExplode(',', $allowed, TRUE);
2220 if (!count($tempFT)) {
2221 $info .= '*';
2222 }
2223 foreach ($tempFT as $ext) {
2224 if ($ext) {
2225 $info .= strtoupper($ext) . ' ';
2226 }
2227 }
2228 // Creating string, showing disallowed types:
2229 $tempFT_dis = t3lib_div::trimExplode(',', $disallowed, TRUE);
2230 if (count($tempFT_dis)) {
2231 $info .= '<br />';
2232 }
2233 foreach ($tempFT_dis as $ext) {
2234 if ($ext) {
2235 $info .= '-' . strtoupper($ext) . ' ';
2236 }
2237 }
2238
2239 // Making the array of file items:
2240 $itemArray = t3lib_div::trimExplode(',', $PA['itemFormElValue'], TRUE);
2241
2242 // Showing thumbnails:
2243 $thumbsnail = '';
2244 if ($show_thumbs) {
2245 $imgs = array();
2246 foreach ($itemArray as $imgRead) {
2247 $imgP = explode('|', $imgRead);
2248 $imgPath = rawurldecode($imgP[0]);
2249
2250 $rowCopy = array();
2251 $rowCopy[$field] = $imgPath;
2252
2253 $imgs[] = '<span class="nobr">' . t3lib_BEfunc::thumbCode($rowCopy, $table, $field, $this->backPath, 'thumbs.php', $config['uploadfolder'], 0, ' align="middle"') .
2254 $imgPath .
2255 '</span>';
2256 }
2257 $thumbsnail = implode('<br />', $imgs);
2258 }
2259
2260 // Creating the element:
2261 $params = array(
2262 'size' => $size,
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 . '"',
2267 'info' => $info,
2268 'thumbnails' => $thumbsnail,
2269 'readOnly' => $disabled,
2270 'noBrowser' => $noList || (isset($config['disable_controls']) && t3lib_div::inList($config['disable_controls'], 'browser')),
2271 'noList' => $noList,
2272 );
2273 $item .= $this->dbFileIcons($PA['itemFormElName'], 'file', implode(',', $tempFT), $itemArray, '', $params, $PA['onFocus']);
2274
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>';
2279 }
2280 }
2281 break;
2282 case 'folder': // If the element is of the internal type "folder":
2283
2284 // array of folder items:
2285 $itemArray = t3lib_div::trimExplode(',', $PA['itemFormElValue'], 1);
2286
2287 // Creating the element:
2288 $params = array(
2289 'size' => $size,
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 . '"',
2296 'info' => $info,
2297 'readOnly' => $disabled,
2298 'noBrowser' => $noList || (isset($config['disable_controls']) && t3lib_div::inList($config['disable_controls'], 'browser')),
2299 'noList' => $noList,
2300 );
2301
2302 $item .= $this->dbFileIcons(
2303 $PA['itemFormElName'],
2304 'folder',
2305 '',
2306 $itemArray,
2307 '',
2308 $params,
2309 $PA['onFocus']
2310 );
2311 break;
2312 case 'db': // If the element is of the internal type "db":
2313
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')) .
2320 '</span><br />';
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'])) .
2327 '</span><br />';
2328 }
2329 }
2330
2331 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
2332 $itemArray = array();
2333 $imgs = array();
2334
2335 // Thumbnails:
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;
2343 }
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(
2350 $this_table,
2351 $rr,
2352 array(
2353 'style' => 'vertical-align:top',
2354 'title' => htmlspecialchars(t3lib_BEfunc::getRecordPath($rr['pid'], $perms_clause, 15) . ' [UID: ' . $rr['uid'] . ']')
2355 )
2356 ),
2357 $this_table,
2358 $this_uid
2359 ) .
2360 '&nbsp;' .
2361 t3lib_BEfunc::getRecordTitle($this_table, $rr, TRUE) . ' <span class="typo3-dimmed"><em>[' . $rr['uid'] . ']</em></span>' .
2362 '</span>';
2363 }
2364 }
2365 $thumbsnail = '';
2366 if (!$disabled && $show_thumbs) {
2367 $thumbsnail = implode('<br />', $imgs);
2368 }
2369
2370 // Creating the element:
2371 $params = array(
2372 'size' => $size,
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 . '"',
2377 'info' => $info,
2378 'thumbnails' => $thumbsnail,
2379 'readOnly' => $disabled,
2380 'noBrowser' => $noList || (isset($config['disable_controls']) && t3lib_div::inList($config['disable_controls'], 'browser')),
2381 'noList' => $noList,
2382 );
2383 $item .= $this->dbFileIcons($PA['itemFormElName'], 'db', implode(',', $tempFT), $itemArray, '', $params, $PA['onFocus'], $table, $field, $row['uid']);
2384
2385 break;
2386 }
2387
2388 // Wizards:
2389 $altItem = '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
2390 if (!$disabled) {
2391 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf);
2392 }
2393
2394 return $item;
2395 }
2396
2397 /**
2398 * Generation of TCEform elements of the type "none"
2399 * This will render a non-editable display of the content of the field.
2400 *
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
2406 */
2407 function getSingleField_typeNone($table, $field, $row, &$PA) {
2408 // Init:
2409 $config = $PA['fieldConf']['config'];
2410 $itemValue = $PA['itemFormElValue'];
2411
2412 return $this->getSingleField_typeNone_render($config, $itemValue);
2413 }
2414
2415 /**
2416 * HTML rendering of a value which is not editable.
2417 *
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();
2422 */
2423 function getSingleField_typeNone_render($config, $itemValue) {
2424
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;';
2427
2428 if ($config['format']) {
2429 $itemValue = $this->formatValue($config, $itemValue);
2430 }
2431
2432 $rows = intval($config['rows']);
2433 if ($rows > 1) {
2434 if (!$config['pass_content']) {
2435 $itemValue = nl2br(htmlspecialchars($itemValue));
2436 }
2437 // like textarea
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) {
2445 $rows = $origRows;
2446 }
2447 }
2448 }
2449
2450 if ($this->docLarge) {
2451 $cols = round($cols * $this->form_largeComp);
2452 }
2453 $width = ceil($cols * $this->form_rowsToStylewidth);
2454 // hardcoded: 12 is the height of the font
2455 $height = $rows * 12;
2456
2457 $item = '
2458 <div style="' . htmlspecialchars($divStyle . ' overflow:auto; height:' . $height . 'px; width:' . $width . 'px;') . '" class="' . htmlspecialchars($this->formElClass('none')) . '">' .
2459 $itemValue .
2460 '</div>';
2461 } else {
2462 if (!$config['pass_content']) {
2463 $itemValue = htmlspecialchars($itemValue);
2464 }
2465
2466 $cols = $config['cols'] ? $config['cols'] : ($config['size'] ? $config['size'] : $this->maxInputWidth);
2467 if ($this->docLarge) {
2468 $cols = round($cols * $this->form_largeComp);
2469 }
2470 $width = ceil($cols * $this->form_rowsToStylewidth);
2471
2472 // overflow:auto crashes mozilla here. Title tag is usefull when text is longer than the div box (overflow:hidden).
2473 $item = '
2474 <div style="' . htmlspecialchars($divStyle . ' overflow:hidden; width:' . $width . 'px;') . '" class="' . htmlspecialchars($this->formElClass('none')) . '" title="' . $itemValue . '">' .
2475 '<span class="nobr">' . (strcmp($itemValue, '') ? $itemValue : '&nbsp;') . '</span>' .
2476 '</div>';
2477 }
2478
2479 return $item;
2480 }
2481
2482 /**
2483 * Handler for Flex Forms
2484 *
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
2490 */
2491 function getSingleField_typeFlex($table, $field, $row, &$PA) {
2492
2493 // Data Structure:
2494 $dataStructArray = t3lib_BEfunc::getFlexFormDS($PA['fieldConf']['config'], $row, $table);
2495 $item = '';
2496
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);
2502 }
2503
2504 // Get data structure:
2505 if (is_array($dataStructArray)) {
2506
2507 // Get data:
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);
2514 }
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();
2520 }
2521
2522 // Find the data structure if sheets are found:
2523 $sheet = $editData['meta']['currentSheetId'] ? $editData['meta']['currentSheetId'] : 'sDEF'; // Sheet to display
2524
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 />';
2529 // }
2530
2531 // Create language menu:
2532 $langChildren = $dataStructArray['meta']['langChildren'] ? 1 : 0;
2533 $langDisabled = $dataStructArray['meta']['langDisable'] ? 1 : 0;
2534
2535 $editData['meta']['currentLangId'] = array();
2536
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(
2541 '*',
2542 'pages_language_overlay',
2543 'pid=' . intval($row['pid']) .
2544 t3lib_BEfunc::deleteClause('pages_language_overlay') .
2545 t3lib_BEfunc::versioningPlaceholderClause('pages_language_overlay'),
2546 '',
2547 '',
2548 '',
2549 'sys_language_uid'
2550 );
2551 }
2552 $languages = $this->getAvailableLanguages();
2553
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'];
2557 }
2558 }
2559 if (!is_array($editData['meta']['currentLangId']) || !count($editData['meta']['currentLangId'])) {
2560 $editData['meta']['currentLangId'] = array('DEF');
2561 }
2562
2563 $editData['meta']['currentLangId'] = array_unique($editData['meta']['currentLangId']);
2564
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 />';
2568 // }
2569
2570 $PA['_noEditDEF'] = FALSE;
2571 if ($langChildren || $langDisabled) {
2572 $rotateLang = array('DEF');
2573 } else {
2574 if (!in_array('DEF', $editData['meta']['currentLangId'])) {
2575 array_unshift($editData['meta']['currentLangId'], 'DEF');
2576 $PA['_noEditDEF'] = TRUE;
2577 }
2578 $rotateLang = $editData['meta']['currentLangId'];
2579 }
2580
2581 // Tabs sheets
2582 if (is_array($dataStructArray['sheets'])) {
2583 $tabsToTraverse = array_keys($dataStructArray['sheets']);
2584 } else {
2585 $tabsToTraverse = array($sheet);
2586 }
2587
2588 foreach ($rotateLang as $lKey) {
2589 if (!$langChildren && !$langDisabled) {
2590 $item .= '<strong>' . $this->getLanguageIcon($table, $row, 'v' . $lKey) . $lKey . ':</strong>';
2591 }
2592
2593 $tabParts = array();
2594 foreach ($tabsToTraverse as $sheet) {
2595 list ($dataStruct, $sheet) = t3lib_div::resolveSheetDefInDS($dataStructArray, $sheet);
2596
2597 // Render 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];
2607 }
2608
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));
2613 }
2614 // Render flexform:
2615 $tRows = $this->getSingleField_typeFlex_draw(
2616 $dataStruct['ROOT']['el'],
2617 $editData['data'][$sheet][$lang],
2618 $table,
2619 $field,
2620 $row,
2621 $PA,
2622 '[data][' . $sheet . '][' . $lang . ']'
2623 );
2624 $sheetContent = '<div class="typo3-TCEforms-flexForm">' . $tRows . '</div>';
2625
2626
2627 // Pop the sheet level tab from DynNestedStack
2628 if (is_array($dataStructArray['sheets'])) {
2629 $this->popFromDynNestedStack('tab', $tabIdentString . '-' . (count($tabParts) + 1));
2630 }
2631 } else {
2632 $sheetContent = 'Data Structure ERROR: No ROOT element found for sheet "' . $sheet . '".';
2633 }
2634
2635 // Add to tab:
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
2641 );
2642 }
2643
2644 if (is_array($dataStructArray['sheets'])) {
2645 $dividersToTabsBehaviour = (isset($GLOBALS['TCA'][$table]['ctrl']['dividers2tabs']) ? $GLOBALS['TCA'][$table]['ctrl']['dividers2tabs'] : 1);
2646 $item .= $this->getDynTabMenu($tabParts, 'TCEFORMS:flexform:' . $PA['itemFormElName'] . $PA['_lang'], $dividersToTabsBehaviour);
2647 } else {
2648 $item .= $sheetContent;
2649 }
2650 }
2651 } else {
2652 $item = 'Data Structure ERROR: ' . $dataStructArray;
2653 }
2654
2655 return $item;
2656 }
2657
2658 /**
2659 * Creates the language menu for FlexForms:
2660 *
2661 * @param [type] $languages: ...
2662 * @param [type] $elName: ...
2663 * @param [type] $selectedLanguage: ...
2664 * @param [type] $multi: ...
2665 * @return string HTML for menu
2666 */
2667 function getSingleField_typeFlex_langMenu($languages, $elName, $selectedLanguage, $multi = 1) {
2668 $opt = array();
2669 foreach ($languages as $lArr) {
2670 $opt[] = '<option value="' . htmlspecialchars($lArr['ISOcode']) . '"' . (in_array($lArr['ISOcode'], $selectedLanguage) ? ' selected="selected"' : '') . '>' . htmlspecialchars($lArr['title']) . '</option>';
2671 }
2672
2673 $output = '<select id="' . uniqid('tceforms-multiselect-') . ' class="tceforms-select tceforms-multiselect tceforms-flexlangmenu" name="' . $elName . '[]"' . ($multi ? ' multiple="multiple" size="' . count($languages) . '"' : '') . '>' . implode('', $opt) . '</select>';
2674
2675 return $output;
2676 }
2677
2678 /**
2679 * Creates the menu for selection of the sheets:
2680 *
2681 * @param array Sheet array for which to render the menu
2682 * @param string Form element name of the field containing the sheet pointer
2683 * @param string Current sheet key
2684 * @return string HTML for menu
2685 */
2686 function getSingleField_typeFlex_sheetMenu($sArr, $elName, $sheetKey) {
2687
2688 $tCells = array();
2689 $pct = round(100 / count($sArr));
2690 foreach ($sArr as $sKey => $sheetCfg) {
2691 if ($GLOBALS['BE_USER']->jsConfirmation(1)) {