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