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 * 196: class t3lib_TCEforms
42 * 302: function t3lib_TCEforms()
43 * 338: function initDefaultBEmode()
45 * SECTION: Rendering the forms, fields etc
46 * 385: function getSoloField($table,$row,$theFieldToReturn)
47 * 424: function getMainFields($table,$row,$depth=0)
48 * 618: function getListedFields($table,$row,$list)
49 * 660: function getPaletteFields($table,$row,$palette,$header='',$itemList='',$collapsedHeader='')
50 * 737: function getSingleField($table,$field,$row,$altName='',$palette=0,$extra='',$pal=0)
51 * 900: function getSingleField_SW($table,$field,$row,&$PA)
53 * SECTION: Rendering of each TCEform field type
54 * 976: function getSingleField_typeInput($table,$field,$row,&$PA)
55 * 1057: function getSingleField_typeText($table,$field,$row,&$PA)
56 * 1178: function getSingleField_typeCheck($table,$field,$row,&$PA)
57 * 1244: function getSingleField_typeRadio($table,$field,$row,&$PA)
58 * 1279: function getSingleField_typeSelect($table,$field,$row,&$PA)
59 * 1359: function getSingleField_typeSelect_single($table,$field,$row,&$PA,$config,$selItems,$nMV_label)
60 * 1490: function getSingleField_typeSelect_checkbox($table,$field,$row,&$PA,$config,$selItems,$nMV_label)
61 * 1609: function getSingleField_typeSelect_singlebox($table,$field,$row,&$PA,$config,$selItems,$nMV_label)
62 * 1719: function getSingleField_typeSelect_multiple($table,$field,$row,&$PA,$config,$selItems,$nMV_label)
63 * 1823: function getSingleField_typeGroup($table,$field,$row,&$PA)
64 * 1992: function getSingleField_typeNone($table,$field,$row,&$PA)
65 * 2008: function getSingleField_typeNone_render($config,$itemValue)
66 * 2070: function getSingleField_typeFlex($table,$field,$row,&$PA)
67 * 2205: function getSingleField_typeFlex_langMenu($languages,$elName,$selectedLanguage,$multi=1)
68 * 2224: function getSingleField_typeFlex_sheetMenu($sArr,$elName,$sheetKey)
69 * 2259: function getSingleField_typeFlex_draw($dataStruct,$editData,$cmdData,$table,$field,$row,&$PA,$formPrefix='',$level=0,$tRows=array())
70 * 2452: function getSingleField_typeUnknown($table,$field,$row,&$PA)
71 * 2467: function getSingleField_typeUser($table,$field,$row,&$PA)
73 * SECTION: Field content processing
74 * 2496: function formatValue ($config, $itemValue)
76 * SECTION: "Configuration" fetching/processing functions
77 * 2588: function getRTypeNum($table,$row)
78 * 2614: function rearrange($fields)
79 * 2640: function getExcludeElements($table,$row,$typeNum)
80 * 2688: function getFieldsToAdd($table,$row,$typeNum)
81 * 2713: function mergeFieldsWithAddedFields($fields,$fieldsToAdd)
82 * 2745: function setTSconfig($table,$row,$field='')
83 * 2767: function getSpecConfForField($table,$row,$field)
84 * 2788: function getSpecConfFromString($extraString, $defaultExtras)
86 * SECTION: Display of localized content etc.
87 * 2816: function registerDefaultLanguageData($table,$rec)
88 * 2848: function getLanguageOverlayRawValue($table, $row, $field, $fieldConf)
89 * 2876: function renderDefaultLanguageContent($table,$field,$row,$item)
90 * 2899: function renderDefaultLanguageDiff($table,$field,$row,$item)
92 * SECTION: Form element helper functions
93 * 2955: function dbFileIcons($fName,$mode,$allowed,$itemArray,$selector='',$params=array(),$onFocus='')
94 * 3108: function getClipboardElements($allowed,$mode)
95 * 3157: function getClickMenu($str,$table,$uid='')
96 * 3178: function renderWizards($itemKinds,$wizConf,$table,$row,$field,&$PA,$itemName,$specConf,$RTE=0)
97 * 3382: function getIcon($icon)
98 * 3409: function optionTagStyle($iconString)
99 * 3425: function extractValuesOnlyFromValueLabelList($itemFormElValue)
100 * 3447: function wrapOpenPalette($header,$table,$row,$palette,$retFunc=0)
101 * 3471: function checkBoxParams($itemName,$thisValue,$c,$iCount,$addFunc='')
102 * 3485: function elName($itemName)
103 * 3496: function noTitle($str,$wrapParts=array())
104 * 3505: function blur()
105 * 3514: function thisReturnUrl()
106 * 3527: function getSingleHiddenField($table,$field,$row)
107 * 3549: function formWidth($size=48,$textarea=0)
108 * 3576: function formWidthText($size=48,$wrap='')
109 * 3592: function formElStyle($type)
110 * 3603: function formElClass($type)
111 * 3614: function formElStyleClassValue($type, $class=FALSE)
112 * 3638: function insertDefStyle($type)
113 * 3657: function getDynTabMenu($parts, $idString)
115 * SECTION: Item-array manipulation functions (check/select/radio)
116 * 3696: function initItemArray($fieldValue)
117 * 3714: function addItems($items,$iArray)
118 * 3736: function procItems($items,$iArray,$config,$table,$row,$field)
119 * 3760: function addSelectOptionsToItemArray($items,$fieldValue,$TSconfig,$field)
120 * 3980: function addSelectOptionsToItemArray_makeModuleData($value)
121 * 4002: function foreignTable($items,$fieldValue,$TSconfig,$field,$pFFlag=0)
123 * SECTION: Template functions
124 * 4083: function setNewBEDesign()
125 * 4138: function intoTemplate($inArr,$altTemplate='')
126 * 4162: function addUserTemplateMarkers($marker,$table,$field,$row,&$PA)
127 * 4173: function wrapLabels($str)
128 * 4186: function wrapTotal($c,$rec,$table)
129 * 4199: function replaceTableWrap($arr,$rec,$table)
130 * 4236: function wrapBorder(&$out_array,&$out_pointer)
131 * 4258: function rplColorScheme($inTemplate)
132 * 4278: function getDivider()
133 * 4288: function printPalette($palArr)
134 * 4339: function helpTextIcon($table,$field,$force=0)
135 * 4359: function helpText($table,$field)
136 * 4380: function setColorScheme($scheme)
137 * 4404: function resetSchemes()
138 * 4415: function storeSchemes()
139 * 4427: function restoreSchemes()
141 * SECTION: JavaScript related functions
142 * 4457: function JStop()
143 * 4508: function JSbottom($formname='forms[0]')
144 * 4835: function dbFileCon($formObj='document.forms[0]')
145 * 5053: function printNeededJSFunctions()
146 * 5080: function printNeededJSFunctions_top()
148 * SECTION: Various helper functions
149 * 5128: function getDefaultRecord($table,$pid=0)
150 * 5167: function getRecordPath($table,$rec)
151 * 5181: function readPerms()
152 * 5195: function sL($str)
153 * 5208: function getLL($str)
154 * 5229: function isPalettesCollapsed($table,$palette)
155 * 5245: function isDisplayCondition($displayCond,$row,$ffValueKey='')
156 * 5349: function getTSCpid($table,$uid,$pid)
157 * 5363: function doLoadTableDescr($table)
158 * 5375: function getAvailableLanguages($onlyIsoCoded=1,$setDefault=1)
161 * 5417: class t3lib_TCEforms_FE extends t3lib_TCEforms
162 * 5425: function wrapLabels($str)
163 * 5435: function printPalette($palArr)
164 * 5460: 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');
184 require_once(PATH_t3lib
.'class.t3lib_tceforms_inline.php');
189 * 'TCEforms' - Class for creating the backend editing forms.
191 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
192 * @coauthor Rene Fritz <r.fritz@colorcube.de>
196 class t3lib_TCEforms
{
198 // variables not commented yet.... (do so...)
199 var $palFieldArr = array();
200 var $disableWizards = 0;
201 var $isPalettedoc = 0;
202 var $paletteMargin = 1;
203 var $defStyle = ''; // 'font-family:Verdana;font-size:10px;';
204 var $cachedTSconfig = array();
205 var $cachedTSconfig_fieldLevel = array();
206 var $cachedLanguageFlag = array();
207 var $cachedAdditionalPreviewLanguages = NULL;
208 var $transformedRow = array();
210 var $printNeededJS = array();
211 var $hiddenFieldAccum=array();
212 var $TBE_EDITOR_fieldChanged_func='';
214 var $prevBorderStyle='[nothing here...]'; // Something unique...
215 var $allowUpload=0; // If set direct upload fields will be shown
216 var $titleLen=15; // @deprecated: $BE_USER->uc['titleLen'] but what is default??
217 var $defaultLanguageData = array(); // Array where records in the default language is stored. (processed by transferdata)
218 var $defaultLanguageData_diff = array(); // Array where records in the default language is stored (raw without any processing. used for making diff)
219 var $additionalPreviewLanguageData = array();
223 var $backPath=''; // Set this to the 'backPath' pointing back to the typo3 admin directory from the script where this form is displayed.
224 var $returnUrl=''; // Alternative return URL path (default is t3lib_div::linkThisScript())
225 var $doSaveFieldName=''; // Can be set to point to a field name in the form which will be set to '1' when the form is submitted with a *save* button. This way the recipient script can determine that the form was submitted for save and not "close" for example.
226 var $palettesCollapsed=0; // Can be set true/false to whether palettes (secondary options) are in the topframe or in form. True means they are NOT IN-form. So a collapsed palette is one, which is shown in the top frame, not in the page.
227 var $disableRTE=0; // If set, the RTE is disabled (from form display, eg. by checkbox in the bottom of the page!)
228 var $globalShowHelp=1; // If false, then all CSH will be disabled, regardless of settings in $this->edit_showFieldHelp
229 var $localizationMode=''; // If true, the forms are rendering only localization relevant fields of the records.
230 var $fieldOrder=''; // Overrule the field order set in TCA[types][showitem], eg for tt_content this value, 'bodytext,image', would make first the 'bodytext' field, then the 'image' field (if set for display)... and then the rest in the old order.
231 var $doPrintPalette=1; // If set to false, palettes will NEVER be rendered.
232 var $clipObj=FALSE; // Set to initialized clipboard object; Then the element browser will offer a link to paste in records from clipboard.
233 var $enableClickMenu=FALSE; // Enable click menu on reference icons.
234 var $enableTabMenu = FALSE; // Enable Tab Menus. If set to true, the JavaScript content from template::getDynTabMenuJScode() must be included in the document.
235 var $renderReadonly = FALSE; // When enabled all fields are rendered non-editable.
237 var $form_rowsToStylewidth = 9.58; // Form field width compensation: Factor from NN4 form field widths to style-aware browsers (like NN6+ and MSIE, with the $CLIENT[FORMSTYLE] value set)
238 var $form_largeComp = 1.33; // Form field width compensation: Compensation for large documents, doc-tab (editing)
239 var $charsPerRow=40; // The number of chars expected per row when the height of a text area field is automatically calculated based on the number of characters found in the field content.
240 var $maxTextareaWidth=48; // The maximum abstract value for textareas
241 var $maxInputWidth=48; // The maximum abstract value for input fields
242 var $defaultMultipleSelectorStyle='width:250px;'; // Default style for the selector boxes used for multiple items in "select" and "group" types.
246 var $prependFormFieldNames = 'data'; // The string to prepend formfield names with.
247 var $prependCmdFieldNames = 'cmd'; // The string to prepend commands for tcemain::process_cmdmap with.
248 var $prependFormFieldNames_file = 'data_files'; // The string to prepend FILE form field names with.
249 var $formName = 'editform'; // The name attribute of the form.
254 var $perms_clause=''; // Set by readPerms() (caching)
255 var $perms_clause_set=0; // Set by readPerms() (caching-flag)
256 var $edit_showFieldHelp=''; // Used to indicate the mode of CSH (Context Sensitive Help), whether it should be icons-only ('icon'), full description ('text') or not at all (blank).
257 var $docLarge=0; // If set, the forms will be rendered a little wider, more precisely with a factor of $this->form_largeComp.
258 var $clientInfo=array(); // Loaded with info about the browser when class is instantiated.
259 var $RTEenabled=0; // True, if RTE is possible for the current user (based on result from BE_USER->isRTE())
260 var $RTEenabled_notReasons=''; // If $this->RTEenabled was false, you can find the reasons listed in this array which is filled with reasons why the RTE could not be loaded)
261 var $RTEcounter = 0; // Counter that is incremented before an RTE is created. Can be used for unique ids etc.
263 var $colorScheme; // Contains current color scheme
264 var $classScheme; // Contains current class scheme
265 var $defColorScheme; // Contains the default color scheme
266 var $defClassScheme; // Contains the default class scheme
267 var $fieldStyle; // Contains field style values
268 var $borderStyle; // Contains border style values.
270 var $commentMessages=array(); // An accumulation of messages from the class.
272 // INTERNAL, templates
273 var $totalWrap='<hr />|<hr />'; // Total wrapping for the table rows.
274 var $fieldTemplate='<b>###FIELD_NAME###</b><br />###FIELD_ITEM###<hr />'; // Field template
275 var $sectionWrap=''; // Wrapping template code for a section
276 var $palFieldTemplateHeader=''; // Template for palette headers
277 var $palFieldTemplate=''; // Template for palettes
279 // INTERNAL, working memory
280 var $excludeElements=''; // Set to the fields NOT to display, if any.
281 var $palettesRendered=array(); // During rendering of forms this will keep track of which palettes has already been rendered (so they are not rendered twice by mistake)
282 var $hiddenFieldListArr = array(); // This array of fields will be set as hidden-fields instead of rendered normally! For instance palette fields edited in the top frame are set as hidden fields since the main form has to submit the values. The top frame actually just sets the value in the main form!
283 var $requiredFields=array(); // Used to register input-field names, which are required. (Done during rendering of the fields). This information is then used later when the JavaScript is made.
284 var $requiredElements=array(); // Used to register the min and max number of elements for selectorboxes where that apply (in the "group" type for instance)
285 var $renderDepth=0; // Keeps track of the rendering depth of nested records.
286 var $savedSchemes=array(); // Color scheme buffer.
287 var $dynTabLevelStack = array(); // holds tab dividers which were cascaded, required for RTE&IRRE
289 // Internal, registers for user defined functions etc.
290 var $additionalCode_pre = array(); // Additional HTML code, printed before the form.
291 var $additionalJS_pre = array(); // Additional JavaScript, printed before the form
292 var $additionalJS_post = array(); // Additional JavaScript printed after the form
293 var $additionalJS_submit = array(); // Additional JavaScript executed on submit; If you set "OK" variable it will raise an error about RTEs not being loaded and offer to block further submission.
295 var $inline; // Instance of t3lib_tceforms_inline
302 * Constructor function, setting internal variables, loading the styles used.
306 function t3lib_TCEforms() {
309 $this->clientInfo
= t3lib_div
::clientInfo();
311 $this->RTEenabled
= $GLOBALS['BE_USER']->isRTE();
312 if (!$this->RTEenabled
) {
313 $this->RTEenabled_notReasons
= implode(chr(10),$GLOBALS['BE_USER']->RTE_errors
);
314 $this->commentMessages
[] = 'RTE NOT ENABLED IN SYSTEM due to:'.chr(10).$this->RTEenabled_notReasons
;
317 // Default color+class scheme
318 $this->defColorScheme
= array(
319 $GLOBALS['SOBE']->doc
->bgColor
, // Background for the field AND palette
320 t3lib_div
::modifyHTMLColorAll($GLOBALS['SOBE']->doc
->bgColor
,-20), // Background for the field header
321 t3lib_div
::modifyHTMLColorAll($GLOBALS['SOBE']->doc
->bgColor
,-10), // Background for the palette field header
322 'black', // Field header font color
323 '#666666' // Palette field header font color
325 $this->defColorScheme
= array();
327 // Override / Setting defaults from TBE_STYLES array
328 $this->resetSchemes();
330 // Setting the current colorScheme to default.
331 $this->defColorScheme
= $this->colorScheme
;
332 $this->defClassScheme
= $this->classScheme
;
334 $this->inline
= t3lib_div
::makeInstance('t3lib_TCEforms_inline');
338 * Initialize various internal variables.
342 function initDefaultBEmode() {
344 $this->prependFormFieldNames
= 'data';
345 $this->formName
= 'editform';
346 $this->setNewBEDesign();
347 $this->docLarge
= $BE_USER->uc
['edit_wideDocument'] ?
1 : 0;
348 $this->edit_showFieldHelp
= $BE_USER->uc
['edit_showFieldHelp'];
350 $this->edit_docModuleUpload
= $BE_USER->uc
['edit_docModuleUpload'];
351 $this->titleLen
= $BE_USER->uc
['titleLen']; // @deprecated
353 $this->inline
->init($this);
372 /*******************************************************
374 * Rendering the forms, fields etc
376 *******************************************************/
379 * Will return the TCEform element for just a single field from a record.
380 * The field must be listed in the currently displayed fields (as found in [types][showitem]) for the record.
381 * This also means that the $table/$row supplied must be complete so the list of fields to show can be found correctly
383 * @param string The table name
384 * @param array The record from the table for which to render a field.
385 * @param string The field name to return the TCEform element for.
386 * @return string HTML output
387 * @see getMainFields()
389 function getSoloField($table,$row,$theFieldToReturn) {
393 t3lib_div
::loadTCA($table);
394 $typeNum = $this->getRTypeNum($table,$row);
395 if ($TCA[$table]['types'][$typeNum]) {
396 $itemList = $TCA[$table]['types'][$typeNum]['showitem'];
398 $fields = t3lib_div
::trimExplode(',',$itemList,1);
399 $excludeElements = $this->excludeElements
= $this->getExcludeElements($table,$row,$typeNum);
402 while(list(,$fieldInfo)=each($fields)) {
403 $parts = explode(';',$fieldInfo);
405 $theField = trim($parts[0]);
406 if (!in_array($theField,$excludeElements) && !strcmp($theField,$theFieldToReturn)) {
407 if ($TCA[$table]['columns'][$theField]) {
408 $sField = $this->getSingleField($table,$theField,$row,$parts[1],1,$parts[3],$parts[2]);
409 return $sField['ITEM'];
419 * Based on the $table and $row of content, this displays the complete TCEform for the record.
420 * The input-$row is required to be preprocessed if necessary by eg. the t3lib_transferdata class. For instance the RTE content should be transformed through this class first.
422 * @param string The table name
423 * @param array The record from the table for which to render a field.
424 * @param integer Depth level
425 * @return string HTML output
426 * @see getSoloField()
428 function getMainFields($table,$row,$depth=0) {
429 global $TCA, $TYPO3_CONF_VARS;
431 $this->renderDepth
=$depth;
434 $out_array = array(array());
435 $out_array_meta = array(array(
436 'title' => $this->getLL('l_generalTab')
441 $this->palettesRendered
=array();
442 $this->palettesRendered
[$this->renderDepth
][$table]=array();
444 // First prepare user defined objects (if any) for hooks which extend this function:
445 $hookObjectsArr = array();
446 if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'])) {
447 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'] as $classRef) {
448 $hookObjectsArr[] = &t3lib_div
::getUserObj($classRef);
452 // Hook: getMainFields_preProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
453 foreach ($hookObjectsArr as $hookObj) {
454 if (method_exists($hookObj,'getMainFields_preProcess')) {
455 $hookObj->getMainFields_preProcess($table,$row,$this);
461 // Load the full TCA for the table.
462 t3lib_div
::loadTCA($table);
464 // Load the description content for the table.
465 if ($this->edit_showFieldHelp ||
$this->doLoadTableDescr($table)) {
466 $GLOBALS['LANG']->loadSingleTableDescription($table);
468 // Get the current "type" value for the record.
469 $typeNum = $this->getRTypeNum($table,$row);
471 // Find the list of fields to display:
472 if ($TCA[$table]['types'][$typeNum]) {
473 $itemList = $TCA[$table]['types'][$typeNum]['showitem'];
474 if ($itemList) { // If such a list existed...
475 // if TCEforms will render a tab menu in the next step, push the name to the tab stack
476 if (strstr($itemList, '--div--') !== false && $this->enableTabMenu
&& $TCA[$table]['ctrl']['dividers2tabs']) {
477 $tabIdentString = 'TCEforms:'.$table.':'.$row['uid'];
478 $tabIdentStringMD5 = $GLOBALS['TBE_TEMPLATE']->getDynTabMenuId('TCEforms:'.$table.':'.$row['uid']);
479 $this->dynTabLevelStack
[$tabIdentStringMD5] = 1;
482 // Explode the field list and possibly rearrange the order of the fields, if configured for
483 $fields = t3lib_div
::trimExplode(',',$itemList,1);
484 if ($this->fieldOrder
) {
485 $fields = $this->rearrange($fields);
488 // Get excluded fields, added fiels and put it together:
489 $excludeElements = $this->excludeElements
= $this->getExcludeElements($table,$row,$typeNum);
490 $fields = $this->mergeFieldsWithAddedFields($fields,$this->getFieldsToAdd($table,$row,$typeNum));
492 // Traverse the fields to render:
494 foreach($fields as $fieldInfo) {
495 // Exploding subparts of the field configuration:
496 $parts = explode(';',$fieldInfo);
498 // Getting the style information out:
499 $color_style_parts = t3lib_div
::trimExplode('-',$parts[4]);
500 if (strcmp($color_style_parts[0],'')) {
501 $this->setColorScheme($GLOBALS['TBE_STYLES']['colorschemes'][intval($color_style_parts[0])]);
503 if (strcmp($color_style_parts[1],'')) {
504 $this->fieldStyle
= $GLOBALS['TBE_STYLES']['styleschemes'][intval($color_style_parts[1])];
505 if (!isset($this->fieldStyle
)) $this->fieldStyle
= $GLOBALS['TBE_STYLES']['styleschemes'][0];
507 if (strcmp($color_style_parts[2],'')) {
508 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
509 $this->borderStyle
= $GLOBALS['TBE_STYLES']['borderschemes'][intval($color_style_parts[2])];
510 if (!isset($this->borderStyle
)) $this->borderStyle
= $GLOBALS['TBE_STYLES']['borderschemes'][0];
514 $theField = $parts[0];
515 if (!in_array($theField,$excludeElements)) {
516 if ($TCA[$table]['columns'][$theField]) {
519 if ($parts[2] && !isset($this->palettesRendered
[$this->renderDepth
][$table][$parts[2]])) {
520 $sFieldPal=$this->getPaletteFields($table,$row,$parts[2]);
521 $this->palettesRendered
[$this->renderDepth
][$table][$parts[2]] = 1;
523 $sField = $this->getSingleField($table,$theField,$row,$parts[1],0,$parts[3],$parts[2]);
524 if ($sField) { $sField.= $sFieldPal; }
526 $out_array[$out_sheet][$out_pointer].= $sField;
527 } elseif ($theField=='--div--') {
529 $out_array[$out_sheet][$out_pointer].=$this->getDivider();
531 if ($this->enableTabMenu
&& $TCA[$table]['ctrl']['dividers2tabs']) {
532 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
534 // remember what sheet we're currently in
535 $this->dynTabLevelStack
[$tabIdentStringMD5] = $out_sheet+
1;
536 $out_array[$out_sheet] = array();
537 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
539 } else { // Setting alternative title for "General" tab if "--div--" is the very first element.
540 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
542 } elseif($theField=='--palette--') {
543 if ($parts[2] && !isset($this->palettesRendered
[$this->renderDepth
][$table][$parts[2]])) {
544 // render a 'header' if not collapsed
545 if ($TCA[$table]['palettes'][$parts[2]]['canNotCollapse'] AND $parts[1]) {
546 $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$parts[2],$this->sL($parts[1]));
548 $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$parts[2],'','',$this->sL($parts[1]));
550 $this->palettesRendered
[$this->renderDepth
][$table][$parts[2]] = 1;
561 // Hook: getMainFields_postProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
562 foreach ($hookObjectsArr as $hookObj) {
563 if (method_exists($hookObj,'getMainFields_postProcess')) {
564 $hookObj->getMainFields_postProcess($table,$row,$this);
568 // Wrapping a border around it all:
569 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
572 $this->resetSchemes();
574 // Rendering Main palettes, if any
575 $mParr = t3lib_div
::trimExplode(',',$TCA[$table]['ctrl']['mainpalette']);
578 foreach ($mParr as $mP) {
579 if (!isset($this->palettesRendered
[$this->renderDepth
][$table][$mP])) {
580 $temp_palettesCollapsed=$this->palettesCollapsed
;
581 $this->palettesCollapsed
=0;
582 $label = ($i==0?
$this->getLL('l_generalOptions'):$this->getLL('l_generalOptions_more'));
583 $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$mP,$label);
584 $this->palettesCollapsed
=$temp_palettesCollapsed;
585 $this->palettesRendered
[$this->renderDepth
][$table][$mP] = 1;
587 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
589 if ($this->renderDepth
) {
590 $this->renderDepth
--;
595 // Return the imploded $out_array:
596 if ($out_sheet>0) { // There were --div-- dividers around...
598 // Create parts array for the tab menu:
600 foreach ($out_array as $idx => $sheetContent) {
602 'label' => $out_array_meta[$idx]['title'],
603 'content' => '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.
604 implode('',$sheetContent).
609 // unset the current level of tab menus
610 unset($this->dynTabLevelStack
[$tabIdentStringMD5]);
615 '.$this->getDynTabMenu($parts, $tabIdentString).'
618 } else { // Only one, so just implode:
619 return implode('',$out_array[$out_sheet]);
624 * Will return the TCEform elements for a pre-defined list of fields.
625 * Notice that this will STILL use the configuration found in the list [types][showitem] for those fields which are found there. So ideally the list of fields given as argument to this function should also be in the current [types][showitem] list of the record.
626 * Used for displaying forms for the frontend edit icons for instance.
628 * @param string The table name
629 * @param array The record array.
630 * @param string Commalist of fields from the table. These will be shown in the specified order in a form.
631 * @return string TCEform elements in a string.
633 function getListedFields($table,$row,$list) {
636 t3lib_div
::loadTCA($table);
637 if ($this->edit_showFieldHelp ||
$this->doLoadTableDescr($table)) {
638 $GLOBALS['LANG']->loadSingleTableDescription($table);
642 $types_fieldConfig = t3lib_BEfunc
::getTCAtypes($table,$row,1);
644 $editFieldList=array_unique(t3lib_div
::trimExplode(',',$list,1));
645 foreach($editFieldList as $theFieldC) {
646 list($theField,$palFields) = split('\[|\]',$theFieldC);
647 $theField = trim($theField);
648 $palFields = trim($palFields);
649 if ($TCA[$table]['columns'][$theField]) {
650 $parts = t3lib_div
::trimExplode(';',$types_fieldConfig[$theField]['origString']);
651 $sField = $this->getSingleField($table,$theField,$row,$parts[1],0,$parts[3],0); // Don't sent palette pointer - there are no options anyways for a field-list.
653 } elseif($theField=='--div--') {
654 $out.= $this->getDivider();
657 $out.= $this->getPaletteFields($table,$row,'','',implode(',',t3lib_div
::trimExplode('|',$palFields,1)));
665 * Creates a palette (collection of secondary options).
667 * @param string The table name
668 * @param array The row array
669 * @param string The palette number/pointer
670 * @param string Header string for the palette (used when in-form). If not set, no header item is made.
671 * @param string Optional alternative list of fields for the palette
672 * @param string Optional Link text for activating a palette (when palettes does not have another form element to belong to).
673 * @return string HTML code.
675 function getPaletteFields($table,$row,$palette,$header='',$itemList='',$collapsedHeader='') {
677 if (!$this->doPrintPalette
) return '';
681 t3lib_div
::loadTCA($table);
683 // Getting excludeElements, if any.
684 if (!is_array($this->excludeElements
)) {
685 $this->excludeElements
= $this->getExcludeElements($table,$row,$this->getRTypeNum($table,$row));
688 // Render the palette TCEform elements.
689 if ($TCA[$table] && (is_array($TCA[$table]['palettes'][$palette]) ||
$itemList)) {
690 $itemList = $itemList?
$itemList:$TCA[$table]['palettes'][$palette]['showitem'];
692 $fields = t3lib_div
::trimExplode(',',$itemList,1);
694 while(list(,$fieldInfo)=each($fields)) {
695 $parts = t3lib_div
::trimExplode(';',$fieldInfo);
696 $theField = $parts[0];
698 if (!in_array($theField,$this->excludeElements
) && $TCA[$table]['columns'][$theField]) {
699 $this->palFieldArr
[$palette][] = $theField;
700 if ($this->isPalettesCollapsed($table,$palette)) {
701 $this->hiddenFieldListArr
[] = $theField;
704 $part = $this->getSingleField($table,$theField,$row,$parts[1],1,'',$parts[2]);
705 if (is_array($part)) {
712 // Put palette together if there are fields in it:
713 if (count($palParts)) {
715 $out.= $this->intoTemplate(array(
716 'HEADER' => htmlspecialchars($header)
718 $this->palFieldTemplateHeader
721 $out.= $this->intoTemplate(array(
722 'PALETTE' => $this->printPalette($palParts)
724 $this->palFieldTemplate
727 // If a palette is collapsed (not shown in form, but in top frame instead) AND a collapse header string is given, then make that string a link to activate the palette.
728 if ($this->isPalettesCollapsed($table,$palette) && $collapsedHeader) {
729 $pC = $this->intoTemplate(array(
730 'PALETTE' => $this->wrapOpenPalette('<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/options.gif','width="18" height="16"').' border="0" title="'.htmlspecialchars($this->getLL('l_moreOptions')).'" align="top" alt="" /><strong>'.$collapsedHeader.'</strong>',$table,$row,$palette),
732 $this->palFieldTemplate
741 * Returns the form HTML code for a database table field.
743 * @param string The table name
744 * @param string The field name
745 * @param array The record to edit from the database table.
746 * @param string Alternative field name label to show.
747 * @param boolean Set this if the field is on a palette (in top frame), otherwise not. (if set, field will render as a hidden field).
748 * @param string The "extra" options from "Part 4" of the field configurations found in the "types" "showitem" list. Typically parsed by $this->getSpecConfFromString() in order to get the options as an associative array.
749 * @param integer The palette pointer.
750 * @return mixed String (normal) or array (palettes)
752 function getSingleField($table,$field,$row,$altName='',$palette=0,$extra='',$pal=0) {
753 global $TCA,$BE_USER;
757 $PA['altName'] = $altName;
758 $PA['palette'] = $palette;
759 $PA['extra'] = $extra;
762 // Make sure to load full $TCA array for the table:
763 t3lib_div
::loadTCA($table);
765 // Get the TCA configuration for the current field:
766 $PA['fieldConf'] = $TCA[$table]['columns'][$field];
767 $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ?
$PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type']; // Using "form_type" locally in this script
769 $skipThisField = $this->inline
->skipField($table, $field, $row, $PA['fieldConf']['config']);
771 // Now, check if this field is configured and editable (according to excludefields + other configuration)
772 if ( is_array($PA['fieldConf']) &&
774 (!$PA['fieldConf']['exclude'] ||
$BE_USER->check('non_exclude_fields',$table.':'.$field)) &&
775 $PA['fieldConf']['config']['form_type']!='passthrough' &&
776 ($this->RTEenabled ||
!$PA['fieldConf']['config']['showIfRTE']) &&
777 (!$PA['fieldConf']['displayCond'] ||
$this->isDisplayCondition($PA['fieldConf']['displayCond'],$row)) &&
778 (!$TCA[$table]['ctrl']['languageField'] ||
$PA['fieldConf']['l10n_display'] ||
strcmp($PA['fieldConf']['l10n_mode'],'exclude') ||
$row[$TCA[$table]['ctrl']['languageField']]<=0) &&
779 (!$TCA[$table]['ctrl']['languageField'] ||
!$this->localizationMode ||
$this->localizationMode
===$PA['fieldConf']['l10n_cat'])
784 // Fetching the TSconfig for the current table/field. This includes the $row which means that
785 $PA['fieldTSConfig'] = $this->setTSconfig($table,$row,$field);
787 // If the field is NOT disabled from TSconfig (which it could have been) then render it
788 if (!$PA['fieldTSConfig']['disabled']) {
791 $PA['itemFormElName']=$this->prependFormFieldNames
.'['.$table.']['.$row['uid'].']['.$field.']'; // Form field name
792 $PA['itemFormElName_file']=$this->prependFormFieldNames_file
.'['.$table.']['.$row['uid'].']['.$field.']'; // Form field name, in case of file uploads
793 $PA['itemFormElValue']=$row[$field]; // The value to show in the form field.
794 $PA['itemFormElID']=$this->prependFormFieldNames
.'_'.$table.'_'.$row['uid'].'_'.$field;
796 // set field to read-only if configured for translated records to show default language content as readonly
797 if ($PA['fieldConf']['l10n_display'] AND t3lib_div
::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly') AND $row[$TCA[$table]['ctrl']['languageField']]) {
798 $PA['fieldConf']['config']['readOnly'] = true;
799 $PA['itemFormElValue'] = $this->defaultLanguageData
[$table.':'.$row['uid']][$field];
802 // Create a JavaScript code line which will ask the user to save/update the form due to changing the element. This is used for eg. "type" fields and others configured with "requestUpdate"
804 ($TCA[$table]['ctrl']['type'] && !strcmp($field,$TCA[$table]['ctrl']['type'])) ||
805 ($TCA[$table]['ctrl']['requestUpdate'] && t3lib_div
::inList($TCA[$table]['ctrl']['requestUpdate'],$field))) {
806 if($GLOBALS['BE_USER']->jsConfirmation(1)) {
807 $alertMsgOnChange = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
809 $alertMsgOnChange = 'if (TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
812 $alertMsgOnChange = '';
815 // Render as a hidden field?
816 if (in_array($field,$this->hiddenFieldListArr
)) {
817 $this->hiddenFieldAccum
[]='<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
818 } else { // Render as a normal field:
820 // If the field is NOT a palette field, then we might create an icon which links to a palette for the field, if one exists.
821 if (!$PA['palette']) {
822 if ($PA['pal'] && $this->isPalettesCollapsed($table,$PA['pal'])) {
823 list($thePalIcon,$palJSfunc) = $this->wrapOpenPalette('<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/options.gif','width="18" height="16"').' border="0" title="'.htmlspecialchars($this->getLL('l_moreOptions')).'" alt="" />',$table,$row,$PA['pal'],1);
829 // onFocus attribute to add to the field:
830 $PA['onFocus'] = ($palJSfunc && !$BE_USER->uc
['dontShowPalettesOnFocusInAB']) ?
' onfocus="'.htmlspecialchars($palJSfunc).'"' : '';
834 $PA['label'] = $PA['altName'] ?
$PA['altName'] : $PA['fieldConf']['label'];
835 $PA['label'] = $this->sL($PA['label']);
836 // JavaScript code for event handlers:
837 $PA['fieldChangeFunc']=array();
838 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = "TBE_EDITOR.fieldChanged('".$table."','".$row['uid']."','".$field."','".$PA['itemFormElName']."');";
839 $PA['fieldChangeFunc']['alert']=$alertMsgOnChange;
840 // if this is the child of an inline type and it is the field creating the label
841 if ($this->inline
->isInlineChildAndLabelField($table, $field)) {
842 $PA['fieldChangeFunc']['inline'] = "inline.handleChangedField('".$PA['itemFormElName']."','".$this->inline
->inlineNames
['object']."[$table][".$row['uid']."]');";
845 // Based on the type of the item, call a render function:
846 $item = $this->getSingleField_SW($table,$field,$row,$PA);
848 // Add language + diff
849 if ($PA['fieldConf']['l10n_display'] && (t3lib_div
::inList($PA['fieldConf']['l10n_display'], 'hideDiff') || t3lib_div
::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly'))) {
850 $renderLanguageDiff = false;
852 $renderLanguageDiff = true;
855 if ($renderLanguageDiff) {
856 $item = $this->renderDefaultLanguageContent($table,$field,$row,$item);
857 $item = $this->renderDefaultLanguageDiff($table,$field,$row,$item);
860 // If the record has been saved and the "linkTitleToSelf" is set, we make the field name into a link, which will load ONLY this field in alt_doc.php
861 $PA['label'] = t3lib_div
::deHSCentities(htmlspecialchars($PA['label']));
862 if (t3lib_div
::testInt($row['uid']) && $PA['fieldTSConfig']['linkTitleToSelf']) {
863 $lTTS_url = $this->backPath
.'alt_doc.php?edit['.$table.']['.$row['uid'].']=edit&columnsOnly='.$field.
864 ($PA['fieldTSConfig']['linkTitleToSelf.']['returnUrl']?
'&returnUrl='.rawurlencode($this->thisReturnUrl()):'');
865 $PA['label'] = '<a href="'.htmlspecialchars($lTTS_url).'">'.$PA['label'].'</a>';
868 // Create output value:
869 if ($PA['fieldConf']['config']['form_type']=='user' && $PA['fieldConf']['config']['noTableWrapping']) {
871 } elseif ($PA['palette']) {
874 'NAME'=>$PA['label'],
879 'HELP_ICON' => $this->helpTextIcon($table,$field,1)
881 $out = $this->addUserTemplateMarkers($out,$table,$field,$row,$PA);
885 'NAME'=>$PA['label'],
889 'HELP_ICON'=>$this->helpTextIcon($table,$field),
890 'HELP_TEXT'=>$this->helpText($table,$field),
891 'PAL_LINK_ICON'=>$thePalIcon,
894 $out = $this->addUserTemplateMarkers($out,$table,$field,$row,$PA);
896 $out=$this->intoTemplate($out);
899 } else $this->commentMessages
[]=$this->prependFormFieldNames
.'['.$table.']['.$row['uid'].']['.$field.']: Disabled by TSconfig';
901 // Return value (string or array)
906 * Rendering a single item for the form
908 * @param string Table name of record
909 * @param string Fieldname to render
910 * @param array The record
911 * @param array parameters array containing a lot of stuff. Value by Reference!
912 * @return string Returns the item as HTML code to insert
914 * @see getSingleField(), getSingleField_typeFlex_draw()
916 function getSingleField_SW($table,$field,$row,&$PA) {
917 $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ?
$PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type']; // Using "form_type" locally in this script
919 switch($PA['fieldConf']['config']['form_type']) {
921 $item = $this->getSingleField_typeInput($table,$field,$row,$PA);
924 $item = $this->getSingleField_typeText($table,$field,$row,$PA);
927 $item = $this->getSingleField_typeCheck($table,$field,$row,$PA);
930 $item = $this->getSingleField_typeRadio($table,$field,$row,$PA);
933 $item = $this->getSingleField_typeSelect($table,$field,$row,$PA);
936 $item = $this->getSingleField_typeGroup($table,$field,$row,$PA);
939 $item = $this->inline
->getSingleField_typeInline($table,$field,$row,$PA);
942 $item = $this->getSingleField_typeNone($table,$field,$row,$PA);
945 $item = $this->getSingleField_typeUser($table,$field,$row,$PA);
948 $item = $this->getSingleField_typeFlex($table,$field,$row,$PA);
951 $item = $this->getSingleField_typeUnknown($table,$field,$row,$PA);
976 /**********************************************************
978 * Rendering of each TCEform field type
980 ************************************************************/
983 * Generation of TCEform elements of the type "input"
984 * This will render a single-line input form field, possibly with various control/validation features
986 * @param string The table name of the record
987 * @param string The field name which this element is supposed to edit
988 * @param array The record data array where the value(s) for the field can be found
989 * @param array An array with additional configuration options.
990 * @return string The HTML code for the TCEform field
992 function getSingleField_typeInput($table,$field,$row,&$PA) {
993 // typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue)
994 // typo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off)
996 $config = $PA['fieldConf']['config'];
998 # $specConf = $this->getSpecConfForField($table,$row,$field);
999 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1000 $size = t3lib_div
::intInRange($config['size']?
$config['size']:30,5,$this->maxInputWidth
);
1001 $evalList = t3lib_div
::trimExplode(',',$config['eval'],1);
1004 if($this->renderReadonly ||
$config['readOnly']) {
1005 $itemFormElValue = $PA['itemFormElValue'];
1006 if (in_array('date',$evalList)) {
1007 $config['format'] = 'date';
1008 } elseif (in_array('date',$evalList)) {
1009 $config['format'] = 'date';
1010 } elseif (in_array('datetime',$evalList)) {
1011 $config['format'] = 'datetime';
1012 } elseif (in_array('time',$evalList)) {
1013 $config['format'] = 'time';
1015 if (in_array('password',$evalList)) {
1016 $itemFormElValue = $itemFormElValue ?
'*********' : '';
1018 return $this->getSingleField_typeNone_render($config, $itemFormElValue);
1021 if (in_array('required',$evalList)) {
1022 $this->requiredFields
[$table.'_'.$row['uid'].'_'.$field]=$PA['itemFormElName'];
1025 $paramsList = "'".$PA['itemFormElName']."','".implode(',',$evalList)."','".trim($config['is_in'])."',".(isset($config['checkbox'])?
1:0).",'".$config['checkbox']."'";
1026 if (isset($config['checkbox'])) {
1027 // Setting default "click-checkbox" values for eval types "date" and "datetime":
1028 $thisMidnight = mktime(0,0,0);
1029 $checkSetValue = in_array('date',$evalList) ?
$thisMidnight : '';
1030 $checkSetValue = in_array('datetime',$evalList) ?
time() : $checkSetValue;
1032 $cOnClick = 'typo3form.fieldGet('.$paramsList.',1,\''.$checkSetValue.'\');'.implode('',$PA['fieldChangeFunc']);
1033 $item.='<input type="checkbox"'.$this->insertDefStyle('check').' name="'.$PA['itemFormElName'].'_cb" onclick="'.htmlspecialchars($cOnClick).'" />';
1036 $PA['fieldChangeFunc'] = array_merge(array('typo3form.fieldGet'=>'typo3form.fieldGet('.$paramsList.');'), $PA['fieldChangeFunc']);
1037 $mLgd = ($config['max']?
$config['max']:256);
1038 $iOnChange = implode('',$PA['fieldChangeFunc']);
1039 $item.='<input type="text" name="'.$PA['itemFormElName'].'_hr" value=""'.$this->formWidth($size).' maxlength="'.$mLgd.'" onchange="'.htmlspecialchars($iOnChange).'"'.$PA['onFocus'].' />'; // This is the EDITABLE form field.
1040 $item.='<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />'; // This is the ACTUAL form field - values from the EDITABLE field must be transferred to this field which is the one that is written to the database.
1041 $this->extJSCODE
.='typo3form.fieldSet('.$paramsList.');';
1043 // going through all custom evaluations configured for this field
1044 foreach ($evalList as $evalData) {
1045 if (substr($evalData, 0, 3) == 'tx_') {
1046 $evalObj = t3lib_div
::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$evalData].':&'.$evalData);
1047 if(is_object($evalObj) && method_exists($evalObj, 'returnFieldJS')) {
1048 $this->extJSCODE
.= "\n\nfunction ".$evalData."(value) {\n".$evalObj->returnFieldJS()."\n}\n";
1053 // Creating an alternative item without the JavaScript handlers.
1054 $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'_hr" value="" />';
1055 $altItem.= '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
1057 // Wrap a wizard around the item?
1058 $item= $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'].'_hr',$specConf);
1064 * Generation of TCEform elements of the type "text"
1065 * This will render a <textarea> OR RTE area form field, possibly with various control/validation features
1067 * @param string The table name of the record
1068 * @param string The field name which this element is supposed to edit
1069 * @param array The record data array where the value(s) for the field can be found
1070 * @param array An array with additional configuration options.
1071 * @return string The HTML code for the TCEform field
1073 function getSingleField_typeText($table,$field,$row,&$PA) {
1076 $config = $PA['fieldConf']['config'];
1078 if($this->renderReadonly ||
$config['readOnly']) {
1079 return $this->getSingleField_typeNone_render($config, $PA['itemFormElValue']);
1082 // Setting columns number:
1083 $cols = t3lib_div
::intInRange($config['cols'] ?
$config['cols'] : 30, 5, $this->maxTextareaWidth
);
1085 // Setting number of rows:
1086 $origRows = $rows = t3lib_div
::intInRange($config['rows'] ?
$config['rows'] : 5, 1, 20);
1087 if (strlen($PA['itemFormElValue']) > $this->charsPerRow
*2) {
1088 $cols = $this->maxTextareaWidth
;
1089 $rows = t3lib_div
::intInRange(round(strlen($PA['itemFormElValue'])/$this->charsPerRow
), count(explode(chr(10),$PA['itemFormElValue'])), 20);
1090 if ($rows<$origRows) $rows = $origRows;
1094 $RTEwasLoaded = 0; // Set true, if the RTE is loaded; If not a normal textarea is shown.
1095 $RTEwouldHaveBeenLoaded = 0; // Set true, if the RTE would have been loaded if it wasn't for the disable-RTE flag in the bottom of the page...
1097 // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. Traditionally, this is where RTE configuration has been found.
1098 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1100 // Setting up the altItem form field, which is a hidden field containing the value
1101 $altItem = '<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
1103 // If RTE is generally enabled (TYPO3_CONF_VARS and user settings)
1104 if ($this->RTEenabled
) {
1105 $p = t3lib_BEfunc
::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
1106 if (isset($specConf['richtext']) && (!$p['flag'] ||
!$row[$p['flag']])) { // If the field is configured for RTE and if any flag-field is not set to disable it.
1107 t3lib_BEfunc
::fixVersioningPid($table,$row);
1108 list($tscPID,$thePidValue) = $this->getTSCpid($table,$row['uid'],$row['pid']);
1110 // If the pid-value is not negative (that is, a pid could NOT be fetched)
1111 if ($thePidValue >= 0) {
1112 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc
::getPagesTSconfig($tscPID));
1113 $RTEtypeVal = t3lib_BEfunc
::getTCAtypeValue($table,$row);
1114 $thisConfig = t3lib_BEfunc
::RTEsetup($RTEsetup['properties'],$table,$field,$RTEtypeVal);
1116 if (!$thisConfig['disabled']) {
1117 if (!$this->disableRTE
) {
1118 $this->RTEcounter++
;
1120 // Find alternative relative path for RTE images/links:
1121 $eFile = t3lib_parsehtml_proc
::evalWriteFile($specConf['static_write'], $row);
1122 $RTErelPath = is_array($eFile) ?
dirname($eFile['relEditFile']) : '';
1124 // Get RTE object, draw form and set flag:
1125 $RTEobj = &t3lib_BEfunc
::RTEgetObj();
1126 $item = $RTEobj->drawRTE($this,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue);
1129 $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf,1);
1133 $RTEwouldHaveBeenLoaded = 1;
1134 $this->commentMessages
[] = $PA['itemFormElName'].': RTE is disabled by the on-page RTE-flag (probably you can enable it by the check-box in the bottom of this page!)';
1136 } else $this->commentMessages
[] = $PA['itemFormElName'].': RTE is disabled by the Page TSconfig, "RTE"-key (eg. by RTE.default.disabled=0 or such)';
1137 } else $this->commentMessages
[] = $PA['itemFormElName'].': PID value could NOT be fetched. Rare error, normally with new records.';
1139 if (!isset($specConf['richtext'])) $this->commentMessages
[] = $PA['itemFormElName'].': RTE was not configured for this field in TCA-types';
1140 if (!(!$p['flag'] ||
!$row[$p['flag']])) $this->commentMessages
[] = $PA['itemFormElName'].': Field-flag ('.$PA['flag'].') has been set to disable RTE!';
1144 // Display ordinary field if RTE was not loaded.
1145 if (!$RTEwasLoaded) {
1146 if ($specConf['rte_only']) { // Show message, if no RTE (field can only be edited with RTE!)
1147 $item = '<p><em>'.htmlspecialchars($this->getLL('l_noRTEfound')).'</em></p>';
1149 if ($specConf['nowrap']) {
1152 $wrap = ($config['wrap'] ?
$config['wrap'] : 'virtual');
1156 if ($specConf['fixed-font']) { $classes[] = 'fixed-font'; }
1157 if ($specConf['enable-tab']) { $classes[] = 'enable-tab'; }
1159 $formWidthText = $this->formWidthText($cols,$wrap);
1161 // Extract class attributes from $formWidthText (otherwise it would be added twice to the output)
1162 if (preg_match('/ class="(.+?)"/',$formWidthText,$res)) {
1163 $formWidthText = str_replace(' class="'.$res[1].'"','',$formWidthText);
1164 $classes = array_merge($classes, explode(' ',$res[1]));
1167 if (count($classes)) {
1168 $class = ' class="'.implode(' ',$classes).'"';
1171 $iOnChange = implode('',$PA['fieldChangeFunc']);
1173 <textarea name="'.$PA['itemFormElName'].'"'.$formWidthText.$class.' rows="'.$rows.'" wrap="'.$wrap.'" onchange="'.htmlspecialchars($iOnChange).'"'.$PA['onFocus'].'>'.
1174 t3lib_div
::formatForTextarea($PA['itemFormElValue']).
1176 $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf,$RTEwouldHaveBeenLoaded);
1180 // Return field HTML:
1185 * Generation of TCEform elements of the type "check"
1186 * This will render a check-box OR an array of checkboxes
1188 * @param string The table name of the record
1189 * @param string The field name which this element is supposed to edit
1190 * @param array The record data array where the value(s) for the field can be found
1191 * @param array An array with additional configuration options.
1192 * @return string The HTML code for the TCEform field
1194 function getSingleField_typeCheck($table,$field,$row,&$PA) {
1195 $config = $PA['fieldConf']['config'];
1198 if($this->renderReadonly ||
$config['readOnly']) {
1199 $disabled = ' disabled="disabled"';
1202 // Traversing the array of items:
1203 $selItems = $this->initItemArray($PA['fieldConf']);
1204 if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
1206 if (!count($selItems)) {
1207 $selItems[]=array('','');
1209 $thisValue = intval($PA['itemFormElValue']);
1211 $cols = intval($config['cols']);
1213 $item.= '<table border="0" cellspacing="0" cellpadding="0" class="typo3-TCEforms-checkboxArray">';
1214 for ($c=0;$c<count($selItems);$c++
) {
1216 if(!($c%
$cols)) { $item.='<tr>'; }
1217 $cBP = $this->checkBoxParams($PA['itemFormElName'],$thisValue,$c,count($selItems),implode('',$PA['fieldChangeFunc']));
1218 $cBName = $PA['itemFormElName'].'_'.$c;
1219 $cBID = $PA['itemFormElID'].'_'.$c;
1220 $item.= '<td nowrap="nowrap">'.
1221 '<input type="checkbox"'.$this->insertDefStyle('check').' value="1" name="'.$cBName.'"'.$cBP.$disabled.' id="'.$cBID.'" />'.
1222 $this->wrapLabels('<label for="'.$cBID.'">'.htmlspecialchars($p[0]).'</label> ').
1224 if(($c%
$cols)+
1==$cols) {$item.='</tr>';}
1227 $rest=$cols-($c%
$cols);
1228 for ($c=0;$c<$rest;$c++
) {
1229 $item.= '<td></td>';
1231 if ($c>0) { $item.= '</tr>'; }
1235 for ($c=0;$c<count($selItems);$c++
) {
1237 $cBP = $this->checkBoxParams($PA['itemFormElName'],$thisValue,$c,count($selItems),implode('',$PA['fieldChangeFunc']));
1238 $cBName = $PA['itemFormElName'].'_'.$c;
1239 $cBID = $PA['itemFormElID'].'_'.$c;
1240 $item.= ($c>0?
'<br />':'').
1241 '<input type="checkbox"'.$this->insertDefStyle('check').' value="1" name="'.$cBName.'"'.$cBP.$PA['onFocus'].$disabled.' id="'.$cBID.'" />'.
1242 htmlspecialchars($p[0]);
1246 $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($thisValue).'" />';
1253 * Generation of TCEform elements of the type "radio"
1254 * This will render a series of radio buttons.
1256 * @param string The table name of the record
1257 * @param string The field name which this element is supposed to edit
1258 * @param array The record data array where the value(s) for the field can be found
1259 * @param array An array with additional configuration options.
1260 * @return string The HTML code for the TCEform field
1262 function getSingleField_typeRadio($table,$field,$row,&$PA) {
1263 $config = $PA['fieldConf']['config'];
1266 if($this->renderReadonly ||
$config['readOnly']) {
1267 $disabled = ' disabled="disabled"';
1270 // Get items for the array:
1271 $selItems = $this->initItemArray($PA['fieldConf']);
1272 if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
1274 // Traverse the items, making the form elements:
1275 for ($c=0;$c<count($selItems);$c++
) {
1277 $rID = $PA['itemFormElID'].'_'.$c;
1278 $rOnClick = implode('',$PA['fieldChangeFunc']);
1279 $rChecked = (!strcmp($p[1],$PA['itemFormElValue'])?
' checked="checked"':'');
1280 $item.= '<input type="radio"'.$this->insertDefStyle('radio').' name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($p[1]).'" onclick="'.htmlspecialchars($rOnClick).'"'.$rChecked.$PA['onFocus'].$disabled.' id="'.$rID.'" />
1281 <label for="'.$rID.'">'.htmlspecialchars($p[0]).'</label>
1289 * Generation of TCEform elements of the type "select"
1290 * This will render a selector box element, or possibly a special construction with two selector boxes. That depends on configuration.
1292 * @param string The table name of the record
1293 * @param string The field name which this element is supposed to edit
1294 * @param array The record data array where the value(s) for the field can be found
1295 * @param array An array with additional configuration options.
1296 * @return string The HTML code for the TCEform field
1298 function getSingleField_typeSelect($table,$field,$row,&$PA) {
1301 // Field configuration from TCA:
1302 $config = $PA['fieldConf']['config'];
1305 if($this->renderReadonly ||
$config['readOnly']) {
1306 $disabled = ' disabled="disabled"';
1309 // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. See http://typo3.org/documentation/document-library/doc_core_api/Wizards_Configuratio/.
1310 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1312 // Getting the selector box items from the system
1313 $selItems = $this->addSelectOptionsToItemArray($this->initItemArray($PA['fieldConf']),$PA['fieldConf'],$this->setTSconfig($table,$row),$field);
1314 $selItems = $this->addItems($selItems,$PA['fieldTSConfig']['addItems.']);
1315 if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
1317 // Possibly remove some items:
1318 $removeItems = t3lib_div
::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
1319 foreach($selItems as $tk => $p) {
1321 // Checking languages and authMode:
1322 $languageDeny = $TCA[$table]['ctrl']['languageField'] && !strcmp($TCA[$table]['ctrl']['languageField'], $field) && !$GLOBALS['BE_USER']->checkLanguageAccess($p[1]);
1323 $authModeDeny = $config['form_type']=='select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table,$field,$p[1],$config['authMode']);
1324 if (in_array($p[1],$removeItems) ||
$languageDeny ||
$authModeDeny) {
1325 unset($selItems[$tk]);
1326 } elseif (isset($PA['fieldTSConfig']['altLabels.'][$p[1]])) {
1327 $selItems[$tk][0]=$this->sL($PA['fieldTSConfig']['altLabels.'][$p[1]]);
1330 // Removing doktypes with no access:
1331 if ($table.'.'.$field == 'pages.doktype') {
1332 if (!($GLOBALS['BE_USER']->isAdmin() || t3lib_div
::inList($GLOBALS['BE_USER']->groupData
['pagetypes_select'],$p[1]))) {
1333 unset($selItems[$tk]);
1338 // Creating the label for the "No Matching Value" entry.
1339 $nMV_label = isset($PA['fieldTSConfig']['noMatchingValue_label']) ?
$this->sL($PA['fieldTSConfig']['noMatchingValue_label']) : '[ '.$this->getLL('l_noMatchingValue').' ]';
1341 // Prepare some values:
1342 $maxitems = intval($config['maxitems']);
1344 // If a SINGLE selector box...
1346 $item = $this->getSingleField_typeSelect_single($table,$field,$row,$PA,$config,$selItems,$nMV_label);
1347 } elseif (!strcmp($config['renderMode'],'checkbox')) { // Checkbox renderMode
1348 $item = $this->getSingleField_typeSelect_checkbox($table,$field,$row,$PA,$config,$selItems,$nMV_label);
1349 } elseif (!strcmp($config['renderMode'],'singlebox')) { // Single selector box renderMode
1350 $item = $this->getSingleField_typeSelect_singlebox($table,$field,$row,$PA,$config,$selItems,$nMV_label);
1351 } else { // Traditional multiple selector box:
1352 $item = $this->getSingleField_typeSelect_multiple($table,$field,$row,$PA,$config,$selItems,$nMV_label);
1357 $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
1358 $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf);
1365 * Creates a single-selector box
1366 * (Render function for getSingleField_typeSelect())
1368 * @param string See getSingleField_typeSelect()
1369 * @param string See getSingleField_typeSelect()
1370 * @param array See getSingleField_typeSelect()
1371 * @param array See getSingleField_typeSelect()
1372 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1373 * @param array Items available for selection
1374 * @param string Label for no-matching-value
1375 * @return string The HTML code for the item
1376 * @see getSingleField_typeSelect()
1378 function getSingleField_typeSelect_single($table,$field,$row,&$PA,$config,$selItems,$nMV_label) {
1379 // check against inline uniqueness
1380 $inlineParent = $this->inline
->getStructureLevel(-1);
1381 if(is_array($inlineParent) && $inlineParent['uid']) {
1382 if ($inlineParent['config']['foreign_table'] == $table && $inlineParent['config']['foreign_unique'] == $field) {
1383 $uniqueIds = $this->inline
->inlineData
['unique'][$this->inline
->inlineNames
['object'].'['.$table.']']['used'];
1384 $PA['fieldChangeFunc']['inlineUnique'] = "inline.updateUnique(this,'".$this->inline
->inlineNames
['object'].'['.$table."]','".$this->inline
->inlineNames
['form']."','".$row['uid']."');";
1386 // hide uid of parent record for symmetric relations
1387 if ($inlineParent['config']['foreign_table'] == $table && ($inlineParent['config']['foreign_field'] == $field ||
$inlineParent['config']['symmetric_field'] == $field)) {
1388 $uniqueIds[] = $inlineParent['uid'];
1395 $noMatchingValue = 1;
1397 $selicons = array();
1398 $onlySelectedIconShown = 0;
1399 $size = intval($config['size']);
1402 if($this->renderReadonly ||
$config['readOnly']) {
1403 $disabled = ' disabled="disabled"';
1404 $onlySelectedIconShown = 1;
1407 // Icon configuration:
1408 if ($config['suppress_icons']=='IF_VALUE_FALSE') {
1409 $suppressIcons = !$PA['itemFormElValue'] ?
1 : 0;
1410 } elseif ($config['suppress_icons']=='ONLY_SELECTED') {
1412 $onlySelectedIconShown=1;
1413 } elseif ($config['suppress_icons']) {
1415 } else $suppressIcons = 0;
1417 // Traverse the Array of selector box items:
1418 foreach($selItems as $p) {
1419 $sM = (!strcmp($PA['itemFormElValue'],$p[1])?
' selected="selected"':'');
1422 $noMatchingValue = 0;
1425 // Getting style attribute value (for icons):
1426 if ($config['iconsInOptionTags']) {
1427 $styleAttrValue = $this->optionTagStyle($p[2]);
1430 // Compiling the <option> tag:
1431 if (!($p[1] != $PA['itemFormElValue'] && is_array($uniqueIds) && in_array($p[1], $uniqueIds))) {
1432 $opt[]= '<option value="'.htmlspecialchars($p[1]).'"'.
1434 ($styleAttrValue ?
' style="'.htmlspecialchars($styleAttrValue).'"' : '').
1435 (!strcmp($p[1],'--div--') ?
' class="c-divider"' : '').
1436 '>'.t3lib_div
::deHSCentities(htmlspecialchars($p[0])).'</option>';
1439 // If there is an icon for the selector box (rendered in table under)...:
1440 if ($p[2] && !$suppressIcons && (!$onlySelectedIconShown ||
$sM)) {
1441 list($selIconFile,$selIconInfo)=$this->getIcon($p[2]);
1442 $iOnClick = $this->elName($PA['itemFormElName']).'.selectedIndex='.$c.'; '.implode('',$PA['fieldChangeFunc']).$this->blur().'return false;';
1444 (!$onlySelectedIconShown ?
'<a href="#" onclick="'.htmlspecialchars($iOnClick).'">' : '').
1445 '<img src="'.$selIconFile.'" '.$selIconInfo[3].' vspace="2" border="0" title="'.htmlspecialchars($p[0]).'" alt="'.htmlspecialchars($p[0]).'" />'.
1446 (!$onlySelectedIconShown ?
'</a>' : ''),
1452 // No-matching-value:
1453 if ($PA['itemFormElValue'] && $noMatchingValue && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1454 $nMV_label = @sprintf
($nMV_label, $PA['itemFormElValue']);
1455 $opt[]= '<option value="'.htmlspecialchars($PA['itemFormElValue']).'" selected="selected">'.htmlspecialchars($nMV_label).'</option>';
1458 // Create item form fields:
1459 $sOnChange = 'if (this.options[this.selectedIndex].value==\'--div--\') {this.selectedIndex='.$sI.';} '.implode('',$PA['fieldChangeFunc']);
1461 $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'_selIconVal" value="'.htmlspecialchars($sI).'" />'; // MUST be inserted before the selector - else is the value of the hiddenfield here mysteriously submitted...
1463 $item.= '<select name="'.$PA['itemFormElName'].'"'.
1464 $this->insertDefStyle('select').
1465 ($size?
' size="'.$size.'"':'').
1466 ' onchange="'.htmlspecialchars($sOnChange).'"'.
1467 $PA['onFocus'].$disabled.'>';
1468 $item.= implode('',$opt);
1469 $item.= '</select>';
1471 // Create icon table:
1472 if (count($selicons)) {
1473 $item.='<table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-selectIcons">';
1474 $selicon_cols = intval($config['selicon_cols']);
1475 if (!$selicon_cols) $selicon_cols=count($selicons);
1476 $sR = ceil(count($selicons)/$selicon_cols);
1477 $selicons = array_pad($selicons,$sR*$selicon_cols,'');
1478 for($sa=0;$sa<$sR;$sa++
) {
1480 for($sb=0;$sb<$selicon_cols;$sb++
) {
1481 $sk=($sa*$selicon_cols+
$sb);
1482 $imgN = 'selIcon_'.$table.'_'.$row['uid'].'_'.$field.'_'.$selicons[$sk][1];
1483 $imgS = ($selicons[$sk][2]?
$this->backPath
.'gfx/content_selected.gif':'clear.gif');
1484 $item.='<td><img name="'.htmlspecialchars($imgN).'" src="'.$imgS.'" width="7" height="10" alt="" /></td>';
1485 $item.='<td>'.$selicons[$sk][0].'</td>';
1496 * Creates a checkbox list (renderMode = "checkbox")
1497 * (Render function for getSingleField_typeSelect())
1499 * @param string See getSingleField_typeSelect()
1500 * @param string See getSingleField_typeSelect()
1501 * @param array See getSingleField_typeSelect()
1502 * @param array See getSingleField_typeSelect()
1503 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1504 * @param array Items available for selection
1505 * @param string Label for no-matching-value
1506 * @return string The HTML code for the item
1507 * @see getSingleField_typeSelect()
1509 function getSingleField_typeSelect_checkbox($table,$field,$row,&$PA,$config,$selItems,$nMV_label) {
1511 // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
1512 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
1515 if($this->renderReadonly ||
$config['readOnly']) {
1516 $disabled = ' disabled="disabled"';
1519 // Traverse the Array of selector box items:
1523 $sOnChange = implode('',$PA['fieldChangeFunc']);
1524 $setAll = array(); // Used to accumulate the JS needed to restore the original selection.
1525 foreach($selItems as $p) {
1526 // Non-selectable element:
1527 if (!strcmp($p[1],'--div--')) {
1528 if (count($setAll)) {
1532 '<a href="#" onclick="'.htmlspecialchars(implode('',$setAll).' return false;').'">'.
1533 htmlspecialchars($this->getLL('l_setAllCheckboxes')).
1540 <tr class="c-header">
1541 <td colspan="2">'.htmlspecialchars($p[0]).'</td>
1544 // Selected or not by default:
1546 if (isset($itemArray[$p[1]])) {
1547 $sM = ' checked="checked"';
1548 unset($itemArray[$p[1]]);
1554 list($selIconFile,$selIconInfo) = $this->getIcon($p[2]);
1558 $onClickCell = $this->elName($PA['itemFormElName'].'['.$c.']').'.checked=!'.$this->elName($PA['itemFormElName'].'['.$c.']').'.checked;';
1559 $onClick = 'this.attributes.getNamedItem("class").nodeValue = '.$this->elName($PA['itemFormElName'].'['.$c.']').'.checked ? "c-selectedItem" : "";';
1560 $setAll[] = $this->elName($PA['itemFormElName'].'['.$c.']').'.checked=1;';
1562 <tr class="'.($sM ?
'c-selectedItem' : '').'" onclick="'.htmlspecialchars($onClick).'" style="cursor: pointer;">
1563 <td><input type="checkbox"'.$this->insertDefStyle('check').' name="'.htmlspecialchars($PA['itemFormElName'].'['.$c.']').'" value="'.htmlspecialchars($p[1]).'"'.$sM.' onclick="'.htmlspecialchars($sOnChange).'"'.$PA['onFocus'].' /></td>
1564 <td class="c-labelCell" onclick="'.htmlspecialchars($onClickCell).'">'.
1565 ($selIconFile ?
'<img src="'.$selIconFile.'" '.$selIconInfo[3].' vspace="2" border="0" class="absmiddle" style="margin-right: 4px;" alt="" />' : '').
1566 t3lib_div
::deHSCentities(htmlspecialchars($p[0])).
1567 (strcmp($p[3],'') ?
'<br/><p class="c-descr">'.nl2br(trim(htmlspecialchars($p[3]))).'</p>' : '').
1574 // Remaining checkboxes will get their set-all link:
1575 if (count($setAll)) {
1579 '<a href="#" onclick="'.htmlspecialchars(implode('',$setAll).' return false;').'">'.
1580 htmlspecialchars($this->getLL('l_setAllCheckboxes')).
1586 // Remaining values (invalid):
1587 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1588 foreach($itemArray as $theNoMatchValue => $temp) {
1589 // Compile <checkboxes> tag:
1590 array_unshift($tRows,'
1591 <tr class="c-invalidItem">
1592 <td><input type="checkbox"'.$this->insertDefStyle('check').' name="'.htmlspecialchars($PA['itemFormElName'].'['.$c.']').'" value="'.htmlspecialchars($theNoMatchValue).'" checked="checked" onclick="'.htmlspecialchars($sOnChange).'"'.$PA['onFocus'].$disabled.' /></td>
1593 <td class="c-labelCell">'.
1594 t3lib_div
::deHSCentities(htmlspecialchars(@sprintf
($nMV_label, $theNoMatchValue))).
1601 // Add an empty hidden field which will send a blank value if all items are unselected.
1602 $item.='<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="" />';
1604 // Implode rows in table:
1606 <table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-select-checkbox">'.
1607 implode('',$tRows).'
1615 * Creates a selectorbox list (renderMode = "singlebox")
1616 * (Render function for getSingleField_typeSelect())
1618 * @param string See getSingleField_typeSelect()
1619 * @param string See getSingleField_typeSelect()
1620 * @param array See getSingleField_typeSelect()
1621 * @param array See getSingleField_typeSelect()
1622 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1623 * @param array Items available for selection
1624 * @param string Label for no-matching-value
1625 * @return string The HTML code for the item
1626 * @see getSingleField_typeSelect()
1628 function getSingleField_typeSelect_singlebox($table,$field,$row,&$PA,$config,$selItems,$nMV_label) {
1630 // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
1631 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
1634 if($this->renderReadonly ||
$config['readOnly']) {
1635 $disabled = ' disabled="disabled"';
1638 // Traverse the Array of selector box items:
1640 $restoreCmd = array(); // Used to accumulate the JS needed to restore the original selection.
1642 foreach($selItems as $p) {
1643 // Selected or not by default:
1645 if (isset($itemArray[$p[1]])) {
1646 $sM = ' selected="selected"';
1647 $restoreCmd[] = $this->elName($PA['itemFormElName'].'[]').'.options['.$c.'].selected=1;';
1648 unset($itemArray[$p[1]]);
1651 // Non-selectable element:
1653 if (!strcmp($p[1],'--div--')) {
1654 $nonSel = ' onclick="this.selected=0;" class="c-divider"';
1657 // Icon style for option tag:
1658 if ($config['iconsInOptionTags']) {
1659 $styleAttrValue = $this->optionTagStyle($p[2]);
1662 // Compile <option> tag:
1663 $opt[] = '<option value="'.htmlspecialchars($p[1]).'"'.
1666 ($styleAttrValue ?
' style="'.htmlspecialchars($styleAttrValue).'"' : '').
1667 '>'.t3lib_div
::deHSCentities(htmlspecialchars($p[0])).'</option>';
1671 // Remaining values:
1672 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1673 foreach($itemArray as $theNoMatchValue => $temp) {
1674 // Compile <option> tag:
1675 array_unshift($opt,'<option value="'.htmlspecialchars($theNoMatchValue).'" selected="selected">'.t3lib_div
::deHSCentities(htmlspecialchars(@sprintf
($nMV_label, $theNoMatchValue))).'</option>');
1679 // Compile selector box:
1680 $sOnChange = implode('',$PA['fieldChangeFunc']);
1681 $selector_itemListStyle = isset($config['itemListStyle']) ?
' style="'.htmlspecialchars($config['itemListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle
.'"';
1682 $size = intval($config['size']);
1683 $size = $config['autoSizeMax'] ? t3lib_div
::intInRange(count($selItems)+
1,t3lib_div
::intInRange($size,1),$config['autoSizeMax']) : $size;
1684 $selectBox = '<select name="'.$PA['itemFormElName'].'[]"'.
1685 $this->insertDefStyle('select').
1686 ($size ?
' size="'.$size.'"' : '').
1687 ' multiple="multiple" onchange="'.htmlspecialchars($sOnChange).'"'.
1689 $selector_itemListStyle.
1696 // Add an empty hidden field which will send a blank value if all items are unselected.
1698 $item.='<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="" />';
1701 // Put it all into a table:
1703 <table border="0" cellspacing="0" cellpadding="0" width="1" class="typo3-TCEforms-select-singlebox">
1709 htmlspecialchars($this->getLL('l_holdDownCTRL')).
1713 <a href="#" onclick="'.htmlspecialchars($this->elName($PA['itemFormElName'].'[]').'.selectedIndex=-1;'.implode('',$restoreCmd).' return false;').'">'.
1714 '<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/history.gif','width="13" height="12"').' title="'.htmlspecialchars($this->getLL('l_revertSelection')).'" alt="" />'.
1725 * Creates a multiple-selector box (two boxes, side-by-side)
1726 * (Render function for getSingleField_typeSelect())
1728 * @param string See getSingleField_typeSelect()
1729 * @param string See getSingleField_typeSelect()
1730 * @param array See getSingleField_typeSelect()
1731 * @param array See getSingleField_typeSelect()
1732 * @param array (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1733 * @param array Items available for selection
1734 * @param string Label for no-matching-value
1735 * @return string The HTML code for the item
1736 * @see getSingleField_typeSelect()
1738 function getSingleField_typeSelect_multiple($table,$field,$row,&$PA,$config,$selItems,$nMV_label) {
1741 if($this->renderReadonly ||
$config['readOnly']) {
1742 $disabled = ' disabled="disabled"';
1745 // Setting this hidden field (as a flag that JavaScript can read out)
1747 $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'_mul" value="'.($config['multiple']?
1:0).'" />';
1750 // Set max and min items:
1751 $maxitems = t3lib_div
::intInRange($config['maxitems'],0);
1752 if (!$maxitems) $maxitems=100000;
1753 $minitems = t3lib_div
::intInRange($config['minitems'],0);
1755 // Register the required number of elements:
1756 $this->requiredElements
[$PA['itemFormElName']] = array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field);
1758 // Get "removeItems":
1759 $removeItems = t3lib_div
::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
1761 // Perform modification of the selected items array:
1762 $itemArray = t3lib_div
::trimExplode(',',$PA['itemFormElValue'],1);
1763 foreach($itemArray as $tk => $tv) {
1764 $tvP = explode('|',$tv,2);
1765 $evalValue = rawurldecode($tvP[0]);
1766 $isRemoved = in_array($evalValue,$removeItems) ||
($config['form_type']=='select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table,$field,$evalValue,$config['authMode']));
1767 if ($isRemoved && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1768 $tvP[1] = rawurlencode(@sprintf
($nMV_label, $evalValue));
1769 } elseif (isset($PA['fieldTSConfig']['altLabels.'][$evalValue])) {
1770 $tvP[1] = rawurlencode($this->sL($PA['fieldTSConfig']['altLabels.'][$evalValue]));
1772 $itemArray[$tk] = implode('|',$tvP);
1774 $itemsToSelect = '';
1777 // Create option tags:
1779 $styleAttrValue = '';
1780 foreach($selItems as $p) {
1781 if ($config['iconsInOptionTags']) {
1782 $styleAttrValue = $this->optionTagStyle($p[2]);
1784 $opt[]= '<option value="'.htmlspecialchars($p[1]).'"'.
1785 ($styleAttrValue ?
' style="'.htmlspecialchars($styleAttrValue).'"' : '').
1786 '>'.htmlspecialchars($p[0]).'</option>';
1789 // Put together the selector box:
1790 $selector_itemListStyle = isset($config['itemListStyle']) ?
' style="'.htmlspecialchars($config['itemListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle
.'"';
1791 $size = intval($config['size']);
1792 $size = $config['autoSizeMax'] ? t3lib_div
::intInRange(count($itemArray)+
1,t3lib_div
::intInRange($size,1),$config['autoSizeMax']) : $size;
1793 if ($config['exclusiveKeys']) {
1794 $sOnChange = 'setFormValueFromBrowseWin(\''.$PA['itemFormElName'].'\',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text,\''.$config['exclusiveKeys'].'\'); ';
1796 $sOnChange = 'setFormValueFromBrowseWin(\''.$PA['itemFormElName'].'\',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text); ';
1798 $sOnChange .= implode('',$PA['fieldChangeFunc']);
1800 <select name="'.$PA['itemFormElName'].'_sel"'.
1801 $this->insertDefStyle('select').
1802 ($size ?
' size="'.$size.'"' : '').
1803 ' onchange="'.htmlspecialchars($sOnChange).'"'.
1805 $selector_itemListStyle.'>
1811 // Pass to "dbFileIcons" function:
1814 'autoSizeMax' => t3lib_div
::intInRange($config['autoSizeMax'],0),
1815 'style' => isset($config['selectedListStyle']) ?
' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle
.'"',
1816 'dontShowMoveIcons' => ($maxitems<=1),
1817 'maxitems' => $maxitems,
1820 'selector' => $this->getLL('l_selected').':<br />',
1821 'items' => $this->getLL('l_items').':<br />'
1824 'thumbnails' => $itemsToSelect,
1825 'readOnly' => $disabled
1827 $item.= $this->dbFileIcons($PA['itemFormElName'],'','',$itemArray,'',$params,$PA['onFocus']);
1833 * Generation of TCEform elements of the type "group"
1834 * This will render a selectorbox into which elements from either the file system or database can be inserted. Relations.
1836 * @param string The table name of the record
1837 * @param string The field name which this element is supposed to edit
1838 * @param array The record data array where the value(s) for the field can be found
1839 * @param array An array with additional configuration options.
1840 * @return string The HTML code for the TCEform field
1842 function getSingleField_typeGroup($table,$field,$row,&$PA) {
1844 $config = $PA['fieldConf']['config'];
1845 $internal_type = $config['internal_type'];
1846 $show_thumbs = $config['show_thumbs'];
1847 $size = intval($config['size']);
1848 $maxitems = t3lib_div
::intInRange($config['maxitems'],0);
1849 if (!$maxitems) $maxitems=100000;
1850 $minitems = t3lib_div
::intInRange($config['minitems'],0);
1851 $allowed = $config['allowed'];
1852 $disallowed = $config['disallowed'];
1855 if($this->renderReadonly ||
$config['readOnly']) {
1856 $disabled = ' disabled="disabled"';
1859 $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'_mul" value="'.($config['multiple']?
1:0).'"'.$disabled.' />';
1860 $this->requiredElements
[$PA['itemFormElName']] = array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field);
1863 // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. See http://typo3.org/documentation/document-library/doc_core_api/Wizards_Configuratio/.
1864 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1866 // Acting according to either "file" or "db" type:
1867 switch((string)$config['internal_type']) {
1868 case 'file': // If the element is of the internal type "file":
1870 // Creating string showing allowed types:
1871 $tempFT = t3lib_div
::trimExplode(',',$allowed,1);
1872 if (!count($tempFT)) {$info.='*';}
1873 foreach($tempFT as $ext) {
1875 $info.=strtoupper($ext).' ';
1878 // Creating string, showing disallowed types:
1879 $tempFT_dis = t3lib_div
::trimExplode(',',$disallowed,1);
1880 if (count($tempFT_dis)) {$info.='<br />';}
1881 foreach($tempFT_dis as $ext) {
1883 $info.='-'.strtoupper($ext).' ';
1887 // Making the array of file items:
1888 $itemArray = t3lib_div
::trimExplode(',',$PA['itemFormElValue'],1);
1890 // Showing thumbnails:
1894 foreach($itemArray as $imgRead) {
1895 $imgP = explode('|',$imgRead);
1896 $imgPath = rawurldecode($imgP[0]);
1899 $rowCopy[$field] = $imgPath;
1901 // Icon + clickmenu:
1902 $absFilePath = t3lib_div
::getFileAbsFileName($config['uploadfolder'].'/'.$imgPath);
1904 $fI = pathinfo($imgPath);
1905 $fileIcon = t3lib_BEfunc
::getFileIcon(strtolower($fI['extension']));
1906 $fileIcon = '<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/fileicons/'.$fileIcon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].($absFilePath && @is_file
($absFilePath) ?
' ('.t3lib_div
::formatSize(filesize($absFilePath)).'bytes)' : ' - FILE NOT FOUND!')).'" alt="" />';
1908 $imgs[] = '<span class="nobr">'.t3lib_BEfunc
::thumbCode($rowCopy,$table,$field,$this->backPath
,'thumbs.php',$config['uploadfolder'],0,' align="middle"').
1909 ($absFilePath ?
$this->getClickMenu($fileIcon, $absFilePath) : $fileIcon).
1913 $thumbsnail = implode('<br />',$imgs);
1916 // Creating the element:
1919 'dontShowMoveIcons' => ($maxitems<=1),
1920 'autoSizeMax' => t3lib_div
::intInRange($config['autoSizeMax'],0),
1921 'maxitems' => $maxitems,
1922 'style' => isset($config['selectedListStyle']) ?
' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle
.'"',
1924 'thumbnails' => $thumbsnail,
1925 'readOnly' => $disabled
1927 $item.= $this->dbFileIcons($PA['itemFormElName'],'file',implode(',',$tempFT),$itemArray,'',$params,$PA['onFocus']);
1930 // Adding the upload field:
1931 if ($this->edit_docModuleUpload
) $item.='<input type="file" name="'.$PA['itemFormElName_file'].'"'.$this->formWidth().' size="60" />';
1934 case 'db': // If the element is of the internal type "db":
1936 // Creating string showing allowed types:
1937 $tempFT = t3lib_div
::trimExplode(',',$allowed,1);
1938 if (!strcmp(trim($tempFT[0]),'*')) {
1939 $info.='<span class="nobr"> '.
1940 htmlspecialchars($this->getLL('l_allTables')).
1943 while(list(,$theT)=each($tempFT)) {
1945 $info.='<span class="nobr"> '.
1946 t3lib_iconWorks
::getIconImage($theT,array(),$this->backPath
,'align="top"').
1947 htmlspecialchars($this->sL($GLOBALS['TCA'][$theT]['ctrl']['title'])).
1953 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
1954 $itemArray = array();
1958 $temp_itemArray = t3lib_div
::trimExplode(',',$PA['itemFormElValue'],1);
1959 foreach($temp_itemArray as $dbRead) {
1960 $recordParts = explode('|',$dbRead);
1961 list($this_table,$this_uid) = t3lib_BEfunc
::splitTable_Uid($recordParts[0]);
1962 $itemArray[] = array('table'=>$this_table, 'id'=>$this_uid);
1963 if (!$disabled && $show_thumbs) {
1964 $rr = t3lib_BEfunc
::getRecordWSOL($this_table,$this_uid);
1965 $imgs[] = '<span class="nobr">'.
1966 $this->getClickMenu(t3lib_iconWorks
::getIconImage($this_table,$rr,$this->backPath
,'align="top" title="'.htmlspecialchars(t3lib_BEfunc
::getRecordPath($rr['pid'],$perms_clause,15)).' [UID: '.$rr['uid'].']"'),$this_table, $this_uid).
1968 t3lib_BEfunc
::getRecordTitle($this_table,$rr,TRUE).' <span class="typo3-dimmed"><em>['.$rr['uid'].']</em></span>'.
1973 if (!$disabled && $show_thumbs) {
1974 $thumbsnail = implode('<br />',$imgs);
1977 // Creating the element:
1980 'dontShowMoveIcons' => ($maxitems<=1),
1981 'autoSizeMax' => t3lib_div
::intInRange($config['autoSizeMax'],0),
1982 'maxitems' => $maxitems,
1983 'style' => isset($config['selectedListStyle']) ?
' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle
.'"',
1985 'thumbnails' => $thumbsnail,
1986 'readOnly' => $disabled
1988 $item.= $this->dbFileIcons($PA['itemFormElName'],'db',implode(',',$tempFT),$itemArray,'',$params,$PA['onFocus']);
1994 $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
1996 $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf);
2003 * Generation of TCEform elements of the type "none"
2004 * This will render a non-editable display of the content of the field.
2006 * @param string The table name of the record
2007 * @param string The field name which this element is supposed to edit
2008 * @param array The record data array where the value(s) for the field can be found
2009 * @param array An array with additional configuration options.
2010 * @return string The HTML code for the TCEform field
2012 function getSingleField_typeNone($table,$field,$row,&$PA) {
2014 $config = $PA['fieldConf']['config'];
2015 $itemValue = $PA['itemFormElValue'];
2017 return $this->getSingleField_typeNone_render($config,$itemValue);
2021 * HTML rendering of a value which is not editable.
2023 * @param array Configuration for the display
2024 * @param string The value to display
2025 * @return string The HTML code for the display
2026 * @see getSingleField_typeNone();
2028 function getSingleField_typeNone_render($config,$itemValue) {
2030 // is colorScheme[0] the right value?
2031 $divStyle = 'border:solid 1px '.t3lib_div
::modifyHTMLColorAll($this->colorScheme
[0],-30).';'.$this->defStyle
.$this->formElStyle('none').' background-color: '.$this->colorScheme
[0].'; padding-left:1px;color:#555;';
2033 if ($config['format']) {
2034 $itemValue = $this->formatValue($config, $itemValue);
2037 $rows = intval($config['rows']);
2039 if(!$config['pass_content']) {
2040 $itemValue = nl2br(htmlspecialchars($itemValue));
2043 $cols = t3lib_div
::intInRange($config['cols'] ?
$config['cols'] : 30, 5, $this->maxTextareaWidth
);
2044 if (!$config['fixedRows']) {
2045 $origRows = $rows = t3lib_div
::intInRange($rows, 1, 20);
2046 if (strlen($itemValue)>$this->charsPerRow
*2) {
2047 $cols = $this->maxTextareaWidth
;
2048 $rows = t3lib_div
::intInRange(round(strlen($itemValue)/$this->charsPerRow
),count(explode(chr(10),$itemValue)),20);
2049 if ($rows<$origRows) $rows=$origRows;
2053 if ($this->docLarge
) $cols = round($cols*$this->form_largeComp
);
2054 $width = ceil($cols*$this->form_rowsToStylewidth
);
2055 // hardcoded: 12 is the height of the font
2059 <div style="'.htmlspecialchars($divStyle.' overflow:auto; height:'.$height.'px; width:'.$width.'px;').'" class="'.htmlspecialchars($this->formElClass('none')).'">'.
2063 if(!$config['pass_content']) {
2064 $itemValue = htmlspecialchars($itemValue);
2067 $cols = $config['cols']?
$config['cols']:($config['size']?
$config['size']:$this->maxInputWidth
);
2068 if ($this->docLarge
) $cols = round($cols*$this->form_largeComp
);
2069 $width = ceil($cols*$this->form_rowsToStylewidth
);
2071 // overflow:auto crashes mozilla here. Title tag is usefull when text is longer than the div box (overflow:hidden).
2073 <div style="'.htmlspecialchars($divStyle.' overflow:hidden; width:'.$width.'px;').'" class="'.htmlspecialchars($this->formElClass('none')).'" title="'.$itemValue.'">'.
2074 '<span class="nobr">'.(strcmp($itemValue,'')?
$itemValue:' ').'</span>'.
2082 * Handler for Flex Forms
2084 * @param string The table name of the record
2085 * @param string The field name which this element is supposed to edit
2086 * @param array The record data array where the value(s) for the field can be found
2087 * @param array An array with additional configuration options.
2088 * @return string The HTML code for the TCEform field
2090 function getSingleField_typeFlex($table,$field,$row,&$PA) {
2093 $dataStructArray = t3lib_BEfunc
::getFlexFormDS($PA['fieldConf']['config'],$row,$table);
2095 // Get data structure:
2096 if (is_array($dataStructArray)) {
2099 $xmlData = $PA['itemFormElValue'];
2100 $xmlHeaderAttributes = t3lib_div
::xmlGetHeaderAttribs($xmlData);
2101 $storeInCharset = strtolower($xmlHeaderAttributes['encoding']);
2102 if ($storeInCharset) {
2103 $currentCharset=$GLOBALS['LANG']->charSet
;
2104 $xmlData = $GLOBALS['LANG']->csConvObj
->conv($xmlData,$storeInCharset,$currentCharset,1);
2106 $editData=t3lib_div
::xml2array($xmlData);
2107 if (!is_array($editData)) { // Must be XML parsing error...
2109 } elseif (!isset($editData['meta']) ||
!is_array($editData['meta'])) {
2110 $editData['meta'] = array();
2113 // Find the data structure if sheets are found:
2114 $sheet = $editData['meta']['currentSheetId'] ?
$editData['meta']['currentSheetId'] : 'sDEF'; // Sheet to display
2116 // Create sheet menu:
2117 // if (is_array($dataStructArray['sheets'])) {
2118 // #$item.=$this->getSingleField_typeFlex_sheetMenu($dataStructArray['sheets'], $PA['itemFormElName'].'[meta][currentSheetId]', $sheet).'<br />';
2121 // Create language menu:
2122 $langChildren = $dataStructArray['meta']['langChildren'] ?
1 : 0;
2123 $langDisabled = $dataStructArray['meta']['langDisable'] ?
1 : 0;
2125 $editData['meta']['currentLangId']=array();
2126 $languages = $this->getAvailableLanguages();
2128 foreach($languages as $lInfo) {
2129 if ($GLOBALS['BE_USER']->checkLanguageAccess($lInfo['uid'])) {
2130 $editData['meta']['currentLangId'][] = $lInfo['ISOcode'];
2133 if (!is_array($editData['meta']['currentLangId']) ||
!count($editData['meta']['currentLangId'])) {
2134 $editData['meta']['currentLangId']=array('DEF');
2137 $editData['meta']['currentLangId'] = array_unique($editData['meta']['currentLangId']);
2140 // if (!$langDisabled && count($languages) > 1) {
2141 // $item.=$this->getSingleField_typeFlex_langMenu($languages, $PA['itemFormElName'].'[meta][currentLangId]', $editData['meta']['currentLangId']).'<br />';
2144 $PA['_noEditDEF'] = FALSE;
2145 if ($langChildren ||
$langDisabled) {
2146 $rotateLang = array('DEF');
2148 if (!in_array('DEF',$editData['meta']['currentLangId'])) {
2149 array_unshift($editData['meta']['currentLangId'],'DEF');
2150 $PA['_noEditDEF'] = TRUE;
2152 $rotateLang = $editData['meta']['currentLangId'];
2156 if (is_array($dataStructArray['sheets'])) {
2157 $tabsToTraverse = array_keys($dataStructArray['sheets']);
2159 $tabsToTraverse = array($sheet);
2162 foreach ($rotateLang as $lKey) {
2163 if (!$langChildren && !$langDisabled) {
2164 $item.= '<b>'.$this->getLanguageIcon($table,$row,'v'.$lKey).$lKey.':</b>';
2167 $tabParts = array();
2168 foreach ($tabsToTraverse as $sheet) {
2169 $sheetCfg = $dataStructArray['sheets'][$sheet];
2170 list ($dataStruct, $sheet) = t3lib_div
::resolveSheetDefInDS($dataStructArray,$sheet);
2173 if (is_array($dataStruct['ROOT']) && is_array($dataStruct['ROOT']['el'])) {
2174 $cmdData = t3lib_div
::_GP('flexFormsCmdData');
2175 $lang = 'l'.$lKey; // Default language, other options are "lUK" or whatever country code (independant of system!!!)
2176 $PA['_valLang'] = $langChildren && !$langDisabled ?
$editData['meta']['currentLangId'] : 'DEF'; // Default language, other options are "lUK" or whatever country code (independant of system!!!)
2177 $PA['_lang'] = $lang;
2180 $tRows = $this->getSingleField_typeFlex_draw(
2181 $dataStruct['ROOT']['el'],
2182 $editData['data'][$sheet][$lang],
2183 $cmdData['data'][$sheet][$lang],
2188 '[data]['.$sheet.']['.$lang.']'
2190 $sheetContent= '<table border="0" cellpadding="1" cellspacing="1" class="typo3-TCEforms-flexForm">'.implode('',$tRows).'</table>';
2192 # $item = '<div style=" position:absolute;">'.$item.'</div>';
2193 //visibility:hidden;
2194 } else $sheetContent='Data Structure ERROR: No ROOT element found for sheet "'.$sheet.'".';
2197 $tabParts[] = array(
2198 'label' => ($sheetCfg['ROOT']['TCEforms']['sheetTitle'] ?
$this->sL($sheetCfg['ROOT']['TCEforms']['sheetTitle']) : $sheet),
2199 'description' => ($sheetCfg['ROOT']['TCEforms']['sheetDescription'] ?
$this->sL($sheetCfg['ROOT']['TCEforms']['sheetDescription']) : ''),
2200 'linkTitle' => ($sheetCfg['ROOT']['TCEforms']['sheetShortDescr'] ?
$this->sL($sheetCfg['ROOT']['TCEforms']['sheetShortDescr']) : ''),
2201 'content' => $sheetContent
2205 if (is_array($dataStructArray['sheets'])) {
2206 $item.= $this->getDynTabMenu($tabParts,'TCEFORMS:flexform:'.$PA['itemFormElName'].$PA['_lang']);
2208 $item.= $sheetContent;
2211 } else $item='Data Structure ERROR: '.$dataStructArray;
2217 * Creates the language menu for FlexForms:
2219 * @param [type] $languages: ...
2220 * @param [type] $elName: ...
2221 * @param [type] $selectedLanguage: ...
2222 * @param [type] $multi: ...
2223 * @return string HTML for menu
2225 function getSingleField_typeFlex_langMenu($languages,$elName,$selectedLanguage,$multi=1) {
2227 foreach($languages as $lArr) {
2228 $opt[]='<option value="'.htmlspecialchars($lArr['ISOcode']).'"'.(in_array($lArr['ISOcode'],$selectedLanguage)?
' selected="selected"':'').'>'.htmlspecialchars($lArr['title']).'</option>';
2231 $output = '<select name="'.$elName.'[]"'.($multi ?
' multiple="multiple" size="'.count($languages).'"' : '').'>'.implode('',$opt).'</select>';
2237 * Creates the menu for selection of the sheets:
2239 * @param array Sheet array for which to render the menu
2240 * @param string Form element name of the field containing the sheet pointer
2241 * @param string Current sheet key
2242 * @return string HTML for menu
2244 function getSingleField_typeFlex_sheetMenu($sArr,$elName,$sheetKey) {
2247 $pct = round(100/count($sArr));
2248 foreach($sArr as $sKey => $sheetCfg) {
2249 if ($GLOBALS['BE_USER']->jsConfirmation(1)) {
2250 $onClick = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){'.$this->elName($elName).".value='".$sKey."'; TBE_EDITOR.submitForm()};";
2252 $onClick = 'if(TBE_EDITOR.checkSubmit(-1)){ '.$this->elName($elName).".value='".$sKey."'; TBE_EDITOR.submitForm();}";
2256 $tCells[]='<td width="'.$pct.'%" style="'.($sKey==$sheetKey ?
'background-color: #9999cc; font-weight: bold;' : 'background-color: #aaaaaa;').' cursor: hand;" onclick="'.htmlspecialchars($onClick).'" align="center">'.
2257 ($sheetCfg['ROOT']['TCEforms']['sheetTitle'] ?
$this->sL($sheetCfg['ROOT']['TCEforms']['sheetTitle']) : $sKey).
2261 return '<table border="0" cellpadding="0" cellspacing="2" class="typo3-TCEforms-flexForm-sheetMenu"><tr>'.implode('',$tCells).'</tr></table>';
2265 * [Describe function...]
2267 * @param [type] $dataStruct: ...
2268 * @param [type] $editData: ...
2269 * @param [type] $cmdData: ...
2270 * @param [type] $table: ...
2271 * @param [type] $field: ...
2272 * @param [type] $row: ...
2273 * @param [type] $PA: ...
2274 * @param [type] $formPrefix: ...
2275 * @param [type] $level: ...
2276 * @param [type] $tRows: ...
2277 * @return [type] ...
2279 function getSingleField_typeFlex_draw($dataStruct,$editData,$cmdData,$table,$field,$row,&$PA,$formPrefix='',$level=0,$tRows=array()) {
2281 // Data Structure array must be ... and array of course...
2282 if (is_array($dataStruct)) {
2283 foreach($dataStruct as $key => $value) {
2284 if (is_array($value)) { // The value of each entry must be an array.
2286 // ********************
2288 // ********************
2292 $rowCells['title'] = '<img src="clear.gif" width="'.($level*16).'" height="1" alt="" /><strong>'.htmlspecialchars(t3lib_div
::fixed_lgd_cs($this->sL($value['tx_templavoila']['title']),30)).'</strong>';;
2294 $rowCells['formEl']='';
2295 if ($value['type']=='array') {
2296 if ($value['section']) {
2297 // Render "NEW [container]" selectorbox:
2298 if (is_array($value['el'])) {
2300 $opt[]='<option value=""></option>';
2301 foreach($value['el'] as $kk => $vv) {
2302 $opt[]='<option value="'.$kk.'">'.htmlspecialchars($this->getLL('l_new') . ' "'.$this->sL($value['el'][$kk]['tx_templavoila']['title']).'"').'</option>';
2304 $rowCells['formEl']='<select name="flexFormsCmdData'.$formPrefix.'['.$key.'][value]">'.implode('',$opt).'</select>';
2308 $tRows[]='<tr class="bgColor2">
2309 <td nowrap="nowrap" valign="top">'.$rowCells['title'].'</td>
2310 <td>'.$rowCells['formEl'].'</td>
2314 if (is_array($editData[$key]['el'])) {
2315 foreach ($editData[$key]['el'] as $k3 => $v3) {
2317 $theType = key($v3);
2318 $theDat = $v3[$theType];
2319 $newSectionEl = $value['el'][$theType];
2320 if (is_array($newSectionEl)) {
2321 $tRows = $this->getSingleField_typeFlex_draw(
2322 array($theType => $newSectionEl),
2323 array($theType => $theDat),
2324 $cmdData[$key]['el'][$cc],
2329 $formPrefix.'['.$key.'][el]['.$cc.']',
2340 if ($cmdData[$key]['value']) {
2341 $newSectionEl = $value['el'][$cmdData[$key]['value']];
2342 if (is_array($newSectionEl)) {
2343 $tRows = $this->getSingleField_typeFlex_draw(
2344 array($cmdData[$key]['value'] => $newSectionEl),
2351 $formPrefix.'['.$key.'][el]['.($cc+
1).']',
2358 $idTagPrefix = uniqid('id',true); // ID attributes are used for the move and delete checkboxes for referencing to them in the label tag (<label for="the form field id">) that's rendered around the icons
2361 $tRows[]='<tr class="bgColor2">
2362 <td nowrap="nowrap" valign="top">'.
2363 '<input name="_DELETE_FLEX_FORM'.$PA['itemFormElName'].$formPrefix.'" id="'.$idTagPrefix.'-del" type="checkbox"'.$this->insertDefStyle('check').' value="1" /><label for="'.$idTagPrefix.'-del"><img src="'.$this->backPath
.'gfx/garbage.gif" border="0" alt="" /></label>'.
2364 '<input name="_MOVEUP_FLEX_FORM'.$PA['itemFormElName'].$formPrefix.'" id="'.$idTagPrefix.'-mvup" type="checkbox"'.$this->insertDefStyle('check').' value="1" /><label for="'.$idTagPrefix.'-mvup"><img src="'.$this->backPath
.'gfx/button_up.gif" border="0" alt="" /></label>'.
2365 '<input name="_MOVEDOWN_FLEX_FORM'.$PA['itemFormElName'].$formPrefix.'" id="'.$idTagPrefix.'-mvdown" type="checkbox"'.$this->insertDefStyle('check').' value="1" /><label for="'.$idTagPrefix.'-mvdown"><img src="'.$this->backPath
.'gfx/button_down.gif" border="0" alt="" /></label>'.
2366 $rowCells['title'].'</td>
2367 <td>'.$rowCells['formEl'].'</td>
2370 $tRows = $this->getSingleField_typeFlex_draw(
2372 $editData[$key]['el'],
2373 $cmdData[$key]['el'],
2378 $formPrefix.'['.$key.'][el]',
2384 } elseif (is_array($value['TCEforms']['config'])) { // Rendering a single form element:
2386 if (is_array($PA['_valLang'])) {
2387 $rotateLang = $PA['_valLang'];
2389 $rotateLang = array($PA['_valLang']);
2392 foreach($rotateLang as $vDEFkey) {
2393 $vDEFkey = 'v'.$vDEFkey;
2395 if (!$value['TCEforms']['displayCond'] ||
$this->isDisplayCondition($value['TCEforms']['displayCond'],$editData,$vDEFkey)) {
2397 $fakePA['fieldConf']=array(
2398 'label' => $this->sL(trim($value['TCEforms']['label'])),
2399 'config' => $value['TCEforms']['config'],
2400 'defaultExtras' => $value['TCEforms']['defaultExtras'],
2401 'onChange' => $value['TCEforms']['onChange']
2403 if ($PA['_noEditDEF'] && $PA['_lang']==='lDEF') {
2404 $fakePA['fieldConf']['config'] = array(
2411 $fakePA['fieldConf']['onChange'] == 'reload' ||
2412 ($GLOBALS['TCA'][$table]['ctrl']['type'] && !strcmp($key,$GLOBALS['TCA'][$table]['ctrl']['type'])) ||
2413 ($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'] && t3lib_div
::inList($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'],$key))) {
2414 if ($GLOBALS['BE_USER']->jsConfirmation(1)) {
2415 $alertMsgOnChange = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
2417 $alertMsgOnChange = 'if(TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm();}';
2420 $alertMsgOnChange = '';
2423 $fakePA['fieldChangeFunc']=$PA['fieldChangeFunc'];
2424 if (strlen($alertMsgOnChange)) {
2425 $fakePA['fieldChangeFunc']['alert']=$alertMsgOnChange;
2427 $fakePA['onFocus']=$PA['onFocus'];
2428 $fakePA['label']=$PA['label'];
2430 $fakePA['itemFormElName']=$PA['itemFormElName'].$formPrefix.'['.$key.']['.$vDEFkey.']';
2431 $fakePA['itemFormElName_file']=$PA['itemFormElName_file'].$formPrefix.'['.$key.']['.$vDEFkey.']';
2433 if(isset($editData[$key][$vDEFkey])) {
2434 $fakePA['itemFormElValue']=$editData[$key][$vDEFkey];
2436 $fakePA['itemFormElValue']=$fakePA['fieldConf']['config']['default'];
2439 $rowCells['formEl']= $this->getSingleField_SW($table,$field,$row,$fakePA);
2440 $rowCells['title']= htmlspecialchars($fakePA['fieldConf']['label']);
2442 if (!in_array('DEF',$rotateLang)) {
2443 $defInfo = '<div class="typo3-TCEforms-originalLanguageValue">'.$this->getLanguageIcon($table,$row,0).$this->previewFieldValue($editData[$key]['vDEF'], $fakePA['fieldConf']).' </div>';
2448 if (!$PA['_noEditDEF']) {
2449 $prLang = $this->getAdditionalPreviewLanguages();
2450 foreach($prLang as $prL) {
2451 $defInfo.= '<div class="typo3-TCEforms-originalLanguageValue">'.$this->getLanguageIcon($table,$row,'v'.$prL['ISOcode']).$this->previewFieldValue($editData[$key]['v'.$prL['ISOcode']], $fakePA['fieldConf']).' </div>';
2457 <td nowrap="nowrap" valign="top" class="bgColor5">'.($vDEFkey=='vDEF' ?
'' : $this->getLanguageIcon($table,$row,$vDEFkey)).$rowCells['title'].'</td>
2458 <td class="bgColor4">'.$rowCells['formEl'].$defInfo.'</td>
2471 * Handler for unknown types.
2473 * @param string The table name of the record
2474 * @param string The field name which this element is supposed to edit
2475 * @param array The record data array where the value(s) for the field can be found
2476 * @param array An array with additional configuration options.
2477 * @return string The HTML code for the TCEform field
2479 function getSingleField_typeUnknown($table,$field,$row,&$PA) {
2480 $item='Unknown type: '.$PA['fieldConf']['config']['form_type'].'<br />';
2486 * User defined field type
2488 * @param string The table name of the record
2489 * @param string The field name which this element is supposed to edit
2490 * @param array The record data array where the value(s) for the field can be found
2491 * @param array An array with additional configuration options.
2492 * @return string The HTML code for the TCEform field
2494 function getSingleField_typeUser($table,$field,$row,&$PA) {
2495 $PA['table']=$table;
2496 $PA['field']=$field;
2501 return t3lib_div
::callUserFunction($PA['fieldConf']['config']['userFunc'],$PA,$this);
2509 /************************************************************
2511 * Field content processing
2513 ************************************************************/
2516 * Format field content of various types if $config['format'] is set to date, filesize, ..., user
2517 * This is primarily for the field type none but can be used for user field types for example
2519 * @param array Configuration for the display
2520 * @param string The value to display
2521 * @return string Formatted Field content
2523 function formatValue ($config, $itemValue) {
2524 $format = trim($config['format']);
2528 $option = trim($config['format.']['option']);
2530 if ($config['format.']['strftime']) {
2531 $value = strftime($option,$itemValue);
2533 $value = date($option,$itemValue);
2536 $value = date('d-m-Y',$itemValue);
2541 if ($config['format.']['appendAge']) {
2542 $value .= ' ('.t3lib_BEfunc
::calcAge((time()-$itemValue), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')).')';
2544 $itemValue = $value;
2546 case 'datetime': // compatibility with "eval" (type "input")
2547 $itemValue = date('H:i d-m-Y',$itemValue);
2549 case 'time': // compatibility with "eval" (type "input")
2550 $itemValue = date('H:i',$itemValue);
2552 case 'timesec': // compatibility with "eval" (type "input")
2553 $itemValue = date('H:i:s',$itemValue);
2555 case 'year': // compatibility with "eval" (type "input")
2556 $itemValue = date('Y',$itemValue);
2559 $baseArr = array('dec'=>'d','hex'=>'x','HEX'=>'X','oct'=>'o','bin'=>'b');
2560 $base = trim($config['format.']['base']);
2561 $format = $baseArr[$base] ?
$baseArr[$base] : 'd';
2562 $itemValue = sprintf('%'.$format,$itemValue);
2565 $precision = t3lib_div
::intInRange($config['format.']['precision'],1,10,2);
2566 $itemValue = sprintf('%.'.$precision.'f',$itemValue);
2569 $format = trim($config['format.']['option']);
2570 $itemValue = sprintf('%'.$format,$itemValue);
2573 $itemValue = md5($itemValue);
2576 $value = t3lib_div
::formatSize(intval($itemValue));
2577 if ($config['format.']['appendByteSize']) {
2578 $value .= ' ('.$itemValue.')';
2580 $itemValue = $value;
2583 $func = trim($config['format.']['userFunc']);
2586 'value' => $itemValue,
2587 'args' => $config['format.']['userFunc'],
2588 'config' => $config,
2591 $itemValue = t3lib_div
::callUserFunction($func,$params,$this);
2606 /************************************************************
2608 * "Configuration" fetching/processing functions
2610 ************************************************************/
2613 * Calculate and return the current "types" pointer value for a record
2615 * @param string The table name. MUST be in $TCA
2616 * @param array The row from the table, should contain at least the "type" field, if applicable.
2617 * @return string Return the "type" value for this record, ready to pick a "types" configuration from the $TCA array.
2619 function getRTypeNum($table,$row) {
2621 // If there is a "type" field configured...
2622 if ($TCA[$table]['ctrl']['type']) {
2623 $typeFieldName = $TCA[$table]['ctrl']['type'];
2624 $typeNum=$row[$typeFieldName]; // Get value of the row from the record which contains the type value.
2625 if (!strcmp($typeNum,'')) $typeNum=0; // If that value is an empty string, set it to "0" (zero)
2627 $typeNum = 0; // If no "type" field, then set to "0" (zero)
2630 $typeNum = (string)$typeNum; // Force to string. Necessary for eg '-1' to be recognized as a type value.
2631 if (!$TCA[$table]['types'][$typeNum]) { // However, if the type "0" is not found in the "types" array, then default to "1" (for historical reasons)
2639 * Used to adhoc-rearrange the field order normally set in the [types][showitem] list
2641 * @param array A [types][showitem] list of fields, exploded by ","
2642 * @return array Returns rearranged version (keys are changed around as well.)
2643 * @see getMainFields()
2645 function rearrange($fields) {
2646 $fO = array_flip(t3lib_div
::trimExplode(',',$this->fieldOrder
,1));
2649 while(list($cc,$content)=each($fields)) {
2650 $cP = t3lib_div
::trimExplode(';',$content);
2651 if (isset($fO[$cP[0]])) {
2652 $newFields[$fO[$cP[0]]] = $content;
2653 unset($fields[$cc]);
2657 $fields=array_merge($newFields,$fields); // Candidate for t3lib_div::array_merge() if integer-keys will some day make trouble...
2662 * Producing an array of field names NOT to display in the form, based on settings from subtype_value_field, bitmask_excludelist_bits etc.
2663 * Notice, this list is in NO way related to the "excludeField" flag
2665 * @param string Table name, MUST be in $TCA
2666 * @param array A record from table.
2667 * @param string A "type" pointer value, probably the one calculated based on the record array.
2668 * @return array Array with fieldnames as values. The fieldnames are those which should NOT be displayed "anyways"
2669 * @see getMainFields()
2671 function getExcludeElements($table,$row,$typeNum) {
2675 $excludeElements=array();
2677 // If a subtype field is defined for the type
2678 if ($TCA[$table]['types'][$typeNum