2 /***************************************************************
5 * (c) 1999-2006 Kasper Skaarhoj (kasperYYYY@typo3.com)
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Contains TYPO3 Core Form generator - AKA "TCEforms"
31 * Revised for TYPO3 3.6 August/2003 by Kasper Skaarhoj
34 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
37 * [CLASS/FUNCTION INDEX of SCRIPT]
41 * 195: class t3lib_TCEforms
42 * 300: function t3lib_TCEforms()
43 * 334: function initDefaultBEmode()
45 * SECTION: Rendering the forms, fields etc
46 * 379: function getSoloField($table,$row,$theFieldToReturn)
47 * 418: function getMainFields($table,$row,$depth=0)
48 * 613: function getListedFields($table,$row,$list)
49 * 654: function getPaletteFields($table,$row,$palette,$header='',$itemList='',$collapsedHeader='')
50 * 730: function getSingleField($table,$field,$row,$altName='',$palette=0,$extra='',$pal=0)
51 * 886: function getSingleField_SW($table,$field,$row,&$PA)
53 * SECTION: Rendering of each TCEform field type
54 * 959: function getSingleField_typeInput($table,$field,$row,&$PA)
55 * 1040: function getSingleField_typeText($table,$field,$row,&$PA)
56 * 1153: function getSingleField_typeCheck($table,$field,$row,&$PA)
57 * 1219: function getSingleField_typeRadio($table,$field,$row,&$PA)
58 * 1254: function getSingleField_typeSelect($table,$field,$row,&$PA)
59 * 1334: function getSingleField_typeSelect_single($table,$field,$row,&$PA,$config,$selItems,$nMV_label)
60 * 1451: function getSingleField_typeSelect_checkbox($table,$field,$row,&$PA,$config,$selItems,$nMV_label)
61 * 1570: function getSingleField_typeSelect_singlebox($table,$field,$row,&$PA,$config,$selItems,$nMV_label)
62 * 1680: function getSingleField_typeSelect_multiple($table,$field,$row,&$PA,$config,$selItems,$nMV_label)
63 * 1779: function getSingleField_typeGroup($table,$field,$row,&$PA)
64 * 1948: function getSingleField_typeNone($table,$field,$row,&$PA)
65 * 1964: function getSingleField_typeNone_render($config,$itemValue)
66 * 2026: function getSingleField_typeFlex($table,$field,$row,&$PA)
67 * 2164: function getSingleField_typeFlex_langMenu($languages,$elName,$selectedLanguage,$multi=1)
68 * 2183: function getSingleField_typeFlex_sheetMenu($sArr,$elName,$sheetKey)
69 * 2218: function getSingleField_typeFlex_draw($dataStruct,$editData,$cmdData,$table,$field,$row,&$PA,$formPrefix='',$level=0,$tRows=array())
70 * 2411: function getSingleField_typeUnknown($table,$field,$row,&$PA)
71 * 2426: function getSingleField_typeUser($table,$field,$row,&$PA)
73 * SECTION: Field content processing
74 * 2455: function formatValue ($config, $itemValue)
76 * SECTION: "Configuration" fetching/processing functions
77 * 2547: function getRTypeNum($table,$row)
78 * 2573: function rearrange($fields)
79 * 2599: function getExcludeElements($table,$row,$typeNum)
80 * 2647: function getFieldsToAdd($table,$row,$typeNum)
81 * 2672: function mergeFieldsWithAddedFields($fields,$fieldsToAdd)
82 * 2704: function setTSconfig($table,$row,$field='')
83 * 2726: function getSpecConfForField($table,$row,$field)
84 * 2747: function getSpecConfFromString($extraString, $defaultExtras)
86 * SECTION: Display of localized content etc.
87 * 2775: function registerDefaultLanguageData($table,$rec)
88 * 2807: function getLanguageOverlayRawValue($table, $row, $field, $fieldConf)
89 * 2835: function renderDefaultLanguageContent($table,$field,$row,$item)
90 * 2858: function renderDefaultLanguageDiff($table,$field,$row,$item)
92 * SECTION: Form element helper functions
93 * 2914: function dbFileIcons($fName,$mode,$allowed,$itemArray,$selector='',$params=array(),$onFocus='')
94 * 3067: function getClipboardElements($allowed,$mode)
95 * 3116: function getClickMenu($str,$table,$uid='')
96 * 3137: function renderWizards($itemKinds,$wizConf,$table,$row,$field,&$PA,$itemName,$specConf,$RTE=0)
97 * 3341: function getIcon($icon)
98 * 3368: function optionTagStyle($iconString)
99 * 3384: function extractValuesOnlyFromValueLabelList($itemFormElValue)
100 * 3406: function wrapOpenPalette($header,$table,$row,$palette,$retFunc=0)
101 * 3430: function checkBoxParams($itemName,$thisValue,$c,$iCount,$addFunc='')
102 * 3444: function elName($itemName)
103 * 3455: function noTitle($str,$wrapParts=array())
104 * 3464: function blur()
105 * 3473: function thisReturnUrl()
106 * 3486: function getSingleHiddenField($table,$field,$row)
107 * 3508: function formWidth($size=48,$textarea=0)
108 * 3535: function formWidthText($size=48,$wrap='')
109 * 3551: function formElStyle($type)
110 * 3562: function formElClass($type)
111 * 3573: function formElStyleClassValue($type, $class=FALSE)
112 * 3595: function insertDefStyle($type)
113 * 3614: function getDynTabMenu($parts, $idString)
115 * SECTION: Item-array manipulation functions (check/select/radio)
116 * 3653: function initItemArray($fieldValue)
117 * 3671: function addItems($items,$iArray)
118 * 3693: function procItems($items,$iArray,$config,$table,$row,$field)
119 * 3717: function addSelectOptionsToItemArray($items,$fieldValue,$TSconfig,$field)
120 * 3937: function addSelectOptionsToItemArray_makeModuleData($value)
121 * 3959: function foreignTable($items,$fieldValue,$TSconfig,$field,$pFFlag=0)
123 * SECTION: Template functions
124 * 4040: function setNewBEDesign()
125 * 4095: function intoTemplate($inArr,$altTemplate='')
126 * 4119: function addUserTemplateMarkers($marker,$table,$field,$row,&$PA)
127 * 4130: function wrapLabels($str)
128 * 4143: function wrapTotal($c,$rec,$table)
129 * 4156: function replaceTableWrap($arr,$rec,$table)
130 * 4194: function wrapBorder(&$out_array,&$out_pointer)
131 * 4216: function rplColorScheme($inTemplate)
132 * 4236: function getDivider()
133 * 4246: function printPalette($palArr)
134 * 4297: function helpTextIcon($table,$field,$force=0)
135 * 4317: function helpText($table,$field)
136 * 4338: function setColorScheme($scheme)
137 * 4362: function resetSchemes()
138 * 4373: function storeSchemes()
139 * 4385: function restoreSchemes()
141 * SECTION: JavaScript related functions
142 * 4415: function JStop()
143 * 4466: function JSbottom($formname='forms[0]')
144 * 4780: function dbFileCon($formObj='document.forms[0]')
145 * 4982: function printNeededJSFunctions()
146 * 5009: function printNeededJSFunctions_top()
148 * SECTION: Various helper functions
149 * 5057: function getDefaultRecord($table,$pid=0)
150 * 5096: function getRecordPath($table,$rec)
151 * 5110: function readPerms()
152 * 5124: function sL($str)
153 * 5137: function getLL($str)
154 * 5158: function isPalettesCollapsed($table,$palette)
155 * 5174: function isDisplayCondition($displayCond,$row,$ffValueKey='')
156 * 5275: function getTSCpid($table,$uid,$pid)
157 * 5289: function doLoadTableDescr($table)
158 * 5301: function getAvailableLanguages($onlyIsoCoded=1,$setDefault=1)
161 * 5343: class t3lib_TCEforms_FE extends t3lib_TCEforms
162 * 5351: function wrapLabels($str)
163 * 5361: function printPalette($palArr)
164 * 5386: function setFancyDesign()
166 * TOTAL FUNCTIONS: 100
167 * (This index is automatically created/updated by the extension "extdeveval")
183 require_once(PATH_t3lib
.'class.t3lib_diff.php');
188 * 'TCEforms' - Class for creating the backend editing forms.
190 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
191 * @coauthor Rene Fritz <r.fritz@colorcube.de>
195 class t3lib_TCEforms
{
197 // variables not commented yet.... (do so...)
198 var $palFieldArr = array();
199 var $disableWizards = 0;
200 var $isPalettedoc = 0;
201 var $paletteMargin = 1;
202 var $defStyle = ''; // 'font-family:Verdana;font-size:10px;';
203 var $cachedTSconfig = array();
204 var $cachedTSconfig_fieldLevel = array();
205 var $transformedRow = array();
207 var $printNeededJS = array();
208 var $hiddenFieldAccum=array();
209 var $TBE_EDITOR_fieldChanged_func='';
211 var $prevBorderStyle='[nothing here...]'; // Something unique...
212 var $allowUpload=0; // If set direct upload fields will be shown
213 var $titleLen=15; // $BE_USER->uc['titleLen'] but what is default??
214 var $defaultLanguageData = array(); // Array where records in the default language is stored. (processed by transferdata)
215 var $defaultLanguageData_diff = array(); // Array where records in the default language is stored (raw without any processing. used for making diff)
219 var $backPath=''; // Set this to the 'backPath' pointing back to the typo3 admin directory from the script where this form is displayed.
220 var $returnUrl=''; // Alternative return URL path (default is t3lib_div::linkThisScript())
221 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.
222 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.
223 var $disableRTE=0; // If set, the RTE is disabled (from form display, eg. by checkbox in the bottom of the page!)
224 var $globalShowHelp=1; // If false, then all CSH will be disabled, regardless of settings in $this->edit_showFieldHelp
225 var $localizationMode=''; // If true, the forms are rendering only localization relevant fields of the records.
226 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.
227 var $doPrintPalette=1; // If set to false, palettes will NEVER be rendered.
228 var $clipObj=FALSE; // Set to initialized clipboard object; Then the element browser will offer a link to paste in records from clipboard.
229 var $enableClickMenu=FALSE; // Enable click menu on reference icons.
230 var $enableTabMenu = FALSE; // Enable Tab Menus. If set to true, the JavaScript content from template::getDynTabMenuJScode() must be included in the document.
231 var $renderReadonly = FALSE; // When enabled all fields are rendered non-editable.
233 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)
234 var $form_largeComp = 1.33; // Form field width compensation: Compensation for large documents, doc-tab (editing)
235 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.
236 var $maxTextareaWidth=48; // The maximum abstract value for textareas
237 var $maxInputWidth=48; // The maximum abstract value for input fields
238 var $defaultMultipleSelectorStyle='width:250px;'; // Default style for the selector boxes used for multiple items in "select" and "group" types.
242 var $prependFormFieldNames = 'data'; // The string to prepend formfield names with.
243 var $prependFormFieldNames_file = 'data_files'; // The string to prepend FILE form field names with.
244 var $formName = 'editform'; // The name attribute of the form.
249 var $perms_clause=''; // Set by readPerms() (caching)
250 var $perms_clause_set=0; // Set by readPerms() (caching-flag)
251 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).
252 var $docLarge=0; // If set, the forms will be rendered a little wider, more precisely with a factor of $this->form_largeComp.
253 var $clientInfo=array(); // Loaded with info about the browser when class is instantiated.
254 var $RTEenabled=0; // True, if RTE is possible for the current user (based on result from BE_USER->isRTE())
255 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)
256 var $RTEcounter = 0; // Counter that is incremented before an RTE is created. Can be used for unique ids etc.
258 var $colorScheme; // Contains current color scheme
259 var $classScheme; // Contains current class scheme
260 var $defColorScheme; // Contains the default color scheme
261 var $defClassScheme; // Contains the default class scheme
262 var $fieldStyle; // Contains field style values
263 var $borderStyle; // Contains border style values.
265 var $commentMessages=array(); // An accumulation of messages from the class.
267 // INTERNAL, templates
268 var $totalWrap='<hr />|<hr />'; // Total wrapping for the table rows.
269 var $fieldTemplate='<b>###FIELD_NAME###</b><br />###FIELD_ITEM###<hr />'; // Field template
270 var $sectionWrap=''; // Wrapping template code for a section
271 var $palFieldTemplateHeader=''; // Template for palette headers
272 var $palFieldTemplate=''; // Template for palettes
274 // INTERNAL, working memory
275 var $excludeElements=''; // Set to the fields NOT to display, if any.
276 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)
277 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!
278 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.
279 var $requiredElements=array(); // Used to register the min and max number of elements for selectorboxes where that apply (in the "group" type for instance)
280 var $renderDepth=0; // Keeps track of the rendering depth of nested records.
281 var $savedSchemes=array(); // Color scheme buffer.
283 // Internal, registers for user defined functions etc.
284 var $additionalCode_pre = array(); // Additional HTML code, printed before the form.
285 var $additionalJS_pre = array(); // Additional JavaScript, printed before the form
286 var $additionalJS_post = array(); // Additional JavaScript printed after the form
287 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.
296 * Constructor function, setting internal variables, loading the styles used.
300 function t3lib_TCEforms() {
303 $this->clientInfo
= t3lib_div
::clientInfo();
305 $this->RTEenabled
= $GLOBALS['BE_USER']->isRTE();
306 if (!$this->RTEenabled
) {
307 $this->RTEenabled_notReasons
= implode(chr(10),$GLOBALS['BE_USER']->RTE_errors
);
308 $this->commentMessages
[] = 'RTE NOT ENABLED IN SYSTEM due to:'.chr(10).$this->RTEenabled_notReasons
;
311 // Default color+class scheme
312 $this->defColorScheme
= array(
313 $GLOBALS['SOBE']->doc
->bgColor
, // Background for the field AND palette
314 t3lib_div
::modifyHTMLColorAll($GLOBALS['SOBE']->doc
->bgColor
,-20), // Background for the field header
315 t3lib_div
::modifyHTMLColorAll($GLOBALS['SOBE']->doc
->bgColor
,-10), // Background for the palette field header
316 'black', // Field header font color
317 '#666666' // Palette field header font color
319 $this->defColorScheme
= array();
321 // Override / Setting defaults from TBE_STYLES array
322 $this->resetSchemes();
324 // Setting the current colorScheme to default.
325 $this->defColorScheme
= $this->colorScheme
;
326 $this->defClassScheme
= $this->classScheme
;
330 * Initialize various internal variables.
334 function initDefaultBEmode() {
336 $this->prependFormFieldNames
= 'data';
337 $this->formName
= 'editform';
338 $this->setNewBEDesign();
339 $this->docLarge
= $BE_USER->uc
['edit_wideDocument'] ?
1 : 0;
340 $this->edit_showFieldHelp
= $BE_USER->uc
['edit_showFieldHelp'];
342 $this->edit_docModuleUpload
= $BE_USER->uc
['edit_docModuleUpload'];
343 $this->titleLen
= $BE_USER->uc
['titleLen'];
362 /*******************************************************
364 * Rendering the forms, fields etc
366 *******************************************************/
369 * Will return the TCEform element for just a single field from a record.
370 * The field must be listed in the currently displayed fields (as found in [types][showitem]) for the record.
371 * This also means that the $table/$row supplied must be complete so the list of fields to show can be found correctly
373 * @param string The table name
374 * @param array The record from the table for which to render a field.
375 * @param string The field name to return the TCEform element for.
376 * @return string HTML output
377 * @see getMainFields()
379 function getSoloField($table,$row,$theFieldToReturn) {
383 t3lib_div
::loadTCA($table);
384 $typeNum = $this->getRTypeNum($table,$row);
385 if ($TCA[$table]['types'][$typeNum]) {
386 $itemList = $TCA[$table]['types'][$typeNum]['showitem'];
388 $fields = t3lib_div
::trimExplode(',',$itemList,1);
389 $excludeElements = $this->excludeElements
= $this->getExcludeElements($table,$row,$typeNum);
392 while(list(,$fieldInfo)=each($fields)) {
393 $parts = explode(';',$fieldInfo);
395 $theField = trim($parts[0]);
396 if (!in_array($theField,$excludeElements) && !strcmp($theField,$theFieldToReturn)) {
397 if ($TCA[$table]['columns'][$theField]) {
398 $sField = $this->getSingleField($table,$theField,$row,$parts[1],1,$parts[3],$parts[2]);
399 return $sField['ITEM'];
409 * Based on the $table and $row of content, this displays the complete TCEform for the record.
410 * 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.
412 * @param string The table name
413 * @param array The record from the table for which to render a field.
414 * @param integer Depth level
415 * @return string HTML output
416 * @see getSoloField()
418 function getMainFields($table,$row,$depth=0) {
419 global $TCA, $TYPO3_CONF_VARS;
421 $this->renderDepth
=$depth;
424 $out_array = array(array());
425 $out_array_meta = array(array(
426 'title' => $this->getLL('l_generalTab')
431 $this->palettesRendered
=array();
432 $this->palettesRendered
[$this->renderDepth
][$table]=array();
434 // First prepare user defined objects (if any) for hooks which extend this function:
435 $hookObjectsArr = array();
436 if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'])) {
437 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'] as $classRef) {
438 $hookObjectsArr[] = &t3lib_div
::getUserObj($classRef);
442 // Hook: getMainFields_preProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
443 foreach ($hookObjectsArr as $hookObj) {
444 if (method_exists($hookObj,'getMainFields_preProcess')) {
445 $hookObj->getMainFields_preProcess($table,$row,$this);
451 // Load the full TCA for the table.
452 t3lib_div
::loadTCA($table);
454 // Load the description content for the table.
455 if ($this->edit_showFieldHelp ||
$this->doLoadTableDescr($table)) {
456 $GLOBALS['LANG']->loadSingleTableDescription($table);
458 // Get the current "type" value for the record.
459 $typeNum = $this->getRTypeNum($table,$row);
461 // Find the list of fields to display:
462 if ($TCA[$table]['types'][$typeNum]) {
463 $itemList = $TCA[$table]['types'][$typeNum]['showitem'];
464 if ($itemList) { // If such a list existed...
466 // Explode the field list and possibly rearrange the order of the fields, if configured for
467 $fields = t3lib_div
::trimExplode(',',$itemList,1);
468 if ($this->fieldOrder
) {
469 $fields = $this->rearrange($fields);
472 // Get excluded fields, added fiels and put it together:
473 $excludeElements = $this->excludeElements
= $this->getExcludeElements($table,$row,$typeNum);
474 $fields = $this->mergeFieldsWithAddedFields($fields,$this->getFieldsToAdd($table,$row,$typeNum));
476 // Traverse the fields to render:
478 foreach($fields as $fieldInfo) {
479 // Exploding subparts of the field configuration:
480 $parts = explode(';',$fieldInfo);
482 // Getting the style information out:
483 $color_style_parts = t3lib_div
::trimExplode('-',$parts[4]);
484 if (strcmp($color_style_parts[0],'')) {
485 $this->setColorScheme($GLOBALS['TBE_STYLES']['colorschemes'][intval($color_style_parts[0])]);
487 if (strcmp($color_style_parts[1],'')) {
488 $this->fieldStyle
= $GLOBALS['TBE_STYLES']['styleschemes'][intval($color_style_parts[1])];
489 if (!isset($this->fieldStyle
)) $this->fieldStyle
= $GLOBALS['TBE_STYLES']['styleschemes'][0];
491 if (strcmp($color_style_parts[2],'')) {
492 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
493 $this->borderStyle
= $GLOBALS['TBE_STYLES']['borderschemes'][intval($color_style_parts[2])];
494 if (!isset($this->borderStyle
)) $this->borderStyle
= $GLOBALS['TBE_STYLES']['borderschemes'][0];
498 $theField = $parts[0];
499 if (!in_array($theField,$excludeElements)) {
500 if ($TCA[$table]['columns'][$theField]) {
503 if ($parts[2] && !isset($this->palettesRendered
[$this->renderDepth
][$table][$parts[2]])) {
504 $sFieldPal=$this->getPaletteFields($table,$row,$parts[2]);
505 $this->palettesRendered
[$this->renderDepth
][$table][$parts[2]] = 1;
507 $sField = $this->getSingleField($table,$theField,$row,$parts[1],0,$parts[3],$parts[2]);
508 if ($sField) $sField.=$sFieldPal;
510 $out_array[$out_sheet][$out_pointer].= $sField;
511 } elseif ($theField=='--div--') {
513 $out_array[$out_sheet][$out_pointer].=$this->getDivider();
515 if ($this->enableTabMenu
&& $TCA[$table]['ctrl']['dividers2tabs']) {
516 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
518 $out_array[$out_sheet] = array();
519 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
521 } else { // Setting alternative title for "General" tab if "--div--" is the very first element.
522 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
524 } elseif($theField=='--palette--') {
525 if ($parts[2] && !isset($this->palettesRendered
[$this->renderDepth
][$table][$parts[2]])) {
526 // render a 'header' if not collapsed
527 if ($TCA[$table]['palettes'][$parts[2]]['canNotCollapse'] AND $parts[1]) {
528 $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$parts[2],$this->sL($parts[1]));
530 $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$parts[2],'','',$this->sL($parts[1]));
532 $this->palettesRendered
[$this->renderDepth
][$table][$parts[2]] = 1;
543 // Hook: getMainFields_postProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
544 foreach ($hookObjectsArr as $hookObj) {
545 if (method_exists($hookObj,'getMainFields_postProcess')) {
546 $hookObj->getMainFields_postProcess($table,$row,$this);
550 // Wrapping a border around it all:
551 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
554 $this->resetSchemes();
556 // Rendering Main palettes, if any
557 $mParr = t3lib_div
::trimExplode(',',$TCA[$table]['ctrl']['mainpalette']);
560 foreach ($mParr as $mP) {
561 if (!isset($this->palettesRendered
[$this->renderDepth
][$table][$mP])) {
562 $temp_palettesCollapsed=$this->palettesCollapsed
;
563 $this->palettesCollapsed
=0;
564 $label = ($i==0?
$this->getLL('l_generalOptions'):$this->getLL('l_generalOptions_more'));
565 $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$mP,$label);
566 $this->palettesCollapsed
=$temp_palettesCollapsed;
567 $this->palettesRendered
[$this->renderDepth
][$table][$mP] = 1;
569 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
571 if ($this->renderDepth
) {
572 $this->renderDepth
--;
578 // Return the imploded $out_array:
579 if ($out_sheet>0) { // There were --div-- dividers around...
581 // Create parts array for the tab menu:
583 foreach($out_array as $idx => $sheetContent) {
585 'label' => $out_array_meta[$idx]['title'],
586 'content' => '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.
587 implode('',$sheetContent).
595 '.$this->getDynTabMenu($parts, 'TCEforms:'.$table.':'.$row['uid']).'
598 } else { // Only one, so just implode:
599 return implode('',$out_array[$out_sheet]);
604 * Will return the TCEform elements for a pre-defined list of fields.
605 * 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.
606 * Used for displaying forms for the frontend edit icons for instance.
608 * @param string The table name
609 * @param array The record array.
610 * @param string Commalist of fields from the table. These will be shown in the specified order in a form.
611 * @return string TCEform elements in a string.
613 function getListedFields($table,$row,$list) {
616 t3lib_div
::loadTCA($table);
617 if ($this->edit_showFieldHelp ||
$this->doLoadTableDescr($table)) {
618 $GLOBALS['LANG']->loadSingleTableDescription($table);
622 $types_fieldConfig=t3lib_BEfunc
::getTCAtypes($table,$row,1);
624 $editFieldList=array_unique(t3lib_div
::trimExplode(',',$list,1));
625 foreach($editFieldList as $theFieldC) {
626 list($theField,$palFields) = split('\[|\]',$theFieldC);
627 $theField = trim($theField);
628 $palFields = trim($palFields);
629 if ($TCA[$table]['columns'][$theField]) {
630 $parts = t3lib_div
::trimExplode(';',$types_fieldConfig[$theField]['origString']);
631 $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.
633 } elseif($theField=='--div--') {
634 $out.=$this->getDivider();
637 $out.=$this->getPaletteFields($table,$row,'','',implode(',',t3lib_div
::trimExplode('|',$palFields,1)));
644 * Creates a palette (collection of secondary options).
646 * @param string The table name
647 * @param array The row array
648 * @param string The palette number/pointer
649 * @param string Header string for the palette (used when in-form). If not set, no header item is made.
650 * @param string Optional alternative list of fields for the palette
651 * @param string Optional Link text for activating a palette (when palettes does not have another form element to belong to).
652 * @return string HTML code.
654 function getPaletteFields($table,$row,$palette,$header='',$itemList='',$collapsedHeader='') {
656 if (!$this->doPrintPalette
) return '';
660 t3lib_div
::loadTCA($table);
662 // Getting excludeElements, if any.
663 if (!is_array($this->excludeElements
)) {
664 $this->excludeElements
= $this->getExcludeElements($table,$row,$this->getRTypeNum($table,$row));
667 // Render the palette TCEform elements.
668 if ($TCA[$table] && (is_array($TCA[$table]['palettes'][$palette]) ||
$itemList)) {
669 $itemList = $itemList?
$itemList:$TCA[$table]['palettes'][$palette]['showitem'];
671 $fields = t3lib_div
::trimExplode(',',$itemList,1);
673 while(list(,$fieldInfo)=each($fields)) {
674 $parts = t3lib_div
::trimExplode(';',$fieldInfo);
675 $theField = $parts[0];
677 if (!in_array($theField,$this->excludeElements
) && $TCA[$table]['columns'][$theField]) {
678 $this->palFieldArr
[$palette][] = $theField;
679 if ($this->isPalettesCollapsed($table,$palette)) {
680 $this->hiddenFieldListArr
[] = $theField;
683 $part=$this->getSingleField($table,$theField,$row,$parts[1],1,'',$parts[2]);
684 if (is_array($part)) {
691 // Put palette together if there are fields in it:
692 if (count($palParts)) {
694 $out.= $this->intoTemplate(array(
695 'HEADER' => htmlspecialchars($header)
697 $this->palFieldTemplateHeader
700 $out.= $this->intoTemplate(array(
701 'PALETTE' => $this->printPalette($palParts)
703 $this->palFieldTemplate
706 // 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.
707 if ($this->isPalettesCollapsed($table,$palette) && $collapsedHeader) {
708 $pC= $this->intoTemplate(array(
709 '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),
711 $this->palFieldTemplate
719 * Returns the form HTML code for a database table field.
721 * @param string The table name
722 * @param string The field name
723 * @param array The record to edit from the database table.
724 * @param string Alternative field name label to show.
725 * @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).
726 * @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.
727 * @param integer The palette pointer.
728 * @return mixed String (normal) or array (palettes)
730 function getSingleField($table,$field,$row,$altName='',$palette=0,$extra='',$pal=0) {
731 global $TCA,$BE_USER;
735 $PA['altName'] = $altName;
736 $PA['palette'] = $palette;
737 $PA['extra'] = $extra;
740 // Make sure to load full $TCA array for the table:
741 t3lib_div
::loadTCA($table);
743 // Get the TCA configuration for the current field:
744 $PA['fieldConf'] = $TCA[$table]['columns'][$field];
745 $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
747 // Now, check if this field is configured and editable (according to excludefields + other configuration)
748 if ( is_array($PA['fieldConf']) &&
749 (!$PA['fieldConf']['exclude'] ||
$BE_USER->check('non_exclude_fields',$table.':'.$field)) &&
750 $PA['fieldConf']['config']['form_type']!='passthrough' &&
751 ($this->RTEenabled ||
!$PA['fieldConf']['config']['showIfRTE']) &&
752 (!$PA['fieldConf']['displayCond'] ||
$this->isDisplayCondition($PA['fieldConf']['displayCond'],$row)) &&
753 (!$TCA[$table]['ctrl']['languageField'] ||
$PA['fieldConf']['l10n_display'] ||
strcmp($PA['fieldConf']['l10n_mode'],'exclude') ||
$row[$TCA[$table]['ctrl']['languageField']]<=0) &&
754 (!$TCA[$table]['ctrl']['languageField'] ||
!$this->localizationMode ||
$this->localizationMode
===$PA['fieldConf']['l10n_cat'])
759 // Fetching the TSconfig for the current table/field. This includes the $row which means that
760 $PA['fieldTSConfig'] = $this->setTSconfig($table,$row,$field);
762 // If the field is NOT disabled from TSconfig (which it could have been) then render it
763 if (!$PA['fieldTSConfig']['disabled']) {
766 $PA['itemFormElName']=$this->prependFormFieldNames
.'['.$table.']['.$row['uid'].']['.$field.']'; // Form field name
767 $PA['itemFormElName_file']=$this->prependFormFieldNames_file
.'['.$table.']['.$row['uid'].']['.$field.']'; // Form field name, in case of file uploads
768 $PA['itemFormElValue']=$row[$field]; // The value to show in the form field.
770 // set field to read-only if configured for translated records to show default language content as readonly
771 if ($PA['fieldConf']['l10n_display'] AND t3lib_div
::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly') AND $row[$TCA[$table]['ctrl']['languageField']]) {
772 $PA['fieldConf']['config']['readOnly'] = true;
773 $PA['itemFormElValue'] = $this->defaultLanguageData
[$table.':'.$row['uid']][$field];
776 // 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"
778 ($TCA[$table]['ctrl']['type'] && !strcmp($field,$TCA[$table]['ctrl']['type'])) ||
779 ($TCA[$table]['ctrl']['requestUpdate'] && t3lib_div
::inList($TCA[$table]['ctrl']['requestUpdate'],$field))) {
780 if($GLOBALS['BE_USER']->jsConfirmation(1)) {
781 $alertMsgOnChange = 'if (confirm('.$GLOBALS['LANG']->JScharCode($this->getLL('m_onChangeAlert')).') && TBE_EDITOR_checkSubmit(-1)){ TBE_EDITOR_submitForm() };';
783 $alertMsgOnChange = 'if (TBE_EDITOR_checkSubmit(-1)){ TBE_EDITOR_submitForm() };';
786 $alertMsgOnChange = '';
789 // Render as a hidden field?
790 if (in_array($field,$this->hiddenFieldListArr
)) {
791 $this->hiddenFieldAccum
[]='<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
792 } else { // Render as a normal field:
794 // 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.
795 if (!$PA['palette']) {
796 if ($PA['pal'] && $this->isPalettesCollapsed($table,$PA['pal'])) {
797 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);
803 // onFocus attribute to add to the field:
804 $PA['onFocus'] = ($palJSfunc && !$BE_USER->uc
['dontShowPalettesOnFocusInAB']) ?
' onfocus="'.htmlspecialchars($palJSfunc).'"' : '';
808 $PA['label'] = $PA['altName'] ?
$PA['altName'] : $PA['fieldConf']['label'];
809 $PA['label'] = $this->sL($PA['label']);
810 // JavaScript code for event handlers:
811 $PA['fieldChangeFunc']=array();
812 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = "TBE_EDITOR_fieldChanged('".$table."','".$row['uid']."','".$field."','".$PA['itemFormElName']."');";
813 $PA['fieldChangeFunc']['alert']=$alertMsgOnChange;
815 // Based on the type of the item, call a render function:
816 $item = $this->getSingleField_SW($table,$field,$row,$PA);
819 // Add language + diff
820 if ($PA['fieldConf']['l10n_display'] && (t3lib_div
::inList($PA['fieldConf']['l10n_display'], 'hideDiff') || t3lib_div
::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly'))) {
821 $renderLanguageDiff = false;
823 $renderLanguageDiff = true;
826 if ($renderLanguageDiff) {
827 $item = $this->renderDefaultLanguageContent($table,$field,$row,$item);
828 $item = $this->renderDefaultLanguageDiff($table,$field,$row,$item);
830 // 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
831 $PA['label'] = t3lib_div
::deHSCentities(htmlspecialchars($PA['label']));
832 if (t3lib_div
::testInt($row['uid']) && $PA['fieldTSConfig']['linkTitleToSelf']) {
833 $lTTS_url = $this->backPath
.'alt_doc.php?edit['.$table.']['.$row['uid'].']=edit&columnsOnly='.$field.
834 ($PA['fieldTSConfig']['linkTitleToSelf.']['returnUrl']?
'&returnUrl='.rawurlencode($this->thisReturnUrl()):'');
835 $PA['label'] = '<a href="'.htmlspecialchars($lTTS_url).'">'.$PA['label'].'</a>';
838 // Create output value:
839 if ($PA['fieldConf']['config']['form_type']=='user' && $PA['fieldConf']['config']['noTableWrapping']) {
841 } elseif ($PA['palette']) {
844 'NAME'=>$PA['label'],
849 'HELP_ICON' => $this->helpTextIcon($table,$field,1)
851 $out = $this->addUserTemplateMarkers($out,$table,$field,$row,$PA);
855 'NAME'=>$PA['label'],
859 'HELP_ICON'=>$this->helpTextIcon($table,$field),
860 'HELP_TEXT'=>$this->helpText($table,$field),
861 'PAL_LINK_ICON'=>$thePalIcon,
864 $out = $this->addUserTemplateMarkers($out,$table,$field,$row,$PA);
866 $out=$this->intoTemplate($out);
869 } else $this->commentMessages
[]=$this->prependFormFieldNames
.'['.$table.']['.$row['uid'].']['.$field.']: Disabled by TSconfig';
871 // Return value (string or array)
876 * Rendering a single item for the form
878 * @param string Table name of record
879 * @param string Fieldname to render
880 * @param array The record
881 * @param array parameters array containing a lot of stuff. Value by Reference!
882 * @return string Returns the item as HTML code to insert
884 * @see getSingleField(), getSingleField_typeFlex_draw()
886 function getSingleField_SW($table,$field,$row,&$PA) {
887 $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
889 switch($PA['fieldConf']['config']['form_type']) {
891 $item = $this->getSingleField_typeInput($table,$field,$row,$PA);
894 $item = $this->getSingleField_typeText($table,$field,$row,$PA);
897 $item = $this->getSingleField_typeCheck($table,$field,$row,$PA);
900 $item = $this->getSingleField_typeRadio($table,$field,$row,$PA);
903 $item = $this->getSingleField_typeSelect($table,$field,$row,$PA);
906 $item = $this->getSingleField_typeGroup($table,$field,$row,$PA);
909 $item = $this->getSingleField_typeNone($table,$field,$row,$PA);
912 $item = $this->getSingleField_typeUser($table,$field,$row,$PA);
915 $item = $this->getSingleField_typeFlex($table,$field,$row,$PA);
918 $item = $this->getSingleField_typeUnknown($table,$field,$row,$PA);
943 /**********************************************************
945 * Rendering of each TCEform field type
947 ************************************************************/
950 * Generation of TCEform elements of the type "input"
951 * This will render a single-line input form field, possibly with various control/validation features
953 * @param string The table name of the record
954 * @param string The field name which this element is supposed to edit
955 * @param array The record data array where the value(s) for the field can be found
956 * @param array An array with additional configuration options.
957 * @return string The HTML code for the TCEform field
959 function getSingleField_typeInput($table,$field,$row,&$PA) {
960 // typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue)
961 // typo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off)
963 $config = $PA['fieldConf']['config'];
965 # $specConf = $this->getSpecConfForField($table,$row,$field);
966 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
967 $size = t3lib_div
::intInRange($config['size']?
$config['size']:30,5,$this->maxInputWidth
);
968 $evalList = t3lib_div
::trimExplode(',',$config['eval'],1);
971 if($this->renderReadonly ||
$config['readOnly']) {
972 $itemFormElValue = $PA['itemFormElValue'];
973 if (in_array('date',$evalList)) {
974 $config['format'] = 'date';
975 } elseif (in_array('date',$evalList)) {
976 $config['format'] = 'date';
977 } elseif (in_array('datetime',$evalList)) {
978 $config['format'] = 'datetime';
979 } elseif (in_array('time',$evalList)) {
980 $config['format'] = 'time';
982 if (in_array('password',$evalList)) {
983 $itemFormElValue = $itemFormElValue ?
'*********' : '';
985 return $this->getSingleField_typeNone_render($config, $itemFormElValue);
988 if (in_array('required',$evalList)) {
989 $this->requiredFields
[$table.'_'.$row['uid'].'_'.$field]=$PA['itemFormElName'];
992 $paramsList = "'".$PA['itemFormElName']."','".implode(',',$evalList)."','".trim($config['is_in'])."',".(isset($config['checkbox'])?
1:0).",'".$config['checkbox']."'";
993 if (isset($config['checkbox'])) {
994 // Setting default "click-checkbox" values for eval types "date" and "datetime":
995 $thisMidnight = mktime(0,0,0);
996 $checkSetValue = in_array('date',$evalList) ?
$thisMidnight : '';
997 $checkSetValue = in_array('datetime',$evalList) ?
time() : $checkSetValue;
999 $cOnClick = 'typo3FormFieldGet('.$paramsList.',1,\''.$checkSetValue.'\');'.implode('',$PA['fieldChangeFunc']);
1000 $item.='<input type="checkbox"'.$this->insertDefStyle('check').' name="'.$PA['itemFormElName'].'_cb" onclick="'.htmlspecialchars($cOnClick).'" />';
1003 $PA['fieldChangeFunc'] = array_merge(array('typo3FormFieldGet'=>'typo3FormFieldGet('.$paramsList.');'), $PA['fieldChangeFunc']);
1004 $mLgd = ($config['max']?
$config['max']:256);
1005 $iOnChange = implode('',$PA['fieldChangeFunc']);
1006 $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.
1007 $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.
1008 $this->extJSCODE
.='typo3FormFieldSet('.$paramsList.');';
1010 // going through all custom evaluations configured for this field
1011 foreach ($evalList as $evalData) {
1012 if (substr($evalData, 0, 3) == 'tx_') {
1013 $evalObj = t3lib_div
::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$evalData].':&'.$evalData);
1014 if(is_object($evalObj) && method_exists($evalObj, 'returnFieldJS')) {
1015 $this->extJSCODE
.= "\n\nfunction ".$evalData."(value) {\n".$evalObj->returnFieldJS()."\n}\n";
1020 // Creating an alternative item without the JavaScript handlers.
1021 $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'_hr" value="" />';
1022 $altItem.= '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
1024 // Wrap a wizard around the item?
1025 $item= $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'].'_hr',$specConf);
1031 * Generation of TCEform elements of the type "text"
1032 * This will render a <textarea> OR RTE area form field, possibly with various control/validation features
1034 * @param string The table name of the record
1035 * @param string The field name which this element is supposed to edit
1036 * @param array The record data array where the value(s) for the field can be found
1037 * @param array An array with additional configuration options.
1038 * @return string The HTML code for the TCEform field
1040 function getSingleField_typeText($table,$field,$row,&$PA) {
1043 $config = $PA['fieldConf']['config'];
1045 if($this->renderReadonly ||
$config['readOnly']) {
1046 return $this->getSingleField_typeNone_render($config, $PA['itemFormElValue']);
1049 // Setting columns number:
1050 $cols = t3lib_div
::intInRange($config['cols'] ?
$config['cols'] : 30, 5, $this->maxTextareaWidth
);
1052 // Setting number of rows:
1053 $origRows = $rows = t3lib_div
::intInRange($config['rows'] ?
$config['rows'] : 5, 1, 20);
1054 if (strlen($PA['itemFormElValue']) > $this->charsPerRow
*2) {
1055 $cols = $this->maxTextareaWidth
;
1056 $rows = t3lib_div
::intInRange(round(strlen($PA['itemFormElValue'])/$this->charsPerRow
), count(explode(chr(10),$PA['itemFormElValue'])), 20);
1057 if ($rows<$origRows) $rows = $origRows;
1061 $RTEwasLoaded = 0; // Set true, if the RTE is loaded; If not a normal textarea is shown.
1062 $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...
1064 // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. Traditionally, this is where RTE configuration has been found.
1065 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1067 // Setting up the altItem form field, which is a hidden field containing the value
1068 $altItem = '<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
1070 // If RTE is generally enabled (TYPO3_CONF_VARS and user settings)
1071 if ($this->RTEenabled
) {
1072 $p = t3lib_BEfunc
::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
1073 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.
1074 t3lib_BEfunc
::fixVersioningPid($table,$row);
1075 list($tscPID,$thePidValue) = $this->getTSCpid($table,$row['uid'],$row['pid']);
1077 // If the pid-value is not negative (that is, a pid could NOT be fetched)
1078 if ($thePidValue >= 0) {
1079 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc
::getPagesTSconfig($tscPID));
1080 $RTEtypeVal = t3lib_BEfunc
::getTCAtypeValue($table,$row);
1081 $thisConfig = t3lib_BEfunc
::RTEsetup($RTEsetup['properties'],$table,$field,$RTEtypeVal);
1083 if (!$thisConfig['disabled']) {
1084 if (!$this->disableRTE
) {
1085 $this->RTEcounter++
;
1087 // Find alternative relative path for RTE images/links:
1088 $eFile = t3lib_parsehtml_proc
::evalWriteFile($specConf['static_write'], $row);
1089 $RTErelPath = is_array($eFile) ?
dirname($eFile['relEditFile']) : '';
1091 // Get RTE object, draw form and set flag:
1092 $RTEobj = &t3lib_BEfunc
::RTEgetObj();
1093 $item = $RTEobj->drawRTE($this,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue);
1096 $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf,1);
1100 $RTEwouldHaveBeenLoaded = 1;
1101 $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!)';
1103 } else $this->commentMessages
[] = $PA['itemFormElName'].': RTE is disabled by the Page TSconfig, "RTE"-key (eg. by RTE.default.disabled=0 or such)';
1104 } else $this->commentMessages
[] = $PA['itemFormElName'].': PID value could NOT be fetched. Rare error, normally with new records.';
1106 if (!isset($specConf['richtext'])) $this->commentMessages
[] = $PA['itemFormElName'].': RTE was not configured for this field in TCA-types';
1107 if (!(!$p['flag'] ||
!$row[$p['flag']])) $this->commentMessages
[] = $PA['itemFormElName'].': Field-flag ('.$PA['flag'].') has been set to disable RTE!';
1111 // Display ordinary field if RTE was not loaded.
1112 if (!$RTEwasLoaded) {
1113 if ($specConf['rte_only']) { // Show message, if no RTE (field can only be edited with RTE!)
1114 $item = '<p><em>'.htmlspecialchars($this->getLL('l_noRTEfound')).'</em></p>';
1116 if ($specConf['nowrap']) {
1119 $wrap = ($config['wrap'] ?
$config['wrap'] : 'virtual');
1123 if ($specConf['fixed-font']) { $classes[] = 'fixed-font'; }
1124 if ($specConf['enable-tab']) { $classes[] = 'enable-tab'; }
1126 if (count($classes)) {
1127 $class = ' class="'.implode(' ',$classes).'"';
1130 $iOnChange = implode('',$PA['fieldChangeFunc']);
1132 <textarea name="'.$PA['itemFormElName'].'"'.$this->formWidthText($cols,$wrap).$class.' rows="'.$rows.'" wrap="'.$wrap.'" onchange="'.htmlspecialchars($iOnChange).'"'.$PA['onFocus'].'>'.
1133 t3lib_div
::formatForTextarea($PA['itemFormElValue']).
1135 $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf,$RTEwouldHaveBeenLoaded);
1139 // Return field HTML:
1144 * Generation of TCEform elements of the type "check"
1145 * This will render a check-box OR an array of checkboxes
1147 * @param string The table name of the record
1148 * @param string The field name which this element is supposed to edit
1149 * @param array The record data array where the value(s) for the field can be found
1150 * @param array An array with additional configuration options.
1151 * @return string The HTML code for the TCEform field
1153 function getSingleField_typeCheck($table,$field,$row,&$PA) {
1154 $config = $PA['fieldConf']['config'];
1157 if($this->renderReadonly ||
$config['readOnly']) {
1158 $disabled = ' disabled="disabled"';
1161 // Traversing the array of items:
1162 $selItems = $this->initItemArray($PA['fieldConf']);
1163 if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
1165 if (!count($selItems)) {
1166 $selItems[]=array('','');
1168 $thisValue = intval($PA['itemFormElValue']);
1170 $cols = intval($config['cols']);
1172 $item.= '<table border="0" cellspacing="0" cellpadding="0" class="typo3-TCEforms-checkboxArray">';
1173 for ($c=0;$c<count($selItems);$c++
) {
1175 if(!($c%
$cols)) { $item.='<tr>'; }
1176 $cBP = $this->checkBoxParams($PA['itemFormElName'],$thisValue,$c,count($selItems),implode('',$PA['fieldChangeFunc']));
1177 $cBName = $PA['itemFormElName'].'_'.$c;
1178 $item.= '<td nowrap="nowrap">'.
1179 '<input type="checkbox"'.$this->insertDefStyle('check').' value="1" name="'.$cBName.'"'.$cBP.$disabled.' />'.
1180 $this->wrapLabels(htmlspecialchars($p[0]).' ').
1182 if(($c%
$cols)+
1==$cols) {$item.='</tr>';}
1185 $rest=$cols-($c%
$cols);
1186 for ($c=0;$c<$rest;$c++
) {
1187 $item.= '<td></td>';
1189 if ($c>0) { $item.= '</tr>'; }
1193 for ($c=0;$c<count($selItems);$c++
) {
1195 $cBP = $this->checkBoxParams($PA['itemFormElName'],$thisValue,$c,count($selItems),implode('',$PA['fieldChangeFunc']));
1196 $cBName = $PA['itemFormElName'].'_'.$c;
1197 $item.= ($c>0?
'<br />':'').
1198 '<input type="checkbox"'.$this->insertDefStyle('check').' value="1" name="'.$cBName.'"'.$cBP.$PA['onFocus'].$disabled.' />'.
1199 htmlspecialchars($p[0]);
1203 $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($thisValue).'" />';
1210 * Generation of TCEform elements of the type "radio"
1211 * This will render a series of radio buttons.
1213 * @param string The table name of the record
1214 * @param string The field name which this element is supposed to edit
1215 * @param array The record data array where the value(s) for the field can be found
1216 * @param array An array with additional configuration options.
1217 * @return string The HTML code for the TCEform field
1219 function getSingleField_typeRadio($table,$field,$row,&$PA) {
1220 $config = $PA['fieldConf']['config'];
1223 if($this->renderReadonly ||
$config['readOnly']) {
1224 $disabled = ' disabled="disabled"';
1227 // Get items for the array:
1228 $selItems = $this->initItemArray($PA['fieldConf']);
1229 if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
1231 // Traverse the items, making the form elements:
1232 for ($c=0;$c<count($selItems);$c++
) {
1234 $rOnClick = implode('',$PA['fieldChangeFunc']);
1235 $rChecked = (!strcmp($p[1],$PA['itemFormElValue'])?
' checked="checked"':'');
1236 $item.= '<input type="radio"'.$this->insertDefStyle('radio').' name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($p[1]).'" onclick="'.htmlspecialchars($rOnClick).'"'.$rChecked.$PA['onFocus'].$disabled.' />'.
1237 htmlspecialchars($p[0]).
1245 * Generation of TCEform elements of the type "select"
1246 * This will render a selector box element, or possibly a special construction with two selector boxes. That depends on configuration.
1248 * @param string The table name of the record
1249 * @param string The field name which this element is supposed to edit
1250 * @param array The record data array where the value(s) for the field can be found
1251 * @param array An array with additional configuration options.
1252 * @return string The HTML code for the TCEform field
1254 function getSingleField_typeSelect($table,$field,$row,&$PA) {
1257 // Field configuration from TCA:
1258 $config = $PA['fieldConf']['config'];
1261 if($this->renderReadonly ||
$config['readOnly']) {
1262 $disabled = ' disabled="disabled"';
1265 // "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/.
1266 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1268 // Getting the selector box items from the system
1269 $selItems = $this->addSelectOptionsToItemArray($this->initItemArray($PA['fieldConf']),$PA['fieldConf'],$this->setTSconfig($table,$row),$field);
1270 $selItems = $this->addItems($selItems,$PA['fieldTSConfig']['addItems.']);
1271 if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
1273 // Possibly remove some items:
1274 $removeItems = t3lib_div
::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
1275 foreach($selItems as $tk => $p) {
1277 // Checking languages and authMode:
1278 $languageDeny = $TCA[$table]['ctrl']['languageField'] && !strcmp($TCA[$table]['ctrl']['languageField'], $field) && !$GLOBALS['BE_USER']->checkLanguageAccess($p[1]);
1279 $authModeDeny = $config['form_type']=='select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table,$field,$p[1],$config['authMode']);
1280 if (in_array($p[1],$removeItems) ||
$languageDeny ||
$authModeDeny) {
1281 unset($selItems[$tk]);
1282 } elseif (isset($PA['fieldTSConfig']['altLabels.'][$p[1]])) {
1283 $selItems[$tk][0]=$this->sL($PA['fieldTSConfig']['altLabels.'][$p[1]]);
1286 // Removing doktypes with no access:
1287 if ($table.'.'.$field == 'pages.doktype') {
1288 if (!($GLOBALS['BE_USER']->isAdmin() || t3lib_div
::inList($GLOBALS['BE_USER']->groupData
['pagetypes_select'],$p[1]))) {
1289 unset($selItems[$tk]);
1294 // Creating the label for the "No Matching Value" entry.
1295 $nMV_label = isset($PA['fieldTSConfig']['noMatchingValue_label']) ?
$this->sL($PA['fieldTSConfig']['noMatchingValue_label']) : '[ '.$this->getLL('l_noMatchingValue').' ]';
1297 // Prepare some values:
1298 $maxitems = intval($config['maxitems']);
1300 // If a SINGLE selector box...
1302 $item = $this->getSingleField_typeSelect_single($table,$field,$row,$PA,$config,$selItems,$nMV_label);
1303 } elseif (!strcmp($config['renderMode'],'checkbox')) { // Checkbox renderMode
1304 $item = $this->getSingleField_typeSelect_checkbox($table,$field,$row,$PA,$config,$selItems,$nMV_label);
1305 } elseif (!strcmp($config['renderMode'],'singlebox')) { // Single selector box renderMode
1306 $item = $this->getSingleField_typeSelect_singlebox($table,$field,$row,$PA,$config,$selItems,$nMV_label);
1307 } else { // Traditional multiple selector box:
1308 $item = $this->getSingleField_typeSelect_multiple($table,$field,$row,$PA,$config,$selItems,$nMV_label);
1313 $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
1314 $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf);
1321 * Creates a single-selector box
1322 * (Render function for getSingleField_typeSelect())
1324 * @param string See getSingleField_typeSelect()
1325 * @param string See getSingleField_typeSelect()
1326 * @param array See getSingleField_typeSelect()
1327 * @param array See getSingleField_typeSelect()
1328 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1329 * @param array Items available for selection
1330 * @param string Label for no-matching-value
1331 * @return string The HTML code for the item
1332 * @see getSingleField_typeSelect()
1334 function getSingleField_typeSelect_single($table,$field,$row,&$PA,$config,$selItems,$nMV_label) {
1339 $noMatchingValue = 1;
1341 $selicons = array();
1342 $onlySelectedIconShown = 0;
1343 $size = intval($config['size']);
1346 if($this->renderReadonly ||
$config['readOnly']) {
1347 $disabled = ' disabled="disabled"';
1348 $onlySelectedIconShown = 1;
1351 // Icon configuration:
1352 if ($config['suppress_icons']=='IF_VALUE_FALSE') {
1353 $suppressIcons = !$PA['itemFormElValue'] ?
1 : 0;
1354 } elseif ($config['suppress_icons']=='ONLY_SELECTED') {
1356 $onlySelectedIconShown=1;
1357 } elseif ($config['suppress_icons']) {
1359 } else $suppressIcons = 0;
1361 // Traverse the Array of selector box items:
1362 foreach($selItems as $p) {
1363 $sM = (!strcmp($PA['itemFormElValue'],$p[1])?
' selected="selected"':'');
1366 $noMatchingValue = 0;
1369 // Getting style attribute value (for icons):
1370 if ($config['iconsInOptionTags']) {
1371 $styleAttrValue = $this->optionTagStyle($p[2]);
1374 // Compiling the <option> tag:
1375 $opt[]= '<option value="'.htmlspecialchars($p[1]).'"'.
1377 ($styleAttrValue ?
' style="'.htmlspecialchars($styleAttrValue).'"' : '').
1378 (!strcmp($p[1],'--div--') ?
' class="c-divider"' : '').
1379 '>'.t3lib_div
::deHSCentities(htmlspecialchars($p[0])).'</option>';
1381 // If there is an icon for the selector box (rendered in table under)...:
1382 if ($p[2] && !$suppressIcons && (!$onlySelectedIconShown ||
$sM)) {
1383 list($selIconFile,$selIconInfo)=$this->getIcon($p[2]);
1384 $iOnClick = $this->elName($PA['itemFormElName']).'.selectedIndex='.$c.'; '.implode('',$PA['fieldChangeFunc']).$this->blur().'return false;';
1386 (!$onlySelectedIconShown ?
'<a href="#" onclick="'.htmlspecialchars($iOnClick).'">' : '').
1387 '<img src="'.$selIconFile.'" '.$selIconInfo[3].' vspace="2" border="0" title="'.htmlspecialchars($p[0]).'" alt="'.htmlspecialchars($p[0]).'" />'.
1388 (!$onlySelectedIconShown ?
'</a>' : ''),
1394 // No-matching-value:
1395 if ($PA['itemFormElValue'] && $noMatchingValue && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1396 $nMV_label = @sprintf
($nMV_label, $PA['itemFormElValue']);
1397 $opt[]= '<option value="'.htmlspecialchars($PA['itemFormElValue']).'" selected="selected">'.htmlspecialchars($nMV_label).'</option>';
1400 // Create item form fields:
1401 $sOnChange = 'if (this.options[this.selectedIndex].value==\'--div--\') {this.selectedIndex='.$sI.';} '.implode('',$PA['fieldChangeFunc']);
1403 $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...
1405 $item.= '<select name="'.$PA['itemFormElName'].'"'.
1406 $this->insertDefStyle('select').
1407 ($size?
' size="'.$size.'"':'').
1408 ' onchange="'.htmlspecialchars($sOnChange).'"'.
1409 $PA['onFocus'].$disabled.'>';
1410 $item.= implode('',$opt);
1411 $item.= '</select>';
1413 // Create icon table:
1414 if (count($selicons)) {
1415 $item.='<table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-selectIcons">';
1416 $selicon_cols = intval($config['selicon_cols']);
1417 if (!$selicon_cols) $selicon_cols=count($selicons);
1418 $sR = ceil(count($selicons)/$selicon_cols);
1419 $selicons = array_pad($selicons,$sR*$selicon_cols,'');
1420 for($sa=0;$sa<$sR;$sa++
) {
1422 for($sb=0;$sb<$selicon_cols;$sb++
) {
1423 $sk=($sa*$selicon_cols+
$sb);
1424 $imgN = 'selIcon_'.$table.'_'.$row['uid'].'_'.$field.'_'.$selicons[$sk][1];
1425 $imgS = ($selicons[$sk][2]?
$this->backPath
.'gfx/content_selected.gif':'clear.gif');
1426 $item.='<td><img name="'.htmlspecialchars($imgN).'" src="'.$imgS.'" width="7" height="10" alt="" /></td>';
1427 $item.='<td>'.$selicons[$sk][0].'</td>';
1438 * Creates a checkbox list (renderMode = "checkbox")
1439 * (Render function for getSingleField_typeSelect())
1441 * @param string See getSingleField_typeSelect()
1442 * @param string See getSingleField_typeSelect()
1443 * @param array See getSingleField_typeSelect()
1444 * @param array See getSingleField_typeSelect()
1445 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1446 * @param array Items available for selection
1447 * @param string Label for no-matching-value
1448 * @return string The HTML code for the item
1449 * @see getSingleField_typeSelect()
1451 function getSingleField_typeSelect_checkbox($table,$field,$row,&$PA,$config,$selItems,$nMV_label) {
1453 // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
1454 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
1457 if($this->renderReadonly ||
$config['readOnly']) {
1458 $disabled = ' disabled="disabled"';
1461 // Traverse the Array of selector box items:
1465 $sOnChange = implode('',$PA['fieldChangeFunc']);
1466 $setAll = array(); // Used to accumulate the JS needed to restore the original selection.
1467 foreach($selItems as $p) {
1468 // Non-selectable element:
1469 if (!strcmp($p[1],'--div--')) {
1470 if (count($setAll)) {
1474 '<a href="#" onclick="'.htmlspecialchars(implode('',$setAll).' return false;').'">'.
1475 htmlspecialchars($this->getLL('l_setAllCheckboxes')).
1482 <tr class="c-header">
1483 <td colspan="2">'.htmlspecialchars($p[0]).'</td>
1486 // Selected or not by default:
1488 if (isset($itemArray[$p[1]])) {
1489 $sM = ' checked="checked"';
1490 unset($itemArray[$p[1]]);
1496 list($selIconFile,$selIconInfo) = $this->getIcon($p[2]);
1500 $onClickCell = $this->elName($PA['itemFormElName'].'['.$c.']').'.checked=!'.$this->elName($PA['itemFormElName'].'['.$c.']').'.checked;';
1501 $onClick = 'this.attributes.getNamedItem("class").nodeValue = '.$this->elName($PA['itemFormElName'].'['.$c.']').'.checked ? "c-selectedItem" : "";';
1502 $setAll[] = $this->elName($PA['itemFormElName'].'['.$c.']').'.checked=1;';
1504 <tr class="'.($sM ?
'c-selectedItem' : '').'" onclick="'.htmlspecialchars($onClick).'" style="cursor: pointer;">
1505 <td><input type="checkbox"'.$this->insertDefStyle('check').' name="'.htmlspecialchars($PA['itemFormElName'].'['.$c.']').'" value="'.htmlspecialchars($p[1]).'"'.$sM.' onclick="'.htmlspecialchars($sOnChange).'"'.$PA['onFocus'].' /></td>
1506 <td class="c-labelCell" onclick="'.htmlspecialchars($onClickCell).'">'.
1507 ($selIconFile ?
'<img src="'.$selIconFile.'" '.$selIconInfo[3].' vspace="2" border="0" class="absmiddle" style="margin-right: 4px;" alt="" />' : '').
1508 t3lib_div
::deHSCentities(htmlspecialchars($p[0])).
1509 (strcmp($p[3],'') ?
'<br/><p class="c-descr">'.nl2br(trim(htmlspecialchars($p[3]))).'</p>' : '').
1516 // Remaining checkboxes will get their set-all link:
1517 if (count($setAll)) {
1521 '<a href="#" onclick="'.htmlspecialchars(implode('',$setAll).' return false;').'">'.
1522 htmlspecialchars($this->getLL('l_setAllCheckboxes')).
1528 // Remaining values (invalid):
1529 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1530 foreach($itemArray as $theNoMatchValue => $temp) {
1531 // Compile <checkboxes> tag:
1532 array_unshift($tRows,'
1533 <tr class="c-invalidItem">
1534 <td><input type="checkbox"'.$this->insertDefStyle('check').' name="'.htmlspecialchars($PA['itemFormElName'].'['.$c.']').'" value="'.htmlspecialchars($theNoMatchValue).'" checked="checked" onclick="'.htmlspecialchars($sOnChange).'"'.$PA['onFocus'].$disabled.' /></td>
1535 <td class="c-labelCell">'.
1536 t3lib_div
::deHSCentities(htmlspecialchars(@sprintf
($nMV_label, $theNoMatchValue))).
1543 // Add an empty hidden field which will send a blank value if all items are unselected.
1544 $item.='<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="" />';
1546 // Implode rows in table:
1548 <table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-select-checkbox">'.
1549 implode('',$tRows).'
1557 * Creates a selectorbox list (renderMode = "singlebox")
1558 * (Render function for getSingleField_typeSelect())
1560 * @param string See getSingleField_typeSelect()
1561 * @param string See getSingleField_typeSelect()
1562 * @param array See getSingleField_typeSelect()
1563 * @param array See getSingleField_typeSelect()
1564 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1565 * @param array Items available for selection
1566 * @param string Label for no-matching-value
1567 * @return string The HTML code for the item
1568 * @see getSingleField_typeSelect()
1570 function getSingleField_typeSelect_singlebox($table,$field,$row,&$PA,$config,$selItems,$nMV_label) {
1572 // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
1573 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
1576 if($this->renderReadonly ||
$config['readOnly']) {
1577 $disabled = ' disabled="disabled"';
1580 // Traverse the Array of selector box items:
1582 $restoreCmd = array(); // Used to accumulate the JS needed to restore the original selection.
1584 foreach($selItems as $p) {
1585 // Selected or not by default:
1587 if (isset($itemArray[$p[1]])) {
1588 $sM = ' selected="selected"';
1589 $restoreCmd[] = $this->elName($PA['itemFormElName'].'[]').'.options['.$c.'].selected=1;';
1590 unset($itemArray[$p[1]]);
1593 // Non-selectable element:
1595 if (!strcmp($p[1],'--div--')) {
1596 $nonSel = ' onclick="this.selected=0;" class="c-divider"';
1599 // Icon style for option tag:
1600 if ($config['iconsInOptionTags']) {
1601 $styleAttrValue = $this->optionTagStyle($p[2]);
1604 // Compile <option> tag:
1605 $opt[] = '<option value="'.htmlspecialchars($p[1]).'"'.
1608 ($styleAttrValue ?
' style="'.htmlspecialchars($styleAttrValue).'"' : '').
1609 '>'.t3lib_div
::deHSCentities(htmlspecialchars($p[0])).'</option>';
1613 // Remaining values:
1614 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1615 foreach($itemArray as $theNoMatchValue => $temp) {
1616 // Compile <option> tag:
1617 array_unshift($opt,'<option value="'.htmlspecialchars($theNoMatchValue).'" selected="selected">'.t3lib_div
::deHSCentities(htmlspecialchars(@sprintf
($nMV_label, $theNoMatchValue))).'</option>');
1621 // Compile selector box:
1622 $sOnChange = implode('',$PA['fieldChangeFunc']);
1623 $selector_itemListStyle = isset($config['itemListStyle']) ?
' style="'.htmlspecialchars($config['itemListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle
.'"';
1624 $size = intval($config['size']);
1625 $size = $config['autoSizeMax'] ? t3lib_div
::intInRange(count($selItems)+
1,t3lib_div
::intInRange($size,1),$config['autoSizeMax']) : $size;
1626 $selectBox = '<select name="'.$PA['itemFormElName'].'[]"'.
1627 $this->insertDefStyle('select').
1628 ($size ?
' size="'.$size.'"' : '').
1629 ' multiple="multiple" onchange="'.htmlspecialchars($sOnChange).'"'.
1631 $selector_itemListStyle.
1638 // Add an empty hidden field which will send a blank value if all items are unselected.
1640 $item.='<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="" />';
1643 // Put it all into a table:
1645 <table border="0" cellspacing="0" cellpadding="0" width="1" class="typo3-TCEforms-select-singlebox">
1651 htmlspecialchars($this->getLL('l_holdDownCTRL')).
1655 <a href="#" onclick="'.htmlspecialchars($this->elName($PA['itemFormElName'].'[]').'.selectedIndex=-1;'.implode('',$restoreCmd).' return false;').'">'.
1656 '<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/history.gif','width="13" height="12"').' title="'.htmlspecialchars($this->getLL('l_revertSelection')).'" alt="" />'.
1667 * Creates a multiple-selector box (two boxes, side-by-side)
1668 * (Render function for getSingleField_typeSelect())
1670 * @param string See getSingleField_typeSelect()
1671 * @param string See getSingleField_typeSelect()
1672 * @param array See getSingleField_typeSelect()
1673 * @param array See getSingleField_typeSelect()
1674 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1675 * @param array Items available for selection
1676 * @param string Label for no-matching-value
1677 * @return string The HTML code for the item
1678 * @see getSingleField_typeSelect()
1680 function getSingleField_typeSelect_multiple($table,$field,$row,&$PA,$config,$selItems,$nMV_label) {
1683 if($this->renderReadonly ||
$config['readOnly']) {
1684 $disabled = ' disabled="disabled"';
1687 // Setting this hidden field (as a flag that JavaScript can read out)
1689 $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'_mul" value="'.($config['multiple']?
1:0).'" />';
1692 // Set max and min items:
1693 $maxitems = t3lib_div
::intInRange($config['maxitems'],0);
1694 if (!$maxitems) $maxitems=100000;
1695 $minitems = t3lib_div
::intInRange($config['minitems'],0);
1697 // Register the required number of elements:
1698 $this->requiredElements
[$PA['itemFormElName']] = array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field);
1700 // Get "removeItems":
1701 $removeItems = t3lib_div
::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
1703 // Perform modification of the selected items array:
1704 $itemArray = t3lib_div
::trimExplode(',',$PA['itemFormElValue'],1);
1705 foreach($itemArray as $tk => $tv) {
1706 $tvP = explode('|',$tv,2);
1707 $evalValue = rawurldecode($tvP[0]);
1708 $isRemoved = in_array($evalValue,$removeItems) ||
($config['form_type']=='select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table,$field,$evalValue,$config['authMode']));
1709 if ($isRemoved && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1710 $tvP[1] = rawurlencode(@sprintf
($nMV_label, $evalValue));
1711 } elseif (isset($PA['fieldTSConfig']['altLabels.'][$evalValue])) {
1712 $tvP[1] = rawurlencode($this->sL($PA['fieldTSConfig']['altLabels.'][$evalValue]));
1714 $itemArray[$tk] = implode('|',$tvP);
1716 $itemsToSelect = '';
1719 // Create option tags:
1721 $styleAttrValue = '';
1722 foreach($selItems as $p) {
1723 if ($config['iconsInOptionTags']) {
1724 $styleAttrValue = $this->optionTagStyle($p[2]);
1726 $opt[]= '<option value="'.htmlspecialchars($p[1]).'"'.
1727 ($styleAttrValue ?
' style="'.htmlspecialchars($styleAttrValue).'"' : '').
1728 '>'.htmlspecialchars($p[0]).'</option>';
1731 // Put together the selector box:
1732 $selector_itemListStyle = isset($config['itemListStyle']) ?
' style="'.htmlspecialchars($config['itemListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle
.'"';
1733 $size = intval($config['size']);
1734 $size = $config['autoSizeMax'] ? t3lib_div
::intInRange(count($itemArray)+
1,t3lib_div
::intInRange($size,1),$config['autoSizeMax']) : $size;
1735 if ($config['exclusiveKeys']) {
1736 $sOnChange = 'setFormValueFromBrowseWin(\''.$PA['itemFormElName'].'\',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text,\''.$config['exclusiveKeys'].'\'); ';
1738 $sOnChange = 'setFormValueFromBrowseWin(\''.$PA['itemFormElName'].'\',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text); ';
1740 $sOnChange .= implode('',$PA['fieldChangeFunc']);
1742 <select name="'.$PA['itemFormElName'].'_sel"'.
1743 $this->insertDefStyle('select').
1744 ($size ?
' size="'.$size.'"' : '').
1745 ' onchange="'.htmlspecialchars($sOnChange).'"'.
1747 $selector_itemListStyle.'>
1753 // Pass to "dbFileIcons" function:
1756 'autoSizeMax' => t3lib_div
::intInRange($config['autoSizeMax'],0),
1757 'style' => isset($config['selectedListStyle']) ?
' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle
.'"',
1758 'dontShowMoveIcons' => ($maxitems<=1),
1759 'maxitems' => $maxitems,
1762 'selector' => $this->getLL('l_selected').':<br />',
1763 'items' => $this->getLL('l_items').':<br />'
1766 'thumbnails' => $itemsToSelect,
1767 'readOnly' => $disabled
1769 $item.= $this->dbFileIcons($PA['itemFormElName'],'','',$itemArray,'',$params,$PA['onFocus']);
1775 * Generation of TCEform elements of the type "group"
1776 * This will render a selectorbox into which elements from either the file system or database can be inserted. Relations.
1778 * @param string The table name of the record
1779 * @param string The field name which this element is supposed to edit
1780 * @param array The record data array where the value(s) for the field can be found
1781 * @param array An array with additional configuration options.
1782 * @return string The HTML code for the TCEform field
1784 function getSingleField_typeGroup($table,$field,$row,&$PA) {
1786 $config = $PA['fieldConf']['config'];
1787 $internal_type = $config['internal_type'];
1788 $show_thumbs = $config['show_thumbs'];
1789 $size = intval($config['size']);
1790 $maxitems = t3lib_div
::intInRange($config['maxitems'],0);
1791 if (!$maxitems) $maxitems=100000;
1792 $minitems = t3lib_div
::intInRange($config['minitems'],0);
1793 $allowed = $config['allowed'];
1794 $disallowed = $config['disallowed'];
1797 if($this->renderReadonly ||
$config['readOnly']) {
1798 $disabled = ' disabled="disabled"';
1801 $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'_mul" value="'.($config['multiple']?
1:0).'"'.$disabled.' />';
1802 $this->requiredElements
[$PA['itemFormElName']] = array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field);
1805 // "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/.
1806 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1808 // Acting according to either "file" or "db" type:
1809 switch((string)$config['internal_type']) {
1810 case 'file': // If the element is of the internal type "file":
1812 // Creating string showing allowed types:
1813 $tempFT = t3lib_div
::trimExplode(',',$allowed,1);
1814 if (!count($tempFT)) {$info.='*';}
1815 foreach($tempFT as $ext) {
1817 $info.=strtoupper($ext).' ';
1820 // Creating string, showing disallowed types:
1821 $tempFT_dis = t3lib_div
::trimExplode(',',$disallowed,1);
1822 if (count($tempFT_dis)) {$info.='<br />';}
1823 foreach($tempFT_dis as $ext) {
1825 $info.='-'.strtoupper($ext).' ';
1829 // Making the array of file items:
1830 $itemArray = t3lib_div
::trimExplode(',',$PA['itemFormElValue'],1);
1832 // Showing thumbnails:
1836 foreach($itemArray as $imgRead) {
1837 $imgP = explode('|',$imgRead);
1840 $rowCopy[$field] = $imgP[0];
1842 // Icon + clickmenu:
1843 $absFilePath = t3lib_div
::getFileAbsFileName($config['uploadfolder'].'/'.$imgP[0]);
1845 $fI = pathinfo($imgP[0]);
1846 $fileIcon = t3lib_BEfunc
::getFileIcon(strtolower($fI['extension']));
1847 $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="" />';
1849 $imgs[] = '<span class="nobr">'.t3lib_BEfunc
::thumbCode($rowCopy,$table,$field,$this->backPath
,'thumbs.php',$config['uploadfolder'],0,' align="middle"').
1850 ($absFilePath ?
$this->getClickMenu($fileIcon, $absFilePath) : $fileIcon).
1854 $thumbsnail = implode('<br />',$imgs);
1857 // Creating the element:
1860 'dontShowMoveIcons' => ($maxitems<=1),
1861 'autoSizeMax' => t3lib_div
::intInRange($config['autoSizeMax'],0),
1862 'maxitems' => $maxitems,
1863 'style' => isset($config['selectedListStyle']) ?
' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle
.'"',
1865 'thumbnails' => $thumbsnail,
1866 'readOnly' => $disabled
1868 $item.= $this->dbFileIcons($PA['itemFormElName'],'file',implode(',',$tempFT),$itemArray,'',$params,$PA['onFocus']);
1871 // Adding the upload field:
1872 if ($this->edit_docModuleUpload
) $item.='<input type="file" name="'.$PA['itemFormElName_file'].'"'.$this->formWidth().' size="60" />';
1875 case 'db': // If the element is of the internal type "db":
1877 // Creating string showing allowed types:
1878 $tempFT = t3lib_div
::trimExplode(',',$allowed,1);
1879 if (!strcmp(trim($tempFT[0]),'*')) {
1880 $info.='<span class="nobr"> '.
1881 htmlspecialchars($this->getLL('l_allTables')).
1884 while(list(,$theT)=each($tempFT)) {
1886 $info.='<span class="nobr"> '.
1887 t3lib_iconWorks
::getIconImage($theT,array(),$this->backPath
,'align="top"').
1888 htmlspecialchars($this->sL($GLOBALS['TCA'][$theT]['ctrl']['title'])).
1894 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
1895 $itemArray = array();
1899 $temp_itemArray = t3lib_div
::trimExplode(',',$PA['itemFormElValue'],1);
1900 foreach($temp_itemArray as $dbRead) {
1901 $recordParts = explode('|',$dbRead);
1902 list($this_table,$this_uid) = t3lib_BEfunc
::splitTable_Uid($recordParts[0]);
1903 $itemArray[] = array('table'=>$this_table, 'id'=>$this_uid);
1904 if (!$disabled && $show_thumbs) {
1905 $rr = t3lib_BEfunc
::getRecordWSOL($this_table,$this_uid);
1906 $imgs[] = '<span class="nobr">'.
1907 $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).
1909 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>'.
1914 if (!$disabled && $show_thumbs) {
1915 $thumbsnail = implode('<br />',$imgs);
1918 // Creating the element:
1921 'dontShowMoveIcons' => ($maxitems<=1),
1922 'autoSizeMax' => t3lib_div
::intInRange($config['autoSizeMax'],0),
1923 'maxitems' => $maxitems,
1924 'style' => isset($config['selectedListStyle']) ?
' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle
.'"',
1926 'thumbnails' => $thumbsnail,
1927 'readOnly' => $disabled
1929 $item.= $this->dbFileIcons($PA['itemFormElName'],'db',implode(',',$tempFT),$itemArray,'',$params,$PA['onFocus']);
1935 $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
1937 $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf);
1944 * Generation of TCEform elements of the type "none"
1945 * This will render a non-editable display of the content of the field.
1947 * @param string The table name of the record
1948 * @param string The field name which this element is supposed to edit
1949 * @param array The record data array where the value(s) for the field can be found
1950 * @param array An array with additional configuration options.
1951 * @return string The HTML code for the TCEform field
1953 function getSingleField_typeNone($table,$field,$row,&$PA) {
1955 $config = $PA['fieldConf']['config'];
1956 $itemValue = $PA['itemFormElValue'];
1958 return $this->getSingleField_typeNone_render($config,$itemValue);
1962 * HTML rendering of a value which is not editable.
1964 * @param array Configuration for the display
1965 * @param string The value to display
1966 * @return string The HTML code for the display
1967 * @see getSingleField_typeNone();
1969 function getSingleField_typeNone_render($config,$itemValue) {
1971 // is colorScheme[0] the right value?
1972 $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;';
1974 if ($config['format']) {
1975 $itemValue = $this->formatValue($config, $itemValue);
1978 $rows = intval($config['rows']);
1980 if(!$config['pass_content']) {
1981 $itemValue = nl2br(htmlspecialchars($itemValue));
1984 $cols = t3lib_div
::intInRange($config['cols'] ?
$config['cols'] : 30, 5, $this->maxTextareaWidth
);
1985 if (!$config['fixedRows']) {
1986 $origRows = $rows = t3lib_div
::intInRange($rows, 1, 20);
1987 if (strlen($itemValue)>$this->charsPerRow
*2) {
1988 $cols = $this->maxTextareaWidth
;
1989 $rows = t3lib_div
::intInRange(round(strlen($itemValue)/$this->charsPerRow
),count(explode(chr(10),$itemValue)),20);
1990 if ($rows<$origRows) $rows=$origRows;
1994 if ($this->docLarge
) $cols = round($cols*$this->form_largeComp
);
1995 $width = ceil($cols*$this->form_rowsToStylewidth
);
1996 // hardcoded: 12 is the height of the font
2000 <div style="'.htmlspecialchars($divStyle.' overflow:auto; height:'.$height.'px; width:'.$width.'px;').'" class="'.htmlspecialchars($this->formElClass('none')).'">'.
2004 if(!$config['pass_content']) {
2005 $itemValue = htmlspecialchars($itemValue);
2008 $cols = $config['cols']?
$config['cols']:($config['size']?
$config['size']:$this->maxInputWidth
);
2009 if ($this->docLarge
) $cols = round($cols*$this->form_largeComp
);
2010 $width = ceil($cols*$this->form_rowsToStylewidth
);
2012 // overflow:auto crashes mozilla here. Title tag is usefull when text is longer than the div box (overflow:hidden).
2014 <div style="'.htmlspecialchars($divStyle.' overflow:hidden; width:'.$width.'px;').'" class="'.htmlspecialchars($this->formElClass('none')).'" title="'.$itemValue.'">'.
2015 '<span class="nobr">'.(strcmp($itemValue,'')?
$itemValue:' ').'</span>'.
2023 * Handler for Flex Forms
2025 * @param string The table name of the record
2026 * @param string The field name which this element is supposed to edit
2027 * @param array The record data array where the value(s) for the field can be found
2028 * @param array An array with additional configuration options.
2029 * @return string The HTML code for the TCEform field
2031 function getSingleField_typeFlex($table,$field,$row,&$PA) {
2034 $dataStructArray = t3lib_BEfunc
::getFlexFormDS($PA['fieldConf']['config'],$row,$table);
2036 // Get data structure:
2037 if (is_array($dataStructArray)) {
2040 $xmlData = $PA['itemFormElValue'];
2041 $xmlHeaderAttributes = t3lib_div
::xmlGetHeaderAttribs($xmlData);
2042 $storeInCharset = strtolower($xmlHeaderAttributes['encoding']);
2043 if ($storeInCharset) {
2044 $currentCharset=$GLOBALS['LANG']->charSet
;
2045 $xmlData = $GLOBALS['LANG']->csConvObj
->conv($xmlData,$storeInCharset,$currentCharset,1);
2047 $editData=t3lib_div
::xml2array($xmlData);
2048 if (!is_array($editData)) { // Must be XML parsing error...
2050 } elseif (isset($editData['meta']) && !is_array($editData['meta'])) {
2051 $editData['meta'] = array();
2054 // Find the data structure if sheets are found:
2055 $sheet = $editData['meta']['currentSheetId'] ?
$editData['meta']['currentSheetId'] : 'sDEF'; // Sheet to display
2057 // Create sheet menu:
2058 // if (is_array($dataStructArray['sheets'])) {
2059 // #$item.=$this->getSingleField_typeFlex_sheetMenu($dataStructArray['sheets'], $PA['itemFormElName'].'[meta][currentSheetId]', $sheet).'<br />';
2062 // Create language menu:
2063 $langChildren = $dataStructArray['meta']['langChildren'] ?
1 : 0;
2064 $langDisabled = $dataStructArray['meta']['langDisable'] ?
1 : 0;
2066 $editData['meta']['currentLangId']=array();
2067 $languages = $this->getAvailableLanguages();
2069 foreach($languages as $lInfo) {
2070 if ($GLOBALS['BE_USER']->checkLanguageAccess($lInfo['uid'])) {
2071 $editData['meta']['currentLangId'][] = $lInfo['ISOcode'];
2074 if (!is_array($editData['meta']['currentLangId']) ||
!count($editData['meta']['currentLangId'])) {
2075 $editData['meta']['currentLangId']=array('DEF');
2078 $editData['meta']['currentLangId'] = array_unique($editData['meta']['currentLangId']);
2081 // if (!$langDisabled && count($languages) > 1) {
2082 // $item.=$this->getSingleField_typeFlex_langMenu($languages, $PA['itemFormElName'].'[meta][currentLangId]', $editData['meta']['currentLangId']).'<br />';
2085 $PA['_noEditDEF'] = FALSE;
2086 if ($langChildren ||
$langDisabled) {
2087 $rotateLang = array('DEF');
2089 if (!in_array('DEF',$editData['meta']['currentLangId'])) {
2090 array_unshift($editData['meta']['currentLangId'],'DEF');
2091 $PA['_noEditDEF'] = TRUE;
2093 $rotateLang = $editData['meta']['currentLangId'];
2097 if (is_array($dataStructArray['sheets'])) {
2098 $tabsToTraverse = array_keys($dataStructArray['sheets']);
2100 $tabsToTraverse = array($sheet);
2103 foreach($rotateLang as $lKey) {
2104 if (!$langChildren && !$langDisabled) {
2105 $item.= '<b>'.$lKey.':</b>';
2108 $tabParts = array();
2109 foreach($tabsToTraverse as $sheet) {
2110 $sheetCfg = $dataStructArray['sheets'][$sheet];
2111 list ($dataStruct, $sheet) = t3lib_div
::resolveSheetDefInDS($dataStructArray,$sheet);
2114 if (is_array($dataStruct['ROOT']) && is_array($dataStruct['ROOT']['el'])) {
2115 $cmdData = t3lib_div
::_GP('flexFormsCmdData');
2116 $lang = 'l'.$lKey; // Default language, other options are "lUK" or whatever country code (independant of system!!!)
2117 $PA['_valLang'] = $langChildren && !$langDisabled ?
$editData['meta']['currentLangId'] : 'DEF'; // Default language, other options are "lUK" or whatever country code (independant of system!!!)
2118 $PA['_lang'] = $lang;
2121 $tRows = $this->getSingleField_typeFlex_draw(
2122 $dataStruct['ROOT']['el'],
2123 $editData['data'][$sheet][$lang],
2124 $cmdData['data'][$sheet][$lang],
2129 '[data]['.$sheet.']['.$lang.']'
2131 $sheetContent= '<table border="0" cellpadding="1" cellspacing="1" class="typo3-TCEforms-flexForm">'.implode('',$tRows).'</table>';
2133 # $item = '<div style=" position:absolute;">'.$item.'</div>';
2134 //visibility:hidden;
2135 } else $sheetContent='Data Structure ERROR: No ROOT element found for sheet "'.$sheet.'".';
2138 $tabParts[] = array(
2139 'label' => ($sheetCfg['ROOT']['TCEforms']['sheetTitle'] ?
$this->sL($sheetCfg['ROOT']['TCEforms']['sheetTitle']) : $sheet),
2140 'description' => ($sheetCfg['ROOT']['TCEforms']['sheetDescription'] ?
$this->sL($sheetCfg['ROOT']['TCEforms']['sheetDescription']) : ''),
2141 'linkTitle' => ($sheetCfg['ROOT']['TCEforms']['sheetShortDescr'] ?
$this->sL($sheetCfg['ROOT']['TCEforms']['sheetShortDescr']) : ''),
2142 'content' => $sheetContent
2146 if (is_array($dataStructArray['sheets'])) {
2147 $item.= $this->getDynTabMenu($tabParts,'TCEFORMS:flexform:'.$PA['itemFormElName'].$PA['_lang']);
2149 $item.= $sheetContent;
2152 } else $item='Data Structure ERROR: '.$dataStructArray;
2158 * Creates the language menu for FlexForms:
2160 * @param [type] $languages: ...
2161 * @param [type] $elName: ...
2162 * @param [type] $selectedLanguage: ...
2163 * @param [type] $multi: ...
2164 * @return string HTML for menu
2166 function getSingleField_typeFlex_langMenu($languages,$elName,$selectedLanguage,$multi=1) {
2168 foreach($languages as $lArr) {
2169 $opt[]='<option value="'.htmlspecialchars($lArr['ISOcode']).'"'.(in_array($lArr['ISOcode'],$selectedLanguage)?
' selected="selected"':'').'>'.htmlspecialchars($lArr['title']).'</option>';
2172 $output = '<select name="'.$elName.'[]"'.($multi ?
' multiple="multiple" size="'.count($languages).'"' : '').'>'.implode('',$opt).'</select>';
2178 * Creates the menu for selection of the sheets:
2180 * @param array Sheet array for which to render the menu
2181 * @param string Form element name of the field containing the sheet pointer
2182 * @param string Current sheet key
2183 * @return string HTML for menu
2185 function getSingleField_typeFlex_sheetMenu($sArr,$elName,$sheetKey) {
2188 $pct = round(100/count($sArr));
2189 foreach($sArr as $sKey => $sheetCfg) {
2190 if ($GLOBALS['BE_USER']->jsConfirmation(1)) {
2191 $onClick = 'if (confirm('.$GLOBALS['LANG']->JScharCode($this->getLL('m_onChangeAlert')).') && TBE_EDITOR_checkSubmit(-1)){'.$this->elName($elName).".value='".$sKey."'; TBE_EDITOR_submitForm()};";
2193 $onClick = 'if(TBE_EDITOR_checkSubmit(-1)){ '.$this->elName($elName).".value='".$sKey."'; TBE_EDITOR_submitForm();}";
2197 $tCells[]='<td width="'.$pct.'%" style="'.($sKey==$sheetKey ?
'background-color: #9999cc; font-weight: bold;' : 'background-color: #aaaaaa;').' cursor: hand;" onclick="'.htmlspecialchars($onClick).'" align="center">'.
2198 ($sheetCfg['ROOT']['TCEforms']['sheetTitle'] ?
$this->sL($sheetCfg['ROOT']['TCEforms']['sheetTitle']) : $sKey).
2202 return '<table border="0" cellpadding="0" cellspacing="2" class="typo3-TCEforms-flexForm-sheetMenu"><tr>'.implode('',$tCells).'</tr></table>';
2206 * [Describe function...]
2208 * @param [type] $dataStruct: ...
2209 * @param [type] $editData: ...
2210 * @param [type] $cmdData: ...
2211 * @param [type] $table: ...
2212 * @param [type] $field: ...
2213 * @param [type] $row: ...
2214 * @param [type] $PA: ...
2215 * @param [type] $formPrefix: ...
2216 * @param [type] $level: ...
2217 * @param [type] $tRows: ...
2218 * @return [type] ...
2220 function getSingleField_typeFlex_draw($dataStruct,$editData,$cmdData,$table,$field,$row,&$PA,$formPrefix='',$level=0,$tRows=array()) {
2222 // Data Structure array must be ... and array of course...
2223 if (is_array($dataStruct)) {
2224 foreach($dataStruct as $key => $value) {
2225 if (is_array($value)) { // The value of each entry must be an array.
2227 // ********************
2229 // ********************
2233 $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>';;
2235 $rowCells['formEl']='';
2236 if ($value['type']=='array') {
2237 if ($value['section']) {
2238 // Render "NEW [container]" selectorbox:
2239 if (is_array($value['el'])) {
2241 $opt[]='<option value=""></option>';
2242 foreach($value['el'] as $kk => $vv) {
2243 $opt[]='<option value="'.$kk.'">'.htmlspecialchars('NEW "'.$value['el'][$kk]['tx_templavoila']['title'].'"').'</option>';
2245 $rowCells['formEl']='<select name="flexFormsCmdData'.$formPrefix.'['.$key.'][value]">'.implode('',$opt).'</select>';
2249 $tRows[]='<tr class="bgColor2">
2250 <td nowrap="nowrap" valign="top">'.$rowCells['title'].'</td>
2251 <td>'.$rowCells['formEl'].'</td>
2255 if (is_array($editData[$key]['el'])) {
2256 foreach($editData[$key]['el'] as $k3 => $v3) {
2258 $theType = key($v3);
2259 $theDat = $v3[$theType];
2260 $newSectionEl = $value['el'][$theType];
2261 if (is_array($newSectionEl)) {
2262 $tRows = $this->getSingleField_typeFlex_draw(
2263 array($theType => $newSectionEl),
2264 array($theType => $theDat),
2265 $cmdData[$key]['el'][$cc],
2270 $formPrefix.'['.$key.'][el]['.$cc.']',
2281 if ($cmdData[$key]['value']) {
2282 $newSectionEl = $value['el'][$cmdData[$key]['value']];
2283 if (is_array($newSectionEl)) {
2284 $tRows = $this->getSingleField_typeFlex_draw(
2285 array($cmdData[$key]['value'] => $newSectionEl),
2292 $formPrefix.'['.$key.'][el]['.($cc+
1).']',
2299 $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
2302 $tRows[]='<tr class="bgColor2">
2303 <td nowrap="nowrap" valign="top">'.
2304 '<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>'.
2305 '<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>'.
2306 '<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>'.
2307 $rowCells['title'].'</td>
2308 <td>'.$rowCells['formEl'].'</td>
2311 $tRows = $this->getSingleField_typeFlex_draw(
2313 $editData[$key]['el'],
2314 $cmdData[$key]['el'],
2319 $formPrefix.'['.$key.'][el]',
2325 } elseif (is_array($value['TCEforms']['config'])) { // Rendering a single form element:
2327 if (is_array($PA['_valLang'])) {
2328 $rotateLang = $PA['_valLang'];
2330 $rotateLang = array($PA['_valLang']);
2333 foreach($rotateLang as $vDEFkey) {
2334 $vDEFkey = 'v'.$vDEFkey;
2336 if (!$value['TCEforms']['displayCond'] ||
$this->isDisplayCondition($value['TCEforms']['displayCond'],$editData,$vDEFkey)) {
2338 $fakePA['fieldConf']=array(
2339 'label' => $this->sL(trim($value['TCEforms']['label'])),
2340 'config' => $value['TCEforms']['config'],
2341 'defaultExtras' => $value['TCEforms']['defaultExtras'],
2342 'onChange' => $value['TCEforms']['onChange']
2344 if ($PA['_noEditDEF'] && $PA['_lang']==='lDEF') {
2345 $fakePA['fieldConf']['config'] = array(
2352 $fakePA['fieldConf']['onChange'] == 'reload' ||
2353 ($GLOBALS['TCA'][$table]['ctrl']['type'] && !strcmp($key,$GLOBALS['TCA'][$table]['ctrl']['type'])) ||
2354 ($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'] && t3lib_div
::inList($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'],$key))) {
2355 if ($GLOBALS['BE_USER']->jsConfirmation(1)) {
2356 $alertMsgOnChange = 'if (confirm('.$GLOBALS['LANG']->JScharCode($this->getLL('m_onChangeAlert')).') && TBE_EDITOR_checkSubmit(-1)){ TBE_EDITOR_submitForm() };';
2358 $alertMsgOnChange = 'if(TBE_EDITOR_checkSubmit(-1)){ TBE_EDITOR_submitForm();}';
2361 $alertMsgOnChange = '';
2364 $fakePA['fieldChangeFunc']=$PA['fieldChangeFunc'];
2365 if (strlen($alertMsgOnChange)) {
2366 $fakePA['fieldChangeFunc']['alert']=$alertMsgOnChange;
2368 $fakePA['onFocus']=$PA['onFocus'];
2369 $fakePA['label']=$PA['label'];
2371 $fakePA['itemFormElName']=$PA['itemFormElName'].$formPrefix.'['.$key.']['.$vDEFkey.']';
2372 $fakePA['itemFormElName_file']=$PA['itemFormElName_file'].$formPrefix.'['.$key.']['.$vDEFkey.']';
2374 if(isset($editData[$key][$vDEFkey])) {
2375 $fakePA['itemFormElValue']=$editData[$key][$vDEFkey];
2377 $fakePA['itemFormElValue']=$fakePA['fieldConf']['config']['default'];
2380 $rowCells['formEl']= $this->getSingleField_SW($table,$field,$row,$fakePA);
2381 $rowCells['title']= htmlspecialchars($fakePA['fieldConf']['label']);
2383 if (!in_array('DEF',$rotateLang)) {
2384 $defInfo = '<div class="typo3-TCEforms-originalLanguageValue">'.nl2br(htmlspecialchars($editData[$key]['vDEF'])).' </div>';
2391 <td nowrap="nowrap" valign="top" class="bgColor5">'.$rowCells['title'].($vDEFkey=='vDEF' ?
'' : ' ('.$vDEFkey.')').'</td>
2392 <td class="bgColor4">'.$rowCells['formEl'].$defInfo.'</td>
2405 * Handler for unknown types.
2407 * @param string The table name of the record
2408 * @param string The field name which this element is supposed to edit
2409 * @param array The record data array where the value(s) for the field can be found
2410 * @param array An array with additional configuration options.
2411 * @return string The HTML code for the TCEform field
2413 function getSingleField_typeUnknown($table,$field,$row,&$PA) {
2414 $item='Unknown type: '.$PA['fieldConf']['config']['form_type'].'<br />';
2420 * User defined field type
2422 * @param string The table name of the record
2423 * @param string The field name which this element is supposed to edit
2424 * @param array The record data array where the value(s) for the field can be found
2425 * @param array An array with additional configuration options.
2426 * @return string The HTML code for the TCEform field
2428 function getSingleField_typeUser($table,$field,$row,&$PA) {
2429 $PA['table']=$table;
2430 $PA['field']=$field;
2435 return t3lib_div
::callUserFunction($PA['fieldConf']['config']['userFunc'],$PA,$this);
2443 /************************************************************
2445 * Field content processing
2447 ************************************************************/
2450 * Format field content of various types if $config['format'] is set to date, filesize, ..., user
2451 * This is primarily for the field type none but can be used for user field types for example
2453 * @param array Configuration for the display
2454 * @param string The value to display
2455 * @return string Formatted Field content
2457 function formatValue ($config, $itemValue) {
2458 $format = trim($config['format']);
2461 $option = trim($config['format.']['option']);
2463 if ($config['format.']['strftime']) {
2464 $value = strftime($option,$itemValue);
2466 $value = date($option,$itemValue);
2469 $value = date('d-m-Y',$itemValue);
2471 if ($config['format.']['appendAge']) {
2472 $value .= ' ('.t3lib_BEfunc
::calcAge((time()-$itemValue), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')).')';
2474 $itemValue = $value;
2476 case 'datetime': // compatibility with "eval" (type "input")
2477 $itemValue = date('H:i d-m-Y',$itemValue);
2479 case 'time': // compatibility with "eval" (type "input")
2480 $itemValue = date('H:i',$itemValue);
2482 case 'timesec': // compatibility with "eval" (type "input")
2483 $itemValue = date('H:i:s',$itemValue);
2485 case 'year': // compatibility with "eval" (type "input")
2486 $itemValue = date('Y',$itemValue);
2489 $baseArr = array('dec'=>'d','hex'=>'x','HEX'=>'X','oct'=>'o','bin'=>'b');
2490 $base = trim($config['format.']['base']);
2491 $format = $baseArr[$base] ?
$baseArr[$base] : 'd';
2492 $itemValue = sprintf('%'.$format,$itemValue);
2495 $precision = t3lib_div
::intInRange($config['format.']['precision'],1,10,2);
2496 $itemValue = sprintf('%.'.$precision.'f',$itemValue);
2499 $format = trim($config['format.']['option']);
2500 $itemValue = sprintf('%'.$format,$itemValue);
2503 $itemValue = md5($itemValue);
2506 $value = t3lib_div
::formatSize(intval($itemValue));
2507 if ($config['format.']['appendByteSize']) {
2508 $value .= ' ('.$itemValue.')';
2510 $itemValue = $value;
2513 $func = trim($config['format.']['userFunc']);
2516 'value' => $itemValue,
2517 'args' => $config['format.']['userFunc'],
2518 'config' => $config,
2521 $itemValue = t3lib_div
::callUserFunction($func,$params,$this);
2536 /************************************************************
2538 * "Configuration" fetching/processing functions
2540 ************************************************************/
2543 * Calculate and return the current "types" pointer value for a record
2545 * @param string The table name. MUST be in $TCA
2546 * @param array The row from the table, should contain at least the "type" field, if applicable.
2547 * @return string Return the "type" value for this record, ready to pick a "types" configuration from the $TCA array.
2549 function getRTypeNum($table,$row) {
2551 // If there is a "type" field configured...
2552 if ($TCA[$table]['ctrl']['type']) {
2553 $typeFieldName = $TCA[$table]['ctrl']['type'];
2554 $typeNum=$row[$typeFieldName]; // Get value of the row from the record which contains the type value.
2555 if (!strcmp($typeNum,'')) $typeNum=0; // If that value is an empty string, set it to "0" (zero)
2557 $typeNum = 0; // If no "type" field, then set to "0" (zero)
2560 $typeNum = (string)$typeNum; // Force to string. Necessary for eg '-1' to be recognized as a type value.
2561 if (!$TCA[$table]['types'][$typeNum]) { // However, if the type "0" is not found in the "types" array, then default to "1" (for historical reasons)
2569 * Used to adhoc-rearrange the field order normally set in the [types][showitem] list
2571 * @param array A [types][showitem] list of fields, exploded by ","
2572 * @return array Returns rearranged version (keys are changed around as well.)
2573 * @see getMainFields()
2575 function rearrange($fields) {
2576 $fO = array_flip(t3lib_div
::trimExplode(',',$this->fieldOrder
,1));
2579 while(list($cc,$content)=each($fields)) {
2580 $cP = t3lib_div
::trimExplode(';',$content);
2581 if (isset($fO[$cP[0]])) {
2582 $newFields[$fO[$cP[0]]] = $content;
2583 unset($fields[$cc]);
2587 $fields=array_merge($newFields,$fields); // Candidate for t3lib_div::array_merge() if integer-keys will some day make trouble...
2592 * Producing an array of field names NOT to display in the form, based on settings from subtype_value_field, bitmask_excludelist_bits etc.
2593 * Notice, this list is in NO way related to the "excludeField" flag
2595 * @param string Table name, MUST be in $TCA
2596 * @param array A record from table.
2597 * @param string A "type" pointer value, probably the one calculated based on the record array.
2598 * @return array Array with fieldnames as values. The fieldnames are those which should NOT be displayed "anyways"
2599 * @see getMainFields()
2601 function getExcludeElements($table,$row,$typeNum) {
2605 $excludeElements=array();
2607 // If a subtype field is defined for the type
2608 if ($TCA[$table]['types'][$typeNum]['subtype_value_field']) {
2609 $sTfield = $TCA[$table]['types'][$typeNum]['subtype_value_field'];
2610 if (trim($TCA[$table]['types'][$typeNum]['subtypes_excludelist'][$row[$sTfield]])) {
2611 $excludeElements=t3lib_div
::trimExplode(',',$TCA[$table]['types'][$typeNum]['subtypes_excludelist'][$row[$sTfield]],1);
2615 // If a bitmask-value field has been configured, then find possible fields to exclude based on that:
2616 if ($TCA[$table]['types'][$typeNum]['bitmask_value_field']) {
2617 $sTfield = $TCA[$table]['types'][$typeNum]['bitmask_value_field'];
2618 $sTValue = t3lib_div
::intInRange($row[$sTfield],0);
2619 if (is_array($TCA[$table]['types'][$typeNum]['bitmask_excludelist_bits'])) {
2620 reset($TCA[$table]['types'][$typeNum]['bitmask_excludelist_bits']);
2621 while(list($bitKey,$eList)=each($TCA[$table]['types'][$typeNum]['bitmask_excludelist_bits'])) {
2622 $bit=substr($bitKey,1);
2623 if (t3lib_div
::testInt($bit)) {
2624 $bit = t3lib_div
::intInRange($bit,0,30);
2626 (substr($bitKey,0,1)=='-' && !($sTValue&pow(2,$bit))) ||
2627 (substr($bitKey,0,1)=='+' && ($sTValue&pow(2,$bit)))
2629 $excludeElements = array_merge($excludeElements,t3lib_div
::trimExplode(',',$eList,1));
2636 // Return the array of elements:
2637 return $excludeElements;
2641 * Finds possible field to add to the form, based on subtype fields.
2643 * @param string Table name, MUST be in $TCA
2644 * @param array A record from table.
2645 * @param string A "type" pointer value, probably the one calculated based on the record array.
2646 * @return array An array containing two values: 1) Another array containing fieldnames to add and 2) the subtype value field.
2647 * @see getMainFields()
2649 function getFieldsToAdd($table,$row,$typeNum) {
2653 $addElements=array();
2655 // If a subtype field is defined for the type
2656 if ($TCA[$table]['types'][$typeNum]['subtype_value_field']) {
2657 $sTfield = $TCA[$table]['types'][$typeNum]['subtype_value_field'];
2658 if (trim($TCA[$table]['types'][$typeNum]['subtypes_addlist'][$row[$sTfield]])) {
2659 $addElements=t3lib_div
::trimExplode(',',$TCA[$table]['types'][$typeNum]['subtypes_addlist'][$row[$sTfield]],1);
2662 // Return the return
2663 return array($addElements,$sTfield);
2667 * Merges the current [types][showitem] array with the array of fields to add for the current subtype field of the "type" value.
2669 * @param array A [types][showitem] list of fields, exploded by ","
2670 * @param array The output from getFieldsToAdd()
2671 * @return array Return the modified $fields array.
2672 * @see getMainFields(),getFieldsToAdd()
2674 function mergeFieldsWithAddedFields($fields,$fieldsToAdd) {
2675 if (count($fieldsToAdd[0])) {
2678 while(list(,$fieldInfo)=each($fields)) {
2679 $parts = explode(';',$fieldInfo);
2680 if (!strcmp(trim($parts[0]),$fieldsToAdd[1])) {