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
--;
577 // Return the imploded $out_array:
578 if ($out_sheet>0) { // There were --div-- dividers around...
580 // Create parts array for the tab menu:
582 foreach ($out_array as $idx => $sheetContent) {
584 'label' => $out_array_meta[$idx]['title'],
585 'content' => '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.
586 implode('',$sheetContent).
594 '.$this->getDynTabMenu($parts, 'TCEforms:'.$table.':'.$row['uid']).'
597 } else { // Only one, so just implode:
598 return implode('',$out_array[$out_sheet]);
603 * Will return the TCEform elements for a pre-defined list of fields.
604 * 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.
605 * Used for displaying forms for the frontend edit icons for instance.
607 * @param string The table name
608 * @param array The record array.
609 * @param string Commalist of fields from the table. These will be shown in the specified order in a form.
610 * @return string TCEform elements in a string.
612 function getListedFields($table,$row,$list) {
615 t3lib_div
::loadTCA($table);
616 if ($this->edit_showFieldHelp ||
$this->doLoadTableDescr($table)) {
617 $GLOBALS['LANG']->loadSingleTableDescription($table);
621 $types_fieldConfig = t3lib_BEfunc
::getTCAtypes($table,$row,1);
623 $editFieldList=array_unique(t3lib_div
::trimExplode(',',$list,1));
624 foreach($editFieldList as $theFieldC) {
625 list($theField,$palFields) = split('\[|\]',$theFieldC);
626 $theField = trim($theField);
627 $palFields = trim($palFields);
628 if ($TCA[$table]['columns'][$theField]) {
629 $parts = t3lib_div
::trimExplode(';',$types_fieldConfig[$theField]['origString']);
630 $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.
632 } elseif($theField=='--div--') {
633 $out.= $this->getDivider();
636 $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
720 * Returns the form HTML code for a database table field.
722 * @param string The table name
723 * @param string The field name
724 * @param array The record to edit from the database table.
725 * @param string Alternative field name label to show.
726 * @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).
727 * @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.
728 * @param integer The palette pointer.
729 * @return mixed String (normal) or array (palettes)
731 function getSingleField($table,$field,$row,$altName='',$palette=0,$extra='',$pal=0) {
732 global $TCA,$BE_USER;
736 $PA['altName'] = $altName;
737 $PA['palette'] = $palette;
738 $PA['extra'] = $extra;
741 // Make sure to load full $TCA array for the table:
742 t3lib_div
::loadTCA($table);
744 // Get the TCA configuration for the current field:
745 $PA['fieldConf'] = $TCA[$table]['columns'][$field];
746 $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
748 // Now, check if this field is configured and editable (according to excludefields + other configuration)
749 if ( is_array($PA['fieldConf']) &&
750 (!$PA['fieldConf']['exclude'] ||
$BE_USER->check('non_exclude_fields',$table.':'.$field)) &&
751 $PA['fieldConf']['config']['form_type']!='passthrough' &&
752 ($this->RTEenabled ||
!$PA['fieldConf']['config']['showIfRTE']) &&
753 (!$PA['fieldConf']['displayCond'] ||
$this->isDisplayCondition($PA['fieldConf']['displayCond'],$row)) &&
754 (!$TCA[$table]['ctrl']['languageField'] ||
$PA['fieldConf']['l10n_display'] ||
strcmp($PA['fieldConf']['l10n_mode'],'exclude') ||
$row[$TCA[$table]['ctrl']['languageField']]<=0) &&
755 (!$TCA[$table]['ctrl']['languageField'] ||
!$this->localizationMode ||
$this->localizationMode
===$PA['fieldConf']['l10n_cat'])
760 // Fetching the TSconfig for the current table/field. This includes the $row which means that
761 $PA['fieldTSConfig'] = $this->setTSconfig($table,$row,$field);
763 // If the field is NOT disabled from TSconfig (which it could have been) then render it
764 if (!$PA['fieldTSConfig']['disabled']) {
767 $PA['itemFormElName']=$this->prependFormFieldNames
.'['.$table.']['.$row['uid'].']['.$field.']'; // Form field name
768 $PA['itemFormElName_file']=$this->prependFormFieldNames_file
.'['.$table.']['.$row['uid'].']['.$field.']'; // Form field name, in case of file uploads
769 $PA['itemFormElValue']=$row[$field]; // The value to show in the form field.
771 // set field to read-only if configured for translated records to show default language content as readonly
772 if ($PA['fieldConf']['l10n_display'] AND t3lib_div
::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly') AND $row[$TCA[$table]['ctrl']['languageField']]) {
773 $PA['fieldConf']['config']['readOnly'] = true;
774 $PA['itemFormElValue'] = $this->defaultLanguageData
[$table.':'.$row['uid']][$field];
777 // 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"
779 ($TCA[$table]['ctrl']['type'] && !strcmp($field,$TCA[$table]['ctrl']['type'])) ||
780 ($TCA[$table]['ctrl']['requestUpdate'] && t3lib_div
::inList($TCA[$table]['ctrl']['requestUpdate'],$field))) {
781 if($GLOBALS['BE_USER']->jsConfirmation(1)) {
782 $alertMsgOnChange = 'if (confirm('.$GLOBALS['LANG']->JScharCode($this->getLL('m_onChangeAlert')).') && TBE_EDITOR_checkSubmit(-1)){ TBE_EDITOR_submitForm() };';
784 $alertMsgOnChange = 'if (TBE_EDITOR_checkSubmit(-1)){ TBE_EDITOR_submitForm() };';
787 $alertMsgOnChange = '';
790 // Render as a hidden field?
791 if (in_array($field,$this->hiddenFieldListArr
)) {
792 $this->hiddenFieldAccum
[]='<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
793 } else { // Render as a normal field:
795 // 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.
796 if (!$PA['palette']) {
797 if ($PA['pal'] && $this->isPalettesCollapsed($table,$PA['pal'])) {
798 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);
804 // onFocus attribute to add to the field:
805 $PA['onFocus'] = ($palJSfunc && !$BE_USER->uc
['dontShowPalettesOnFocusInAB']) ?
' onfocus="'.htmlspecialchars($palJSfunc).'"' : '';
809 $PA['label'] = $PA['altName'] ?
$PA['altName'] : $PA['fieldConf']['label'];
810 $PA['label'] = $this->sL($PA['label']);
811 // JavaScript code for event handlers:
812 $PA['fieldChangeFunc']=array();
813 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = "TBE_EDITOR_fieldChanged('".$table."','".$row['uid']."','".$field."','".$PA['itemFormElName']."');";
814 $PA['fieldChangeFunc']['alert']=$alertMsgOnChange;
816 // Based on the type of the item, call a render function:
817 $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);
831 // 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
832 $PA['label'] = t3lib_div
::deHSCentities(htmlspecialchars($PA['label']));
833 if (t3lib_div
::testInt($row['uid']) && $PA['fieldTSConfig']['linkTitleToSelf']) {
834 $lTTS_url = $this->backPath
.'alt_doc.php?edit['.$table.']['.$row['uid'].']=edit&columnsOnly='.$field.
835 ($PA['fieldTSConfig']['linkTitleToSelf.']['returnUrl']?
'&returnUrl='.rawurlencode($this->thisReturnUrl()):'');
836 $PA['label'] = '<a href="'.htmlspecialchars($lTTS_url).'">'.$PA['label'].'</a>';
839 // Create output value:
840 if ($PA['fieldConf']['config']['form_type']=='user' && $PA['fieldConf']['config']['noTableWrapping']) {
842 } elseif ($PA['palette']) {
845 'NAME'=>$PA['label'],
850 'HELP_ICON' => $this->helpTextIcon($table,$field,1)
852 $out = $this->addUserTemplateMarkers($out,$table,$field,$row,$PA);
856 'NAME'=>$PA['label'],
860 'HELP_ICON'=>$this->helpTextIcon($table,$field),
861 'HELP_TEXT'=>$this->helpText($table,$field),
862 'PAL_LINK_ICON'=>$thePalIcon,
865 $out = $this->addUserTemplateMarkers($out,$table,$field,$row,$PA);
867 $out=$this->intoTemplate($out);
870 } else $this->commentMessages
[]=$this->prependFormFieldNames
.'['.$table.']['.$row['uid'].']['.$field.']: Disabled by TSconfig';
872 // Return value (string or array)
877 * Rendering a single item for the form
879 * @param string Table name of record
880 * @param string Fieldname to render
881 * @param array The record
882 * @param array parameters array containing a lot of stuff. Value by Reference!
883 * @return string Returns the item as HTML code to insert
885 * @see getSingleField(), getSingleField_typeFlex_draw()
887 function getSingleField_SW($table,$field,$row,&$PA) {
888 $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
890 switch($PA['fieldConf']['config']['form_type']) {
892 $item = $this->getSingleField_typeInput($table,$field,$row,$PA);
895 $item = $this->getSingleField_typeText($table,$field,$row,$PA);
898 $item = $this->getSingleField_typeCheck($table,$field,$row,$PA);
901 $item = $this->getSingleField_typeRadio($table,$field,$row,$PA);
904 $item = $this->getSingleField_typeSelect($table,$field,$row,$PA);
907 $item = $this->getSingleField_typeGroup($table,$field,$row,$PA);
910 $item = $this->getSingleField_typeNone($table,$field,$row,$PA);
913 $item = $this->getSingleField_typeUser($table,$field,$row,$PA);
916 $item = $this->getSingleField_typeFlex($table,$field,$row,$PA);
919 $item = $this->getSingleField_typeUnknown($table,$field,$row,$PA);
944 /**********************************************************
946 * Rendering of each TCEform field type
948 ************************************************************/
951 * Generation of TCEform elements of the type "input"
952 * This will render a single-line input form field, possibly with various control/validation features
954 * @param string The table name of the record
955 * @param string The field name which this element is supposed to edit
956 * @param array The record data array where the value(s) for the field can be found
957 * @param array An array with additional configuration options.
958 * @return string The HTML code for the TCEform field
960 function getSingleField_typeInput($table,$field,$row,&$PA) {
961 // typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue)
962 // typo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off)
964 $config = $PA['fieldConf']['config'];
966 # $specConf = $this->getSpecConfForField($table,$row,$field);
967 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
968 $size = t3lib_div
::intInRange($config['size']?
$config['size']:30,5,$this->maxInputWidth
);
969 $evalList = t3lib_div
::trimExplode(',',$config['eval'],1);
972 if($this->renderReadonly ||
$config['readOnly']) {
973 $itemFormElValue = $PA['itemFormElValue'];
974 if (in_array('date',$evalList)) {
975 $config['format'] = 'date';
976 } elseif (in_array('date',$evalList)) {
977 $config['format'] = 'date';
978 } elseif (in_array('datetime',$evalList)) {
979 $config['format'] = 'datetime';
980 } elseif (in_array('time',$evalList)) {
981 $config['format'] = 'time';
983 if (in_array('password',$evalList)) {
984 $itemFormElValue = $itemFormElValue ?
'*********' : '';
986 return $this->getSingleField_typeNone_render($config, $itemFormElValue);
989 if (in_array('required',$evalList)) {
990 $this->requiredFields
[$table.'_'.$row['uid'].'_'.$field]=$PA['itemFormElName'];
993 $paramsList = "'".$PA['itemFormElName']."','".implode(',',$evalList)."','".trim($config['is_in'])."',".(isset($config['checkbox'])?
1:0).",'".$config['checkbox']."'";
994 if (isset($config['checkbox'])) {
995 // Setting default "click-checkbox" values for eval types "date" and "datetime":
996 $thisMidnight = mktime(0,0,0);
997 $checkSetValue = in_array('date',$evalList) ?
$thisMidnight : '';
998 $checkSetValue = in_array('datetime',$evalList) ?
time() : $checkSetValue;
1000 $cOnClick = 'typo3FormFieldGet('.$paramsList.',1,\''.$checkSetValue.'\');'.implode('',$PA['fieldChangeFunc']);
1001 $item.='<input type="checkbox"'.$this->insertDefStyle('check').' name="'.$PA['itemFormElName'].'_cb" onclick="'.htmlspecialchars($cOnClick).'" />';
1004 $PA['fieldChangeFunc'] = array_merge(array('typo3FormFieldGet'=>'typo3FormFieldGet('.$paramsList.');'), $PA['fieldChangeFunc']);
1005 $mLgd = ($config['max']?
$config['max']:256);
1006 $iOnChange = implode('',$PA['fieldChangeFunc']);
1007 $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.
1008 $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.
1009 $this->extJSCODE
.='typo3FormFieldSet('.$paramsList.');';
1011 // going through all custom evaluations configured for this field
1012 foreach ($evalList as $evalData) {
1013 if (substr($evalData, 0, 3) == 'tx_') {
1014 $evalObj = t3lib_div
::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$evalData].':&'.$evalData);
1015 if(is_object($evalObj) && method_exists($evalObj, 'returnFieldJS')) {
1016 $this->extJSCODE
.= "\n\nfunction ".$evalData."(value) {\n".$evalObj->returnFieldJS()."\n}\n";
1021 // Creating an alternative item without the JavaScript handlers.
1022 $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'_hr" value="" />';
1023 $altItem.= '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
1025 // Wrap a wizard around the item?
1026 $item= $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'].'_hr',$specConf);
1032 * Generation of TCEform elements of the type "text"
1033 * This will render a <textarea> OR RTE area form field, possibly with various control/validation features
1035 * @param string The table name of the record
1036 * @param string The field name which this element is supposed to edit
1037 * @param array The record data array where the value(s) for the field can be found
1038 * @param array An array with additional configuration options.
1039 * @return string The HTML code for the TCEform field
1041 function getSingleField_typeText($table,$field,$row,&$PA) {
1044 $config = $PA['fieldConf']['config'];
1046 if($this->renderReadonly ||
$config['readOnly']) {
1047 return $this->getSingleField_typeNone_render($config, $PA['itemFormElValue']);
1050 // Setting columns number:
1051 $cols = t3lib_div
::intInRange($config['cols'] ?
$config['cols'] : 30, 5, $this->maxTextareaWidth
);
1053 // Setting number of rows:
1054 $origRows = $rows = t3lib_div
::intInRange($config['rows'] ?
$config['rows'] : 5, 1, 20);
1055 if (strlen($PA['itemFormElValue']) > $this->charsPerRow
*2) {
1056 $cols = $this->maxTextareaWidth
;
1057 $rows = t3lib_div
::intInRange(round(strlen($PA['itemFormElValue'])/$this->charsPerRow
), count(explode(chr(10),$PA['itemFormElValue'])), 20);
1058 if ($rows<$origRows) $rows = $origRows;
1062 $RTEwasLoaded = 0; // Set true, if the RTE is loaded; If not a normal textarea is shown.
1063 $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...
1065 // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. Traditionally, this is where RTE configuration has been found.
1066 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1068 // Setting up the altItem form field, which is a hidden field containing the value
1069 $altItem = '<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
1071 // If RTE is generally enabled (TYPO3_CONF_VARS and user settings)
1072 if ($this->RTEenabled
) {
1073 $p = t3lib_BEfunc
::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
1074 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.
1075 t3lib_BEfunc
::fixVersioningPid($table,$row);
1076 list($tscPID,$thePidValue) = $this->getTSCpid($table,$row['uid'],$row['pid']);
1078 // If the pid-value is not negative (that is, a pid could NOT be fetched)
1079 if ($thePidValue >= 0) {
1080 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc
::getPagesTSconfig($tscPID));
1081 $RTEtypeVal = t3lib_BEfunc
::getTCAtypeValue($table,$row);
1082 $thisConfig = t3lib_BEfunc
::RTEsetup($RTEsetup['properties'],$table,$field,$RTEtypeVal);
1084 if (!$thisConfig['disabled']) {
1085 if (!$this->disableRTE
) {
1086 $this->RTEcounter++
;
1088 // Find alternative relative path for RTE images/links:
1089 $eFile = t3lib_parsehtml_proc
::evalWriteFile($specConf['static_write'], $row);
1090 $RTErelPath = is_array($eFile) ?
dirname($eFile['relEditFile']) : '';
1092 // Get RTE object, draw form and set flag:
1093 $RTEobj = &t3lib_BEfunc
::RTEgetObj();
1094 $item = $RTEobj->drawRTE($this,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue);
1097 $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf,1);
1101 $RTEwouldHaveBeenLoaded = 1;
1102 $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!)';
1104 } else $this->commentMessages
[] = $PA['itemFormElName'].': RTE is disabled by the Page TSconfig, "RTE"-key (eg. by RTE.default.disabled=0 or such)';
1105 } else $this->commentMessages
[] = $PA['itemFormElName'].': PID value could NOT be fetched. Rare error, normally with new records.';
1107 if (!isset($specConf['richtext'])) $this->commentMessages
[] = $PA['itemFormElName'].': RTE was not configured for this field in TCA-types';
1108 if (!(!$p['flag'] ||
!$row[$p['flag']])) $this->commentMessages
[] = $PA['itemFormElName'].': Field-flag ('.$PA['flag'].') has been set to disable RTE!';
1112 // Display ordinary field if RTE was not loaded.
1113 if (!$RTEwasLoaded) {
1114 if ($specConf['rte_only']) { // Show message, if no RTE (field can only be edited with RTE!)
1115 $item = '<p><em>'.htmlspecialchars($this->getLL('l_noRTEfound')).'</em></p>';
1117 if ($specConf['nowrap']) {
1120 $wrap = ($config['wrap'] ?
$config['wrap'] : 'virtual');
1124 if ($specConf['fixed-font']) { $classes[] = 'fixed-font'; }
1125 if ($specConf['enable-tab']) { $classes[] = 'enable-tab'; }
1127 $formWidthText = $this->formWidthText($cols,$wrap);
1129 // Extract class attributes from $formWidthText (otherwise it would be added twice to the output)
1130 if (preg_match('/ class="(.+?)"/',$formWidthText,$res)) {
1131 $formWidthText = str_replace(' class="'.$res[1].'"','',$formWidthText);
1132 $classes = array_merge($classes, explode(' ',$res[1]));
1135 if (count($classes)) {
1136 $class = ' class="'.implode(' ',$classes).'"';
1139 $iOnChange = implode('',$PA['fieldChangeFunc']);
1141 <textarea name="'.$PA['itemFormElName'].'"'.$formWidthText.$class.' rows="'.$rows.'" wrap="'.$wrap.'" onchange="'.htmlspecialchars($iOnChange).'"'.$PA['onFocus'].'>'.
1142 t3lib_div
::formatForTextarea($PA['itemFormElValue']).
1144 $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf,$RTEwouldHaveBeenLoaded);
1148 // Return field HTML:
1153 * Generation of TCEform elements of the type "check"
1154 * This will render a check-box OR an array of checkboxes
1156 * @param string The table name of the record
1157 * @param string The field name which this element is supposed to edit
1158 * @param array The record data array where the value(s) for the field can be found
1159 * @param array An array with additional configuration options.
1160 * @return string The HTML code for the TCEform field
1162 function getSingleField_typeCheck($table,$field,$row,&$PA) {
1163 $config = $PA['fieldConf']['config'];
1166 if($this->renderReadonly ||
$config['readOnly']) {
1167 $disabled = ' disabled="disabled"';
1170 // Traversing the array of items:
1171 $selItems = $this->initItemArray($PA['fieldConf']);
1172 if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
1174 if (!count($selItems)) {
1175 $selItems[]=array('','');
1177 $thisValue = intval($PA['itemFormElValue']);
1179 $cols = intval($config['cols']);
1181 $item.= '<table border="0" cellspacing="0" cellpadding="0" class="typo3-TCEforms-checkboxArray">';
1182 for ($c=0;$c<count($selItems);$c++
) {
1184 if(!($c%
$cols)) { $item.='<tr>'; }
1185 $cBP = $this->checkBoxParams($PA['itemFormElName'],$thisValue,$c,count($selItems),implode('',$PA['fieldChangeFunc']));
1186 $cBName = $PA['itemFormElName'].'_'.$c;
1187 $item.= '<td nowrap="nowrap">'.
1188 '<input type="checkbox"'.$this->insertDefStyle('check').' value="1" name="'.$cBName.'"'.$cBP.$disabled.' />'.
1189 $this->wrapLabels(htmlspecialchars($p[0]).' ').
1191 if(($c%
$cols)+
1==$cols) {$item.='</tr>';}
1194 $rest=$cols-($c%
$cols);
1195 for ($c=0;$c<$rest;$c++
) {
1196 $item.= '<td></td>';
1198 if ($c>0) { $item.= '</tr>'; }
1202 for ($c=0;$c<count($selItems);$c++
) {
1204 $cBP = $this->checkBoxParams($PA['itemFormElName'],$thisValue,$c,count($selItems),implode('',$PA['fieldChangeFunc']));
1205 $cBName = $PA['itemFormElName'].'_'.$c;
1206 $item.= ($c>0?
'<br />':'').
1207 '<input type="checkbox"'.$this->insertDefStyle('check').' value="1" name="'.$cBName.'"'.$cBP.$PA['onFocus'].$disabled.' />'.
1208 htmlspecialchars($p[0]);
1212 $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($thisValue).'" />';
1219 * Generation of TCEform elements of the type "radio"
1220 * This will render a series of radio buttons.
1222 * @param string The table name of the record
1223 * @param string The field name which this element is supposed to edit
1224 * @param array The record data array where the value(s) for the field can be found
1225 * @param array An array with additional configuration options.
1226 * @return string The HTML code for the TCEform field
1228 function getSingleField_typeRadio($table,$field,$row,&$PA) {
1229 $config = $PA['fieldConf']['config'];
1232 if($this->renderReadonly ||
$config['readOnly']) {
1233 $disabled = ' disabled="disabled"';
1236 // Get items for the array:
1237 $selItems = $this->initItemArray($PA['fieldConf']);
1238 if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
1240 // Traverse the items, making the form elements:
1241 for ($c=0;$c<count($selItems);$c++
) {
1243 $rOnClick = implode('',$PA['fieldChangeFunc']);
1244 $rChecked = (!strcmp($p[1],$PA['itemFormElValue'])?
' checked="checked"':'');
1245 $item.= '<input type="radio"'.$this->insertDefStyle('radio').' name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($p[1]).'" onclick="'.htmlspecialchars($rOnClick).'"'.$rChecked.$PA['onFocus'].$disabled.' />'.
1246 htmlspecialchars($p[0]).
1254 * Generation of TCEform elements of the type "select"
1255 * This will render a selector box element, or possibly a special construction with two selector boxes. That depends on configuration.
1257 * @param string The table name of the record
1258 * @param string The field name which this element is supposed to edit
1259 * @param array The record data array where the value(s) for the field can be found
1260 * @param array An array with additional configuration options.
1261 * @return string The HTML code for the TCEform field
1263 function getSingleField_typeSelect($table,$field,$row,&$PA) {
1266 // Field configuration from TCA:
1267 $config = $PA['fieldConf']['config'];
1270 if($this->renderReadonly ||
$config['readOnly']) {
1271 $disabled = ' disabled="disabled"';
1274 // "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/.
1275 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1277 // Getting the selector box items from the system
1278 $selItems = $this->addSelectOptionsToItemArray($this->initItemArray($PA['fieldConf']),$PA['fieldConf'],$this->setTSconfig($table,$row),$field);
1279 $selItems = $this->addItems($selItems,$PA['fieldTSConfig']['addItems.']);
1280 if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
1282 // Possibly remove some items:
1283 $removeItems = t3lib_div
::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
1284 foreach($selItems as $tk => $p) {
1286 // Checking languages and authMode:
1287 $languageDeny = $TCA[$table]['ctrl']['languageField'] && !strcmp($TCA[$table]['ctrl']['languageField'], $field) && !$GLOBALS['BE_USER']->checkLanguageAccess($p[1]);
1288 $authModeDeny = $config['form_type']=='select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table,$field,$p[1],$config['authMode']);
1289 if (in_array($p[1],$removeItems) ||
$languageDeny ||
$authModeDeny) {
1290 unset($selItems[$tk]);
1291 } elseif (isset($PA['fieldTSConfig']['altLabels.'][$p[1]])) {
1292 $selItems[$tk][0]=$this->sL($PA['fieldTSConfig']['altLabels.'][$p[1]]);
1295 // Removing doktypes with no access:
1296 if ($table.'.'.$field == 'pages.doktype') {
1297 if (!($GLOBALS['BE_USER']->isAdmin() || t3lib_div
::inList($GLOBALS['BE_USER']->groupData
['pagetypes_select'],$p[1]))) {
1298 unset($selItems[$tk]);
1303 // Creating the label for the "No Matching Value" entry.
1304 $nMV_label = isset($PA['fieldTSConfig']['noMatchingValue_label']) ?
$this->sL($PA['fieldTSConfig']['noMatchingValue_label']) : '[ '.$this->getLL('l_noMatchingValue').' ]';
1306 // Prepare some values:
1307 $maxitems = intval($config['maxitems']);
1309 // If a SINGLE selector box...
1311 $item = $this->getSingleField_typeSelect_single($table,$field,$row,$PA,$config,$selItems,$nMV_label);
1312 } elseif (!strcmp($config['renderMode'],'checkbox')) { // Checkbox renderMode
1313 $item = $this->getSingleField_typeSelect_checkbox($table,$field,$row,$PA,$config,$selItems,$nMV_label);
1314 } elseif (!strcmp($config['renderMode'],'singlebox')) { // Single selector box renderMode
1315 $item = $this->getSingleField_typeSelect_singlebox($table,$field,$row,$PA,$config,$selItems,$nMV_label);
1316 } else { // Traditional multiple selector box:
1317 $item = $this->getSingleField_typeSelect_multiple($table,$field,$row,$PA,$config,$selItems,$nMV_label);
1322 $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
1323 $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf);
1330 * Creates a single-selector box
1331 * (Render function for getSingleField_typeSelect())
1333 * @param string See getSingleField_typeSelect()
1334 * @param string See getSingleField_typeSelect()
1335 * @param array See getSingleField_typeSelect()
1336 * @param array See getSingleField_typeSelect()
1337 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1338 * @param array Items available for selection
1339 * @param string Label for no-matching-value
1340 * @return string The HTML code for the item
1341 * @see getSingleField_typeSelect()
1343 function getSingleField_typeSelect_single($table,$field,$row,&$PA,$config,$selItems,$nMV_label) {
1348 $noMatchingValue = 1;
1350 $selicons = array();
1351 $onlySelectedIconShown = 0;
1352 $size = intval($config['size']);
1355 if($this->renderReadonly ||
$config['readOnly']) {
1356 $disabled = ' disabled="disabled"';
1357 $onlySelectedIconShown = 1;
1360 // Icon configuration:
1361 if ($config['suppress_icons']=='IF_VALUE_FALSE') {
1362 $suppressIcons = !$PA['itemFormElValue'] ?
1 : 0;
1363 } elseif ($config['suppress_icons']=='ONLY_SELECTED') {
1365 $onlySelectedIconShown=1;
1366 } elseif ($config['suppress_icons']) {
1368 } else $suppressIcons = 0;
1370 // Traverse the Array of selector box items:
1371 foreach($selItems as $p) {
1372 $sM = (!strcmp($PA['itemFormElValue'],$p[1])?
' selected="selected"':'');
1375 $noMatchingValue = 0;
1378 // Getting style attribute value (for icons):
1379 if ($config['iconsInOptionTags']) {
1380 $styleAttrValue = $this->optionTagStyle($p[2]);
1383 // Compiling the <option> tag:
1384 $opt[]= '<option value="'.htmlspecialchars($p[1]).'"'.
1386 ($styleAttrValue ?
' style="'.htmlspecialchars($styleAttrValue).'"' : '').
1387 (!strcmp($p[1],'--div--') ?
' class="c-divider"' : '').
1388 '>'.t3lib_div
::deHSCentities(htmlspecialchars($p[0])).'</option>';
1390 // If there is an icon for the selector box (rendered in table under)...:
1391 if ($p[2] && !$suppressIcons && (!$onlySelectedIconShown ||
$sM)) {
1392 list($selIconFile,$selIconInfo)=$this->getIcon($p[2]);
1393 $iOnClick = $this->elName($PA['itemFormElName']).'.selectedIndex='.$c.'; '.implode('',$PA['fieldChangeFunc']).$this->blur().'return false;';
1395 (!$onlySelectedIconShown ?
'<a href="#" onclick="'.htmlspecialchars($iOnClick).'">' : '').
1396 '<img src="'.$selIconFile.'" '.$selIconInfo[3].' vspace="2" border="0" title="'.htmlspecialchars($p[0]).'" alt="'.htmlspecialchars($p[0]).'" />'.
1397 (!$onlySelectedIconShown ?
'</a>' : ''),
1403 // No-matching-value:
1404 if ($PA['itemFormElValue'] && $noMatchingValue && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1405 $nMV_label = @sprintf
($nMV_label, $PA['itemFormElValue']);
1406 $opt[]= '<option value="'.htmlspecialchars($PA['itemFormElValue']).'" selected="selected">'.htmlspecialchars($nMV_label).'</option>';
1409 // Create item form fields:
1410 $sOnChange = 'if (this.options[this.selectedIndex].value==\'--div--\') {this.selectedIndex='.$sI.';} '.implode('',$PA['fieldChangeFunc']);
1412 $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...
1414 $item.= '<select name="'.$PA['itemFormElName'].'"'.
1415 $this->insertDefStyle('select').
1416 ($size?
' size="'.$size.'"':'').
1417 ' onchange="'.htmlspecialchars($sOnChange).'"'.
1418 $PA['onFocus'].$disabled.'>';
1419 $item.= implode('',$opt);
1420 $item.= '</select>';
1422 // Create icon table:
1423 if (count($selicons)) {
1424 $item.='<table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-selectIcons">';
1425 $selicon_cols = intval($config['selicon_cols']);
1426 if (!$selicon_cols) $selicon_cols=count($selicons);
1427 $sR = ceil(count($selicons)/$selicon_cols);
1428 $selicons = array_pad($selicons,$sR*$selicon_cols,'');
1429 for($sa=0;$sa<$sR;$sa++
) {
1431 for($sb=0;$sb<$selicon_cols;$sb++
) {
1432 $sk=($sa*$selicon_cols+
$sb);
1433 $imgN = 'selIcon_'.$table.'_'.$row['uid'].'_'.$field.'_'.$selicons[$sk][1];
1434 $imgS = ($selicons[$sk][2]?
$this->backPath
.'gfx/content_selected.gif':'clear.gif');
1435 $item.='<td><img name="'.htmlspecialchars($imgN).'" src="'.$imgS.'" width="7" height="10" alt="" /></td>';
1436 $item.='<td>'.$selicons[$sk][0].'</td>';
1447 * Creates a checkbox list (renderMode = "checkbox")
1448 * (Render function for getSingleField_typeSelect())
1450 * @param string See getSingleField_typeSelect()
1451 * @param string See getSingleField_typeSelect()
1452 * @param array See getSingleField_typeSelect()
1453 * @param array See getSingleField_typeSelect()
1454 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1455 * @param array Items available for selection
1456 * @param string Label for no-matching-value
1457 * @return string The HTML code for the item
1458 * @see getSingleField_typeSelect()
1460 function getSingleField_typeSelect_checkbox($table,$field,$row,&$PA,$config,$selItems,$nMV_label) {
1462 // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
1463 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
1466 if($this->renderReadonly ||
$config['readOnly']) {
1467 $disabled = ' disabled="disabled"';
1470 // Traverse the Array of selector box items:
1474 $sOnChange = implode('',$PA['fieldChangeFunc']);
1475 $setAll = array(); // Used to accumulate the JS needed to restore the original selection.
1476 foreach($selItems as $p) {
1477 // Non-selectable element:
1478 if (!strcmp($p[1],'--div--')) {
1479 if (count($setAll)) {
1483 '<a href="#" onclick="'.htmlspecialchars(implode('',$setAll).' return false;').'">'.
1484 htmlspecialchars($this->getLL('l_setAllCheckboxes')).
1491 <tr class="c-header">
1492 <td colspan="2">'.htmlspecialchars($p[0]).'</td>
1495 // Selected or not by default:
1497 if (isset($itemArray[$p[1]])) {
1498 $sM = ' checked="checked"';
1499 unset($itemArray[$p[1]]);
1505 list($selIconFile,$selIconInfo) = $this->getIcon($p[2]);
1509 $onClickCell = $this->elName($PA['itemFormElName'].'['.$c.']').'.checked=!'.$this->elName($PA['itemFormElName'].'['.$c.']').'.checked;';
1510 $onClick = 'this.attributes.getNamedItem("class").nodeValue = '.$this->elName($PA['itemFormElName'].'['.$c.']').'.checked ? "c-selectedItem" : "";';
1511 $setAll[] = $this->elName($PA['itemFormElName'].'['.$c.']').'.checked=1;';
1513 <tr class="'.($sM ?
'c-selectedItem' : '').'" onclick="'.htmlspecialchars($onClick).'" style="cursor: pointer;">
1514 <td><input type="checkbox"'.$this->insertDefStyle('check').' name="'.htmlspecialchars($PA['itemFormElName'].'['.$c.']').'" value="'.htmlspecialchars($p[1]).'"'.$sM.' onclick="'.htmlspecialchars($sOnChange).'"'.$PA['onFocus'].' /></td>
1515 <td class="c-labelCell" onclick="'.htmlspecialchars($onClickCell).'">'.
1516 ($selIconFile ?
'<img src="'.$selIconFile.'" '.$selIconInfo[3].' vspace="2" border="0" class="absmiddle" style="margin-right: 4px;" alt="" />' : '').
1517 t3lib_div
::deHSCentities(htmlspecialchars($p[0])).
1518 (strcmp($p[3],'') ?
'<br/><p class="c-descr">'.nl2br(trim(htmlspecialchars($p[3]))).'</p>' : '').
1525 // Remaining checkboxes will get their set-all link:
1526 if (count($setAll)) {
1530 '<a href="#" onclick="'.htmlspecialchars(implode('',$setAll).' return false;').'">'.
1531 htmlspecialchars($this->getLL('l_setAllCheckboxes')).
1537 // Remaining values (invalid):
1538 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1539 foreach($itemArray as $theNoMatchValue => $temp) {
1540 // Compile <checkboxes> tag:
1541 array_unshift($tRows,'
1542 <tr class="c-invalidItem">
1543 <td><input type="checkbox"'.$this->insertDefStyle('check').' name="'.htmlspecialchars($PA['itemFormElName'].'['.$c.']').'" value="'.htmlspecialchars($theNoMatchValue).'" checked="checked" onclick="'.htmlspecialchars($sOnChange).'"'.$PA['onFocus'].$disabled.' /></td>
1544 <td class="c-labelCell">'.
1545 t3lib_div
::deHSCentities(htmlspecialchars(@sprintf
($nMV_label, $theNoMatchValue))).
1552 // Add an empty hidden field which will send a blank value if all items are unselected.
1553 $item.='<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="" />';
1555 // Implode rows in table:
1557 <table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-select-checkbox">'.
1558 implode('',$tRows).'
1566 * Creates a selectorbox list (renderMode = "singlebox")
1567 * (Render function for getSingleField_typeSelect())
1569 * @param string See getSingleField_typeSelect()
1570 * @param string See getSingleField_typeSelect()
1571 * @param array See getSingleField_typeSelect()
1572 * @param array See getSingleField_typeSelect()
1573 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1574 * @param array Items available for selection
1575 * @param string Label for no-matching-value
1576 * @return string The HTML code for the item
1577 * @see getSingleField_typeSelect()
1579 function getSingleField_typeSelect_singlebox($table,$field,$row,&$PA,$config,$selItems,$nMV_label) {
1581 // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
1582 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
1585 if($this->renderReadonly ||
$config['readOnly']) {
1586 $disabled = ' disabled="disabled"';
1589 // Traverse the Array of selector box items:
1591 $restoreCmd = array(); // Used to accumulate the JS needed to restore the original selection.
1593 foreach($selItems as $p) {
1594 // Selected or not by default:
1596 if (isset($itemArray[$p[1]])) {
1597 $sM = ' selected="selected"';
1598 $restoreCmd[] = $this->elName($PA['itemFormElName'].'[]').'.options['.$c.'].selected=1;';
1599 unset($itemArray[$p[1]]);
1602 // Non-selectable element:
1604 if (!strcmp($p[1],'--div--')) {
1605 $nonSel = ' onclick="this.selected=0;" class="c-divider"';
1608 // Icon style for option tag:
1609 if ($config['iconsInOptionTags']) {
1610 $styleAttrValue = $this->optionTagStyle($p[2]);
1613 // Compile <option> tag:
1614 $opt[] = '<option value="'.htmlspecialchars($p[1]).'"'.
1617 ($styleAttrValue ?
' style="'.htmlspecialchars($styleAttrValue).'"' : '').
1618 '>'.t3lib_div
::deHSCentities(htmlspecialchars($p[0])).'</option>';
1622 // Remaining values:
1623 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1624 foreach($itemArray as $theNoMatchValue => $temp) {
1625 // Compile <option> tag:
1626 array_unshift($opt,'<option value="'.htmlspecialchars($theNoMatchValue).'" selected="selected">'.t3lib_div
::deHSCentities(htmlspecialchars(@sprintf
($nMV_label, $theNoMatchValue))).'</option>');
1630 // Compile selector box:
1631 $sOnChange = implode('',$PA['fieldChangeFunc']);
1632 $selector_itemListStyle = isset($config['itemListStyle']) ?
' style="'.htmlspecialchars($config['itemListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle
.'"';
1633 $size = intval($config['size']);
1634 $size = $config['autoSizeMax'] ? t3lib_div
::intInRange(count($selItems)+
1,t3lib_div
::intInRange($size,1),$config['autoSizeMax']) : $size;
1635 $selectBox = '<select name="'.$PA['itemFormElName'].'[]"'.
1636 $this->insertDefStyle('select').
1637 ($size ?
' size="'.$size.'"' : '').
1638 ' multiple="multiple" onchange="'.htmlspecialchars($sOnChange).'"'.
1640 $selector_itemListStyle.
1647 // Add an empty hidden field which will send a blank value if all items are unselected.
1649 $item.='<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="" />';
1652 // Put it all into a table:
1654 <table border="0" cellspacing="0" cellpadding="0" width="1" class="typo3-TCEforms-select-singlebox">
1660 htmlspecialchars($this->getLL('l_holdDownCTRL')).
1664 <a href="#" onclick="'.htmlspecialchars($this->elName($PA['itemFormElName'].'[]').'.selectedIndex=-1;'.implode('',$restoreCmd).' return false;').'">'.
1665 '<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/history.gif','width="13" height="12"').' title="'.htmlspecialchars($this->getLL('l_revertSelection')).'" alt="" />'.
1676 * Creates a multiple-selector box (two boxes, side-by-side)
1677 * (Render function for getSingleField_typeSelect())
1679 * @param string See getSingleField_typeSelect()
1680 * @param string See getSingleField_typeSelect()
1681 * @param array See getSingleField_typeSelect()
1682 * @param array See getSingleField_typeSelect()
1683 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1684 * @param array Items available for selection
1685 * @param string Label for no-matching-value
1686 * @return string The HTML code for the item
1687 * @see getSingleField_typeSelect()
1689 function getSingleField_typeSelect_multiple($table,$field,$row,&$PA,$config,$selItems,$nMV_label) {
1692 if($this->renderReadonly ||
$config['readOnly']) {
1693 $disabled = ' disabled="disabled"';
1696 // Setting this hidden field (as a flag that JavaScript can read out)
1698 $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'_mul" value="'.($config['multiple']?
1:0).'" />';
1701 // Set max and min items:
1702 $maxitems = t3lib_div
::intInRange($config['maxitems'],0);
1703 if (!$maxitems) $maxitems=100000;
1704 $minitems = t3lib_div
::intInRange($config['minitems'],0);
1706 // Register the required number of elements:
1707 $this->requiredElements
[$PA['itemFormElName']] = array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field);
1709 // Get "removeItems":
1710 $removeItems = t3lib_div
::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
1712 // Perform modification of the selected items array:
1713 $itemArray = t3lib_div
::trimExplode(',',$PA['itemFormElValue'],1);
1714 foreach($itemArray as $tk => $tv) {
1715 $tvP = explode('|',$tv,2);
1716 $evalValue = rawurldecode($tvP[0]);
1717 $isRemoved = in_array($evalValue,$removeItems) ||
($config['form_type']=='select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table,$field,$evalValue,$config['authMode']));
1718 if ($isRemoved && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1719 $tvP[1] = rawurlencode(@sprintf
($nMV_label, $evalValue));
1720 } elseif (isset($PA['fieldTSConfig']['altLabels.'][$evalValue])) {
1721 $tvP[1] = rawurlencode($this->sL($PA['fieldTSConfig']['altLabels.'][$evalValue]));
1723 $itemArray[$tk] = implode('|',$tvP);
1725 $itemsToSelect = '';
1728 // Create option tags:
1730 $styleAttrValue = '';
1731 foreach($selItems as $p) {
1732 if ($config['iconsInOptionTags']) {
1733 $styleAttrValue = $this->optionTagStyle($p[2]);
1735 $opt[]= '<option value="'.htmlspecialchars($p[1]).'"'.
1736 ($styleAttrValue ?
' style="'.htmlspecialchars($styleAttrValue).'"' : '').
1737 '>'.htmlspecialchars($p[0]).'</option>';
1740 // Put together the selector box:
1741 $selector_itemListStyle = isset($config['itemListStyle']) ?
' style="'.htmlspecialchars($config['itemListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle
.'"';
1742 $size = intval($config['size']);
1743 $size = $config['autoSizeMax'] ? t3lib_div
::intInRange(count($itemArray)+
1,t3lib_div
::intInRange($size,1),$config['autoSizeMax']) : $size;
1744 if ($config['exclusiveKeys']) {
1745 $sOnChange = 'setFormValueFromBrowseWin(\''.$PA['itemFormElName'].'\',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text,\''.$config['exclusiveKeys'].'\'); ';
1747 $sOnChange = 'setFormValueFromBrowseWin(\''.$PA['itemFormElName'].'\',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text); ';
1749 $sOnChange .= implode('',$PA['fieldChangeFunc']);
1751 <select name="'.$PA['itemFormElName'].'_sel"'.
1752 $this->insertDefStyle('select').
1753 ($size ?
' size="'.$size.'"' : '').
1754 ' onchange="'.htmlspecialchars($sOnChange).'"'.
1756 $selector_itemListStyle.'>
1762 // Pass to "dbFileIcons" function:
1765 'autoSizeMax' => t3lib_div
::intInRange($config['autoSizeMax'],0),
1766 'style' => isset($config['selectedListStyle']) ?
' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle
.'"',
1767 'dontShowMoveIcons' => ($maxitems<=1),
1768 'maxitems' => $maxitems,
1771 'selector' => $this->getLL('l_selected').':<br />',
1772 'items' => $this->getLL('l_items').':<br />'
1775 'thumbnails' => $itemsToSelect,
1776 'readOnly' => $disabled
1778 $item.= $this->dbFileIcons($PA['itemFormElName'],'','',$itemArray,'',$params,$PA['onFocus']);
1784 * Generation of TCEform elements of the type "group"
1785 * This will render a selectorbox into which elements from either the file system or database can be inserted. Relations.
1787 * @param string The table name of the record
1788 * @param string The field name which this element is supposed to edit
1789 * @param array The record data array where the value(s) for the field can be found
1790 * @param array An array with additional configuration options.
1791 * @return string The HTML code for the TCEform field
1793 function getSingleField_typeGroup($table,$field,$row,&$PA) {
1795 $config = $PA['fieldConf']['config'];
1796 $internal_type = $config['internal_type'];
1797 $show_thumbs = $config['show_thumbs'];
1798 $size = intval($config['size']);
1799 $maxitems = t3lib_div
::intInRange($config['maxitems'],0);
1800 if (!$maxitems) $maxitems=100000;
1801 $minitems = t3lib_div
::intInRange($config['minitems'],0);
1802 $allowed = $config['allowed'];
1803 $disallowed = $config['disallowed'];
1806 if($this->renderReadonly ||
$config['readOnly']) {
1807 $disabled = ' disabled="disabled"';
1810 $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'_mul" value="'.($config['multiple']?
1:0).'"'.$disabled.' />';
1811 $this->requiredElements
[$PA['itemFormElName']] = array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field);
1814 // "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/.
1815 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1817 // Acting according to either "file" or "db" type:
1818 switch((string)$config['internal_type']) {
1819 case 'file': // If the element is of the internal type "file":
1821 // Creating string showing allowed types:
1822 $tempFT = t3lib_div
::trimExplode(',',$allowed,1);
1823 if (!count($tempFT)) {$info.='*';}
1824 foreach($tempFT as $ext) {
1826 $info.=strtoupper($ext).' ';
1829 // Creating string, showing disallowed types:
1830 $tempFT_dis = t3lib_div
::trimExplode(',',$disallowed,1);
1831 if (count($tempFT_dis)) {$info.='<br />';}
1832 foreach($tempFT_dis as $ext) {
1834 $info.='-'.strtoupper($ext).' ';
1838 // Making the array of file items:
1839 $itemArray = t3lib_div
::trimExplode(',',$PA['itemFormElValue'],1);
1841 // Showing thumbnails:
1845 foreach($itemArray as $imgRead) {
1846 $imgP = explode('|',$imgRead);
1849 $rowCopy[$field] = $imgP[0];
1851 // Icon + clickmenu:
1852 $absFilePath = t3lib_div
::getFileAbsFileName($config['uploadfolder'].'/'.$imgP[0]);
1854 $fI = pathinfo($imgP[0]);
1855 $fileIcon = t3lib_BEfunc
::getFileIcon(strtolower($fI['extension']));
1856 $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="" />';
1858 $imgs[] = '<span class="nobr">'.t3lib_BEfunc
::thumbCode($rowCopy,$table,$field,$this->backPath
,'thumbs.php',$config['uploadfolder'],0,' align="middle"').
1859 ($absFilePath ?
$this->getClickMenu($fileIcon, $absFilePath) : $fileIcon).
1863 $thumbsnail = implode('<br />',$imgs);
1866 // Creating the element:
1869 'dontShowMoveIcons' => ($maxitems<=1),
1870 'autoSizeMax' => t3lib_div
::intInRange($config['autoSizeMax'],0),
1871 'maxitems' => $maxitems,
1872 'style' => isset($config['selectedListStyle']) ?
' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle
.'"',
1874 'thumbnails' => $thumbsnail,
1875 'readOnly' => $disabled
1877 $item.= $this->dbFileIcons($PA['itemFormElName'],'file',implode(',',$tempFT),$itemArray,'',$params,$PA['onFocus']);
1880 // Adding the upload field:
1881 if ($this->edit_docModuleUpload
) $item.='<input type="file" name="'.$PA['itemFormElName_file'].'"'.$this->formWidth().' size="60" />';
1884 case 'db': // If the element is of the internal type "db":
1886 // Creating string showing allowed types:
1887 $tempFT = t3lib_div
::trimExplode(',',$allowed,1);
1888 if (!strcmp(trim($tempFT[0]),'*')) {
1889 $info.='<span class="nobr"> '.
1890 htmlspecialchars($this->getLL('l_allTables')).
1893 while(list(,$theT)=each($tempFT)) {
1895 $info.='<span class="nobr"> '.
1896 t3lib_iconWorks
::getIconImage($theT,array(),$this->backPath
,'align="top"').
1897 htmlspecialchars($this->sL($GLOBALS['TCA'][$theT]['ctrl']['title'])).
1903 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
1904 $itemArray = array();
1908 $temp_itemArray = t3lib_div
::trimExplode(',',$PA['itemFormElValue'],1);
1909 foreach($temp_itemArray as $dbRead) {
1910 $recordParts = explode('|',$dbRead);
1911 list($this_table,$this_uid) = t3lib_BEfunc
::splitTable_Uid($recordParts[0]);
1912 $itemArray[] = array('table'=>$this_table, 'id'=>$this_uid);
1913 if (!$disabled && $show_thumbs) {
1914 $rr = t3lib_BEfunc
::getRecordWSOL($this_table,$this_uid);
1915 $imgs[] = '<span class="nobr">'.
1916 $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).
1918 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>'.
1923 if (!$disabled && $show_thumbs) {
1924 $thumbsnail = implode('<br />',$imgs);
1927 // Creating the element:
1930 'dontShowMoveIcons' => ($maxitems<=1),
1931 'autoSizeMax' => t3lib_div
::intInRange($config['autoSizeMax'],0),
1932 'maxitems' => $maxitems,
1933 'style' => isset($config['selectedListStyle']) ?
' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle
.'"',
1935 'thumbnails' => $thumbsnail,
1936 'readOnly' => $disabled
1938 $item.= $this->dbFileIcons($PA['itemFormElName'],'db',implode(',',$tempFT),$itemArray,'',$params,$PA['onFocus']);
1944 $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
1946 $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf);
1953 * Generation of TCEform elements of the type "none"
1954 * This will render a non-editable display of the content of the field.
1956 * @param string The table name of the record
1957 * @param string The field name which this element is supposed to edit
1958 * @param array The record data array where the value(s) for the field can be found
1959 * @param array An array with additional configuration options.
1960 * @return string The HTML code for the TCEform field
1962 function getSingleField_typeNone($table,$field,$row,&$PA) {
1964 $config = $PA['fieldConf']['config'];
1965 $itemValue = $PA['itemFormElValue'];
1967 return $this->getSingleField_typeNone_render($config,$itemValue);
1971 * HTML rendering of a value which is not editable.
1973 * @param array Configuration for the display
1974 * @param string The value to display
1975 * @return string The HTML code for the display
1976 * @see getSingleField_typeNone();
1978 function getSingleField_typeNone_render($config,$itemValue) {
1980 // is colorScheme[0] the right value?
1981 $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;';
1983 if ($config['format']) {
1984 $itemValue = $this->formatValue($config, $itemValue);
1987 $rows = intval($config['rows']);
1989 if(!$config['pass_content']) {
1990 $itemValue = nl2br(htmlspecialchars($itemValue));
1993 $cols = t3lib_div
::intInRange($config['cols'] ?
$config['cols'] : 30, 5, $this->maxTextareaWidth
);
1994 if (!$config['fixedRows']) {
1995 $origRows = $rows = t3lib_div
::intInRange($rows, 1, 20);
1996 if (strlen($itemValue)>$this->charsPerRow
*2) {
1997 $cols = $this->maxTextareaWidth
;
1998 $rows = t3lib_div
::intInRange(round(strlen($itemValue)/$this->charsPerRow
),count(explode(chr(10),$itemValue)),20);
1999 if ($rows<$origRows) $rows=$origRows;
2003 if ($this->docLarge
) $cols = round($cols*$this->form_largeComp
);
2004 $width = ceil($cols*$this->form_rowsToStylewidth
);
2005 // hardcoded: 12 is the height of the font
2009 <div style="'.htmlspecialchars($divStyle.' overflow:auto; height:'.$height.'px; width:'.$width.'px;').'" class="'.htmlspecialchars($this->formElClass('none')).'">'.
2013 if(!$config['pass_content']) {
2014 $itemValue = htmlspecialchars($itemValue);
2017 $cols = $config['cols']?
$config['cols']:($config['size']?
$config['size']:$this->maxInputWidth
);
2018 if ($this->docLarge
) $cols = round($cols*$this->form_largeComp
);
2019 $width = ceil($cols*$this->form_rowsToStylewidth
);
2021 // overflow:auto crashes mozilla here. Title tag is usefull when text is longer than the div box (overflow:hidden).
2023 <div style="'.htmlspecialchars($divStyle.' overflow:hidden; width:'.$width.'px;').'" class="'.htmlspecialchars($this->formElClass('none')).'" title="'.$itemValue.'">'.
2024 '<span class="nobr">'.(strcmp($itemValue,'')?
$itemValue:' ').'</span>'.
2032 * Handler for Flex Forms
2034 * @param string The table name of the record
2035 * @param string The field name which this element is supposed to edit
2036 * @param array The record data array where the value(s) for the field can be found
2037 * @param array An array with additional configuration options.
2038 * @return string The HTML code for the TCEform field
2040 function getSingleField_typeFlex($table,$field,$row,&$PA) {
2043 $dataStructArray = t3lib_BEfunc
::getFlexFormDS($PA['fieldConf']['config'],$row,$table);
2045 // Get data structure:
2046 if (is_array($dataStructArray)) {
2049 $xmlData = $PA['itemFormElValue'];
2050 $xmlHeaderAttributes = t3lib_div
::xmlGetHeaderAttribs($xmlData);
2051 $storeInCharset = strtolower($xmlHeaderAttributes['encoding']);
2052 if ($storeInCharset) {
2053 $currentCharset=$GLOBALS['LANG']->charSet
;
2054 $xmlData = $GLOBALS['LANG']->csConvObj
->conv($xmlData,$storeInCharset,$currentCharset,1);
2056 $editData=t3lib_div
::xml2array($xmlData);
2057 if (!is_array($editData)) { // Must be XML parsing error...
2059 } elseif (isset($editData['meta']) && !is_array($editData['meta'])) {
2060 $editData['meta'] = array();
2063 // Find the data structure if sheets are found:
2064 $sheet = $editData['meta']['currentSheetId'] ?
$editData['meta']['currentSheetId'] : 'sDEF'; // Sheet to display
2066 // Create sheet menu:
2067 // if (is_array($dataStructArray['sheets'])) {
2068 // #$item.=$this->getSingleField_typeFlex_sheetMenu($dataStructArray['sheets'], $PA['itemFormElName'].'[meta][currentSheetId]', $sheet).'<br />';
2071 // Create language menu:
2072 $langChildren = $dataStructArray['meta']['langChildren'] ?
1 : 0;
2073 $langDisabled = $dataStructArray['meta']['langDisable'] ?
1 : 0;
2075 $editData['meta']['currentLangId']=array();
2076 $languages = $this->getAvailableLanguages();
2078 foreach($languages as $lInfo) {
2079 if ($GLOBALS['BE_USER']->checkLanguageAccess($lInfo['uid'])) {
2080 $editData['meta']['currentLangId'][] = $lInfo['ISOcode'];
2083 if (!is_array($editData['meta']['currentLangId']) ||
!count($editData['meta']['currentLangId'])) {
2084 $editData['meta']['currentLangId']=array('DEF');
2087 $editData['meta']['currentLangId'] = array_unique($editData['meta']['currentLangId']);
2090 // if (!$langDisabled && count($languages) > 1) {
2091 // $item.=$this->getSingleField_typeFlex_langMenu($languages, $PA['itemFormElName'].'[meta][currentLangId]', $editData['meta']['currentLangId']).'<br />';
2094 $PA['_noEditDEF'] = FALSE;
2095 if ($langChildren ||
$langDisabled) {
2096 $rotateLang = array('DEF');
2098 if (!in_array('DEF',$editData['meta']['currentLangId'])) {
2099 array_unshift($editData['meta']['currentLangId'],'DEF');
2100 $PA['_noEditDEF'] = TRUE;
2102 $rotateLang = $editData['meta']['currentLangId'];
2106 if (is_array($dataStructArray['sheets'])) {
2107 $tabsToTraverse = array_keys($dataStructArray['sheets']);
2109 $tabsToTraverse = array($sheet);
2112 foreach ($rotateLang as $lKey) {
2113 if (!$langChildren && !$langDisabled) {
2114 $item.= '<b>'.$lKey.':</b>';
2117 $tabParts = array();
2118 foreach ($tabsToTraverse as $sheet) {
2119 $sheetCfg = $dataStructArray['sheets'][$sheet];
2120 list ($dataStruct, $sheet) = t3lib_div
::resolveSheetDefInDS($dataStructArray,$sheet);
2123 if (is_array($dataStruct['ROOT']) && is_array($dataStruct['ROOT']['el'])) {
2124 $cmdData = t3lib_div
::_GP('flexFormsCmdData');
2125 $lang = 'l'.$lKey; // Default language, other options are "lUK" or whatever country code (independant of system!!!)
2126 $PA['_valLang'] = $langChildren && !$langDisabled ?
$editData['meta']['currentLangId'] : 'DEF'; // Default language, other options are "lUK" or whatever country code (independant of system!!!)
2127 $PA['_lang'] = $lang;
2130 $tRows = $this->getSingleField_typeFlex_draw(
2131 $dataStruct['ROOT']['el'],
2132 $editData['data'][$sheet][$lang],
2133 $cmdData['data'][$sheet][$lang],
2138 '[data]['.$sheet.']['.$lang.']'
2140 $sheetContent= '<table border="0" cellpadding="1" cellspacing="1" class="typo3-TCEforms-flexForm">'.implode('',$tRows).'</table>';
2142 # $item = '<div style=" position:absolute;">'.$item.'</div>';
2143 //visibility:hidden;
2144 } else $sheetContent='Data Structure ERROR: No ROOT element found for sheet "'.$sheet.'".';
2147 $tabParts[] = array(
2148 'label' => ($sheetCfg['ROOT']['TCEforms']['sheetTitle'] ?
$this->sL($sheetCfg['ROOT']['TCEforms']['sheetTitle']) : $sheet),
2149 'description' => ($sheetCfg['ROOT']['TCEforms']['sheetDescription'] ?
$this->sL($sheetCfg['ROOT']['TCEforms']['sheetDescription']) : ''),
2150 'linkTitle' => ($sheetCfg['ROOT']['TCEforms']['sheetShortDescr'] ?
$this->sL($sheetCfg['ROOT']['TCEforms']['sheetShortDescr']) : ''),
2151 'content' => $sheetContent
2155 if (is_array($dataStructArray['sheets'])) {
2156 $item.= $this->getDynTabMenu($tabParts,'TCEFORMS:flexform:'.$PA['itemFormElName'].$PA['_lang']);
2158 $item.= $sheetContent;
2161 } else $item='Data Structure ERROR: '.$dataStructArray;
2167 * Creates the language menu for FlexForms:
2169 * @param [type] $languages: ...
2170 * @param [type] $elName: ...
2171 * @param [type] $selectedLanguage: ...
2172 * @param [type] $multi: ...
2173 * @return string HTML for menu
2175 function getSingleField_typeFlex_langMenu($languages,$elName,$selectedLanguage,$multi=1) {
2177 foreach($languages as $lArr) {
2178 $opt[]='<option value="'.htmlspecialchars($lArr['ISOcode']).'"'.(in_array($lArr['ISOcode'],$selectedLanguage)?
' selected="selected"':'').'>'.htmlspecialchars($lArr['title']).'</option>';
2181 $output = '<select name="'.$elName.'[]"'.($multi ?
' multiple="multiple" size="'.count($languages).'"' : '').'>'.implode('',$opt).'</select>';
2187 * Creates the menu for selection of the sheets:
2189 * @param array Sheet array for which to render the menu
2190 * @param string Form element name of the field containing the sheet pointer
2191 * @param string Current sheet key
2192 * @return string HTML for menu
2194 function getSingleField_typeFlex_sheetMenu($sArr,$elName,$sheetKey) {
2197 $pct = round(100/count($sArr));
2198 foreach($sArr as $sKey => $sheetCfg) {
2199 if ($GLOBALS['BE_USER']->jsConfirmation(1)) {
2200 $onClick = 'if (confirm('.$GLOBALS['LANG']->JScharCode($this->getLL('m_onChangeAlert')).') && TBE_EDITOR_checkSubmit(-1)){'.$this->elName($elName).".value='".$sKey."'; TBE_EDITOR_submitForm()};";
2202 $onClick = 'if(TBE_EDITOR_checkSubmit(-1)){ '.$this->elName($elName).".value='".$sKey."'; TBE_EDITOR_submitForm();}";
2206 $tCells[]='<td width="'.$pct.'%" style="'.($sKey==$sheetKey ?
'background-color: #9999cc; font-weight: bold;' : 'background-color: #aaaaaa;').' cursor: hand;" onclick="'.htmlspecialchars($onClick).'" align="center">'.
2207 ($sheetCfg['ROOT']['TCEforms']['sheetTitle'] ?
$this->sL($sheetCfg['ROOT']['TCEforms']['sheetTitle']) : $sKey).
2211 return '<table border="0" cellpadding="0" cellspacing="2" class="typo3-TCEforms-flexForm-sheetMenu"><tr>'.implode('',$tCells).'</tr></table>';
2215 * [Describe function...]
2217 * @param [type] $dataStruct: ...
2218 * @param [type] $editData: ...
2219 * @param [type] $cmdData: ...
2220 * @param [type] $table: ...
2221 * @param [type] $field: ...
2222 * @param [type] $row: ...
2223 * @param [type] $PA: ...
2224 * @param [type] $formPrefix: ...
2225 * @param [type] $level: ...
2226 * @param [type] $tRows: ...
2227 * @return [type] ...
2229 function getSingleField_typeFlex_draw($dataStruct,$editData,$cmdData,$table,$field,$row,&$PA,$formPrefix='',$level=0,$tRows=array()) {
2231 // Data Structure array must be ... and array of course...
2232 if (is_array($dataStruct)) {
2233 foreach($dataStruct as $key => $value) {
2234 if (is_array($value)) { // The value of each entry must be an array.
2236 // ********************
2238 // ********************
2242 $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>';;
2244 $rowCells['formEl']='';
2245 if ($value['type']=='array') {
2246 if ($value['section']) {
2247 // Render "NEW [container]" selectorbox:
2248 if (is_array($value['el'])) {
2250 $opt[]='<option value=""></option>';
2251 foreach($value['el'] as $kk => $vv) {
2252 $opt[]='<option value="'.$kk.'">'.htmlspecialchars($this->getLL('l_new') . ' "'.$this->sL($value['el'][$kk]['tx_templavoila']['title']).'"').'</option>';
2254 $rowCells['formEl']='<select name="flexFormsCmdData'.$formPrefix.'['.$key.'][value]">'.implode('',$opt).'</select>';
2258 $tRows[]='<tr class="bgColor2">
2259 <td nowrap="nowrap" valign="top">'.$rowCells['title'].'</td>
2260 <td>'.$rowCells['formEl'].'</td>
2264 if (is_array($editData[$key]['el'])) {
2265 foreach ($editData[$key]['el'] as $k3 => $v3) {
2267 $theType = key($v3);
2268 $theDat = $v3[$theType];
2269 $newSectionEl = $value['el'][$theType];
2270 if (is_array($newSectionEl)) {
2271 $tRows = $this->getSingleField_typeFlex_draw(
2272 array($theType => $newSectionEl),
2273 array($theType => $theDat),
2274 $cmdData[$key]['el'][$cc],
2279 $formPrefix.'['.$key.'][el]['.$cc.']',
2290 if ($cmdData[$key]['value']) {
2291 $newSectionEl = $value['el'][$cmdData[$key]['value']];
2292 if (is_array($newSectionEl)) {
2293 $tRows = $this->getSingleField_typeFlex_draw(
2294 array($cmdData[$key]['value'] => $newSectionEl),
2301 $formPrefix.'['.$key.'][el]['.($cc+
1).']',
2308 $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
2311 $tRows[]='<tr class="bgColor2">
2312 <td nowrap="nowrap" valign="top">'.
2313 '<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>'.
2314 '<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>'.
2315 '<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>'.
2316 $rowCells['title'].'</td>
2317 <td>'.$rowCells['formEl'].'</td>
2320 $tRows = $this->getSingleField_typeFlex_draw(
2322 $editData[$key]['el'],
2323 $cmdData[$key]['el'],
2328 $formPrefix.'['.$key.'][el]',
2334 } elseif (is_array($value['TCEforms']['config'])) { // Rendering a single form element:
2336 if (is_array($PA['_valLang'])) {
2337 $rotateLang = $PA['_valLang'];
2339 $rotateLang = array($PA['_valLang']);
2342 foreach($rotateLang as $vDEFkey) {
2343 $vDEFkey = 'v'.$vDEFkey;
2345 if (!$value['TCEforms']['displayCond'] ||
$this->isDisplayCondition($value['TCEforms']['displayCond'],$editData,$vDEFkey)) {
2347 $fakePA['fieldConf']=array(
2348 'label' => $this->sL(trim($value['TCEforms']['label'])),
2349 'config' => $value['TCEforms']['config'],
2350 'defaultExtras' => $value['TCEforms']['defaultExtras'],
2351 'onChange' => $value['TCEforms']['onChange']
2353 if ($PA['_noEditDEF'] && $PA['_lang']==='lDEF') {
2354 $fakePA['fieldConf']['config'] = array(
2361 $fakePA['fieldConf']['onChange'] == 'reload' ||
2362 ($GLOBALS['TCA'][$table]['ctrl']['type'] && !strcmp($key,$GLOBALS['TCA'][$table]['ctrl']['type'])) ||
2363 ($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'] && t3lib_div
::inList($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'],$key))) {
2364 if ($GLOBALS['BE_USER']->jsConfirmation(1)) {
2365 $alertMsgOnChange = 'if (confirm('.$GLOBALS['LANG']->JScharCode($this->getLL('m_onChangeAlert')).') && TBE_EDITOR_checkSubmit(-1)){ TBE_EDITOR_submitForm() };';
2367 $alertMsgOnChange = 'if(TBE_EDITOR_checkSubmit(-1)){ TBE_EDITOR_submitForm();}';
2370 $alertMsgOnChange = '';
2373 $fakePA['fieldChangeFunc']=$PA['fieldChangeFunc'];
2374 if (strlen($alertMsgOnChange)) {
2375 $fakePA['fieldChangeFunc']['alert']=$alertMsgOnChange;
2377 $fakePA['onFocus']=$PA['onFocus'];
2378 $fakePA['label']=$PA['label'];
2380 $fakePA['itemFormElName']=$PA['itemFormElName'].$formPrefix.'['.$key.']['.$vDEFkey.']';
2381 $fakePA['itemFormElName_file']=$PA['itemFormElName_file'].$formPrefix.'['.$key.']['.$vDEFkey.']';
2383 if(isset($editData[$key][$vDEFkey])) {
2384 $fakePA['itemFormElValue']=$editData[$key][$vDEFkey];
2386 $fakePA['itemFormElValue']=$fakePA['fieldConf']['config']['default'];
2389 $rowCells['formEl']= $this->getSingleField_SW($table,$field,$row,$fakePA);
2390 $rowCells['title']= htmlspecialchars($fakePA['fieldConf']['label']);
2392 if (!in_array('DEF',$rotateLang)) {
2393 $defInfo = '<div class="typo3-TCEforms-originalLanguageValue">'.nl2br(htmlspecialchars($editData[$key]['vDEF'])).' </div>';
2400 <td nowrap="nowrap" valign="top" class="bgColor5">'.$rowCells['title'].($vDEFkey=='vDEF' ?
'' : ' ('.$vDEFkey.')').'</td>
2401 <td class="bgColor4">'.$rowCells['formEl'].$defInfo.'</td>
2414 * Handler for unknown types.
2416 * @param string The table name of the record
2417 * @param string The field name which this element is supposed to edit
2418 * @param array The record data array where the value(s) for the field can be found
2419 * @param array An array with additional configuration options.
2420 * @return string The HTML code for the TCEform field
2422 function getSingleField_typeUnknown($table,$field,$row,&$PA) {
2423 $item='Unknown type: '.$PA['fieldConf']['config']['form_type'].'<br />';
2429 * User defined field type
2431 * @param string The table name of the record
2432 * @param string The field name which this element is supposed to edit
2433 * @param array The record data array where the value(s) for the field can be found
2434 * @param array An array with additional configuration options.
2435 * @return string The HTML code for the TCEform field
2437 function getSingleField_typeUser($table,$field,$row,&$PA) {
2438 $PA['table']=$table;
2439 $PA['field']=$field;
2444 return t3lib_div
::callUserFunction($PA['fieldConf']['config']['userFunc'],$PA,$this);
2452 /************************************************************
2454 * Field content processing
2456 ************************************************************/
2459 * Format field content of various types if $config['format'] is set to date, filesize, ..., user
2460 * This is primarily for the field type none but can be used for user field types for example
2462 * @param array Configuration for the display
2463 * @param string The value to display
2464 * @return string Formatted Field content
2466 function formatValue ($config, $itemValue) {
2467 $format = trim($config['format']);
2470 $option = trim($config['format.']['option']);
2472 if ($config['format.']['strftime']) {
2473 $value = strftime($option,$itemValue);
2475 $value = date($option,$itemValue);
2478 $value = date('d-m-Y',$itemValue);
2480 if ($config['format.']['appendAge']) {
2481 $value .= ' ('.t3lib_BEfunc
::calcAge((time()-$itemValue), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')).')';
2483 $itemValue = $value;
2485 case 'datetime': // compatibility with "eval" (type "input")
2486 $itemValue = date('H:i d-m-Y',$itemValue);
2488 case 'time': // compatibility with "eval" (type "input")
2489 $itemValue = date('H:i',$itemValue);
2491 case 'timesec': // compatibility with "eval" (type "input")
2492 $itemValue = date('H:i:s',$itemValue);
2494 case 'year': // compatibility with "eval" (type "input")
2495 $itemValue = date('Y',$itemValue);
2498 $baseArr = array('dec'=>'d','hex'=>'x','HEX'=>'X','oct'=>'o','bin'=>'b');
2499 $base = trim($config['format.']['base']);
2500 $format = $baseArr[$base] ?
$baseArr[$base] : 'd';
2501 $itemValue = sprintf('%'.$format,$itemValue);
2504 $precision = t3lib_div
::intInRange($config['format.']['precision'],1,10,2);
2505 $itemValue = sprintf('%.'.$precision.'f',$itemValue);
2508 $format = trim($config['format.']['option']);
2509 $itemValue = sprintf('%'.$format,$itemValue);
2512 $itemValue = md5($itemValue);
2515 $value = t3lib_div
::formatSize(intval($itemValue));
2516 if ($config['format.']['appendByteSize']) {
2517 $value .= ' ('.$itemValue.')';
2519 $itemValue = $value;
2522 $func = trim($config['format.']['userFunc']);
2525 'value' => $itemValue,
2526 'args' => $config['format.']['userFunc'],
2527 'config' => $config,
2530 $itemValue = t3lib_div
::callUserFunction($func,$params,$this);
2545 /************************************************************
2547 * "Configuration" fetching/processing functions
2549 ************************************************************/
2552 * Calculate and return the current "types" pointer value for a record
2554 * @param string The table name. MUST be in $TCA
2555 * @param array The row from the table, should contain at least the "type" field, if applicable.
2556 * @return string Return the "type" value for this record, ready to pick a "types" configuration from the $TCA array.
2558 function getRTypeNum($table,$row) {
2560 // If there is a "type" field configured...
2561 if ($TCA[$table]['ctrl']['type']) {
2562 $typeFieldName = $TCA[$table]['ctrl']['type'];
2563 $typeNum=$row[$typeFieldName]; // Get value of the row from the record which contains the type value.
2564 if (!strcmp($typeNum,'')) $typeNum=0; // If that value is an empty string, set it to "0" (zero)
2566 $typeNum = 0; // If no "type" field, then set to "0" (zero)
2569 $typeNum = (string)$typeNum; // Force to string. Necessary for eg '-1' to be recognized as a type value.
2570 if (!$TCA[$table]['types'][$typeNum]) { // However, if the type "0" is not found in the "types" array, then default to "1" (for historical reasons)
2578 * Used to adhoc-rearrange the field order normally set in the [types][showitem] list
2580 * @param array A [types][showitem] list of fields, exploded by ","
2581 * @return array Returns rearranged version (keys are changed around as well.)
2582 * @see getMainFields()
2584 function rearrange($fields) {
2585 $fO = array_flip(t3lib_div
::trimExplode(',',$this->fieldOrder
,1));
2588 while(list($cc,$content)=each($fields)) {
2589 $cP = t3lib_div
::trimExplode(';',$content);
2590 if (isset($fO[$cP[0]])) {
2591 $newFields[$fO[$cP[0]]] = $content;
2592 unset($fields[$cc]);
2596 $fields=array_merge($newFields,$fields); // Candidate for t3lib_div::array_merge() if integer-keys will some day make trouble...
2601 * Producing an array of field names NOT to display in the form, based on settings from subtype_value_field, bitmask_excludelist_bits etc.
2602 * Notice, this list is in NO way related to the "excludeField" flag
2604 * @param string Table name, MUST be in $TCA
2605 * @param array A record from table.
2606 * @param string A "type" pointer value, probably the one calculated based on the record array.
2607 * @return array Array with fieldnames as values. The fieldnames are those which should NOT be displayed "anyways"
2608 * @see getMainFields()
2610 function getExcludeElements($table,$row,$typeNum) {
2614 $excludeElements=array();
2616 // If a subtype field is defined for the type
2617 if ($TCA[$table]['types'][$typeNum]['subtype_value_field']) {
2618 $sTfield = $TCA[$table]['types'][$typeNum]['subtype_value_field'];
2619 if (trim($TCA[$table]['types'][$typeNum]['subtypes_excludelist'][$row[$sTfield]])) {
2620 $excludeElements=t3lib_div
::trimExplode(',',$TCA[$table]['types'][$typeNum]['subtypes_excludelist'][$row[$sTfield]],1);
2624 // If a bitmask-value field has been configured, then find possible fields to exclude based on that:
2625 if ($TCA[$table]['types'][$typeNum]['bitmask_value_field']) {
2626 $sTfield = $TCA[$table]['types'][$typeNum]['bitmask_value_field'];
2627 $sTValue = t3lib_div
::intInRange($row[$sTfield],0);
2628 if (is_array($TCA[$table]['types'][$typeNum]['bitmask_excludelist_bits'])) {
2629 reset($TCA[$table]['types'][$typeNum]['bitmask_excludelist_bits']);
2630 while(list($bitKey,$eList)=each($TCA[$table]['types'][$typeNum]['bitmask_excludelist_bits'])) {
2631 $bit=substr($bitKey,1);
2632 if (t3lib_div
::testInt($bit)) {
2633 $bit = t3lib_div
::intInRange($bit,0,30);
2635 (substr($bitKey,0,1)=='-' && !($sTValue&pow(2,$bit))) ||
2636 (substr($bitKey,0,1)=='+' && ($sTValue&pow(2,$bit)))
2638 $excludeElements = array_merge($excludeElements,t3lib_div
::trimExplode(',',$eList,1));
2645 // Return the array of elements:
2646 return $excludeElements;
2650 * Finds possible field to add to the form, based on subtype fields.
2652 * @param string Table name, MUST be in $TCA
2653 * @param array A record from table.
2654 * @param string A "type" pointer value, probably the one calculated based on the record array.
2655 * @return array An array containing two values: 1) Another array containing fieldnames to add and 2) the subtype value field.
2656 * @see getMainFields()
2658 function getFieldsToAdd($table,$row,$typeNum) {
2662 $addElements=array();
2664 // If a subtype field is defined for the type
2665 if ($TCA[$table]['types'][$typeNum]['subtype_value_field']) {
2666 $sTfield = $TCA[$table]['types'][$typeNum]['subtype_value_field'];
2667 if (trim($TCA[$table]['types'][$typeNum]['subtypes_addlist'][$row[$sTfield]])) {
2668 $addElements=t3lib_div
::trimExplode(',',$TCA[$table]['types'][$typeNum]['subtypes_addlist'][$row[$sTfield]],1);
2671 // Return the return
2672 return array($addElements,$sTfield);
2676 * Merges the current [types][showitem] array with the array of fields to add for the current subtype field of the "type" value.
2678 * @param array A [types][showitem] list of fields, exploded by ","
2679 * @param array The output from getFieldsToAdd()
2680 * @return array Return the modified $fields array.
2681 * @see getMainFields(),getFieldsToAdd()
2683 function mergeFieldsWithAddedFields($fields,$fieldsToAdd) {
2684 if (count($fieldsToAdd[0])) {
2687 while(list(,$fieldInfo)=each($fields)) {
2688 $parts = explode(';',$fieldInfo);
2689 if (!strcmp(trim($parts[0]),$fieldsToAdd[1])) {