3363f751dc121ad271746207d10a20496ec3c512
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_tceforms.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2006 Kasper Skaarhoj (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 * $Id$
31 * Revised for TYPO3 3.6 August/2003 by Kasper Skaarhoj
32 * XHTML compliant
33 *
34 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
35 */
36 /**
37 * [CLASS/FUNCTION INDEX of SCRIPT]
38 *
39 *
40 *
41 * 196: class t3lib_TCEforms
42 * 302: function t3lib_TCEforms()
43 * 338: function initDefaultBEmode()
44 *
45 * SECTION: Rendering the forms, fields etc
46 * 385: function getSoloField($table,$row,$theFieldToReturn)
47 * 424: function getMainFields($table,$row,$depth=0)
48 * 618: function getListedFields($table,$row,$list)
49 * 660: function getPaletteFields($table,$row,$palette,$header='',$itemList='',$collapsedHeader='')
50 * 737: function getSingleField($table,$field,$row,$altName='',$palette=0,$extra='',$pal=0)
51 * 900: function getSingleField_SW($table,$field,$row,&$PA)
52 *
53 * SECTION: Rendering of each TCEform field type
54 * 976: function getSingleField_typeInput($table,$field,$row,&$PA)
55 * 1057: function getSingleField_typeText($table,$field,$row,&$PA)
56 * 1178: function getSingleField_typeCheck($table,$field,$row,&$PA)
57 * 1244: function getSingleField_typeRadio($table,$field,$row,&$PA)
58 * 1279: function getSingleField_typeSelect($table,$field,$row,&$PA)
59 * 1359: function getSingleField_typeSelect_single($table,$field,$row,&$PA,$config,$selItems,$nMV_label)
60 * 1490: function getSingleField_typeSelect_checkbox($table,$field,$row,&$PA,$config,$selItems,$nMV_label)
61 * 1609: function getSingleField_typeSelect_singlebox($table,$field,$row,&$PA,$config,$selItems,$nMV_label)
62 * 1719: function getSingleField_typeSelect_multiple($table,$field,$row,&$PA,$config,$selItems,$nMV_label)
63 * 1823: function getSingleField_typeGroup($table,$field,$row,&$PA)
64 * 1992: function getSingleField_typeNone($table,$field,$row,&$PA)
65 * 2008: function getSingleField_typeNone_render($config,$itemValue)
66 * 2070: function getSingleField_typeFlex($table,$field,$row,&$PA)
67 * 2205: function getSingleField_typeFlex_langMenu($languages,$elName,$selectedLanguage,$multi=1)
68 * 2224: function getSingleField_typeFlex_sheetMenu($sArr,$elName,$sheetKey)
69 * 2259: function getSingleField_typeFlex_draw($dataStruct,$editData,$cmdData,$table,$field,$row,&$PA,$formPrefix='',$level=0,$tRows=array())
70 * 2452: function getSingleField_typeUnknown($table,$field,$row,&$PA)
71 * 2467: function getSingleField_typeUser($table,$field,$row,&$PA)
72 *
73 * SECTION: Field content processing
74 * 2496: function formatValue ($config, $itemValue)
75 *
76 * SECTION: "Configuration" fetching/processing functions
77 * 2588: function getRTypeNum($table,$row)
78 * 2614: function rearrange($fields)
79 * 2640: function getExcludeElements($table,$row,$typeNum)
80 * 2688: function getFieldsToAdd($table,$row,$typeNum)
81 * 2713: function mergeFieldsWithAddedFields($fields,$fieldsToAdd)
82 * 2745: function setTSconfig($table,$row,$field='')
83 * 2767: function getSpecConfForField($table,$row,$field)
84 * 2788: function getSpecConfFromString($extraString, $defaultExtras)
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
174
175
176
177
178
179
180
181
182
183 require_once(PATH_t3lib.'class.t3lib_diff.php');
184 require_once(PATH_t3lib.'class.t3lib_tceforms_inline.php');
185
186
187
188 /**
189 * 'TCEforms' - Class for creating the backend editing forms.
190 *
191 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
192 * @coauthor Rene Fritz <r.fritz@colorcube.de>
193 * @package TYPO3
194 * @subpackage t3lib
195 */
196 class t3lib_TCEforms {
197
198 // variables not commented yet.... (do so...)
199 var $palFieldArr = array();
200 var $disableWizards = 0;
201 var $isPalettedoc = 0;
202 var $paletteMargin = 1;
203 var $defStyle = ''; // 'font-family:Verdana;font-size:10px;';
204 var $cachedTSconfig = array();
205 var $cachedTSconfig_fieldLevel = array();
206 var $cachedLanguageFlag = array();
207 var $cachedAdditionalPreviewLanguages = NULL;
208 var $transformedRow = array();
209 var $extJSCODE = '';
210 var $printNeededJS = array();
211 var $hiddenFieldAccum=array();
212 var $TBE_EDITOR_fieldChanged_func='';
213 var $loadMD5_JS=1;
214 var $prevBorderStyle='[nothing here...]'; // Something unique...
215 var $allowUpload=0; // If set direct upload fields will be shown
216 var $titleLen=15; // @deprecated: $BE_USER->uc['titleLen'] but what is default??
217 var $defaultLanguageData = array(); // Array where records in the default language is stored. (processed by transferdata)
218 var $defaultLanguageData_diff = array(); // Array where records in the default language is stored (raw without any processing. used for making diff)
219 var $additionalPreviewLanguageData = array();
220
221
222 // EXTERNAL, static
223 var $backPath=''; // Set this to the 'backPath' pointing back to the typo3 admin directory from the script where this form is displayed.
224 var $returnUrl=''; // Alternative return URL path (default is t3lib_div::linkThisScript())
225 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.
226 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.
227 var $disableRTE=0; // If set, the RTE is disabled (from form display, eg. by checkbox in the bottom of the page!)
228 var $globalShowHelp=1; // If false, then all CSH will be disabled, regardless of settings in $this->edit_showFieldHelp
229 var $localizationMode=''; // If true, the forms are rendering only localization relevant fields of the records.
230 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.
231 var $doPrintPalette=1; // If set to false, palettes will NEVER be rendered.
232 var $clipObj=FALSE; // Set to initialized clipboard object; Then the element browser will offer a link to paste in records from clipboard.
233 var $enableClickMenu=FALSE; // Enable click menu on reference icons.
234 var $enableTabMenu = FALSE; // Enable Tab Menus. If set to true, the JavaScript content from template::getDynTabMenuJScode() must be included in the document.
235 var $renderReadonly = FALSE; // When enabled all fields are rendered non-editable.
236
237 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)
238 var $form_largeComp = 1.33; // Form field width compensation: Compensation for large documents, doc-tab (editing)
239 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.
240 var $maxTextareaWidth=48; // The maximum abstract value for textareas
241 var $maxInputWidth=48; // The maximum abstract value for input fields
242 var $defaultMultipleSelectorStyle='width:250px;'; // Default style for the selector boxes used for multiple items in "select" and "group" types.
243
244
245 // INTERNAL, static
246 var $prependFormFieldNames = 'data'; // The string to prepend formfield names with.
247 var $prependCmdFieldNames = 'cmd'; // The string to prepend commands for tcemain::process_cmdmap with.
248 var $prependFormFieldNames_file = 'data_files'; // The string to prepend FILE form field names with.
249 var $formName = 'editform'; // The name attribute of the form.
250 var $allowOverrideMatrix = array(); // Whitelist that allows TCA field configuration to be overridden by TSconfig, @see overrideFieldConf()
251
252
253
254 // INTERNAL, dynamic
255 var $perms_clause=''; // Set by readPerms() (caching)
256 var $perms_clause_set=0; // Set by readPerms() (caching-flag)
257 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).
258 var $docLarge=0; // If set, the forms will be rendered a little wider, more precisely with a factor of $this->form_largeComp.
259 var $clientInfo=array(); // Loaded with info about the browser when class is instantiated.
260 var $RTEenabled=0; // True, if RTE is possible for the current user (based on result from BE_USER->isRTE())
261 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)
262 var $RTEcounter = 0; // Counter that is incremented before an RTE is created. Can be used for unique ids etc.
263
264 var $colorScheme; // Contains current color scheme
265 var $classScheme; // Contains current class scheme
266 var $defColorScheme; // Contains the default color scheme
267 var $defClassScheme; // Contains the default class scheme
268 var $fieldStyle; // Contains field style values
269 var $borderStyle; // Contains border style values.
270
271 var $commentMessages=array(); // An accumulation of messages from the class.
272
273 // INTERNAL, templates
274 var $totalWrap='<hr />|<hr />'; // Total wrapping for the table rows.
275 var $fieldTemplate='<b>###FIELD_NAME###</b><br />###FIELD_ITEM###<hr />'; // Field template
276 var $sectionWrap=''; // Wrapping template code for a section
277 var $palFieldTemplateHeader=''; // Template for palette headers
278 var $palFieldTemplate=''; // Template for palettes
279
280 // INTERNAL, working memory
281 var $excludeElements=''; // Set to the fields NOT to display, if any.
282 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)
283 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!
284 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.
285 var $requiredElements=array(); // Used to register the min and max number of elements for selectorboxes where that apply (in the "group" type for instance)
286 var $renderDepth=0; // Keeps track of the rendering depth of nested records.
287 var $savedSchemes=array(); // Color scheme buffer.
288 var $dynTabLevelStack = array(); // holds tab dividers which were cascaded, required for RTE&IRRE
289
290 // Internal, registers for user defined functions etc.
291 var $additionalCode_pre = array(); // Additional HTML code, printed before the form.
292 var $additionalJS_pre = array(); // Additional JavaScript, printed before the form
293 var $additionalJS_post = array(); // Additional JavaScript printed after the form
294 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.
295
296 var $inline; // Instance of t3lib_tceforms_inline
297
298
299
300
301
302 /**
303 * Constructor function, setting internal variables, loading the styles used.
304 *
305 * @return void
306 */
307 function t3lib_TCEforms() {
308 global $CLIENT;
309
310 $this->clientInfo = t3lib_div::clientInfo();
311
312 $this->RTEenabled = $GLOBALS['BE_USER']->isRTE();
313 if (!$this->RTEenabled) {
314 $this->RTEenabled_notReasons = implode(chr(10),$GLOBALS['BE_USER']->RTE_errors);
315 $this->commentMessages[] = 'RTE NOT ENABLED IN SYSTEM due to:'.chr(10).$this->RTEenabled_notReasons;
316 }
317
318 // Default color+class scheme
319 $this->defColorScheme = array(
320 $GLOBALS['SOBE']->doc->bgColor, // Background for the field AND palette
321 t3lib_div::modifyHTMLColorAll($GLOBALS['SOBE']->doc->bgColor,-20), // Background for the field header
322 t3lib_div::modifyHTMLColorAll($GLOBALS['SOBE']->doc->bgColor,-10), // Background for the palette field header
323 'black', // Field header font color
324 '#666666' // Palette field header font color
325 );
326 $this->defColorScheme = array();
327
328 // Override / Setting defaults from TBE_STYLES array
329 $this->resetSchemes();
330
331 // Setting the current colorScheme to default.
332 $this->defColorScheme = $this->colorScheme;
333 $this->defClassScheme = $this->classScheme;
334
335 // Define whitelist that allows TCA field configuration to be overridden by TSconfig, @see overrideFieldConf():
336 $this->allowOverrideMatrix = array(
337 'input' => array('size', 'max'),
338 'text' => array('cols', 'rows', 'wrap'),
339 'check' => array('cols', 'showIfRTE'),
340 'select' => array('size', 'autoSizeMax', 'maxitems', 'minitems'),
341 'group' => array('size', 'autoSizeMax', 'max_size', 'show_thumbs', 'maxitems', 'minitems'),
342 'inline' => array('appearance', 'foreign_label', 'foreign_selector', 'foreign_unique', 'maxitems', 'minitems', 'size', 'autoSizeMax', 'symmetric_label'),
343 );
344
345 $this->inline = t3lib_div::makeInstance('t3lib_TCEforms_inline');
346 }
347
348 /**
349 * Initialize various internal variables.
350 *
351 * @return void
352 */
353 function initDefaultBEmode() {
354 global $BE_USER;
355 $this->prependFormFieldNames = 'data';
356 $this->formName = 'editform';
357 $this->setNewBEDesign();
358 $this->docLarge = $BE_USER->uc['edit_wideDocument'] ? 1 : 0;
359 $this->edit_showFieldHelp = $BE_USER->uc['edit_showFieldHelp'];
360
361 $this->edit_docModuleUpload = $BE_USER->uc['edit_docModuleUpload'];
362 $this->titleLen = $BE_USER->uc['titleLen']; // @deprecated
363
364 $this->inline->init($this);
365 }
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383 /*******************************************************
384 *
385 * Rendering the forms, fields etc
386 *
387 *******************************************************/
388
389 /**
390 * Will return the TCEform element for just a single field from a record.
391 * The field must be listed in the currently displayed fields (as found in [types][showitem]) for the record.
392 * This also means that the $table/$row supplied must be complete so the list of fields to show can be found correctly
393 *
394 * @param string The table name
395 * @param array The record from the table for which to render a field.
396 * @param string The field name to return the TCEform element for.
397 * @return string HTML output
398 * @see getMainFields()
399 */
400 function getSoloField($table,$row,$theFieldToReturn) {
401 global $TCA;
402
403 if ($TCA[$table]) {
404 t3lib_div::loadTCA($table);
405 $typeNum = $this->getRTypeNum($table,$row);
406 if ($TCA[$table]['types'][$typeNum]) {
407 $itemList = $TCA[$table]['types'][$typeNum]['showitem'];
408 if ($itemList) {
409 $fields = t3lib_div::trimExplode(',',$itemList,1);
410 $excludeElements = $this->excludeElements = $this->getExcludeElements($table,$row,$typeNum);
411
412 reset($fields);
413 while(list(,$fieldInfo)=each($fields)) {
414 $parts = explode(';',$fieldInfo);
415
416 $theField = trim($parts[0]);
417 if (!in_array($theField,$excludeElements) && !strcmp($theField,$theFieldToReturn)) {
418 if ($TCA[$table]['columns'][$theField]) {
419 $sField = $this->getSingleField($table,$theField,$row,$parts[1],1,$parts[3],$parts[2]);
420 return $sField['ITEM'];
421 }
422 }
423 }
424 }
425 }
426 }
427 }
428
429 /**
430 * Based on the $table and $row of content, this displays the complete TCEform for the record.
431 * 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.
432 *
433 * @param string The table name
434 * @param array The record from the table for which to render a field.
435 * @param integer Depth level
436 * @return string HTML output
437 * @see getSoloField()
438 */
439 function getMainFields($table,$row,$depth=0) {
440 global $TCA, $TYPO3_CONF_VARS;
441
442 $this->renderDepth=$depth;
443
444 // Init vars:
445 $out_array = array(array());
446 $out_array_meta = array(array(
447 'title' => $this->getLL('l_generalTab')
448 ));
449
450 $out_pointer=0;
451 $out_sheet=0;
452 $this->palettesRendered=array();
453 $this->palettesRendered[$this->renderDepth][$table]=array();
454
455 // First prepare user defined objects (if any) for hooks which extend this function:
456 $hookObjectsArr = array();
457 if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'])) {
458 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'] as $classRef) {
459 $hookObjectsArr[] = &t3lib_div::getUserObj($classRef);
460 }
461 }
462
463 // Hook: getMainFields_preProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
464 foreach ($hookObjectsArr as $hookObj) {
465 if (method_exists($hookObj,'getMainFields_preProcess')) {
466 $hookObj->getMainFields_preProcess($table,$row,$this);
467 }
468 }
469
470 if ($TCA[$table]) {
471
472 // Load the full TCA for the table.
473 t3lib_div::loadTCA($table);
474
475 // Load the description content for the table.
476 if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table)) {
477 $GLOBALS['LANG']->loadSingleTableDescription($table);
478 }
479 // Get the current "type" value for the record.
480 $typeNum = $this->getRTypeNum($table,$row);
481
482 // Find the list of fields to display:
483 if ($TCA[$table]['types'][$typeNum]) {
484 $itemList = $TCA[$table]['types'][$typeNum]['showitem'];
485 if ($itemList) { // If such a list existed...
486 // if TCEforms will render a tab menu in the next step, push the name to the tab stack
487 if (strstr($itemList, '--div--') !== false && $this->enableTabMenu && $TCA[$table]['ctrl']['dividers2tabs']) {
488 $tabIdentString = 'TCEforms:'.$table.':'.$row['uid'];
489 $tabIdentStringMD5 = $GLOBALS['TBE_TEMPLATE']->getDynTabMenuId('TCEforms:'.$table.':'.$row['uid']);
490 $this->dynTabLevelStack[$tabIdentStringMD5] = 1;
491 }
492
493 // Explode the field list and possibly rearrange the order of the fields, if configured for
494 $fields = t3lib_div::trimExplode(',',$itemList,1);
495 if ($this->fieldOrder) {
496 $fields = $this->rearrange($fields);
497 }
498
499 // Get excluded fields, added fiels and put it together:
500 $excludeElements = $this->excludeElements = $this->getExcludeElements($table,$row,$typeNum);
501 $fields = $this->mergeFieldsWithAddedFields($fields,$this->getFieldsToAdd($table,$row,$typeNum));
502
503 // Traverse the fields to render:
504 $cc=0;
505 foreach($fields as $fieldInfo) {
506 // Exploding subparts of the field configuration:
507 $parts = explode(';',$fieldInfo);
508
509 // Getting the style information out:
510 $color_style_parts = t3lib_div::trimExplode('-',$parts[4]);
511 if (strcmp($color_style_parts[0],'')) {
512 $this->setColorScheme($GLOBALS['TBE_STYLES']['colorschemes'][intval($color_style_parts[0])]);
513 }
514 if (strcmp($color_style_parts[1],'')) {
515 $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][intval($color_style_parts[1])];
516 if (!isset($this->fieldStyle)) $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][0];
517 }
518 if (strcmp($color_style_parts[2],'')) {
519 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
520 $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][intval($color_style_parts[2])];
521 if (!isset($this->borderStyle)) $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][0];
522 }
523
524 // Render the field:
525 $theField = $parts[0];
526 if (!in_array($theField,$excludeElements)) {
527 if ($TCA[$table]['columns'][$theField]) {
528 $sFieldPal='';
529
530 if ($parts[2] && !isset($this->palettesRendered[$this->renderDepth][$table][$parts[2]])) {
531 $sFieldPal=$this->getPaletteFields($table,$row,$parts[2]);
532 $this->palettesRendered[$this->renderDepth][$table][$parts[2]] = 1;
533 }
534 $sField = $this->getSingleField($table,$theField,$row,$parts[1],0,$parts[3],$parts[2]);
535 if ($sField) { $sField.= $sFieldPal; }
536
537 $out_array[$out_sheet][$out_pointer].= $sField;
538 } elseif ($theField=='--div--') {
539 if ($cc>0) {
540 $out_array[$out_sheet][$out_pointer].=$this->getDivider();
541
542 if ($this->enableTabMenu && $TCA[$table]['ctrl']['dividers2tabs']) {
543 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
544 $out_sheet++;
545 // remember what sheet we're currently in
546 $this->dynTabLevelStack[$tabIdentStringMD5] = $out_sheet+1;
547 $out_array[$out_sheet] = array();
548 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
549 }
550 } else { // Setting alternative title for "General" tab if "--div--" is the very first element.
551 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
552 }
553 } elseif($theField=='--palette--') {
554 if ($parts[2] && !isset($this->palettesRendered[$this->renderDepth][$table][$parts[2]])) {
555 // render a 'header' if not collapsed
556 if ($TCA[$table]['palettes'][$parts[2]]['canNotCollapse'] AND $parts[1]) {
557 $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$parts[2],$this->sL($parts[1]));
558 } else {
559 $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$parts[2],'','',$this->sL($parts[1]));
560 }
561 $this->palettesRendered[$this->renderDepth][$table][$parts[2]] = 1;
562 }
563 }
564 }
565
566 $cc++;
567 }
568 }
569 }
570 }
571
572 // Hook: getMainFields_postProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
573 foreach ($hookObjectsArr as $hookObj) {
574 if (method_exists($hookObj,'getMainFields_postProcess')) {
575 $hookObj->getMainFields_postProcess($table,$row,$this);
576 }
577 }
578
579 // Wrapping a border around it all:
580 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
581
582 // Resetting styles:
583 $this->resetSchemes();
584
585 // Rendering Main palettes, if any
586 $mParr = t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['mainpalette']);
587 $i = 0;
588 if (count($mParr)) {
589 foreach ($mParr as $mP) {
590 if (!isset($this->palettesRendered[$this->renderDepth][$table][$mP])) {
591 $temp_palettesCollapsed=$this->palettesCollapsed;
592 $this->palettesCollapsed=0;
593 $label = ($i==0?$this->getLL('l_generalOptions'):$this->getLL('l_generalOptions_more'));
594 $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$mP,$label);
595 $this->palettesCollapsed=$temp_palettesCollapsed;
596 $this->palettesRendered[$this->renderDepth][$table][$mP] = 1;
597 }
598 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
599 $i++;
600 if ($this->renderDepth) {
601 $this->renderDepth--;
602 }
603 }
604 }
605
606 // Return the imploded $out_array:
607 if ($out_sheet>0) { // There were --div-- dividers around...
608
609 // Create parts array for the tab menu:
610 $parts = array();
611 foreach ($out_array as $idx => $sheetContent) {
612 $parts[] = array(
613 'label' => $out_array_meta[$idx]['title'],
614 'content' => '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.
615 implode('',$sheetContent).
616 '</table>'
617 );
618 }
619
620 // unset the current level of tab menus
621 unset($this->dynTabLevelStack[$tabIdentStringMD5]);
622
623 return '
624 <tr>
625 <td colspan="2">
626 '.$this->getDynTabMenu($parts, $tabIdentString).'
627 </td>
628 </tr>';
629 } else { // Only one, so just implode:
630 return implode('',$out_array[$out_sheet]);
631 }
632 }
633
634 /**
635 * Will return the TCEform elements for a pre-defined list of fields.
636 * 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.
637 * Used for displaying forms for the frontend edit icons for instance.
638 *
639 * @param string The table name
640 * @param array The record array.
641 * @param string Commalist of fields from the table. These will be shown in the specified order in a form.
642 * @return string TCEform elements in a string.
643 */
644 function getListedFields($table,$row,$list) {
645 global $TCA;
646
647 t3lib_div::loadTCA($table);
648 if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table)) {
649 $GLOBALS['LANG']->loadSingleTableDescription($table);
650 }
651
652 $out = '';
653 $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table,$row,1);
654
655 $editFieldList=array_unique(t3lib_div::trimExplode(',',$list,1));
656 foreach($editFieldList as $theFieldC) {
657 list($theField,$palFields) = split('\[|\]',$theFieldC);
658 $theField = trim($theField);
659 $palFields = trim($palFields);
660 if ($TCA[$table]['columns'][$theField]) {
661 $parts = t3lib_div::trimExplode(';',$types_fieldConfig[$theField]['origString']);
662 $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.
663 $out.= $sField;
664 } elseif($theField=='--div--') {
665 $out.= $this->getDivider();
666 }
667 if ($palFields) {
668 $out.= $this->getPaletteFields($table,$row,'','',implode(',',t3lib_div::trimExplode('|',$palFields,1)));
669 }
670 }
671
672 return $out;
673 }
674
675 /**
676 * Creates a palette (collection of secondary options).
677 *
678 * @param string The table name
679 * @param array The row array
680 * @param string The palette number/pointer
681 * @param string Header string for the palette (used when in-form). If not set, no header item is made.
682 * @param string Optional alternative list of fields for the palette
683 * @param string Optional Link text for activating a palette (when palettes does not have another form element to belong to).
684 * @return string HTML code.
685 */
686 function getPaletteFields($table,$row,$palette,$header='',$itemList='',$collapsedHeader='') {
687 global $TCA;
688 if (!$this->doPrintPalette) return '';
689
690 $out='';
691 $palParts = array();
692 t3lib_div::loadTCA($table);
693
694 // Getting excludeElements, if any.
695 if (!is_array($this->excludeElements)) {
696 $this->excludeElements = $this->getExcludeElements($table,$row,$this->getRTypeNum($table,$row));
697 }
698
699 // Render the palette TCEform elements.
700 if ($TCA[$table] && (is_array($TCA[$table]['palettes'][$palette]) || $itemList)) {
701 $itemList = $itemList?$itemList:$TCA[$table]['palettes'][$palette]['showitem'];
702 if ($itemList) {
703 $fields = t3lib_div::trimExplode(',',$itemList,1);
704 reset($fields);
705 while(list(,$fieldInfo)=each($fields)) {
706 $parts = t3lib_div::trimExplode(';',$fieldInfo);
707 $theField = $parts[0];
708
709 if (!in_array($theField,$this->excludeElements) && $TCA[$table]['columns'][$theField]) {
710 $this->palFieldArr[$palette][] = $theField;
711 if ($this->isPalettesCollapsed($table,$palette)) {
712 $this->hiddenFieldListArr[] = $theField;
713 }
714
715 $part = $this->getSingleField($table,$theField,$row,$parts[1],1,'',$parts[2]);
716 if (is_array($part)) {
717 $palParts[] = $part;
718 }
719 }
720 }
721 }
722 }
723 // Put palette together if there are fields in it:
724 if (count($palParts)) {
725 if ($header) {
726 $out.= $this->intoTemplate(array(
727 'HEADER' => htmlspecialchars($header)
728 ),
729 $this->palFieldTemplateHeader
730 );
731 }
732 $out.= $this->intoTemplate(array(
733 'PALETTE' => $this->printPalette($palParts)
734 ),
735 $this->palFieldTemplate
736 );
737 }
738 // If a palette is collapsed (not shown in form, but in top frame instead) AND a collapse header string is given, then make that string a link to activate the palette.
739 if ($this->isPalettesCollapsed($table,$palette) && $collapsedHeader) {
740 $pC = $this->intoTemplate(array(
741 'PALETTE' => $this->wrapOpenPalette('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/options.gif','width="18" height="16"').' border="0" title="'.htmlspecialchars($this->getLL('l_moreOptions')).'" align="top" alt="" /><strong>'.$collapsedHeader.'</strong>',$table,$row,$palette),
742 ),
743 $this->palFieldTemplate
744 );
745 $out.= $pC;
746 }
747
748 return $out;
749 }
750
751 /**
752 * Returns the form HTML code for a database table field.
753 *
754 * @param string The table name
755 * @param string The field name
756 * @param array The record to edit from the database table.
757 * @param string Alternative field name label to show.
758 * @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).
759 * @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.
760 * @param integer The palette pointer.
761 * @return mixed String (normal) or array (palettes)
762 */
763 function getSingleField($table,$field,$row,$altName='',$palette=0,$extra='',$pal=0) {
764 global $TCA,$BE_USER;
765
766 $out = '';
767 $PA = array();
768 $PA['altName'] = $altName;
769 $PA['palette'] = $palette;
770 $PA['extra'] = $extra;
771 $PA['pal'] = $pal;
772
773 // Make sure to load full $TCA array for the table:
774 t3lib_div::loadTCA($table);
775
776 // Get the TCA configuration for the current field:
777 $PA['fieldConf'] = $TCA[$table]['columns'][$field];
778 $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
779
780 $skipThisField = $this->inline->skipField($table, $field, $row, $PA['fieldConf']['config']);
781
782 // Now, check if this field is configured and editable (according to excludefields + other configuration)
783 if ( is_array($PA['fieldConf']) &&
784 !$skipThisField &&
785 (!$PA['fieldConf']['exclude'] || $BE_USER->check('non_exclude_fields',$table.':'.$field)) &&
786 $PA['fieldConf']['config']['form_type']!='passthrough' &&
787 ($this->RTEenabled || !$PA['fieldConf']['config']['showIfRTE']) &&
788 (!$PA['fieldConf']['displayCond'] || $this->isDisplayCondition($PA['fieldConf']['displayCond'],$row)) &&
789 (!$TCA[$table]['ctrl']['languageField'] || $PA['fieldConf']['l10n_display'] || strcmp($PA['fieldConf']['l10n_mode'],'exclude') || $row[$TCA[$table]['ctrl']['languageField']]<=0) &&
790 (!$TCA[$table]['ctrl']['languageField'] || !$this->localizationMode || $this->localizationMode===$PA['fieldConf']['l10n_cat'])
791 ) {
792
793
794
795 // Fetching the TSconfig for the current table/field. This includes the $row which means that
796 $PA['fieldTSConfig'] = $this->setTSconfig($table,$row,$field);
797
798 // If the field is NOT disabled from TSconfig (which it could have been) then render it
799 if (!$PA['fieldTSConfig']['disabled']) {
800 // Override fieldConf by fieldTSconfig:
801 $PA['fieldConf']['config'] = $this->overrideFieldConf($PA['fieldConf']['config'], $PA['fieldTSConfig']);
802
803 // Init variables:
804 $PA['itemFormElName']=$this->prependFormFieldNames.'['.$table.']['.$row['uid'].']['.$field.']'; // Form field name
805 $PA['itemFormElName_file']=$this->prependFormFieldNames_file.'['.$table.']['.$row['uid'].']['.$field.']'; // Form field name, in case of file uploads
806 $PA['itemFormElValue']=$row[$field]; // The value to show in the form field.
807 $PA['itemFormElID']=$this->prependFormFieldNames.'_'.$table.'_'.$row['uid'].'_'.$field;
808
809 // set field to read-only if configured for translated records to show default language content as readonly
810 if ($PA['fieldConf']['l10n_display'] AND t3lib_div::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly') AND $row[$TCA[$table]['ctrl']['languageField']]) {
811 $PA['fieldConf']['config']['readOnly'] = true;
812 $PA['itemFormElValue'] = $this->defaultLanguageData[$table.':'.$row['uid']][$field];
813 }
814
815 // 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"
816 if (
817 ($TCA[$table]['ctrl']['type'] && !strcmp($field,$TCA[$table]['ctrl']['type'])) ||
818 ($TCA[$table]['ctrl']['requestUpdate'] && t3lib_div::inList($TCA[$table]['ctrl']['requestUpdate'],$field))) {
819 if($GLOBALS['BE_USER']->jsConfirmation(1)) {
820 $alertMsgOnChange = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
821 } else {
822 $alertMsgOnChange = 'if (TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
823 }
824 } else {
825 $alertMsgOnChange = '';
826 }
827
828 // Render as a hidden field?
829 if (in_array($field,$this->hiddenFieldListArr)) {
830 $this->hiddenFieldAccum[]='<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
831 } else { // Render as a normal field:
832
833 // 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.
834 if (!$PA['palette']) {
835 if ($PA['pal'] && $this->isPalettesCollapsed($table,$PA['pal'])) {
836 list($thePalIcon,$palJSfunc) = $this->wrapOpenPalette('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/options.gif','width="18" height="16"').' border="0" title="'.htmlspecialchars($this->getLL('l_moreOptions')).'" alt="" />',$table,$row,$PA['pal'],1);
837 } else {
838 $thePalIcon = '';
839 $palJSfunc = '';
840 }
841 }
842 // onFocus attribute to add to the field:
843 $PA['onFocus'] = ($palJSfunc && !$BE_USER->uc['dontShowPalettesOnFocusInAB']) ? ' onfocus="'.htmlspecialchars($palJSfunc).'"' : '';
844
845 // Find item
846 $item='';
847 $PA['label'] = $PA['altName'] ? $PA['altName'] : $PA['fieldConf']['label'];
848 $PA['label'] = $this->sL($PA['label']);
849 // JavaScript code for event handlers:
850 $PA['fieldChangeFunc']=array();
851 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = "TBE_EDITOR.fieldChanged('".$table."','".$row['uid']."','".$field."','".$PA['itemFormElName']."');";
852 $PA['fieldChangeFunc']['alert']=$alertMsgOnChange;
853 // if this is the child of an inline type and it is the field creating the label
854 if ($this->inline->isInlineChildAndLabelField($table, $field)) {
855 $PA['fieldChangeFunc']['inline'] = "inline.handleChangedField('".$PA['itemFormElName']."','".$this->inline->inlineNames['object']."[$table][".$row['uid']."]');";
856 }
857
858 // Based on the type of the item, call a render function:
859 $item = $this->getSingleField_SW($table,$field,$row,$PA);
860
861 // Add language + diff
862 if ($PA['fieldConf']['l10n_display'] && (t3lib_div::inList($PA['fieldConf']['l10n_display'], 'hideDiff') || t3lib_div::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly'))) {
863 $renderLanguageDiff = false;
864 } else {
865 $renderLanguageDiff = true;
866 }
867
868 if ($renderLanguageDiff) {
869 $item = $this->renderDefaultLanguageContent($table,$field,$row,$item);
870 $item = $this->renderDefaultLanguageDiff($table,$field,$row,$item);
871 }
872
873 // 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
874 $PA['label'] = t3lib_div::deHSCentities(htmlspecialchars($PA['label']));
875 if (t3lib_div::testInt($row['uid']) && $PA['fieldTSConfig']['linkTitleToSelf']) {
876 $lTTS_url = $this->backPath.'alt_doc.php?edit['.$table.']['.$row['uid'].']=edit&columnsOnly='.$field.
877 ($PA['fieldTSConfig']['linkTitleToSelf.']['returnUrl']?'&returnUrl='.rawurlencode($this->thisReturnUrl()):'');
878 $PA['label'] = '<a href="'.htmlspecialchars($lTTS_url).'">'.$PA['label'].'</a>';
879 }
880
881 // Create output value:
882 if ($PA['fieldConf']['config']['form_type']=='user' && $PA['fieldConf']['config']['noTableWrapping']) {
883 $out = $item;
884 } elseif ($PA['palette']) {
885 // Array:
886 $out=array(
887 'NAME'=>$PA['label'],
888 'ID'=>$row['uid'],
889 'FIELD'=>$field,
890 'TABLE'=>$table,
891 'ITEM'=>$item,
892 'HELP_ICON' => $this->helpTextIcon($table,$field,1)
893 );
894 $out = $this->addUserTemplateMarkers($out,$table,$field,$row,$PA);
895 } else {
896 // String:
897 $out=array(
898 'NAME'=>$PA['label'],
899 'ITEM'=>$item,
900 'TABLE'=>$table,
901 'ID'=>$row['uid'],
902 'HELP_ICON'=>$this->helpTextIcon($table,$field),
903 'HELP_TEXT'=>$this->helpText($table,$field),
904 'PAL_LINK_ICON'=>$thePalIcon,
905 'FIELD'=>$field
906 );
907 $out = $this->addUserTemplateMarkers($out,$table,$field,$row,$PA);
908 // String:
909 $out=$this->intoTemplate($out);
910 }
911 }
912 } else $this->commentMessages[]=$this->prependFormFieldNames.'['.$table.']['.$row['uid'].']['.$field.']: Disabled by TSconfig';
913 }
914 // Return value (string or array)
915 return $out;
916 }
917
918 /**
919 * Rendering a single item for the form
920 *
921 * @param string Table name of record
922 * @param string Fieldname to render
923 * @param array The record
924 * @param array parameters array containing a lot of stuff. Value by Reference!
925 * @return string Returns the item as HTML code to insert
926 * @access private
927 * @see getSingleField(), getSingleField_typeFlex_draw()
928 */
929 function getSingleField_SW($table,$field,$row,&$PA) {
930 $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
931
932 switch($PA['fieldConf']['config']['form_type']) {
933 case 'input':
934 $item = $this->getSingleField_typeInput($table,$field,$row,$PA);
935 break;
936 case 'text':
937 $item = $this->getSingleField_typeText($table,$field,$row,$PA);
938 break;
939 case 'check':
940 $item = $this->getSingleField_typeCheck($table,$field,$row,$PA);
941 break;
942 case 'radio':
943 $item = $this->getSingleField_typeRadio($table,$field,$row,$PA);
944 break;
945 case 'select':
946 $item = $this->getSingleField_typeSelect($table,$field,$row,$PA);
947 break;
948 case 'group':
949 $item = $this->getSingleField_typeGroup($table,$field,$row,$PA);
950 break;
951 case 'inline':
952 $item = $this->inline->getSingleField_typeInline($table,$field,$row,$PA);
953 break;
954 case 'none':
955 $item = $this->getSingleField_typeNone($table,$field,$row,$PA);
956 break;
957 case 'user':
958 $item = $this->getSingleField_typeUser($table,$field,$row,$PA);
959 break;
960 case 'flex':
961 $item = $this->getSingleField_typeFlex($table,$field,$row,$PA);
962 break;
963 default:
964 $item = $this->getSingleField_typeUnknown($table,$field,$row,$PA);
965 break;
966 }
967
968 return $item;
969 }
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989 /**********************************************************
990 *
991 * Rendering of each TCEform field type
992 *
993 ************************************************************/
994
995 /**
996 * Generation of TCEform elements of the type "input"
997 * This will render a single-line input form field, possibly with various control/validation features
998 *
999 * @param string The table name of the record
1000 * @param string The field name which this element is supposed to edit
1001 * @param array The record data array where the value(s) for the field can be found
1002 * @param array An array with additional configuration options.
1003 * @return string The HTML code for the TCEform field
1004 */
1005 function getSingleField_typeInput($table,$field,$row,&$PA) {
1006 // typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue)
1007 // typo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off)
1008
1009 $config = $PA['fieldConf']['config'];
1010
1011 # $specConf = $this->getSpecConfForField($table,$row,$field);
1012 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1013 $size = t3lib_div::intInRange($config['size']?$config['size']:30,5,$this->maxInputWidth);
1014 $evalList = t3lib_div::trimExplode(',',$config['eval'],1);
1015
1016
1017 if($this->renderReadonly || $config['readOnly']) {
1018 $itemFormElValue = $PA['itemFormElValue'];
1019 if (in_array('date',$evalList)) {
1020 $config['format'] = 'date';
1021 } elseif (in_array('date',$evalList)) {
1022 $config['format'] = 'date';
1023 } elseif (in_array('datetime',$evalList)) {
1024 $config['format'] = 'datetime';
1025 } elseif (in_array('time',$evalList)) {
1026 $config['format'] = 'time';
1027 }
1028 if (in_array('password',$evalList)) {
1029 $itemFormElValue = $itemFormElValue ? '*********' : '';
1030 }
1031 return $this->getSingleField_typeNone_render($config, $itemFormElValue);
1032 }
1033
1034 if (in_array('required',$evalList)) {
1035 $this->requiredFields[$table.'_'.$row['uid'].'_'.$field]=$PA['itemFormElName'];
1036 }
1037
1038 $paramsList = "'".$PA['itemFormElName']."','".implode(',',$evalList)."','".trim($config['is_in'])."',".(isset($config['checkbox'])?1:0).",'".$config['checkbox']."'";
1039 if (isset($config['checkbox'])) {
1040 // Setting default "click-checkbox" values for eval types "date" and "datetime":
1041 $thisMidnight = mktime(0,0,0);
1042 $checkSetValue = in_array('date',$evalList) ? $thisMidnight : '';
1043 $checkSetValue = in_array('datetime',$evalList) ? time() : $checkSetValue;
1044
1045 $cOnClick = 'typo3form.fieldGet('.$paramsList.',1,\''.$checkSetValue.'\');'.implode('',$PA['fieldChangeFunc']);
1046 $item.='<input type="checkbox"'.$this->insertDefStyle('check').' name="'.$PA['itemFormElName'].'_cb" onclick="'.htmlspecialchars($cOnClick).'" />';
1047 }
1048
1049 $PA['fieldChangeFunc'] = array_merge(array('typo3form.fieldGet'=>'typo3form.fieldGet('.$paramsList.');'), $PA['fieldChangeFunc']);
1050 $mLgd = ($config['max']?$config['max']:256);
1051 $iOnChange = implode('',$PA['fieldChangeFunc']);
1052 $item.='<input type="text" name="'.$PA['itemFormElName'].'_hr" value=""'.$this->formWidth($size).' maxlength="'.$mLgd.'" onchange="'.htmlspecialchars($iOnChange).'"'.$PA['onFocus'].' />'; // This is the EDITABLE form field.
1053 $item.='<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.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.
1054 $this->extJSCODE.='typo3form.fieldSet('.$paramsList.');';
1055
1056 // going through all custom evaluations configured for this field
1057 foreach ($evalList as $evalData) {
1058 if (substr($evalData, 0, 3) == 'tx_') {
1059 $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$evalData].':&'.$evalData);
1060 if(is_object($evalObj) && method_exists($evalObj, 'returnFieldJS')) {
1061 $this->extJSCODE .= "\n\nfunction ".$evalData."(value) {\n".$evalObj->returnFieldJS()."\n}\n";
1062 }
1063 }
1064 }
1065
1066 // Creating an alternative item without the JavaScript handlers.
1067 $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'_hr" value="" />';
1068 $altItem.= '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
1069
1070 // Wrap a wizard around the item?
1071 $item= $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'].'_hr',$specConf);
1072
1073 return $item;
1074 }
1075
1076 /**
1077 * Generation of TCEform elements of the type "text"
1078 * This will render a <textarea> OR RTE area form field, possibly with various control/validation features
1079 *
1080 * @param string The table name of the record
1081 * @param string The field name which this element is supposed to edit
1082 * @param array The record data array where the value(s) for the field can be found
1083 * @param array An array with additional configuration options.
1084 * @return string The HTML code for the TCEform field
1085 */
1086 function getSingleField_typeText($table,$field,$row,&$PA) {
1087
1088 // Init config:
1089 $config = $PA['fieldConf']['config'];
1090
1091 if($this->renderReadonly || $config['readOnly']) {
1092 return $this->getSingleField_typeNone_render($config, $PA['itemFormElValue']);
1093 }
1094
1095 // Setting columns number:
1096 $cols = t3lib_div::intInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
1097
1098 // Setting number of rows:
1099 $origRows = $rows = t3lib_div::intInRange($config['rows'] ? $config['rows'] : 5, 1, 20);
1100 if (strlen($PA['itemFormElValue']) > $this->charsPerRow*2) {
1101 $cols = $this->maxTextareaWidth;
1102 $rows = t3lib_div::intInRange(round(strlen($PA['itemFormElValue'])/$this->charsPerRow), count(explode(chr(10),$PA['itemFormElValue'])), 20);
1103 if ($rows<$origRows) $rows = $origRows;
1104 }
1105
1106 // Init RTE vars:
1107 $RTEwasLoaded = 0; // Set true, if the RTE is loaded; If not a normal textarea is shown.
1108 $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...
1109
1110 // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. Traditionally, this is where RTE configuration has been found.
1111 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1112
1113 // Setting up the altItem form field, which is a hidden field containing the value
1114 $altItem = '<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
1115
1116 // If RTE is generally enabled (TYPO3_CONF_VARS and user settings)
1117 if ($this->RTEenabled) {
1118 $p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
1119 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.
1120 t3lib_BEfunc::fixVersioningPid($table,$row);
1121 list($tscPID,$thePidValue) = $this->getTSCpid($table,$row['uid'],$row['pid']);
1122
1123 // If the pid-value is not negative (that is, a pid could NOT be fetched)
1124 if ($thePidValue >= 0) {
1125 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($tscPID));
1126 $RTEtypeVal = t3lib_BEfunc::getTCAtypeValue($table,$row);
1127 $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$table,$field,$RTEtypeVal);
1128
1129 if (!$thisConfig['disabled']) {
1130 if (!$this->disableRTE) {
1131 $this->RTEcounter++;
1132
1133 // Find alternative relative path for RTE images/links:
1134 $eFile = t3lib_parsehtml_proc::evalWriteFile($specConf['static_write'], $row);
1135 $RTErelPath = is_array($eFile) ? dirname($eFile['relEditFile']) : '';
1136
1137 // Get RTE object, draw form and set flag:
1138 $RTEobj = &t3lib_BEfunc::RTEgetObj();
1139 $item = $RTEobj->drawRTE($this,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue);
1140
1141 // Wizard:
1142 $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf,1);
1143
1144 $RTEwasLoaded = 1;
1145 } else {
1146 $RTEwouldHaveBeenLoaded = 1;
1147 $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!)';
1148 }
1149 } else $this->commentMessages[] = $PA['itemFormElName'].': RTE is disabled by the Page TSconfig, "RTE"-key (eg. by RTE.default.disabled=0 or such)';
1150 } else $this->commentMessages[] = $PA['itemFormElName'].': PID value could NOT be fetched. Rare error, normally with new records.';
1151 } else {
1152 if (!isset($specConf['richtext'])) $this->commentMessages[] = $PA['itemFormElName'].': RTE was not configured for this field in TCA-types';
1153 if (!(!$p['flag'] || !$row[$p['flag']])) $this->commentMessages[] = $PA['itemFormElName'].': Field-flag ('.$PA['flag'].') has been set to disable RTE!';
1154 }
1155 }
1156
1157 // Display ordinary field if RTE was not loaded.
1158 if (!$RTEwasLoaded) {
1159 if ($specConf['rte_only']) { // Show message, if no RTE (field can only be edited with RTE!)
1160 $item = '<p><em>'.htmlspecialchars($this->getLL('l_noRTEfound')).'</em></p>';
1161 } else {
1162 if ($specConf['nowrap']) {
1163 $wrap = 'off';
1164 } else {
1165 $wrap = ($config['wrap'] ? $config['wrap'] : 'virtual');
1166 }
1167
1168 $classes = array();
1169 if ($specConf['fixed-font']) { $classes[] = 'fixed-font'; }
1170 if ($specConf['enable-tab']) { $classes[] = 'enable-tab'; }
1171
1172 $formWidthText = $this->formWidthText($cols,$wrap);
1173
1174 // Extract class attributes from $formWidthText (otherwise it would be added twice to the output)
1175 if (preg_match('/ class="(.+?)"/',$formWidthText,$res)) {
1176 $formWidthText = str_replace(' class="'.$res[1].'"','',$formWidthText);
1177 $classes = array_merge($classes, explode(' ',$res[1]));
1178 }
1179
1180 if (count($classes)) {
1181 $class = ' class="'.implode(' ',$classes).'"';
1182 } else $class='';
1183
1184 $iOnChange = implode('',$PA['fieldChangeFunc']);
1185 $item.= '
1186 <textarea name="'.$PA['itemFormElName'].'"'.$formWidthText.$class.' rows="'.$rows.'" wrap="'.$wrap.'" onchange="'.htmlspecialchars($iOnChange).'"'.$PA['onFocus'].'>'.
1187 t3lib_div::formatForTextarea($PA['itemFormElValue']).
1188 '</textarea>';
1189 $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf,$RTEwouldHaveBeenLoaded);
1190 }
1191 }
1192
1193 // Return field HTML:
1194 return $item;
1195 }
1196
1197 /**
1198 * Generation of TCEform elements of the type "check"
1199 * This will render a check-box OR an array of checkboxes
1200 *
1201 * @param string The table name of the record
1202 * @param string The field name which this element is supposed to edit
1203 * @param array The record data array where the value(s) for the field can be found
1204 * @param array An array with additional configuration options.
1205 * @return string The HTML code for the TCEform field
1206 */
1207 function getSingleField_typeCheck($table,$field,$row,&$PA) {
1208 $config = $PA['fieldConf']['config'];
1209
1210 $disabled = '';
1211 if($this->renderReadonly || $config['readOnly']) {
1212 $disabled = ' disabled="disabled"';
1213 }
1214
1215 // Traversing the array of items:
1216 $selItems = $this->initItemArray($PA['fieldConf']);
1217 if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
1218
1219 if (!count($selItems)) {
1220 $selItems[]=array('','');
1221 }
1222 $thisValue = intval($PA['itemFormElValue']);
1223
1224 $cols = intval($config['cols']);
1225 if ($cols > 1) {
1226 $item.= '<table border="0" cellspacing="0" cellpadding="0" class="typo3-TCEforms-checkboxArray">';
1227 for ($c=0;$c<count($selItems);$c++) {
1228 $p = $selItems[$c];
1229 if(!($c%$cols)) { $item.='<tr>'; }
1230 $cBP = $this->checkBoxParams($PA['itemFormElName'],$thisValue,$c,count($selItems),implode('',$PA['fieldChangeFunc']));
1231 $cBName = $PA['itemFormElName'].'_'.$c;
1232 $cBID = $PA['itemFormElID'].'_'.$c;
1233 $item.= '<td nowrap="nowrap">'.
1234 '<input type="checkbox"'.$this->insertDefStyle('check').' value="1" name="'.$cBName.'"'.$cBP.$disabled.' id="'.$cBID.'" />'.
1235 $this->wrapLabels('<label for="'.$cBID.'">'.htmlspecialchars($p[0]).'</label>&nbsp;').
1236 '</td>';
1237 if(($c%$cols)+1==$cols) {$item.='</tr>';}
1238 }
1239 if ($c%$cols) {
1240 $rest=$cols-($c%$cols);
1241 for ($c=0;$c<$rest;$c++) {
1242 $item.= '<td></td>';
1243 }
1244 if ($c>0) { $item.= '</tr>'; }
1245 }
1246 $item.= '</table>';
1247 } else {
1248 for ($c=0;$c<count($selItems);$c++) {
1249 $p = $selItems[$c];
1250 $cBP = $this->checkBoxParams($PA['itemFormElName'],$thisValue,$c,count($selItems),implode('',$PA['fieldChangeFunc']));
1251 $cBName = $PA['itemFormElName'].'_'.$c;
1252 $cBID = $PA['itemFormElID'].'_'.$c;
1253 $item.= ($c>0?'<br />':'').
1254 '<input type="checkbox"'.$this->insertDefStyle('check').' value="1" name="'.$cBName.'"'.$cBP.$PA['onFocus'].$disabled.' id="'.$cBID.'" />'.
1255 htmlspecialchars($p[0]);
1256 }
1257 }
1258 if (!$disabled) {
1259 $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($thisValue).'" />';
1260 }
1261
1262 return $item;
1263 }
1264
1265 /**
1266 * Generation of TCEform elements of the type "radio"
1267 * This will render a series of radio buttons.
1268 *
1269 * @param string The table name of the record
1270 * @param string The field name which this element is supposed to edit
1271 * @param array The record data array where the value(s) for the field can be found
1272 * @param array An array with additional configuration options.
1273 * @return string The HTML code for the TCEform field
1274 */
1275 function getSingleField_typeRadio($table,$field,$row,&$PA) {
1276 $config = $PA['fieldConf']['config'];
1277
1278 $disabled = '';
1279 if($this->renderReadonly || $config['readOnly']) {
1280 $disabled = ' disabled="disabled"';
1281 }
1282
1283 // Get items for the array:
1284 $selItems = $this->initItemArray($PA['fieldConf']);
1285 if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
1286
1287 // Traverse the items, making the form elements:
1288 for ($c=0;$c<count($selItems);$c++) {
1289 $p = $selItems[$c];
1290 $rID = $PA['itemFormElID'].'_'.$c;
1291 $rOnClick = implode('',$PA['fieldChangeFunc']);
1292 $rChecked = (!strcmp($p[1],$PA['itemFormElValue'])?' checked="checked"':'');
1293 $item.= '<input type="radio"'.$this->insertDefStyle('radio').' name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($p[1]).'" onclick="'.htmlspecialchars($rOnClick).'"'.$rChecked.$PA['onFocus'].$disabled.' id="'.$rID.'" />
1294 <label for="'.$rID.'">'.htmlspecialchars($p[0]).'</label>
1295 <br />';
1296 }
1297
1298 return $item;
1299 }
1300
1301 /**
1302 * Generation of TCEform elements of the type "select"
1303 * This will render a selector box element, or possibly a special construction with two selector boxes. That depends on configuration.
1304 *
1305 * @param string The table name of the record
1306 * @param string The field name which this element is supposed to edit
1307 * @param array The record data array where the value(s) for the field can be found
1308 * @param array An array with additional configuration options.
1309 * @return string The HTML code for the TCEform field
1310 */
1311 function getSingleField_typeSelect($table,$field,$row,&$PA) {
1312 global $TCA;
1313
1314 // Field configuration from TCA:
1315 $config = $PA['fieldConf']['config'];
1316
1317 $disabled = '';
1318 if($this->renderReadonly || $config['readOnly']) {
1319 $disabled = ' disabled="disabled"';
1320 }
1321
1322 // "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/.
1323 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1324
1325 // Getting the selector box items from the system
1326 $selItems = $this->addSelectOptionsToItemArray($this->initItemArray($PA['fieldConf']),$PA['fieldConf'],$this->setTSconfig($table,$row),$field);
1327 $selItems = $this->addItems($selItems,$PA['fieldTSConfig']['addItems.']);
1328 if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
1329
1330 // Possibly remove some items:
1331 $removeItems = t3lib_div::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
1332 foreach($selItems as $tk => $p) {
1333
1334 // Checking languages and authMode:
1335 $languageDeny = $TCA[$table]['ctrl']['languageField'] && !strcmp($TCA[$table]['ctrl']['languageField'], $field) && !$GLOBALS['BE_USER']->checkLanguageAccess($p[1]);
1336 $authModeDeny = $config['form_type']=='select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table,$field,$p[1],$config['authMode']);
1337 if (in_array($p[1],$removeItems) || $languageDeny || $authModeDeny) {
1338 unset($selItems[$tk]);
1339 } elseif (isset($PA['fieldTSConfig']['altLabels.'][$p[1]])) {
1340 $selItems[$tk][0]=$this->sL($PA['fieldTSConfig']['altLabels.'][$p[1]]);
1341 }
1342
1343 // Removing doktypes with no access:
1344 if ($table.'.'.$field == 'pages.doktype') {
1345 if (!($GLOBALS['BE_USER']->isAdmin() || t3lib_div::inList($GLOBALS['BE_USER']->groupData['pagetypes_select'],$p[1]))) {
1346 unset($selItems[$tk]);
1347 }
1348 }
1349 }
1350
1351 // Creating the label for the "No Matching Value" entry.
1352 $nMV_label = isset($PA['fieldTSConfig']['noMatchingValue_label']) ? $this->sL($PA['fieldTSConfig']['noMatchingValue_label']) : '[ '.$this->getLL('l_noMatchingValue').' ]';
1353
1354 // Prepare some values:
1355 $maxitems = intval($config['maxitems']);
1356
1357 // If a SINGLE selector box...
1358 if ($maxitems<=1) {
1359 $item = $this->getSingleField_typeSelect_single($table,$field,$row,$PA,$config,$selItems,$nMV_label);
1360 } elseif (!strcmp($config['renderMode'],'checkbox')) { // Checkbox renderMode
1361 $item = $this->getSingleField_typeSelect_checkbox($table,$field,$row,$PA,$config,$selItems,$nMV_label);
1362 } elseif (!strcmp($config['renderMode'],'singlebox')) { // Single selector box renderMode
1363 $item = $this->getSingleField_typeSelect_singlebox($table,$field,$row,$PA,$config,$selItems,$nMV_label);
1364 } else { // Traditional multiple selector box:
1365 $item = $this->getSingleField_typeSelect_multiple($table,$field,$row,$PA,$config,$selItems,$nMV_label);
1366 }
1367
1368 // Wizards:
1369 if (!$disabled) {
1370 $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
1371 $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf);
1372 }
1373
1374 return $item;
1375 }
1376
1377 /**
1378 * Creates a single-selector box
1379 * (Render function for getSingleField_typeSelect())
1380 *
1381 * @param string See getSingleField_typeSelect()
1382 * @param string See getSingleField_typeSelect()
1383 * @param array See getSingleField_typeSelect()
1384 * @param array See getSingleField_typeSelect()
1385 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1386 * @param array Items available for selection
1387 * @param string Label for no-matching-value
1388 * @return string The HTML code for the item
1389 * @see getSingleField_typeSelect()
1390 */
1391 function getSingleField_typeSelect_single($table,$field,$row,&$PA,$config,$selItems,$nMV_label) {
1392 // check against inline uniqueness
1393 $inlineParent = $this->inline->getStructureLevel(-1);
1394 if(is_array($inlineParent) && $inlineParent['uid']) {
1395 if ($inlineParent['config']['foreign_table'] == $table && $inlineParent['config']['foreign_unique'] == $field) {
1396 $uniqueIds = $this->inline->inlineData['unique'][$this->inline->inlineNames['object'].'['.$table.']']['used'];
1397 $PA['fieldChangeFunc']['inlineUnique'] = "inline.updateUnique(this,'".$this->inline->inlineNames['object'].'['.$table."]','".$this->inline->inlineNames['form']."','".$row['uid']."');";
1398 }
1399 // hide uid of parent record for symmetric relations
1400 if ($inlineParent['config']['foreign_table'] == $table && ($inlineParent['config']['foreign_field'] == $field || $inlineParent['config']['symmetric_field'] == $field)) {
1401 $uniqueIds[] = $inlineParent['uid'];
1402 }
1403 }
1404
1405 // Initialization:
1406 $c = 0;
1407 $sI = 0;
1408 $noMatchingValue = 1;
1409 $opt = array();
1410 $selicons = array();
1411 $onlySelectedIconShown = 0;
1412 $size = intval($config['size']);
1413
1414 $disabled = '';
1415 if($this->renderReadonly || $config['readOnly']) {
1416 $disabled = ' disabled="disabled"';
1417 $onlySelectedIconShown = 1;
1418 }
1419
1420 // Icon configuration:
1421 if ($config['suppress_icons']=='IF_VALUE_FALSE') {
1422 $suppressIcons = !$PA['itemFormElValue'] ? 1 : 0;
1423 } elseif ($config['suppress_icons']=='ONLY_SELECTED') {
1424 $suppressIcons=0;
1425 $onlySelectedIconShown=1;
1426 } elseif ($config['suppress_icons']) {
1427 $suppressIcons = 1;
1428 } else $suppressIcons = 0;
1429
1430 // Traverse the Array of selector box items:
1431 foreach($selItems as $p) {
1432 $sM = (!strcmp($PA['itemFormElValue'],$p[1])?' selected="selected"':'');
1433 if ($sM) {
1434 $sI = $c;
1435 $noMatchingValue = 0;
1436 }
1437
1438 // Getting style attribute value (for icons):
1439 if ($config['iconsInOptionTags']) {
1440 $styleAttrValue = $this->optionTagStyle($p[2]);
1441 }
1442
1443 // Compiling the <option> tag:
1444 if (!($p[1] != $PA['itemFormElValue'] && is_array($uniqueIds) && in_array($p[1], $uniqueIds))) {
1445 $opt[]= '<option value="'.htmlspecialchars($p[1]).'"'.
1446 $sM.
1447 ($styleAttrValue ? ' style="'.htmlspecialchars($styleAttrValue).'"' : '').
1448 (!strcmp($p[1],'--div--') ? ' class="c-divider"' : '').
1449 '>'.t3lib_div::deHSCentities(htmlspecialchars($p[0])).'</option>';
1450 }
1451
1452 // If there is an icon for the selector box (rendered in table under)...:
1453 if ($p[2] && !$suppressIcons && (!$onlySelectedIconShown || $sM)) {
1454 list($selIconFile,$selIconInfo)=$this->getIcon($p[2]);
1455 $iOnClick = $this->elName($PA['itemFormElName']).'.selectedIndex='.$c.'; '.implode('',$PA['fieldChangeFunc']).$this->blur().'return false;';
1456 $selicons[]=array(
1457 (!$onlySelectedIconShown ? '<a href="#" onclick="'.htmlspecialchars($iOnClick).'">' : '').
1458 '<img src="'.$selIconFile.'" '.$selIconInfo[3].' vspace="2" border="0" title="'.htmlspecialchars($p[0]).'" alt="'.htmlspecialchars($p[0]).'" />'.
1459 (!$onlySelectedIconShown ? '</a>' : ''),
1460 $c,$sM);
1461 }
1462 $c++;
1463 }
1464
1465 // No-matching-value:
1466 if ($PA['itemFormElValue'] && $noMatchingValue && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1467 $nMV_label = @sprintf($nMV_label, $PA['itemFormElValue']);
1468 $opt[]= '<option value="'.htmlspecialchars($PA['itemFormElValue']).'" selected="selected">'.htmlspecialchars($nMV_label).'</option>';
1469 }
1470
1471 // Create item form fields:
1472 $sOnChange = 'if (this.options[this.selectedIndex].value==\'--div--\') {this.selectedIndex='.$sI.';} '.implode('',$PA['fieldChangeFunc']);
1473 if(!$disabled) {
1474 $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...
1475 }
1476 $item.= '<select name="'.$PA['itemFormElName'].'"'.
1477 $this->insertDefStyle('select').
1478 ($size?' size="'.$size.'"':'').
1479 ' onchange="'.htmlspecialchars($sOnChange).'"'.
1480 $PA['onFocus'].$disabled.'>';
1481 $item.= implode('',$opt);
1482 $item.= '</select>';
1483
1484 // Create icon table:
1485 if (count($selicons)) {
1486 $item.='<table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-selectIcons">';
1487 $selicon_cols = intval($config['selicon_cols']);
1488 if (!$selicon_cols) $selicon_cols=count($selicons);
1489 $sR = ceil(count($selicons)/$selicon_cols);
1490 $selicons = array_pad($selicons,$sR*$selicon_cols,'');
1491 for($sa=0;$sa<$sR;$sa++) {
1492 $item.='<tr>';
1493 for($sb=0;$sb<$selicon_cols;$sb++) {
1494 $sk=($sa*$selicon_cols+$sb);
1495 $imgN = 'selIcon_'.$table.'_'.$row['uid'].'_'.$field.'_'.$selicons[$sk][1];
1496 $imgS = ($selicons[$sk][2]?$this->backPath.'gfx/content_selected.gif':'clear.gif');
1497 $item.='<td><img name="'.htmlspecialchars($imgN).'" src="'.$imgS.'" width="7" height="10" alt="" /></td>';
1498 $item.='<td>'.$selicons[$sk][0].'</td>';
1499 }
1500 $item.='</tr>';
1501 }
1502 $item.='</table>';
1503 }
1504
1505 return $item;
1506 }
1507
1508 /**
1509 * Creates a checkbox list (renderMode = "checkbox")
1510 * (Render function for getSingleField_typeSelect())
1511 *
1512 * @param string See getSingleField_typeSelect()
1513 * @param string See getSingleField_typeSelect()
1514 * @param array See getSingleField_typeSelect()
1515 * @param array See getSingleField_typeSelect()
1516 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1517 * @param array Items available for selection
1518 * @param string Label for no-matching-value
1519 * @return string The HTML code for the item
1520 * @see getSingleField_typeSelect()
1521 */
1522 function getSingleField_typeSelect_checkbox($table,$field,$row,&$PA,$config,$selItems,$nMV_label) {
1523
1524 // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
1525 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
1526
1527 $disabled = '';
1528 if($this->renderReadonly || $config['readOnly']) {
1529 $disabled = ' disabled="disabled"';
1530 }
1531
1532 // Traverse the Array of selector box items:
1533 $tRows = array();
1534 $c=0;
1535 if (!$disabled) {
1536 $sOnChange = implode('',$PA['fieldChangeFunc']);
1537 $setAll = array(); // Used to accumulate the JS needed to restore the original selection.
1538 foreach($selItems as $p) {
1539 // Non-selectable element:
1540 if (!strcmp($p[1],'--div--')) {
1541 if (count($setAll)) {
1542 $tRows[] = '
1543 <tr>
1544 <td colspan="2">'.
1545 '<a href="#" onclick="'.htmlspecialchars(implode('',$setAll).' return false;').'">'.
1546 htmlspecialchars($this->getLL('l_setAllCheckboxes')).
1547 '</a></td>
1548 </tr>';
1549 $setAll = array();
1550 }
1551
1552 $tRows[] = '
1553 <tr class="c-header">
1554 <td colspan="2">'.htmlspecialchars($p[0]).'</td>
1555 </tr>';
1556 } else {
1557 // Selected or not by default:
1558 $sM = '';
1559 if (isset($itemArray[$p[1]])) {
1560 $sM = ' checked="checked"';
1561 unset($itemArray[$p[1]]);
1562 }
1563
1564 // Icon:
1565 $selIconFile = '';
1566 if ($p[2]) {
1567 list($selIconFile,$selIconInfo) = $this->getIcon($p[2]);
1568 }
1569
1570 // Compile row:
1571 $onClickCell = $this->elName($PA['itemFormElName'].'['.$c.']').'.checked=!'.$this->elName($PA['itemFormElName'].'['.$c.']').'.checked;';
1572 $onClick = 'this.attributes.getNamedItem("class").nodeValue = '.$this->elName($PA['itemFormElName'].'['.$c.']').'.checked ? "c-selectedItem" : "";';
1573 $setAll[] = $this->elName($PA['itemFormElName'].'['.$c.']').'.checked=1;';
1574 $tRows[] = '
1575 <tr class="'.($sM ? 'c-selectedItem' : '').'" onclick="'.htmlspecialchars($onClick).'" style="cursor: pointer;">
1576 <td><input type="checkbox"'.$this->insertDefStyle('check').' name="'.htmlspecialchars($PA['itemFormElName'].'['.$c.']').'" value="'.htmlspecialchars($p[1]).'"'.$sM.' onclick="'.htmlspecialchars($sOnChange).'"'.$PA['onFocus'].' /></td>
1577 <td class="c-labelCell" onclick="'.htmlspecialchars($onClickCell).'">'.
1578 ($selIconFile ? '<img src="'.$selIconFile.'" '.$selIconInfo[3].' vspace="2" border="0" class="absmiddle" style="margin-right: 4px;" alt="" />' : '').
1579 t3lib_div::deHSCentities(htmlspecialchars($p[0])).
1580 (strcmp($p[3],'') ? '<br/><p class="c-descr">'.nl2br(trim(htmlspecialchars($p[3]))).'</p>' : '').
1581 '</td>
1582 </tr>';
1583 $c++;
1584 }
1585 }
1586
1587 // Remaining checkboxes will get their set-all link:
1588 if (count($setAll)) {
1589 $tRows[] = '
1590 <tr>
1591 <td colspan="2">'.
1592 '<a href="#" onclick="'.htmlspecialchars(implode('',$setAll).' return false;').'">'.
1593 htmlspecialchars($this->getLL('l_setAllCheckboxes')).
1594 '</a></td>
1595 </tr>';
1596 }
1597 }
1598
1599 // Remaining values (invalid):
1600 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1601 foreach($itemArray as $theNoMatchValue => $temp) {
1602 // Compile <checkboxes> tag:
1603 array_unshift($tRows,'
1604 <tr class="c-invalidItem">
1605 <td><input type="checkbox"'.$this->insertDefStyle('check').' name="'.htmlspecialchars($PA['itemFormElName'].'['.$c.']').'" value="'.htmlspecialchars($theNoMatchValue).'" checked="checked" onclick="'.htmlspecialchars($sOnChange).'"'.$PA['onFocus'].$disabled.' /></td>
1606 <td class="c-labelCell">'.
1607 t3lib_div::deHSCentities(htmlspecialchars(@sprintf($nMV_label, $theNoMatchValue))).
1608 '</td>
1609 </tr>');
1610 $c++;
1611 }
1612 }
1613
1614 // Add an empty hidden field which will send a blank value if all items are unselected.
1615 $item.='<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="" />';
1616
1617 // Implode rows in table:
1618 $item.= '
1619 <table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-select-checkbox">'.
1620 implode('',$tRows).'
1621 </table>
1622 ';
1623
1624 return $item;
1625 }
1626
1627 /**
1628 * Creates a selectorbox list (renderMode = "singlebox")
1629 * (Render function for getSingleField_typeSelect())
1630 *
1631 * @param string See getSingleField_typeSelect()
1632 * @param string See getSingleField_typeSelect()
1633 * @param array See getSingleField_typeSelect()
1634 * @param array See getSingleField_typeSelect()
1635 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1636 * @param array Items available for selection
1637 * @param string Label for no-matching-value
1638 * @return string The HTML code for the item
1639 * @see getSingleField_typeSelect()
1640 */
1641 function getSingleField_typeSelect_singlebox($table,$field,$row,&$PA,$config,$selItems,$nMV_label) {
1642
1643 // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
1644 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
1645
1646 $disabled = '';
1647 if($this->renderReadonly || $config['readOnly']) {
1648 $disabled = ' disabled="disabled"';
1649 }
1650
1651 // Traverse the Array of selector box items:
1652 $opt = array();
1653 $restoreCmd = array(); // Used to accumulate the JS needed to restore the original selection.
1654 $c = 0;
1655 foreach($selItems as $p) {
1656 // Selected or not by default:
1657 $sM = '';
1658 if (isset($itemArray[$p[1]])) {
1659 $sM = ' selected="selected"';
1660 $restoreCmd[] = $this->elName($PA['itemFormElName'].'[]').'.options['.$c.'].selected=1;';
1661 unset($itemArray[$p[1]]);
1662 }
1663
1664 // Non-selectable element:
1665 $nonSel = '';
1666 if (!strcmp($p[1],'--div--')) {
1667 $nonSel = ' onclick="this.selected=0;" class="c-divider"';
1668 }
1669
1670 // Icon style for option tag:
1671 if ($config['iconsInOptionTags']) {
1672 $styleAttrValue = $this->optionTagStyle($p[2]);
1673 }
1674
1675 // Compile <option> tag:
1676 $opt[] = '<option value="'.htmlspecialchars($p[1]).'"'.
1677 $sM.
1678 $nonSel.
1679 ($styleAttrValue ? ' style="'.htmlspecialchars($styleAttrValue).'"' : '').
1680 '>'.t3lib_div::deHSCentities(htmlspecialchars($p[0])).'</option>';
1681 $c++;
1682 }
1683
1684 // Remaining values:
1685 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1686 foreach($itemArray as $theNoMatchValue => $temp) {
1687 // Compile <option> tag:
1688 array_unshift($opt,'<option value="'.htmlspecialchars($theNoMatchValue).'" selected="selected">'.t3lib_div::deHSCentities(htmlspecialchars(@sprintf($nMV_label, $theNoMatchValue))).'</option>');
1689 }
1690 }
1691
1692 // Compile selector box:
1693 $sOnChange = implode('',$PA['fieldChangeFunc']);
1694 $selector_itemListStyle = isset($config['itemListStyle']) ? ' style="'.htmlspecialchars($config['itemListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"';
1695 $size = intval($config['size']);
1696 $size = $config['autoSizeMax'] ? t3lib_div::intInRange(count($selItems)+1,t3lib_div::intInRange($size,1),$config['autoSizeMax']) : $size;
1697 $selectBox = '<select name="'.$PA['itemFormElName'].'[]"'.
1698 $this->insertDefStyle('select').
1699 ($size ? ' size="'.$size.'"' : '').
1700 ' multiple="multiple" onchange="'.htmlspecialchars($sOnChange).'"'.
1701 $PA['onFocus'].
1702 $selector_itemListStyle.
1703 $disabled.'>
1704 '.
1705 implode('
1706 ',$opt).'
1707 </select>';
1708
1709 // Add an empty hidden field which will send a blank value if all items are unselected.
1710 if (!$disabled) {
1711 $item.='<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="" />';
1712 }
1713
1714 // Put it all into a table:
1715 $item.= '
1716 <table border="0" cellspacing="0" cellpadding="0" width="1" class="typo3-TCEforms-select-singlebox">
1717 <tr>
1718 <td>
1719 '.$selectBox.'
1720 <br/>
1721 <em>'.
1722 htmlspecialchars($this->getLL('l_holdDownCTRL')).
1723 '</em>
1724 </td>
1725 <td valign="top">
1726 <a href="#" onclick="'.htmlspecialchars($this->elName($PA['itemFormElName'].'[]').'.selectedIndex=-1;'.implode('',$restoreCmd).' return false;').'">'.
1727 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/history.gif','width="13" height="12"').' title="'.htmlspecialchars($this->getLL('l_revertSelection')).'" alt="" />'.
1728 '</a>
1729 </td>
1730 </tr>
1731 </table>
1732 ';
1733
1734 return $item;
1735 }
1736
1737 /**
1738 * Creates a multiple-selector box (two boxes, side-by-side)
1739 * (Render function for getSingleField_typeSelect())
1740 *
1741 * @param string See getSingleField_typeSelect()
1742 * @param string See getSingleField_typeSelect()
1743 * @param array See getSingleField_typeSelect()
1744 * @param array See getSingleField_typeSelect()
1745 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1746 * @param array Items available for selection
1747 * @param string Label for no-matching-value
1748 * @return string The HTML code for the item
1749 * @see getSingleField_typeSelect()
1750 */
1751 function getSingleField_typeSelect_multiple($table,$field,$row,&$PA,$config,$selItems,$nMV_label) {
1752
1753 $disabled = '';
1754 if($this->renderReadonly || $config['readOnly']) {
1755 $disabled = ' disabled="disabled"';
1756 }
1757
1758 // Setting this hidden field (as a flag that JavaScript can read out)
1759 if (!$disabled) {
1760 $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'_mul" value="'.($config['multiple']?1:0).'" />';
1761 }
1762
1763 // Set max and min items:
1764 $maxitems = t3lib_div::intInRange($config['maxitems'],0);
1765 if (!$maxitems) $maxitems=100000;
1766 $minitems = t3lib_div::intInRange($config['minitems'],0);
1767
1768 // Register the required number of elements:
1769 $this->requiredElements[$PA['itemFormElName']] = array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field);
1770
1771 // Get "removeItems":
1772 $removeItems = t3lib_div::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
1773
1774 // Perform modification of the selected items array:
1775 $itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
1776 foreach($itemArray as $tk => $tv) {
1777 $tvP = explode('|',$tv,2);
1778 $evalValue = rawurldecode($tvP[0]);
1779 $isRemoved = in_array($evalValue,$removeItems) || ($config['form_type']=='select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table,$field,$evalValue,$config['authMode']));
1780 if ($isRemoved && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1781 $tvP[1] = rawurlencode(@sprintf($nMV_label, $evalValue));
1782 } elseif (isset($PA['fieldTSConfig']['altLabels.'][$evalValue])) {
1783 $tvP[1] = rawurlencode($this->sL($PA['fieldTSConfig']['altLabels.'][$evalValue]));
1784 }
1785 $itemArray[$tk] = implode('|',$tvP);
1786 }
1787 $itemsToSelect = '';
1788
1789 if(!$disabled) {
1790 // Create option tags:
1791 $opt = array();
1792 $styleAttrValue = '';
1793 foreach($selItems as $p) {
1794 if ($config['iconsInOptionTags']) {
1795 $styleAttrValue = $this->optionTagStyle($p[2]);
1796 }
1797 $opt[]= '<option value="'.htmlspecialchars($p[1]).'"'.
1798 ($styleAttrValue ? ' style="'.htmlspecialchars($styleAttrValue).'"' : '').
1799 '>'.htmlspecialchars($p[0]).'</option>';
1800 }
1801
1802 // Put together the selector box:
1803 $selector_itemListStyle = isset($config['itemListStyle']) ? ' style="'.htmlspecialchars($config['itemListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"';
1804 $size = intval($config['size']);
1805 $size = $config['autoSizeMax'] ? t3lib_div::intInRange(count($itemArray)+1,t3lib_div::intInRange($size,1),$config['autoSizeMax']) : $size;
1806 if ($config['exclusiveKeys']) {
1807 $sOnChange = 'setFormValueFromBrowseWin(\''.$PA['itemFormElName'].'\',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text,\''.$config['exclusiveKeys'].'\'); ';
1808 } else {
1809 $sOnChange = 'setFormValueFromBrowseWin(\''.$PA['itemFormElName'].'\',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text); ';
1810 }
1811 $sOnChange .= implode('',$PA['fieldChangeFunc']);
1812 $itemsToSelect = '
1813 <select name="'.$PA['itemFormElName'].'_sel"'.
1814 $this->insertDefStyle('select').
1815 ($size ? ' size="'.$size.'"' : '').
1816 ' onchange="'.htmlspecialchars($sOnChange).'"'.
1817 $PA['onFocus'].
1818 $selector_itemListStyle.'>
1819 '.implode('
1820 ',$opt).'
1821 </select>';
1822 }
1823
1824 // Pass to "dbFileIcons" function:
1825 $params = array(
1826 'size' => $size,
1827 'autoSizeMax' => t3lib_div::intInRange($config['autoSizeMax'],0),
1828 'style' => isset($config['selectedListStyle']) ? ' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"',
1829 'dontShowMoveIcons' => ($maxitems<=1),
1830 'maxitems' => $maxitems,
1831 'info' => '',
1832 'headers' => array(
1833 'selector' => $this->getLL('l_selected').':<br />',
1834 'items' => $this->getLL('l_items').':<br />'
1835 ),
1836 'noBrowser' => 1,
1837 'thumbnails' => $itemsToSelect,
1838 'readOnly' => $disabled
1839 );
1840 $item.= $this->dbFileIcons($PA['itemFormElName'],'','',$itemArray,'',$params,$PA['onFocus']);
1841
1842 return $item;
1843 }
1844
1845 /**
1846 * Generation of TCEform elements of the type "group"
1847 * This will render a selectorbox into which elements from either the file system or database can be inserted. Relations.
1848 *
1849 * @param string The table name of the record
1850 * @param string The field name which this element is supposed to edit
1851 * @param array The record data array where the value(s) for the field can be found
1852 * @param array An array with additional configuration options.
1853 * @return string The HTML code for the TCEform field
1854 */
1855 function getSingleField_typeGroup($table,$field,$row,&$PA) {
1856 // Init:
1857 $config = $PA['fieldConf']['config'];
1858 $internal_type = $config['internal_type'];
1859 $show_thumbs = $config['show_thumbs'];
1860 $size = intval($config['size']);
1861 $maxitems = t3lib_div::intInRange($config['maxitems'],0);
1862 if (!$maxitems) $maxitems=100000;
1863 $minitems = t3lib_div::intInRange($config['minitems'],0);
1864 $allowed = $config['allowed'];
1865 $disallowed = $config['disallowed'];
1866
1867 $disabled = '';
1868 if($this->renderReadonly || $config['readOnly']) {
1869 $disabled = ' disabled="disabled"';
1870 }
1871
1872 $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'_mul" value="'.($config['multiple']?1:0).'"'.$disabled.' />';
1873 $this->requiredElements[$PA['itemFormElName']] = array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field);
1874 $info='';
1875
1876 // "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/.
1877 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1878
1879 // Acting according to either "file" or "db" type:
1880 switch((string)$config['internal_type']) {
1881 case 'file': // If the element is of the internal type "file":
1882
1883 // Creating string showing allowed types:
1884 $tempFT = t3lib_div::trimExplode(',',$allowed,1);
1885 if (!count($tempFT)) {$info.='*';}
1886 foreach($tempFT as $ext) {
1887 if ($ext) {
1888 $info.=strtoupper($ext).' ';
1889 }
1890 }
1891 // Creating string, showing disallowed types:
1892 $tempFT_dis = t3lib_div::trimExplode(',',$disallowed,1);
1893 if (count($tempFT_dis)) {$info.='<br />';}
1894 foreach($tempFT_dis as $ext) {
1895 if ($ext) {
1896 $info.='-'.strtoupper($ext).' ';
1897 }
1898 }
1899
1900 // Making the array of file items:
1901 $itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
1902
1903 // Showing thumbnails:
1904 $thumbsnail = '';
1905 if ($show_thumbs) {
1906 $imgs = array();
1907 foreach($itemArray as $imgRead) {
1908 $imgP = explode('|',$imgRead);
1909 $imgPath = rawurldecode($imgP[0]);
1910
1911 $rowCopy = array();
1912 $rowCopy[$field] = $imgPath;
1913
1914 // Icon + clickmenu:
1915 $absFilePath = t3lib_div::getFileAbsFileName($config['uploadfolder'].'/'.$imgPath);
1916
1917 $fI = pathinfo($imgPath);
1918 $fileIcon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
1919 $fileIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/fileicons/'.$fileIcon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].($absFilePath && @is_file($absFilePath) ? ' ('.t3lib_div::formatSize(filesize($absFilePath)).'bytes)' : ' - FILE NOT FOUND!')).'" alt="" />';
1920
1921 $imgs[] = '<span class="nobr">'.t3lib_BEfunc::thumbCode($rowCopy,$table,$field,$this->backPath,'thumbs.php',$config['uploadfolder'],0,' align="middle"').
1922 ($absFilePath ? $this->getClickMenu($fileIcon, $absFilePath) : $fileIcon).
1923 $imgPath.
1924 '</span>';
1925 }
1926 $thumbsnail = implode('<br />',$imgs);
1927 }
1928
1929 // Creating the element:
1930 $params = array(
1931 'size' => $size,
1932 'dontShowMoveIcons' => ($maxitems<=1),
1933 'autoSizeMax' => t3lib_div::intInRange($config['autoSizeMax'],0),
1934 'maxitems' => $maxitems,
1935 'style' => isset($config['selectedListStyle']) ? ' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"',
1936 'info' => $info,
1937 'thumbnails' => $thumbsnail,
1938 'readOnly' => $disabled
1939 );
1940 $item.= $this->dbFileIcons($PA['itemFormElName'],'file',implode(',',$tempFT),$itemArray,'',$params,$PA['onFocus']);
1941
1942 if(!$disabled) {
1943 // Adding the upload field:
1944 if ($this->edit_docModuleUpload) $item.='<input type="file" name="'.$PA['itemFormElName_file'].'"'.$this->formWidth().' size="60" />';
1945 }
1946 break;
1947 case 'db': // If the element is of the internal type "db":
1948
1949 // Creating string showing allowed types:
1950 $tempFT = t3lib_div::trimExplode(',',$allowed,1);
1951 if (!strcmp(trim($tempFT[0]),'*')) {
1952 $info.='<span class="nobr">&nbsp;&nbsp;&nbsp;&nbsp;'.
1953 htmlspecialchars($this->getLL('l_allTables')).
1954 '</span><br />';
1955 } else {
1956 while(list(,$theT)=each($tempFT)) {
1957 if ($theT) {
1958 $info.='<span class="nobr">&nbsp;&nbsp;&nbsp;&nbsp;'.
1959 t3lib_iconWorks::getIconImage($theT,array(),$this->backPath,'align="top"').
1960 htmlspecialchars($this->sL($GLOBALS['TCA'][$theT]['ctrl']['title'])).
1961 '</span><br />';
1962 }
1963 }
1964 }
1965
1966 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
1967 $itemArray = array();
1968 $imgs = array();
1969
1970 // Thumbnails:
1971 $temp_itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
1972 foreach($temp_itemArray as $dbRead) {
1973 $recordParts = explode('|',$dbRead);
1974 list($this_table,$this_uid) = t3lib_BEfunc::splitTable_Uid($recordParts[0]);
1975 $itemArray[] = array('table'=>$this_table, 'id'=>$this_uid);
1976 if (!$disabled && $show_thumbs) {
1977 $rr = t3lib_BEfunc::getRecordWSOL($this_table,$this_uid);
1978 $imgs[] = '<span class="nobr">'.
1979 $this->getClickMenu(t3lib_iconWorks::getIconImage($this_table,$rr,$this->backPath,'align="top" title="'.htmlspecialchars(t3lib_BEfunc::getRecordPath($rr['pid'],$perms_clause,15)).' [UID: '.$rr['uid'].']"'),$this_table, $this_uid).
1980 '&nbsp;'.
1981 t3lib_BEfunc::getRecordTitle($this_table,$rr,TRUE).' <span class="typo3-dimmed"><em>['.$rr['uid'].']</em></span>'.
1982 '</span>';
1983 }
1984 }
1985 $thumbsnail='';
1986 if (!$disabled && $show_thumbs) {
1987 $thumbsnail = implode('<br />',$imgs);
1988 }
1989
1990 // Creating the element:
1991 $params = array(
1992 'size' => $size,
1993 'dontShowMoveIcons' => ($maxitems<=1),
1994 'autoSizeMax' => t3lib_div::intInRange($config['autoSizeMax'],0),
1995 'maxitems' => $maxitems,
1996 'style' => isset($config['selectedListStyle']) ? ' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"',
1997 'info' => $info,
1998 'thumbnails' => $thumbsnail,
1999 'readOnly' => $disabled
2000 );
2001 $item.= $this->dbFileIcons($PA['itemFormElName'],'db',implode(',',$tempFT),$itemArray,'',$params,$PA['onFocus'],$table,$field,$row['uid']);
2002
2003 break;
2004 }
2005
2006 // Wizards:
2007 $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
2008 if (!$disabled) {
2009 $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf);
2010 }
2011
2012 return $item;
2013 }
2014
2015 /**
2016 * Generation of TCEform elements of the type "none"
2017 * This will render a non-editable display of the content of the field.
2018 *
2019 * @param string The table name of the record
2020 * @param string The field name which this element is supposed to edit
2021 * @param array The record data array where the value(s) for the field can be found
2022 * @param array An array with additional configuration options.
2023 * @return string The HTML code for the TCEform field
2024 */
2025 function getSingleField_typeNone($table,$field,$row,&$PA) {
2026 // Init:
2027 $config = $PA['fieldConf']['config'];
2028 $itemValue = $PA['itemFormElValue'];
2029
2030 return $this->getSingleField_typeNone_render($config,$itemValue);
2031 }
2032
2033 /**
2034 * HTML rendering of a value which is not editable.
2035 *
2036 * @param array Configuration for the display
2037 * @param string The value to display
2038 * @return string The HTML code for the display
2039 * @see getSingleField_typeNone();
2040 */
2041 function getSingleField_typeNone_render($config,$itemValue) {
2042
2043 // is colorScheme[0] the right value?
2044 $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;';
2045
2046 if ($config['format']) {
2047 $itemValue = $this->formatValue($config, $itemValue);
2048 }
2049
2050 $rows = intval($config['rows']);
2051 if ($rows > 1) {
2052 if(!$config['pass_content']) {
2053 $itemValue = nl2br(htmlspecialchars($itemValue));
2054 }
2055 // like textarea
2056 $cols = t3lib_div::intInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
2057 if (!$config['fixedRows']) {
2058 $origRows = $rows = t3lib_div::intInRange($rows, 1, 20);
2059 if (strlen($itemValue)>$this->charsPerRow*2) {
2060 $cols = $this->maxTextareaWidth;
2061 $rows = t3lib_div::intInRange(round(strlen($itemValue)/$this->charsPerRow),count(explode(chr(10),$itemValue)),20);
2062 if ($rows<$origRows) $rows=$origRows;
2063 }
2064 }
2065
2066 if ($this->docLarge) $cols = round($cols*$this->form_largeComp);
2067 $width = ceil($cols*$this->form_rowsToStylewidth);
2068 // hardcoded: 12 is the height of the font
2069 $height=$rows*12;
2070
2071 $item='
2072 <div style="'.htmlspecialchars($divStyle.' overflow:auto; height:'.$height.'px; width:'.$width.'px;').'" class="'.htmlspecialchars($this->formElClass('none')).'">'.
2073 $itemValue.
2074 '</div>';
2075 } else {
2076 if(!$config['pass_content']) {
2077 $itemValue = htmlspecialchars($itemValue);
2078 }
2079
2080 $cols = $config['cols']?$config['cols']:($config['size']?$config['size']:$this->maxInputWidth);
2081 if ($this->docLarge) $cols = round($cols*$this->form_largeComp);
2082 $width = ceil($cols*$this->form_rowsToStylewidth);
2083
2084 // overflow:auto crashes mozilla here. Title tag is usefull when text is longer than the div box (overflow:hidden).
2085 $item = '
2086 <div style="'.htmlspecialchars($divStyle.' overflow:hidden; width:'.$width.'px;').'" class="'.htmlspecialchars($this->formElClass('none')).'" title="'.$itemValue.'">'.
2087 '<span class="nobr">'.(strcmp($itemValue,'')?$itemValue:'&nbsp;').'</span>'.
2088 '</div>';
2089 }
2090
2091 return $item;
2092 }
2093
2094 /**
2095 * Handler for Flex Forms
2096 *
2097 * @param string The table name of the record
2098 * @param string The field name which this element is supposed to edit
2099 * @param array The record data array where the value(s) for the field can be found
2100 * @param array An array with additional configuration options.
2101 * @return string The HTML code for the TCEform field
2102 */
2103 function getSingleField_typeFlex($table,$field,$row,&$PA) {
2104
2105 // Data Structure:
2106 $dataStructArray = t3lib_BEfunc::getFlexFormDS($PA['fieldConf']['config'],$row,$table);
2107
2108 // Get data structure:
2109 if (is_array($dataStructArray)) {
2110
2111 // Get data:
2112 $xmlData = $PA['itemFormElValue'];
2113 $xmlHeaderAttributes = t3lib_div::xmlGetHeaderAttribs($xmlData);
2114 $storeInCharset = strtolower($xmlHeaderAttributes['encoding']);
2115 if ($storeInCharset) {
2116 $currentCharset=$GLOBALS['LANG']->charSet;
2117 $xmlData = $GLOBALS['LANG']->csConvObj->conv($xmlData,$storeInCharset,$currentCharset,1);
2118 }
2119 $editData=t3lib_div::xml2array($xmlData);
2120 if (!is_array($editData)) { // Must be XML parsing error...
2121 $editData=array();
2122 } elseif (!isset($editData['meta']) || !is_array($editData['meta'])) {
2123 $editData['meta'] = array();
2124 }
2125
2126 // Find the data structure if sheets are found:
2127 $sheet = $editData['meta']['currentSheetId'] ? $editData['meta']['currentSheetId'] : 'sDEF'; // Sheet to display
2128
2129 // Create sheet menu:
2130 // if (is_array($dataStructArray['sheets'])) {
2131 // #$item.=$this->getSingleField_typeFlex_sheetMenu($dataStructArray['sheets'], $PA['itemFormElName'].'[meta][currentSheetId]', $sheet).'<br />';
2132 // }
2133
2134 // Create language menu:
2135 $langChildren = $dataStructArray['meta']['langChildren'] ? 1 : 0;
2136 $langDisabled = $dataStructArray['meta']['langDisable'] ? 1 : 0;
2137
2138 $editData['meta']['currentLangId']=array();
2139 $languages = $this->getAvailableLanguages();
2140
2141 foreach($languages as $lInfo) {
2142 if ($GLOBALS['BE_USER']->checkLanguageAccess($lInfo['uid'])) {
2143 $editData['meta']['currentLangId'][] = $lInfo['ISOcode'];
2144 }
2145 }
2146 if (!is_array($editData['meta']['currentLangId']) || !count($editData['meta']['currentLangId'])) {
2147 $editData['meta']['currentLangId']=array('DEF');
2148 }
2149
2150 $editData['meta']['currentLangId'] = array_unique($editData['meta']['currentLangId']);
2151
2152
2153 // if (!$langDisabled && count($languages) > 1) {
2154 // $item.=$this->getSingleField_typeFlex_langMenu($languages, $PA['itemFormElName'].'[meta][currentLangId]', $editData['meta']['currentLangId']).'<br />';
2155 // }
2156
2157 $PA['_noEditDEF'] = FALSE;
2158 if ($langChildren || $langDisabled) {
2159 $rotateLang = array('DEF');
2160 } else {
2161 if (!in_array('DEF',$editData['meta']['currentLangId'])) {
2162 array_unshift($editData['meta']['currentLangId'],'DEF');
2163 $PA['_noEditDEF'] = TRUE;
2164 }
2165 $rotateLang = $editData['meta']['currentLangId'];
2166 }
2167
2168 // Tabs sheets
2169 if (is_array($dataStructArray['sheets'])) {
2170 $tabsToTraverse = array_keys($dataStructArray['sheets']);
2171 } else {
2172 $tabsToTraverse = array($sheet);
2173 }
2174
2175 foreach ($rotateLang as $lKey) {
2176 if (!$langChildren && !$langDisabled) {
2177 $item.= '<b>'.$this->getLanguageIcon($table,$row,'v'.$lKey).$lKey.':</b>';
2178 }
2179
2180 $tabParts = array();
2181 foreach ($tabsToTraverse as $sheet) {
2182 $sheetCfg = $dataStructArray['sheets'][$sheet];
2183 list ($dataStruct, $sheet) = t3lib_div::resolveSheetDefInDS($dataStructArray,$sheet);
2184
2185 // Render sheet:
2186 if (is_array($dataStruct['ROOT']) && is_array($dataStruct['ROOT']['el'])) {
2187 $cmdData = t3lib_div::_GP('flexFormsCmdData');
2188 $lang = 'l'.$lKey; // Default language, other options are "lUK" or whatever country code (independant of system!!!)
2189 $PA['_valLang'] = $langChildren && !$langDisabled ? $editData['meta']['currentLangId'] : 'DEF'; // Default language, other options are "lUK" or whatever country code (independant of system!!!)
2190 $PA['_lang'] = $lang;
2191
2192 // Render flexform:
2193 $tRows = $this->getSingleField_typeFlex_draw(
2194 $dataStruct['ROOT']['el'],
2195 $editData['data'][$sheet][$lang],
2196 $cmdData['data'][$sheet][$lang],
2197 $table,
2198 $field,
2199 $row,
2200 $PA,
2201 '[data]['.$sheet.']['.$lang.']'
2202 );
2203 $sheetContent= '<table border="0" cellpadding="1" cellspacing="1" class="typo3-TCEforms-flexForm">'.implode('',$tRows).'</table>';
2204
2205 # $item = '<div style=" position:absolute;">'.$item.'</div>';
2206 //visibility:hidden;
2207 } else $sheetContent='Data Structure ERROR: No ROOT element found for sheet "'.$sheet.'".';
2208
2209 // Add to tab:
2210 $tabParts[] = array(
2211 'label' => ($sheetCfg['ROOT']['TCEforms']['sheetTitle'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetTitle']) : $sheet),
2212 'description' => ($sheetCfg['ROOT']['TCEforms']['sheetDescription'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetDescription']) : ''),
2213 'linkTitle' => ($sheetCfg['ROOT']['TCEforms']['sheetShortDescr'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetShortDescr']) : ''),
2214 'content' => $sheetContent
2215 );
2216 }
2217
2218 if (is_array($dataStructArray['sheets'])) {
2219 $item.= $this->getDynTabMenu($tabParts,'TCEFORMS:flexform:'.$PA['itemFormElName'].$PA['_lang']);
2220 } else {
2221 $item.= $sheetContent;
2222 }
2223 }
2224 } else $item='Data Structure ERROR: '.$dataStructArray;
2225
2226 return $item;
2227 }
2228
2229 /**
2230 * Creates the language menu for FlexForms:
2231 *
2232 * @param [type] $languages: ...
2233 * @param [type] $elName: ...
2234 * @param [type] $selectedLanguage: ...
2235 * @param [type] $multi: ...
2236 * @return string HTML for menu
2237 */
2238 function getSingleField_typeFlex_langMenu($languages,$elName,$selectedLanguage,$multi=1) {
2239 $opt=array();
2240 foreach($languages as $lArr) {
2241 $opt[]='<option value="'.htmlspecialchars($lArr['ISOcode']).'"'.(in_array($lArr['ISOcode'],$selectedLanguage)?' selected="selected"':'').'>'.htmlspecialchars($lArr['title']).'</option>';
2242 }
2243
2244 $output = '<select name="'.$elName.'[]"'.($multi ? ' multiple="multiple" size="'.count($languages).'"' : '').'>'.implode('',$opt).'</select>';
2245
2246 return $output;
2247 }
2248
2249 /**
2250 * Creates the menu for selection of the sheets:
2251 *
2252 * @param array Sheet array for which to render the menu
2253 * @param string Form element name of the field containing the sheet pointer
2254 * @param string Current sheet key
2255 * @return string HTML for menu
2256 */
2257 function getSingleField_typeFlex_sheetMenu($sArr,$elName,$sheetKey) {
2258
2259 $tCells =array();
2260 $pct = round(100/count($sArr));
2261 foreach($sArr as $sKey => $sheetCfg) {
2262 if ($GLOBALS['BE_USER']->jsConfirmation(1)) {
2263 $onClick = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){'.$this->elName($elName).".value='".$sKey."'; TBE_EDITOR.submitForm()};";
2264 } else {
2265 $onClick = 'if(TBE_EDITOR.checkSubmit(-1)){ '.$this->elName($elName).".value='".$sKey."'; TBE_EDITOR.submitForm();}";
2266 }
2267
2268
2269 $tCells[]='<td width="'.$pct.'%" style="'.($sKey==$sheetKey ? 'background-color: #9999cc; font-weight: bold;' : 'background-color: #aaaaaa;').' cursor: hand;" onclick="'.htmlspecialchars($onClick).'" align="center">'.
2270 ($sheetCfg['ROOT']['TCEforms']['sheetTitle'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetTitle']) : $sKey).
2271 '</td>';
2272 }
2273
2274 return '<table border="0" cellpadding="0" cellspacing="2" class="typo3-TCEforms-flexForm-sheetMenu"><tr>'.implode('',$tCells).'</tr></table>';
2275 }
2276
2277 /**
2278 * [Describe function...]
2279 *
2280 * @param [type] $dataStruct: ...
2281 * @param [type] $editData: ...
2282 * @param [type] $cmdData: ...
2283 * @param [type] $table: ...
2284 * @param [type] $field: ...
2285 * @param [type] $row: ...
2286 * @param [type] $PA: ...
2287 * @param [type] $formPrefix: ...
2288 * @param [type] $level: ...
2289 * @param [type] $tRows: ...
2290 * @return [type] ...
2291 */
2292 function getSingleField_typeFlex_draw($dataStruct,$editData,$cmdData,$table,$field,$row,&$PA,$formPrefix='',$level=0,$tRows=array()) {
2293
2294 // Data Structure array must be ... and array of course...
2295 if (is_array($dataStruct)) {
2296 foreach($dataStruct as $key => $value) {
2297 if (is_array($value)) { // The value of each entry must be an array.
2298
2299 // ********************
2300 // Making the row:
2301 // ********************
2302 $rowCells=array();
2303
2304 // Icon:
2305 $rowCells['title'] = '<img src="clear.gif" width="'.($level*16).'" height="1" alt="" /><strong>'.htmlspecialchars(t3lib_div::fixed_lgd_cs($this->sL($value['tx_templavoila']['title']),30)).'</strong>';;
2306
2307 $rowCells['formEl']='';
2308 if ($value['type']=='array') {
2309 if ($value['section']) {
2310 // Render "NEW [container]" selectorbox:
2311 if (is_array($value['el'])) {
2312 $opt=array();
2313 $opt[]='<option value=""></option>';
2314 foreach($value['el'] as $kk => $vv) {
2315 $opt[]='<option value="'.$kk.'">'.htmlspecialchars($this->getLL('l_new') . ' "'.$this->sL($value['el'][$kk]['tx_templavoila']['title']).'"').'</option>';
2316 }
2317 $rowCells['formEl']='<select name="flexFormsCmdData'.$formPrefix.'['.$key.'][value]">'.implode('',$opt).'</select>';
2318 }
2319
2320 // Put row together
2321 $tRows[]='<tr class="bgColor2">
2322 <td nowrap="nowrap" valign="top">'.$rowCells['title'].'</td>
2323 <td>'.$rowCells['formEl'].'</td>
2324 </tr>';
2325
2326 $cc=0;
2327 if (is_array($editData[$key]['el'])) {
2328 foreach ($editData[$key]['el'] as $k3 => $v3) {
2329 $cc=$k3;
2330 $theType = key($v3);
2331 $theDat = $v3[$theType];
2332 $newSectionEl = $value['el'][$theType];
2333 if (is_array($newSectionEl)) {
2334 $tRows = $this->getSingleField_typeFlex_draw(
2335 array($theType => $newSectionEl),
2336 array($theType => $theDat),
2337 $cmdData[$key]['el'][$cc],
2338 $table,
2339 $field,
2340 $row,
2341 $PA,
2342 $formPrefix.'['.$key.'][el]['.$cc.']',
2343 $level+1,
2344 $tRows
2345 );
2346 }
2347 }
2348 }
2349
2350
2351
2352 // New form?
2353 if ($cmdData[$key]['value']) {
2354 $newSectionEl = $value['el'][$cmdData[$key]['value']];
2355 if (is_array($newSectionEl)) {
2356 $tRows = $this->getSingleField_typeFlex_draw(
2357 array($cmdData[$key]['value'] => $newSectionEl),
2358 array(),
2359 array(),
2360 $table,
2361 $field,
2362 $row,
2363 $PA,
2364 $formPrefix.'['.$key.'][el]['.($cc+1).']',
2365 $level+1,
2366 $tRows
2367 );
2368 }
2369 }
2370 } else {
2371 $idTagPrefix = uniqid('id',true); // ID attributes are used for the move and delete checkboxes for referencing to them in the label tag (<label for="the form field id">) that's rendered around the icons
2372
2373 // Put row together
2374 $tRows[]='<tr class="bgColor2">
2375 <td nowrap="nowrap" valign="top">'.
2376 '<input name="_DELETE_FLEX_FORM'.$PA['itemFormElName'].$formPrefix.'" id="'.$idTagPrefix.'-del" type="checkbox"'.$this->insertDefStyle('check').' value="1" /><label for="'.$idTagPrefix.'-del"><img src="'.$this->backPath.'gfx/garbage.gif" border="0" alt="" /></label>'.
2377 '<input name="_MOVEUP_FLEX_FORM'.$PA['itemFormElName'].$formPrefix.'" id="'.$idTagPrefix.'-mvup" type="checkbox"'.$this->insertDefStyle('check').' value="1" /><label for="'.$idTagPrefix.'-mvup"><img src="'.$this->backPath.'gfx/button_up.gif" border="0" alt="" /></label>'.
2378 '<input name="_MOVEDOWN_FLEX_FORM'.$PA['itemFormElName'].$formPrefix.'" id="'.$idTagPrefix.'-mvdown" type="checkbox"'.$this->insertDefStyle('check').' value="1" /><label for="'.$idTagPrefix.'-mvdown"><img src="'.$this->backPath.'gfx/button_down.gif" border="0" alt="" /></label>'.
2379 $rowCells['title'].'</td>
2380 <td>'.$rowCells['formEl'].'</td>
2381 </tr>';
2382
2383 $tRows = $this->getSingleField_typeFlex_draw(
2384 $value['el'],
2385 $editData[$key]['el'],
2386 $cmdData[$key]['el'],
2387 $table,
2388 $field,
2389 $row,
2390 $PA,
2391 $formPrefix.'['.$key.'][el]',
2392 $level+1,
2393 $tRows
2394 );
2395 }
2396
2397 } elseif (is_array($value['TCEforms']['config'])) { // Rendering a single form element:
2398
2399 if (is_array($PA['_valLang'])) {
2400 $rotateLang = $PA['_valLang'];
2401 } else {
2402 $rotateLang = array($PA['_valLang']);
2403 }
2404
2405 foreach($rotateLang as $vDEFkey) {
2406 $vDEFkey = 'v'.$vDEFkey;
2407
2408 if (!$value['TCEforms']['displayCond'] || $this->isDisplayCondition($value['TCEforms']['displayCond'],$editData,$vDEFkey)) {
2409 $fakePA=array();
2410 $fakePA['fieldConf']=array(
2411 'label' => $this->sL(trim($value['TCEforms']['label'])),
2412 'config' => $value['TCEforms']['config'],
2413 'defaultExtras' => $value['TCEforms']['defaultExtras'],
2414 'onChange' => $value['TCEforms']['onChange']
2415 );
2416 if ($PA['_noEditDEF'] && $PA['_lang']==='lDEF') {
2417 $fakePA['fieldConf']['config'] = array(
2418 'type' => 'none',
2419 'rows' => 2
2420 );
2421 }
2422
2423 if (
2424 $fakePA['fieldConf']['onChange'] == 'reload' ||
2425 ($GLOBALS['TCA'][$table]['ctrl']['type'] && !strcmp($key,$GLOBALS['TCA'][$table]['ctrl']['type'])) ||
2426 ($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'] && t3lib_div::inList($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'],$key))) {
2427 if ($GLOBALS['BE_USER']->jsConfirmation(1)) {
2428 $alertMsgOnChange = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
2429 } else {
2430 $alertMsgOnChange = 'if(TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm();}';
2431 }
2432 } else {
2433 $alertMsgOnChange = '';
2434 }
2435
2436 $fakePA['fieldChangeFunc']=$PA['fieldChangeFunc'];
2437 if (strlen($alertMsgOnChange)) {
2438 $fakePA['fieldChangeFunc']['alert']=$alertMsgOnChange;
2439 }
2440 $fakePA['onFocus']=$PA['onFocus'];
2441 $fakePA['label']=$PA['label'];
2442
2443 $fakePA['itemFormElName']=$PA['itemFormElName'].$formPrefix.'['.$key.']['.$vDEFkey.']';
2444 $fakePA['itemFormElName_file']=$PA['itemFormElName_file'].$formPrefix.'['.$key.']['.$vDEFkey.']';
2445
2446 if(isset($editData[$key][$vDEFkey])) {
2447 $fakePA['itemFormElValue']=$editData[$key][$vDEFkey];
2448 } else {
2449 $fakePA['itemFormElValue']=$fakePA['fieldConf']['config']['default'];
2450 }
2451
2452 $rowCells['formEl']= $this->getSingleField_SW($table,$field,$row,$fakePA);
2453 $rowCells['title']= htmlspecialchars($fakePA['fieldConf']['label']);
2454
2455 if (!in_array('DEF',$rotateLang)) {
2456 $defInfo = '<div class="typo3-TCEforms-originalLanguageValue">'.$this->getLanguageIcon($table,$row,0).$this->previewFieldValue($editData[$key]['vDEF'], $fakePA['fieldConf']).'&nbsp;</div>';
2457 } else {
2458 $defInfo = '';
2459 }
2460
2461 if (!$PA['_noEditDEF']) {
2462 $prLang = $this->getAdditionalPreviewLanguages();
2463 foreach($prLang as $prL) {
2464 $defInfo.= '<div class="typo3-TCEforms-originalLanguageValue">'.$this->getLanguageIcon($table,$row,'v'.$prL['ISOcode']).$this->previewFieldValue($editData[$key]['v'.$prL['ISOcode']], $fakePA['fieldConf']).'&nbsp;</div>';
2465 }
2466 }
2467
2468 // Put row together
2469 $tRows[]='<tr>
2470 <td nowrap="nowrap" valign="top" class="bgColor5">'.($vDEFkey=='vDEF' ? '' : $this->getLanguageIcon($table,$row,$vDEFkey)).$rowCells['title'].'</td>
2471 <td class="bgColor4">'.$rowCells['formEl'].$defInfo.'</td>
2472 </tr>';
2473 }
2474 }
2475 }
2476 }
2477 }
2478 }
2479
2480 return $tRows;
2481 }
2482
2483 /**
2484 * Handler for unknown types.
2485 *
2486 * @param string The table name of the record
2487 * @param string The field name which this element is supposed to edit
2488 * @param array The record data array where the value(s) for the field can be found
2489 * @param array An array with additional configuration options.
2490 * @return string The HTML code for the TCEform field
2491 */
2492 function getSingleField_typeUnknown($table,$field,$row,&$PA) {
2493 $item='Unknown type: '.$PA['fieldConf']['config']['form_type'].'<br />';
2494
2495 return $item;
2496 }
2497
2498 /**
2499 * User defined field type
2500 *
2501 * @param string The table name of the record
2502 * @param string The field name which this element is supposed to edit
2503 * @param array The record data array where the value(s) for the field can be found
2504 * @param array An array with additional configuration options.
2505 * @return string The HTML code for the TCEform field
2506 */
2507 function getSingleField_typeUser($table,$field,$row,&$PA) {
2508 $PA['table']=$table;
2509 $PA['field']=$field;
2510 $PA['row']=$row;
2511
2512 $PA['pObj']=&$this;
2513
2514 return t3lib_div::callUserFunction($PA['fieldConf']['config']['userFunc'],$PA,$this);
2515 }
2516
2517
2518
2519
2520
2521
2522 /************************************************************
2523 *
2524 * Field content processing
2525 *
2526 ************************************************************/
2527
2528 /**
2529 * Format field content of various types if $config['format'] is set to date, filesize, ..., user
2530 * This is primarily for the field type none but can be used for user field types for example
2531 *
2532 * @param array Configuration for the display
2533 * @param string The value to display
2534 * @return string Formatted Field content
2535 */
2536 function formatValue ($config, $itemValue) {
2537 $format = trim($config['format']);
2538 switch($format) {
2539 case 'date':
2540 if ($itemValue) {
2541 $option = trim($config['format.']['option']);
2542 if ($option) {
2543 if ($config['format.']['strftime']) {
2544 $value = strftime($option,$itemValue);
2545 } else {
2546 $value = date($option,$itemValue);
2547 }
2548 } else {
2549 $value = date('d-m-Y',$itemValue);
2550 }
2551 } else {
2552 $value = '';
2553 }
2554 if ($config['format.']['appendAge']) {
2555 $value .= ' ('.t3lib_BEfunc::calcAge((time()-$itemValue), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')).')';
2556 }
2557 $itemValue = $value;
2558 break;
2559 case 'datetime': // compatibility with "eval" (type "input")
2560 $itemValue = date('H:i d-m-Y',$itemValue);
2561 break;
2562 case 'time': // compatibility with "eval" (type "input")
2563 $itemValue = date('H:i',$itemValue);
2564 break;
2565 case 'timesec': // compatibility with "eval" (type "input")
2566 $itemValue = date('H:i:s',$itemValue);
2567 break;
2568 case 'year': // compatibility with "eval" (type "input")
2569 $itemValue = date('Y',$itemValue);
2570 break;
2571 case 'int':
2572 $baseArr = array('dec'=>'d','hex'=>'x','HEX'=>'X','oct'=>'o','bin'=>'b');
2573 $base = trim($config['format.']['base']);
2574 $format = $baseArr[$base] ? $baseArr[$base] : 'd';
2575 $itemValue = sprintf('%'.$format,$itemValue);
2576 break;
2577 case 'float':
2578 $precision = t3lib_div::intInRange($config['format.']['precision'],1,10,2);
2579 $itemValue = sprintf('%.'.$precision.'f',$itemValue);
2580 break;
2581 case 'number':
2582 $format = trim($config['format.']['option']);
2583 $itemValue = sprintf('%'.$format,$itemValue);
2584 break;
2585 case 'md5':
2586 $itemValue = md5($itemValue);
2587 break;
2588 case 'filesize':
2589 $value = t3lib_div::formatSize(intval($itemValue));
2590 if ($config['format.']['appendByteSize']) {
2591 $value .= ' ('.$itemValue.')';
2592 }
2593 $itemValue = $value;
2594 break;
2595 case 'user':
2596 $func = trim($config['format.']['userFunc']);
2597 if ($func) {
2598 $params = array(
2599 'value' => $itemValue,
2600 'args' => $config['format.']['userFunc'],
2601 'config' => $config,
2602 'pObj' => &$this
2603 );
2604 $itemValue = t3lib_div::callUserFunction($func,$params,$this);
2605 }
2606 break;
2607 default:
2608 break;
2609 }
2610
2611 return $itemValue;
2612 }
2613
2614
2615
2616
2617
2618
2619 /************************************************************
2620 *
2621 * "Configuration" fetching/processing functions
2622 *
2623 ************************************************************/
2624
2625 /**
2626 * Calculate and return the current "types" pointer value for a record
2627 *
2628 * @param string The table name. MUST be in $TCA
2629 * @param array The row from the table, should contain at least the "type" field, if applicable.
2630 * @return string Return the "type" value for this record, ready to pick a "types" configuration from the $TCA array.
2631 */
2632 function getRTypeNum($table,$row) {
2633 global $TCA;
2634 // If there is a "type" field configured...
2635 if ($TCA[$table]['ctrl']['type']) {
2636 $typeFieldName = $TCA[$table]['ctrl']['type'];
2637 $typeNum=$row[$typeFieldName]; // Get value of the row from the record which contains the type value.
2638 if (!strcmp($typeNum,'')) $typeNum=0; // If that value is an empty string, set it to "0" (zero)
2639 } else {
2640 $typeNum = 0; // If no "type" field, then set to "0" (zero)
2641 }
2642
2643 $typeNum = (string)$typeNum; // Force to string. Necessary for eg '-1' to be recognized as a type value.
2644 if (!$TCA[$table]['types'][$typeNum]) { // However, if the type "0" is not found in the "types" array, then default to "1" (for historical reasons)
2645 $typeNum = 1;
2646 }
2647
2648 return $typeNum;
2649 }
2650
2651 /**
2652 * Used to adhoc-rearrange the field order normally set in the [types][showitem] list
2653 *
2654 * @param array A [types][showitem] list of fields, exploded by ","
2655 * @return array Returns rearranged version (keys are changed around as well.)
2656 * @see getMainFields()
2657 */
2658 function rearrange($fields) {
2659 $fO = array_flip(t3lib_div::trimExplode(',',$this->fieldOrder,1));
2660 reset($fields);
2661 $newFields=array();
2662 while(list($cc,$content)=each($fields)) {
2663 $cP = t3lib_div::trimExplode(