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