[TASK] Encapsulate bootstrap base code
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_tceforms.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Contains TYPO3 Core Form generator - AKA "TCEforms"
29 *
30 * Revised for TYPO3 3.6 August/2003 by Kasper Skårhøj
31 * XHTML compliant
32 *
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
34 */
35
36 /**
37 * 'TCEforms' - Class for creating the backend editing forms.
38 *
39 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
40 * @coauthor René Fritz <r.fritz@colorcube.de>
41 * @package TYPO3
42 * @subpackage t3lib
43 */
44 class t3lib_TCEforms {
45
46 // variables not commented yet.... (do so...)
47 var $palFieldArr = array();
48 var $disableWizards = 0;
49 var $isPalettedoc = 0;
50 var $paletteMargin = 1;
51 // 'font-family:Verdana;font-size:10px;';
52 var $defStyle = '';
53 var $cachedTSconfig = array();
54 var $cachedTSconfig_fieldLevel = array();
55 var $cachedLanguageFlag = array();
56 var $cachedAdditionalPreviewLanguages = NULL;
57 var $transformedRow = array();
58 var $extJSCODE = '';
59 var $printNeededJS = array();
60 var $hiddenFieldAccum = array();
61 var $TBE_EDITOR_fieldChanged_func = '';
62 var $loadMD5_JS = 1;
63 // Something unique...
64 var $prevBorderStyle = '[nothing here...]';
65 // If set direct upload fields will be shown
66 var $allowUpload = 0;
67 // Array where records in the default language is stored. (processed by transferdata)
68 var $defaultLanguageData = array();
69 // Array where records in the default language is stored (raw without any processing. used for making diff)
70 var $defaultLanguageData_diff = array();
71 var $additionalPreviewLanguageData = array();
72
73 // EXTERNAL, static
74 // Set this to the 'backPath' pointing back to the typo3 admin directory from the script where this form is displayed.
75 var $backPath = '';
76 // Alternative return URL path (default is t3lib_div::linkThisScript())
77 var $returnUrl = '';
78 // 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.
79 var $doSaveFieldName = '';
80 // 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.
81 var $palettesCollapsed = 0;
82 // If set, the RTE is disabled (from form display, eg. by checkbox in the bottom of the page!)
83 var $disableRTE = 0;
84 // If FALSE, then all CSH will be disabled, regardless of settings in $this->edit_showFieldHelp
85 var $globalShowHelp = 1;
86 // If TRUE, the forms are rendering only localization relevant fields of the records.
87 var $localizationMode = '';
88 // 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.
89 var $fieldOrder = '';
90 // If set to FALSE, palettes will NEVER be rendered.
91 var $doPrintPalette = 1;
92
93 /**
94 * Set to initialized clipboard object; Then the element browser will offer a link to paste in records from clipboard.
95 *
96 * @var t3lib_clipboard
97 */
98 var $clipObj = FALSE;
99 // Enable click menu on reference icons.
100 var $enableClickMenu = FALSE;
101 // Enable Tab Menus.
102 var $enableTabMenu = FALSE;
103 // When enabled all fields are rendered non-editable.
104 var $renderReadonly = FALSE;
105 // Form field width compensation: Factor from NN4 form field widths to style-aware browsers (like NN6+ and MSIE, with the $GLOBALS['CLIENT']['FORMSTYLE'] value set)
106 var $form_rowsToStylewidth = 9.58;
107 // Form field width compensation: Compensation for large documents, doc-tab (editing)
108 var $form_largeComp = 1.33;
109 // 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.
110 var $charsPerRow = 40;
111 // The maximum abstract value for textareas
112 var $maxTextareaWidth = 48;
113 // The maximum abstract value for input fields
114 var $maxInputWidth = 48;
115 // Default style for the selector boxes used for multiple items in "select" and "group" types.
116 var $defaultMultipleSelectorStyle = 'width:310px;';
117
118
119 // INTERNAL, static
120 // The string to prepend formfield names with.
121 var $prependFormFieldNames = 'data';
122 // The string to prepend commands for tcemain::process_cmdmap with.
123 var $prependCmdFieldNames = 'cmd';
124 // The string to prepend FILE form field names with.
125 var $prependFormFieldNames_file = 'data_files';
126 // The name attribute of the form.
127 var $formName = 'editform';
128 // Whitelist that allows TCA field configuration to be overridden by TSconfig, @see overrideFieldConf()
129 var $allowOverrideMatrix = array();
130
131
132 // INTERNAL, dynamic
133 // Set by readPerms() (caching)
134 var $perms_clause = '';
135 // Set by readPerms() (caching-flag)
136 var $perms_clause_set = 0;
137 // 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).
138 var $edit_showFieldHelp = '';
139 // If set, the forms will be rendered a little wider, more precisely with a factor of $this->form_largeComp.
140 var $docLarge = 0;
141 // Loaded with info about the browser when class is instantiated.
142 var $clientInfo = array();
143 // TRUE, if RTE is possible for the current user (based on result from BE_USER->isRTE())
144 var $RTEenabled = 0;
145 // 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)
146 var $RTEenabled_notReasons = '';
147 // Counter that is incremented before an RTE is created. Can be used for unique ids etc.
148 var $RTEcounter = 0;
149 // Contains current color scheme
150 var $colorScheme;
151 // Contains current class scheme
152 var $classScheme;
153 // Contains the default color scheme
154 var $defColorScheme;
155 // Contains the default class scheme
156 var $defClassScheme;
157 // Contains field style values
158 var $fieldStyle;
159 // Contains border style values.
160 var $borderStyle;
161 // An accumulation of messages from the class.
162 var $commentMessages = array();
163
164 // INTERNAL, templates
165 // Total wrapping for the table rows.
166 var $totalWrap = '<hr />|<hr />';
167 // Field template
168 var $fieldTemplate = '<strong>###FIELD_NAME###</strong><br />###FIELD_ITEM###<hr />';
169 // Wrapping template code for a section
170 var $sectionWrap = '';
171 // Template for palette headers
172 var $palFieldTemplateHeader = '';
173 // Template for palettes
174 var $palFieldTemplate = '';
175
176 // INTERNAL, working memory
177 // Set to the fields NOT to display, if any.
178 var $excludeElements = '';
179 // During rendering of forms this will keep track of which palettes has already been rendered (so they are not rendered twice by mistake)
180 var $palettesRendered = array();
181 // 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!
182 var $hiddenFieldListArr = array();
183 // 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.
184 var $requiredFields = array();
185 // Used to register input-field names, which are required an have additional requirements (e.g. like a date/time must be positive integer). The information of this array is merged with $this->requiredFields later.
186 var $requiredAdditional = array();
187 // Used to register the min and max number of elements for selectorboxes where that apply (in the "group" type for instance)
188 var $requiredElements = array();
189 // Used to determine where $requiredFields or $requiredElements are nested (in Tabs or IRRE)
190 var $requiredNested = array();
191 // Keeps track of the rendering depth of nested records.
192 var $renderDepth = 0;
193 // Color scheme buffer.
194 var $savedSchemes = array();
195 // holds the path an element is nested in (e.g. required for RTEhtmlarea)
196 var $dynNestedStack = array();
197
198 // Internal, registers for user defined functions etc.
199 // Additional HTML code, printed before the form.
200 var $additionalCode_pre = array();
201 // Additional JavaScript, printed before the form
202 var $additionalJS_pre = array();
203 // Additional JavaScript printed after the form
204 var $additionalJS_post = array();
205 // 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.
206 var $additionalJS_submit = array();
207 // Additional JavaScript executed when section element is deleted. This is neceessary, for example, to correctly clean up HTMLArea RTE (bug #8232)
208 var $additionalJS_delete = array();
209
210 /**
211 * Instance of t3lib_tceforms_inline
212 *
213 * @var t3lib_TCEforms_inline
214 */
215 var $inline;
216 // Array containing hook class instances called once for a form
217 var $hookObjectsMainFields = array();
218 // Array containing hook class instances called for each field
219 var $hookObjectsSingleField = array();
220 // Rows gettings inserted into the alt_doc headers (when called from alt_doc.php)
221 var $extraFormHeaders = array();
222
223 public $templateFile = ''; // Form templates, relative to typo3 directory
224
225 /**
226 * Constructor function, setting internal variables, loading the styles used.
227 *
228 * @return void
229 */
230 function __construct() {
231 $this->clientInfo = t3lib_div::clientInfo();
232
233 $this->RTEenabled = $GLOBALS['BE_USER']->isRTE();
234 if (!$this->RTEenabled) {
235 $this->RTEenabled_notReasons = implode(LF, $GLOBALS['BE_USER']->RTE_errors);
236 $this->commentMessages[] = 'RTE NOT ENABLED IN SYSTEM due to:' . LF . $this->RTEenabled_notReasons;
237 }
238
239 // Default color+class scheme
240 $this->defColorScheme = array(
241 $GLOBALS['SOBE']->doc->bgColor, // Background for the field AND palette
242 t3lib_div::modifyHTMLColorAll($GLOBALS['SOBE']->doc->bgColor, -20), // Background for the field header
243 t3lib_div::modifyHTMLColorAll($GLOBALS['SOBE']->doc->bgColor, -10), // Background for the palette field header
244 'black', // Field header font color
245 '#666666' // Palette field header font color
246 );
247 $this->defColorScheme = array();
248
249 // Override / Setting defaults from TBE_STYLES array
250 $this->resetSchemes();
251
252 // Setting the current colorScheme to default.
253 $this->defColorScheme = $this->colorScheme;
254 $this->defClassScheme = $this->classScheme;
255
256 // Define whitelist that allows TCA field configuration to be overridden by TSconfig, @see overrideFieldConf():
257 $this->allowOverrideMatrix = array(
258 'input' => array('size', 'max'),
259 'text' => array('cols', 'rows', 'wrap'),
260 'check' => array('cols', 'showIfRTE'),
261 'select' => array('size', 'autoSizeMax', 'maxitems', 'minitems'),
262 'group' => array('size', 'autoSizeMax', 'max_size', 'show_thumbs', 'maxitems', 'minitems', 'disable_controls'),
263 'inline' => array('appearance', 'behaviour', 'foreign_label', 'foreign_selector', 'foreign_unique', 'maxitems', 'minitems', 'size', 'autoSizeMax', 'symmetric_label'),
264 );
265
266 // Create instance of t3lib_TCEforms_inline only if this a non-IRRE-AJAX call:
267 if (!isset($GLOBALS['ajaxID']) || strpos($GLOBALS['ajaxID'], 't3lib_TCEforms_inline::') !== 0) {
268 $this->inline = t3lib_div::makeInstance('t3lib_TCEforms_inline');
269 }
270 // Create instance of t3lib_TCEforms_suggest only if this a non-Suggest-AJAX call:
271 if (!isset($GLOBALS['ajaxID']) || strpos($GLOBALS['ajaxID'], 't3lib_TCEforms_suggest::') !== 0) {
272 $this->suggest = t3lib_div::makeInstance('t3lib_TCEforms_suggest');
273 }
274
275 // Prepare user defined objects (if any) for hooks which extend this function:
276 $this->hookObjectsMainFields = array();
277 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'])) {
278 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'] as $classRef) {
279 $this->hookObjectsMainFields[] = t3lib_div::getUserObj($classRef);
280 }
281 }
282 $this->hookObjectsSingleField = array();
283 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getSingleFieldClass'])) {
284 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getSingleFieldClass'] as $classRef) {
285 $this->hookObjectsSingleField[] = t3lib_div::getUserObj($classRef);
286 }
287 }
288
289 $this->templateFile = 'templates/tceforms.html';
290 }
291
292 /**
293 * Initialize various internal variables.
294 *
295 * @return void
296 */
297 function initDefaultBEmode() {
298 $this->prependFormFieldNames = 'data';
299 $this->formName = 'editform';
300 $this->setNewBEDesign();
301 $this->docLarge = ($GLOBALS['BE_USER']->uc['edit_wideDocument'] ? 1 : 0);
302 $this->edit_showFieldHelp = $GLOBALS['BE_USER']->uc['edit_showFieldHelp'];
303
304 $this->edit_docModuleUpload = $GLOBALS['BE_USER']->uc['edit_docModuleUpload'];
305
306 $this->inline->init($this);
307 $this->suggest->init($this);
308 }
309
310 /*******************************************************
311 *
312 * Rendering the forms, fields etc
313 *
314 *******************************************************/
315
316 /**
317 * Will return the TCEform element for just a single field from a record.
318 * The field must be listed in the currently displayed fields (as found in [types][showitem]) for the record.
319 * This also means that the $table/$row supplied must be complete so the list of fields to show can be found correctly
320 *
321 * @param string $table The table name
322 * @param array $row The record from the table for which to render a field.
323 * @param string $theFieldToReturn The field name to return the TCEform element for.
324 * @return string HTML output
325 * @see getMainFields()
326 */
327 function getSoloField($table, $row, $theFieldToReturn) {
328 if ($GLOBALS['TCA'][$table]) {
329 t3lib_div::loadTCA($table);
330 $typeNum = $this->getRTypeNum($table, $row);
331 if ($GLOBALS['TCA'][$table]['types'][$typeNum]) {
332 $itemList = $GLOBALS['TCA'][$table]['types'][$typeNum]['showitem'];
333 if ($itemList) {
334 $fields = t3lib_div::trimExplode(',', $itemList, 1);
335 $excludeElements = $this->excludeElements = $this->getExcludeElements($table, $row, $typeNum);
336
337 foreach ($fields as $fieldInfo) {
338 $parts = explode(';', $fieldInfo);
339
340 $theField = trim($parts[0]);
341 if (!in_array($theField, $excludeElements) && !strcmp($theField, $theFieldToReturn)) {
342 if ($GLOBALS['TCA'][$table]['columns'][$theField]) {
343 $sField = $this->getSingleField($table, $theField, $row, $parts[1], 1, $parts[3], $parts[2]);
344 return $sField['ITEM'];
345 }
346 }
347 }
348 }
349 }
350 }
351 }
352
353 /**
354 * Based on the $table and $row of content, this displays the complete TCEform for the record.
355 * 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.
356 *
357 * @param string $table The table name
358 * @param array $row The record from the table for which to render a field.
359 * @param integer $depth Depth level
360 * @param array $overruleTypesArray Overrule types array. Can be used to override the showitem etc. configuration for the TCA types of the table. Can contain all settings which are possible in the TCA 'types' section. See e.g. $TCA['tt_content']['types'].
361 * @return string HTML output
362 * @see getSoloField()
363 */
364 function getMainFields($table, array $row, $depth = 0, array $overruleTypesArray = array()) {
365 $this->renderDepth = $depth;
366
367 // Init vars:
368 $out_array = array(array());
369 $out_array_meta = array(array(
370 'title' => $this->getLL('l_generalTab')
371 ));
372
373 $out_pointer = 0;
374 $out_sheet = 0;
375 $this->palettesRendered = array();
376 $this->palettesRendered[$this->renderDepth][$table] = array();
377
378 // Hook: getMainFields_preProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
379 foreach ($this->hookObjectsMainFields as $hookObj) {
380 if (method_exists($hookObj, 'getMainFields_preProcess')) {
381 $hookObj->getMainFields_preProcess($table, $row, $this);
382 }
383 }
384
385 if ($GLOBALS['TCA'][$table]) {
386
387 // Load the full TCA for the table.
388 t3lib_div::loadTCA($table);
389
390 // Get dividers2tabs setting from TCA of the current table:
391 $dividers2tabs =& $GLOBALS['TCA'][$table]['ctrl']['dividers2tabs'];
392
393 // Load the description content for the table.
394 if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table)) {
395 $GLOBALS['LANG']->loadSingleTableDescription($table);
396 }
397 // Get the current "type" value for the record.
398 $typeNum = $this->getRTypeNum($table, $row);
399
400 // Find the list of fields to display:
401 if ($GLOBALS['TCA'][$table]['types'][$typeNum]) {
402 $itemList = $GLOBALS['TCA'][$table]['types'][$typeNum]['showitem'];
403 if (is_array($overruleTypesArray) && isset($overruleTypesArray[$typeNum]['showitem'])) {
404 $itemList = $overruleTypesArray[$typeNum]['showitem'];
405 }
406 // If such a list existed...
407 if ($itemList) {
408 // Explode the field list and possibly rearrange the order of the fields, if configured for
409 $fields = t3lib_div::trimExplode(',', $itemList, 1);
410 if ($this->fieldOrder) {
411 $fields = $this->rearrange($fields);
412 }
413
414 // Get excluded fields, added fiels and put it together:
415 $excludeElements = $this->excludeElements = $this->getExcludeElements($table, $row, $typeNum);
416 $fields = $this->mergeFieldsWithAddedFields($fields, $this->getFieldsToAdd($table, $row, $typeNum));
417
418 // If TCEforms will render a tab menu in the next step, push the name to the tab stack:
419 $tabIdentString = '';
420 $tabIdentStringMD5 = '';
421 if (strstr($itemList, '--div--') !== FALSE && $this->enableTabMenu && $dividers2tabs) {
422 $tabIdentString = 'TCEforms:' . $table . ':' . $row['uid'];
423 $tabIdentStringMD5 = $GLOBALS['TBE_TEMPLATE']->getDynTabMenuId($tabIdentString);
424 // Remember that were currently working on the general tab:
425 if (isset($fields[0]) && strpos($fields[0], '--div--') !== 0) {
426 $this->pushToDynNestedStack('tab', $tabIdentStringMD5 . '-1');
427 }
428 }
429
430 // Traverse the fields to render:
431 $cc = 0;
432 foreach ($fields as $fieldInfo) {
433 // Exploding subparts of the field configuration:
434 $parts = explode(';', $fieldInfo);
435
436 // Getting the style information out:
437 $color_style_parts = t3lib_div::trimExplode('-', $parts[4]);
438 if (strcmp($color_style_parts[0], '')) {
439 $this->setColorScheme($GLOBALS['TBE_STYLES']['colorschemes'][intval($color_style_parts[0])]);
440 }
441 if (strcmp($color_style_parts[1], '')) {
442 $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][intval($color_style_parts[1])];
443 if (!isset($this->fieldStyle)) {
444 $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][0];
445 }
446 }
447 if (strcmp($color_style_parts[2], '')) {
448 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
449 $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][intval($color_style_parts[2])];
450 if (!isset($this->borderStyle)) {
451 $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][0];
452 }
453 }
454
455 // Render the field:
456 $theField = $parts[0];
457 if (!in_array($theField, $excludeElements)) {
458 if ($GLOBALS['TCA'][$table]['columns'][$theField]) {
459 $sFieldPal = '';
460
461 if ($parts[2] && !isset($this->palettesRendered[$this->renderDepth][$table][$parts[2]])) {
462 $sFieldPal = $this->getPaletteFields($table, $row, $parts[2]);
463 $this->palettesRendered[$this->renderDepth][$table][$parts[2]] = 1;
464 }
465 $sField = $this->getSingleField($table, $theField, $row, $parts[1], 0, $parts[3], $parts[2]);
466 if ($sField) {
467 $sField .= $sFieldPal;
468 }
469
470 $out_array[$out_sheet][$out_pointer] .= $sField;
471 } elseif ($theField == '--div--') {
472 if ($cc > 0) {
473 $out_array[$out_sheet][$out_pointer] .= $this->getDivider();
474
475 if ($this->enableTabMenu && $dividers2tabs) {
476 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
477 // Remove last tab entry from the dynNestedStack:
478 $out_sheet++;
479 // Remove the previous sheet from stack (if any):
480 $this->popFromDynNestedStack('tab', $tabIdentStringMD5 . '-' . ($out_sheet));
481 // Remember on which sheet we're currently working:
482 $this->pushToDynNestedStack('tab', $tabIdentStringMD5 . '-' . ($out_sheet + 1));
483 $out_array[$out_sheet] = array();
484 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
485 // Register newline for Tab
486 $out_array_meta[$out_sheet]['newline'] = ($parts[2] == 'newline');
487 }
488 } else { // Setting alternative title for "General" tab if "--div--" is the very first element.
489 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
490 // Only add the first tab to the dynNestedStack if there are more tabs:
491 if ($tabIdentString && strpos($itemList, '--div--', strlen($fieldInfo))) {
492 $this->pushToDynNestedStack('tab', $tabIdentStringMD5 . '-1');
493 }
494 }
495 } elseif ($theField == '--palette--') {
496 if ($parts[2] && !isset($this->palettesRendered[$this->renderDepth][$table][$parts[2]])) {
497 // Render a 'header' if not collapsed
498 if ($GLOBALS['TCA'][$table]['palettes'][$parts[2]]['canNotCollapse'] && $parts[1]) {
499 $out_array[$out_sheet][$out_pointer] .= $this->getPaletteFields($table, $row, $parts[2], $this->sL($parts[1]));
500 } else {
501 $out_array[$out_sheet][$out_pointer] .= $this->getPaletteFields($table, $row, $parts[2], '', '', $this->sL($parts[1]));
502 }
503 $this->palettesRendered[$this->renderDepth][$table][$parts[2]] = 1;
504 }
505 }
506 }
507
508 $cc++;
509 }
510 }
511 }
512 }
513
514 // Hook: getMainFields_postProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
515 foreach ($this->hookObjectsMainFields as $hookObj) {
516 if (method_exists($hookObj, 'getMainFields_postProcess')) {
517 $hookObj->getMainFields_postProcess($table, $row, $this);
518 }
519 }
520
521 // Wrapping a border around it all:
522 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
523
524 // Resetting styles:
525 $this->resetSchemes();
526
527 // Rendering Main palettes, if any
528 $mParr = t3lib_div::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['mainpalette']);
529 $i = 0;
530 if (count($mParr)) {
531 foreach ($mParr as $mP) {
532 if (!isset($this->palettesRendered[$this->renderDepth][$table][$mP])) {
533 $temp_palettesCollapsed = $this->palettesCollapsed;
534 $this->palettesCollapsed = 0;
535 $label = ($i == 0 ? $this->getLL('l_generalOptions') : $this->getLL('l_generalOptions_more'));
536 $out_array[$out_sheet][$out_pointer] .= $this->getPaletteFields($table, $row, $mP, $label);
537 $this->palettesCollapsed = $temp_palettesCollapsed;
538 $this->palettesRendered[$this->renderDepth][$table][$mP] = 1;
539 }
540 $this->wrapBorder($out_array[$out_sheet], $out_pointer);
541 $i++;
542 if ($this->renderDepth) {
543 $this->renderDepth--;
544 }
545 }
546 }
547
548 // Return the imploded $out_array:
549 // There were --div-- dividers around...
550 if ($out_sheet > 0) {
551
552 // Create parts array for the tab menu:
553 $parts = array();
554 foreach ($out_array as $idx => $sheetContent) {
555 $content = implode('', $sheetContent);
556 if ($content) {
557 // Wrap content (row) with table-tag, otherwise tab/sheet will be disabled (see getdynTabMenu() )
558 $content = '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . $content . '</table>';
559 }
560 $parts[$idx] = array(
561 'label' => $out_array_meta[$idx]['title'],
562 'content' => $content,
563 'newline' => $out_array_meta[$idx]['newline'], // Newline for this tab/sheet
564 );
565 }
566
567 if (count($parts) > 1) {
568 // Unset the current level of tab menus:
569 $this->popFromDynNestedStack('tab', $tabIdentStringMD5 . '-' . ($out_sheet + 1));
570 $dividersToTabsBehaviour = (isset($GLOBALS['TCA'][$table]['ctrl']['dividers2tabs'])
571 ? $GLOBALS['TCA'][$table]['ctrl']['dividers2tabs']
572 : 1);
573 $output = $this->getDynTabMenu($parts, $tabIdentString, $dividersToTabsBehaviour);
574
575 } else {
576 // If there is only one tab/part there is no need to wrap it into the dynTab code
577 $output = isset($parts[0]) ? trim($parts[0]['content']) : '';
578 }
579
580 $output = '
581 <tr>
582 <td colspan="2">
583 ' . $output . '
584 </td>
585 </tr>';
586
587 } else {
588 // Only one, so just implode:
589 $output = implode('', $out_array[$out_sheet]);
590 }
591
592 return $output;
593 }
594
595 /**
596 * Will return the TCEform elements for a pre-defined list of fields.
597 * 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.
598 * Used for displaying forms for the frontend edit icons for instance.
599 *
600 * @param string $table The table name
601 * @param array $row The record array.
602 * @param string $list Commalist of fields from the table. These will be shown in the specified order in a form.
603 * @return string TCEform elements in a string.
604 */
605 function getListedFields($table, $row, $list) {
606 t3lib_div::loadTCA($table);
607 if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table)) {
608 $GLOBALS['LANG']->loadSingleTableDescription($table);
609 }
610
611 $out = '';
612 $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table, $row, 1);
613
614 $editFieldList = array_unique(t3lib_div::trimExplode(',', $list, 1));
615 foreach ($editFieldList as $theFieldC) {
616 list($theField, $palFields) = preg_split('/\[|\]/', $theFieldC);
617 $theField = trim($theField);
618 $palFields = trim($palFields);
619 if ($GLOBALS['TCA'][$table]['columns'][$theField]) {
620 $parts = t3lib_div::trimExplode(';', $types_fieldConfig[$theField]['origString']);
621 // Don't sent palette pointer - there are no options anyways for a field-list.
622 $sField = $this->getSingleField($table, $theField, $row, $parts[1], 0, $parts[3], 0);
623 $out .= $sField;
624 } elseif ($theField == '--div--') {
625 $out .= $this->getDivider();
626 }
627 if ($palFields) {
628 $out .= $this->getPaletteFields($table, $row, '', '', implode(',', t3lib_div::trimExplode('|', $palFields, 1)));
629 }
630 }
631
632 return $out;
633 }
634
635 /**
636 * Creates a palette (collection of secondary options).
637 *
638 * @param string $table The table name
639 * @param array $row The row array
640 * @param string $palette The palette number/pointer
641 * @param string $header Header string for the palette (used when in-form). If not set, no header item is made.
642 * @param string $itemList Optional alternative list of fields for the palette
643 * @param string $collapsedHeader Optional Link text for activating a palette (when palettes does not have another form element to belong to).
644 * @return string HTML code.
645 */
646 function getPaletteFields($table, $row, $palette, $header = '', $itemList = '', $collapsedHeader = NULL) {
647 if (!$this->doPrintPalette) {
648 return '';
649 }
650
651 $out = '';
652 $parts = $this->loadPaletteElements($table, $row, $palette, $itemList);
653
654 // Put palette together if there are fields in it:
655 if (count($parts)) {
656
657 $realFields = 0;
658
659 foreach ($parts as $part) {
660 if ($part['NAME'] !== '--linebreak--') {
661 $realFields++;
662 }
663 }
664
665 if ($realFields > 0) {
666
667 if ($header) {
668 $out .= $this->intoTemplate(
669 array('HEADER' => htmlspecialchars($header)),
670 $this->palFieldTemplateHeader
671 );
672 }
673
674 $collapsed = $this->isPalettesCollapsed($table, $palette);
675
676 // Check if the palette is a hidden palette
677 $isHiddenPalette = !empty($GLOBALS['TCA'][$table]['palettes'][$palette]['isHiddenPalette']);
678
679 $thePalIcon = '';
680 if ($collapsed && $collapsedHeader !== NULL && !$isHiddenPalette) {
681 list($thePalIcon,) = $this->wrapOpenPalette(
682 t3lib_iconWorks::getSpriteIcon(
683 'actions-system-options-view',
684 array('title' => htmlspecialchars($this->getLL('l_moreOptions')))
685 ), $table, $row, $palette, 1);
686 $thePalIcon = '<span style="margin-left: 20px;">' . $thePalIcon . $collapsedHeader . '</span>';
687 }
688
689 $paletteHtml = $this->wrapPaletteField($this->printPalette($parts), $table, $row, $palette, $collapsed);
690
691 $out .= $this->intoTemplate(
692 array('PALETTE' => $thePalIcon . $paletteHtml),
693 $this->palFieldTemplate
694 );
695 }
696 }
697 return $out;
698 }
699
700 /**
701 * Returns the form HTML code for a database table field.
702 *
703 * @param string $table The table name
704 * @param string $field The field name
705 * @param array $row The record to edit from the database table.
706 * @param string $altName Alternative field name label to show.
707 * @param boolean $palette Set this if the field is on a palette (in top frame), otherwise not. (if set, field will render as a hidden field).
708 * @param string $extra 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.
709 * @param integer $pal The palette pointer.
710 * @return mixed String (normal) or array (palettes)
711 */
712 function getSingleField($table, $field, $row, $altName = '', $palette = 0, $extra = '', $pal = 0) {
713
714 // Hook: getSingleField_preProcess
715 foreach ($this->hookObjectsSingleField as $hookObj) {
716 if (method_exists($hookObj, 'getSingleField_preProcess')) {
717 $hookObj->getSingleField_preProcess($table, $field, $row, $altName, $palette, $extra, $pal, $this);
718 }
719 }
720
721 $out = '';
722 $PA = array();
723 $PA['altName'] = $altName;
724 $PA['palette'] = $palette;
725 $PA['extra'] = $extra;
726 $PA['pal'] = $pal;
727
728 // Make sure to load full $GLOBALS['TCA'] array for the table:
729 t3lib_div::loadTCA($table);
730
731 // Get the TCA configuration for the current field:
732 $PA['fieldConf'] = $GLOBALS['TCA'][$table]['columns'][$field];
733 $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
734
735 $skipThisField = $this->inline->skipField($table, $field, $row, $PA['fieldConf']['config']);
736
737 // Now, check if this field is configured and editable (according to excludefields + other configuration)
738 if (is_array($PA['fieldConf']) &&
739 !$skipThisField &&
740 (!$PA['fieldConf']['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $table . ':' . $field)) &&
741 $PA['fieldConf']['config']['form_type'] != 'passthrough' &&
742 ($this->RTEenabled || !$PA['fieldConf']['config']['showIfRTE']) &&
743 (!$PA['fieldConf']['displayCond'] || $this->isDisplayCondition($PA['fieldConf']['displayCond'], $row)) &&
744 (!$GLOBALS['TCA'][$table]['ctrl']['languageField'] || $PA['fieldConf']['l10n_display'] || strcmp($PA['fieldConf']['l10n_mode'], 'exclude') || $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] <= 0) &&
745 (!$GLOBALS['TCA'][$table]['ctrl']['languageField'] || !$this->localizationMode || $this->localizationMode === $PA['fieldConf']['l10n_cat'])
746 ) {
747
748
749 // Fetching the TSconfig for the current table/field. This includes the $row which means that
750 $PA['fieldTSConfig'] = $this->setTSconfig($table, $row, $field);
751
752 // If the field is NOT disabled from TSconfig (which it could have been) then render it
753 if (!$PA['fieldTSConfig']['disabled']) {
754 // Override fieldConf by fieldTSconfig:
755 $PA['fieldConf']['config'] = $this->overrideFieldConf($PA['fieldConf']['config'], $PA['fieldTSConfig']);
756
757 // Init variables:
758 $PA['itemFormElName'] = $this->prependFormFieldNames . '[' . $table . '][' . $row['uid'] . '][' . $field . ']';
759 // Form field name, in case of file uploads
760 $PA['itemFormElName_file'] = $this->prependFormFieldNames_file . '[' . $table . '][' . $row['uid'] . '][' . $field . ']';
761 // The value to show in the form field.
762 $PA['itemFormElValue'] = $row[$field];
763 $PA['itemFormElID'] = $this->prependFormFieldNames . '_' . $table . '_' . $row['uid'] . '_' . $field;
764
765 // Set field to read-only if configured for translated records to show default language content as readonly
766 if ($PA['fieldConf']['l10n_display']
767 && t3lib_div::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly')
768 && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] > 0) {
769 $PA['fieldConf']['config']['readOnly'] = TRUE;
770 $PA['itemFormElValue'] = $this->defaultLanguageData[$table . ':' . $row['uid']][$field];
771 }
772
773 if (strpos($GLOBALS['TCA'][$table]['ctrl']['type'], ':') === FALSE) {
774 $typeField = $GLOBALS['TCA'][$table]['ctrl']['type'];
775 } else {
776 $typeField = substr($GLOBALS['TCA'][$table]['ctrl']['type'], 0, strpos($GLOBALS['TCA'][$table]['ctrl']['type'], ':'));
777 }
778
779 // 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"
780 if (
781 ($GLOBALS['TCA'][$table]['ctrl']['type'] && !strcmp($field, $typeField))
782 || ($GLOBALS['TCA'][$table]['ctrl']['requestUpdate']
783 && t3lib_div::inList($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'], $field))) {
784 if ($GLOBALS['BE_USER']->jsConfirmation(1)) {
785 $alertMsgOnChange = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
786 } else {
787 $alertMsgOnChange = 'if (TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
788 }
789 } else {
790 $alertMsgOnChange = '';
791 }
792
793 // Render as a hidden field?
794 if (in_array($field, $this->hiddenFieldListArr)) {
795 $this->hiddenFieldAccum[] = '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
796 } else { // Render as a normal field:
797
798 // 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.
799 if (!$PA['palette']) {
800 $paletteFields = $this->loadPaletteElements($table, $row, $PA['pal']);
801 if ($PA['pal'] && $this->isPalettesCollapsed($table, $PA['pal']) && count($paletteFields)) {
802 list($thePalIcon, $palJSfunc) = $this->wrapOpenPalette(t3lib_iconWorks::getSpriteIcon('actions-system-options-view', array('title' => htmlspecialchars($this->getLL('l_moreOptions')))), $table, $row, $PA['pal'], 1);
803 } else {
804 $thePalIcon = '';
805 $palJSfunc = '';
806 }
807 }
808 // onFocus attribute to add to the field:
809 $PA['onFocus'] = (($palJSfunc && !$GLOBALS['BE_USER']->uc['dontShowPalettesOnFocusInAB'])
810 ? ' onfocus="' . htmlspecialchars($palJSfunc) . '"'
811 : '');
812
813 // Find item
814 $item = '';
815 $PA['label'] = ($PA['altName'] ? $PA['altName'] : $PA['fieldConf']['label']);
816 $PA['label'] = ($PA['fieldTSConfig']['label'] ? $PA['fieldTSConfig']['label'] : $PA['label']);
817 $PA['label'] = ($PA['fieldTSConfig']['label.'][$GLOBALS['LANG']->lang] ? $PA['fieldTSConfig']['label.'][$GLOBALS['LANG']->lang] : $PA['label']);
818 $PA['label'] = $this->sL($PA['label']);
819 // JavaScript code for event handlers:
820 $PA['fieldChangeFunc'] = array();
821 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = "TBE_EDITOR.fieldChanged('" . $table . "','" . $row['uid'] . "','" . $field . "','" . $PA['itemFormElName'] . "');";
822 $PA['fieldChangeFunc']['alert'] = $alertMsgOnChange;
823 // If this is the child of an inline type and it is the field creating the label
824 if ($this->inline->isInlineChildAndLabelField($table, $field)) {
825 $inlineObjectId = implode(
826 t3lib_TCEforms_inline::Structure_Separator,
827 array(
828 $this->inline->inlineNames['object'],
829 $table,
830 $row['uid']
831 )
832 );
833 $PA['fieldChangeFunc']['inline'] = "inline.handleChangedField('" . $PA['itemFormElName'] . "','" . $inlineObjectId . "');";
834 }
835
836 // Based on the type of the item, call a render function:
837 $item = $this->getSingleField_SW($table, $field, $row, $PA);
838
839 // Add language + diff
840 if ($PA['fieldConf']['l10n_display'] && (t3lib_div::inList($PA['fieldConf']['l10n_display'], 'hideDiff') || t3lib_div::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly'))) {
841 $renderLanguageDiff = FALSE;
842 } else {
843 $renderLanguageDiff = TRUE;
844 }
845
846 if ($renderLanguageDiff) {
847 $item = $this->renderDefaultLanguageContent($table, $field, $row, $item);
848 $item = $this->renderDefaultLanguageDiff($table, $field, $row, $item);
849 }
850
851 // 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
852 $label = t3lib_div::deHSCentities(htmlspecialchars($PA['label']));
853 if (t3lib_utility_Math::canBeInterpretedAsInteger($row['uid']) && $PA['fieldTSConfig']['linkTitleToSelf'] && !t3lib_div::_GP('columnsOnly')) {
854 $lTTS_url = $this->backPath . 'alt_doc.php?edit[' . $table . '][' . $row['uid'] . ']=edit&columnsOnly=' . $field . '&returnUrl=' . rawurlencode($this->thisReturnUrl());
855 $label = '<a href="' . htmlspecialchars($lTTS_url) . '">' . $label . '</a>';
856 }
857
858 // Wrap the label with help text
859 $PA['label'] = $label = t3lib_BEfunc::wrapInHelp($table, $field, $label);
860
861 // Create output value:
862 if ($PA['fieldConf']['config']['form_type'] == 'user' && $PA['fieldConf']['config']['noTableWrapping']) {
863 $out = $item;
864 } elseif ($PA['palette']) {
865 // Array:
866 $out = array(
867 'NAME' => $label,
868 'ID' => $row['uid'],
869 'FIELD' => $field,
870 'TABLE' => $table,
871 'ITEM' => $item
872 );
873 $out = $this->addUserTemplateMarkers($out, $table, $field, $row, $PA);
874 } else {
875 // String:
876 $out = array(
877 'NAME' => $label,
878 'ITEM' => $item,
879 'TABLE' => $table,
880 'ID' => $row['uid'],
881 'PAL_LINK_ICON' => $thePalIcon,
882 'FIELD' => $field
883 );
884 $out = $this->addUserTemplateMarkers($out, $table, $field, $row, $PA);
885 // String:
886 $out = $this->intoTemplate($out);
887 }
888 }
889 } else {
890 $this->commentMessages[] = $this->prependFormFieldNames . '[' . $table . '][' . $row['uid'] . '][' . $field . ']: Disabled by TSconfig';
891 }
892 }
893 // Hook: getSingleField_postProcess
894 foreach ($this->hookObjectsSingleField as $hookObj) {
895 if (method_exists($hookObj, 'getSingleField_postProcess')) {
896 $hookObj->getSingleField_postProcess($table, $field, $row, $out, $PA, $this);
897 }
898 }
899 // Return value (string or array)
900 return $out;
901 }
902
903 /**
904 * Rendering a single item for the form
905 *
906 * @param string $table Table name of record
907 * @param string $field Fieldname to render
908 * @param array $row The record
909 * @param array $PA Parameters array containing a lot of stuff. Value by Reference!
910 * @return string Returns the item as HTML code to insert
911 * @access private
912 * @see getSingleField(), getSingleField_typeFlex_draw()
913 */
914 function getSingleField_SW($table, $field, $row, &$PA) {
915 $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
916
917 // Hook: getSingleField_beforeRender
918 foreach ($this->hookObjectsSingleField as $hookObject) {
919 if (method_exists($hookObject, 'getSingleField_beforeRender')) {
920 $hookObject->getSingleField_beforeRender($table, $field, $row, $PA);
921 }
922 }
923
924 switch ($PA['fieldConf']['config']['form_type']) {
925 case 'input':
926 $item = $this->getSingleField_typeInput($table, $field, $row, $PA);
927 break;
928 case 'text':
929 $item = $this->getSingleField_typeText($table, $field, $row, $PA);
930 break;
931 case 'check':
932 $item = $this->getSingleField_typeCheck($table, $field, $row, $PA);
933 break;
934 case 'radio':
935 $item = $this->getSingleField_typeRadio($table, $field, $row, $PA);
936 break;
937 case 'select':
938 $item = $this->getSingleField_typeSelect($table, $field, $row, $PA);
939 break;
940 case 'group':
941 $item = $this->getSingleField_typeGroup($table, $field, $row, $PA);
942 break;
943 case 'inline':
944 $item = $this->inline->getSingleField_typeInline($table, $field, $row, $PA);
945 break;
946 case 'none':
947 $item = $this->getSingleField_typeNone($table, $field, $row, $PA);
948 break;
949 case 'user':
950 $item = $this->getSingleField_typeUser($table, $field, $row, $PA);
951 break;
952 case 'flex':
953 $item = $this->getSingleField_typeFlex($table, $field, $row, $PA);
954 break;
955 default:
956 $item = $this->getSingleField_typeUnknown($table, $field, $row, $PA);
957 break;
958 }
959
960 return $item;
961 }
962
963 /**********************************************************
964 *
965 * Rendering of each TCEform field type
966 *
967 ************************************************************/
968
969 /**
970 * Generation of TCEform elements of the type "input"
971 * This will render a single-line input form field, possibly with various control/validation features
972 *
973 * @param string $table The table name of the record
974 * @param string $field The field name which this element is supposed to edit
975 * @param array $row The record data array where the value(s) for the field can be found
976 * @param array $PA An array with additional configuration options.
977 * @return string The HTML code for the TCEform field
978 */
979 function getSingleField_typeInput($table, $field, $row, &$PA) {
980 $config = $PA['fieldConf']['config'];
981
982 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
983 $size = t3lib_utility_Math::forceIntegerInRange($config['size'] ? $config['size'] : 30, 5, $this->maxInputWidth);
984 $evalList = t3lib_div::trimExplode(',', $config['eval'], 1);
985 $classAndStyleAttributes = $this->formWidthAsArray($size);
986
987 $fieldAppendix = '';
988 $item = '';
989 $cssClasses = array($classAndStyleAttributes['class']);
990 $cssStyle = $classAndStyleAttributes['style'];
991
992 if (!isset($config['checkbox'])) {
993 $config['checkbox'] = '0';
994 $checkboxIsset = FALSE;
995 } else {
996 $checkboxIsset = TRUE;
997 }
998
999 if (in_array('date', $evalList) || in_array('datetime', $evalList)) {
1000 if (in_array('datetime', $evalList)) {
1001 $class = 'datetime';
1002 } else {
1003 $class = 'date';
1004 }
1005 $dateRange = '';
1006 if (isset($config['range']['lower'])) {
1007 $dateRange .= ' lower-' . intval($config['range']['lower']);
1008 }
1009 if (isset($config['range']['upper'])) {
1010 $dateRange .= ' upper-' . intval($config['range']['upper']);
1011 }
1012 $inputId = uniqid('tceforms-' . $class . 'field-');
1013 $cssClasses[] = 'tceforms-textfield tceforms-' . $class . 'field' . $dateRange;
1014 $fieldAppendix = t3lib_iconWorks::getSpriteIcon(
1015 'actions-edit-pick-date',
1016 array(
1017 'style' => 'cursor:pointer;',
1018 'id' => 'picker-' . $inputId
1019 )
1020 );
1021 } elseif (in_array('timesec', $evalList)) {
1022 $inputId = uniqid('tceforms-timesecfield-');
1023 $cssClasses[] = 'tceforms-textfield tceforms-timesecfield';
1024 } elseif (in_array('year', $evalList)) {
1025 $inputId = uniqid('tceforms-yearfield-');
1026 $cssClasses[] = 'tceforms-textfield tceforms-yearfield';
1027 } elseif (in_array('time', $evalList)) {
1028 $inputId = uniqid('tceforms-timefield-');
1029 $cssClasses[] = 'tceforms-textfield tceforms-timefield';
1030 } elseif (in_array('int', $evalList)) {
1031 $inputId = uniqid('tceforms-intfield-');
1032 $cssClasses[] = 'tceforms-textfield tceforms-intfield';
1033 } elseif (in_array('double2', $evalList)) {
1034 $inputId = uniqid('tceforms-double2field-');
1035 $cssClasses[] = 'tceforms-textfield tceforms-double2field';
1036 } else {
1037 $inputId = uniqid('tceforms-textfield-');
1038 $cssClasses[] = 'tceforms-textfield';
1039 if ($checkboxIsset === FALSE) {
1040 $config['checkbox'] = '';
1041 }
1042 }
1043 if (isset($config['wizards']['link'])) {
1044 $inputId = uniqid('tceforms-linkfield-');
1045 $cssClasses[] = 'tceforms-textfield tceforms-linkfield';
1046
1047 } elseif (isset($config['wizards']['color'])) {
1048 $inputId = uniqid('tceforms-colorfield-');
1049 $cssClasses[] = 'tceforms-textfield tceforms-colorfield';
1050 }
1051
1052 if ($this->renderReadonly || $config['readOnly']) {
1053 $itemFormElValue = $PA['itemFormElValue'];
1054 if (in_array('date', $evalList)) {
1055 $config['format'] = 'date';
1056 } elseif (in_array('datetime', $evalList)) {
1057 $config['format'] = 'datetime';
1058 } elseif (in_array('time', $evalList)) {
1059 $config['format'] = 'time';
1060 }
1061 if (in_array('password', $evalList)) {
1062 $itemFormElValue = $itemFormElValue ? '*********' : '';
1063 }
1064 return $this->getSingleField_typeNone_render($config, $itemFormElValue);
1065 }
1066
1067 foreach ($evalList as $func) {
1068 switch ($func) {
1069 case 'required':
1070 $this->registerRequiredProperty('field', $table . '_' . $row['uid'] . '_' . $field, $PA['itemFormElName']);
1071 // Mark this field for date/time disposal:
1072 if (array_intersect($evalList, array('date', 'datetime', 'time'))) {
1073 $this->requiredAdditional[$PA['itemFormElName']]['isPositiveNumber'] = TRUE;
1074 }
1075 break;
1076 default:
1077 if (t3lib_div::hasValidClassPrefix($func)) {
1078 // Pair hook to the one in t3lib_TCEmain::checkValue_input_Eval()
1079 $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
1080 if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue')) {
1081 $_params = array(
1082 'value' => $PA['itemFormElValue']
1083 );
1084 $PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
1085 }
1086 }
1087 break;
1088 }
1089 }
1090
1091 $paramsList = "'" . $PA['itemFormElName'] . "','" . implode(',', $evalList) . "','" . trim($config['is_in']) . "'," . (isset($config['checkbox']) ? 1 : 0) . ",'" . $config['checkbox'] . "'";
1092 if ((in_array('date', $evalList) || in_array('datetime', $evalList))) {
1093 $item .= '<span class="t3-tceforms-input-wrapper-datetime" onmouseOver="if (document.getElementById(\'' .
1094 $inputId . '\').value) {this.className=\'t3-tceforms-input-wrapper-datetime-hover\';} else {this.className=\'t3-tceforms-input-wrapper-datetime\';};" onmouseOut="this.className=\'t3-tceforms-input-wrapper-datetime\';">';
1095
1096 // Add server timezone offset to UTC to our stored date
1097 if ($PA['itemFormElValue'] > 0) {
1098 $PA['itemFormElValue'] += date('Z', $PA['itemFormElValue']);
1099 }
1100 } else {
1101 $item .= '<span class="t3-tceforms-input-wrapper" onmouseOver="if (document.getElementById(\'' . $inputId .
1102 '\').value) {this.className=\'t3-tceforms-input-wrapper-hover\';} else {this.className=\'t3-tceforms-input-wrapper\';};" onmouseOut="this.className=\'t3-tceforms-input-wrapper\';">';
1103 }
1104
1105 $PA['fieldChangeFunc'] = array_merge(
1106 array('typo3form.fieldGet' => 'typo3form.fieldGet(' . $paramsList . ');'),
1107 $PA['fieldChangeFunc']
1108 );
1109 // Old function "checkbox" now the option to set the date / remove the date
1110 if (isset($config['checkbox'])) {
1111 $item .= t3lib_iconWorks::getSpriteIcon('actions-input-clear', array('tag' => 'a', 'class' => 't3-tceforms-input-clearer', 'onclick' => 'document.getElementById(\'' . $inputId . '\').value=\'\';document.getElementById(\'' . $inputId . '\').focus();' . implode('', $PA['fieldChangeFunc'])));
1112 }
1113 $mLgd = ($config['max'] ? $config['max'] : 256);
1114 $iOnChange = implode('', $PA['fieldChangeFunc']);
1115
1116 $cssClasses[] = 'hasDefaultValue';
1117 $item .= '<input type="text" ' .
1118 $this->getPlaceholderAttribute($table, $field, $config, $row) .
1119 'id="' . $inputId . '" ' .
1120 'class="' . implode(' ', $cssClasses) . '" ' .
1121 'name="' . $PA['itemFormElName'] . '_hr" ' .
1122 'value=""' .
1123 'style="' . $cssStyle . '" ' .
1124 'maxlength="' . $mLgd . '" ' .
1125 'onchange="' . htmlspecialchars($iOnChange) . '"' .
1126 $PA['onFocus'] .
1127 ' />'; // This is the EDITABLE form field.
1128 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' .
1129 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.
1130 $item .= $fieldAppendix . '</span><div style="clear:both;"></div>';
1131 $this->extJSCODE .= 'typo3form.fieldSet(' . $paramsList . ');';
1132
1133 // Going through all custom evaluations configured for this field
1134 foreach ($evalList as $evalData) {
1135 if (t3lib_div::hasValidClassPrefix($evalData)) {
1136 $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$evalData] . ':&' . $evalData);
1137 if (is_object($evalObj) && method_exists($evalObj, 'returnFieldJS')) {
1138 $this->extJSCODE .= "\n\nfunction " . $evalData . "(value) {\n" . $evalObj->returnFieldJS() . "\n}\n";
1139 }
1140 }
1141 }
1142
1143 // Creating an alternative item without the JavaScript handlers.
1144 $altItem = '<input type="hidden" name="' . $PA['itemFormElName'] . '_hr" value="" />';
1145 $altItem .= '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1146
1147 // Wrap a wizard around the item?
1148 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'] . '_hr', $specConf);
1149
1150 return $item;
1151 }
1152
1153 /**
1154 * Generation of TCEform elements of the type "text"
1155 * This will render a <textarea> OR RTE area form field, possibly with various control/validation features
1156 *
1157 * @param string $table The table name of the record
1158 * @param string $field The field name which this element is supposed to edit
1159 * @param array $row The record data array where the value(s) for the field can be found
1160 * @param array $PA An array with additional configuration options.
1161 * @return string The HTML code for the TCEform field
1162 */
1163 function getSingleField_typeText($table, $field, $row, &$PA) {
1164
1165 // Init config:
1166 $config = $PA['fieldConf']['config'];
1167 $evalList = t3lib_div::trimExplode(',', $config['eval'], 1);
1168
1169 if ($this->renderReadonly || $config['readOnly']) {
1170 return $this->getSingleField_typeNone_render($config, $PA['itemFormElValue']);
1171 }
1172
1173 // Setting columns number:
1174 $cols = t3lib_utility_Math::forceIntegerInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
1175
1176 // Setting number of rows:
1177 $origRows = $rows = t3lib_utility_Math::forceIntegerInRange($config['rows'] ? $config['rows'] : 5, 1, 20);
1178 if (strlen($PA['itemFormElValue']) > $this->charsPerRow * 2) {
1179 $cols = $this->maxTextareaWidth;
1180 $rows = t3lib_utility_Math::forceIntegerInRange(round(strlen($PA['itemFormElValue']) / $this->charsPerRow), count(explode(LF, $PA['itemFormElValue'])), 20);
1181 if ($rows < $origRows) {
1182 $rows = $origRows;
1183 }
1184 }
1185
1186 if (in_array('required', $evalList)) {
1187 $this->requiredFields[$table . '_' . $row['uid'] . '_' . $field] = $PA['itemFormElName'];
1188 }
1189
1190 // Init RTE vars:
1191 // Set TRUE, if the RTE is loaded; If not a normal textarea is shown.
1192 $RTEwasLoaded = 0;
1193 // Set TRUE, if the RTE would have been loaded if it wasn't for the disable-RTE flag in the bottom of the page...
1194 $RTEwouldHaveBeenLoaded = 0;
1195
1196 // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. Traditionally, this is where RTE configuration has been found.
1197 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1198
1199 // Setting up the altItem form field, which is a hidden field containing the value
1200 $altItem = '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1201
1202 // If RTE is generally enabled (TYPO3_CONF_VARS and user settings)
1203 if ($this->RTEenabled) {
1204 $p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
1205 // If the field is configured for RTE and if any flag-field is not set to disable it.
1206 if (isset($specConf['richtext']) && (!$p['flag'] || !$row[$p['flag']])) {
1207 t3lib_BEfunc::fixVersioningPid($table, $row);
1208 list($tscPID, $thePidValue) = $this->getTSCpid($table, $row['uid'], $row['pid']);
1209
1210 // If the pid-value is not negative (that is, a pid could NOT be fetched)
1211 if ($thePidValue >= 0) {
1212 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($tscPID));
1213 $RTEtypeVal = t3lib_BEfunc::getTCAtypeValue($table, $row);
1214 $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'], $table, $field, $RTEtypeVal);
1215
1216 if (!$thisConfig['disabled']) {
1217 if (!$this->disableRTE) {
1218 $this->RTEcounter++;
1219
1220 // Find alternative relative path for RTE images/links:
1221 $eFile = t3lib_parsehtml_proc::evalWriteFile($specConf['static_write'], $row);
1222 $RTErelPath = is_array($eFile) ? dirname($eFile['relEditFile']) : '';
1223
1224 // Get RTE object, draw form and set flag:
1225 $RTEobj = t3lib_BEfunc::RTEgetObj();
1226 $item = $RTEobj->drawRTE($this, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue);
1227
1228 // Wizard:
1229 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf, 1);
1230
1231 $RTEwasLoaded = 1;
1232 } else {
1233 $RTEwouldHaveBeenLoaded = 1;
1234 $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!)';
1235 }
1236 } else {
1237 $this->commentMessages[] = $PA['itemFormElName'] . ': RTE is disabled by the Page TSconfig, "RTE"-key (eg. by RTE.default.disabled=0 or such)';
1238 }
1239 } else {
1240 $this->commentMessages[] = $PA['itemFormElName'] . ': PID value could NOT be fetched. Rare error, normally with new records.';
1241 }
1242 } else {
1243 if (!isset($specConf['richtext'])) {
1244 $this->commentMessages[] = $PA['itemFormElName'] . ': RTE was not configured for this field in TCA-types';
1245 }
1246 if (!(!$p['flag'] || !$row[$p['flag']])) {
1247 $this->commentMessages[] = $PA['itemFormElName'] . ': Field-flag (' . $PA['flag'] . ') has been set to disable RTE!';
1248 }
1249 }
1250 }
1251
1252 // Display ordinary field if RTE was not loaded.
1253 if (!$RTEwasLoaded) {
1254 // Show message, if no RTE (field can only be edited with RTE!)
1255 if ($specConf['rte_only']) {
1256 $item = '<p><em>' . htmlspecialchars($this->getLL('l_noRTEfound')) . '</em></p>';
1257 } else {
1258 if ($specConf['nowrap']) {
1259 $wrap = 'off';
1260 } else {
1261 $wrap = ($config['wrap'] ? $config['wrap'] : 'virtual');
1262 }
1263
1264 $classes = array();
1265 if ($specConf['fixed-font']) {
1266 $classes[] = 'fixed-font';
1267 }
1268 if ($specConf['enable-tab']) {
1269 $classes[] = 'enable-tab';
1270 }
1271
1272 $formWidthText = $this->formWidthText($cols, $wrap);
1273
1274 // Extract class attributes from $formWidthText (otherwise it would be added twice to the output)
1275 $res = array();
1276 if (preg_match('/ class="(.+?)"/', $formWidthText, $res)) {
1277 $formWidthText = str_replace(' class="' . $res[1] . '"', '', $formWidthText);
1278 $classes = array_merge($classes, explode(' ', $res[1]));
1279 }
1280
1281 if (count($classes)) {
1282 $class = ' class="tceforms-textarea ' . implode(' ', $classes) . '"';
1283 } else {
1284 $class = 'tceforms-textarea';
1285 }
1286
1287 $evalList = t3lib_div::trimExplode(',', $config['eval'], 1);
1288 foreach ($evalList as $func) {
1289 switch ($func) {
1290 case 'required':
1291 $this->registerRequiredProperty('field', $table . '_' . $row['uid'] . '_' . $field, $PA['itemFormElName']);
1292 break;
1293 default:
1294 if (t3lib_div::hasValidClassPrefix($func)) {
1295 // Pair hook to the one in t3lib_TCEmain::checkValue_input_Eval() and t3lib_TCEmain::checkValue_text_Eval()
1296 $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
1297 if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue')) {
1298 $_params = array(
1299 'value' => $PA['itemFormElValue']
1300 );
1301 $PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
1302 }
1303 }
1304 break;
1305 }
1306 }
1307
1308 $iOnChange = implode('', $PA['fieldChangeFunc']);
1309 $item .= '
1310 <textarea ' .
1311 'id="' . uniqid('tceforms-textarea-') . '" ' .
1312 'name="' . $PA['itemFormElName'] . '"' .
1313 $formWidthText .
1314 $class . ' ' .
1315 'rows="' . $rows . '" ' .
1316 'wrap="' . $wrap . '" ' .
1317 'onchange="' . htmlspecialchars($iOnChange) . '"' .
1318 $this->getPlaceholderAttribute($table, $field, $config, $row) .
1319 $PA['onFocus'] . '>' .
1320 t3lib_div::formatForTextarea($PA['itemFormElValue']) .
1321 '</textarea>';
1322 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf, $RTEwouldHaveBeenLoaded);
1323 }
1324 }
1325
1326 // Return field HTML:
1327 return $item;
1328 }
1329
1330 /**
1331 * Generation of TCEform elements of the type "check"
1332 * This will render a check-box OR an array of checkboxes
1333 *
1334 * @param string $table The table name of the record
1335 * @param string $field The field name which this element is supposed to edit
1336 * @param array $row The record data array where the value(s) for the field can be found
1337 * @param array $PA An array with additional configuration options.
1338 * @return string The HTML code for the TCEform field
1339 */
1340 function getSingleField_typeCheck($table, $field, $row, &$PA) {
1341 $config = $PA['fieldConf']['config'];
1342
1343 $item = '';
1344 $disabled = '';
1345 if ($this->renderReadonly || $config['readOnly']) {
1346 $disabled = ' disabled="disabled"';
1347 }
1348
1349 // Traversing the array of items:
1350 $selItems = $this->initItemArray($PA['fieldConf']);
1351 if ($config['itemsProcFunc']) {
1352 $selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
1353 }
1354
1355 if (!count($selItems)) {
1356 $selItems[] = array('', '');
1357 }
1358 $thisValue = intval($PA['itemFormElValue']);
1359
1360 $cols = intval($config['cols']);
1361 if ($cols > 1) {
1362 $item .= '<table border="0" cellspacing="0" cellpadding="0" class="typo3-TCEforms-checkboxArray">';
1363 for ($c = 0; $c < count($selItems); $c++) {
1364 $p = $selItems[$c];
1365 if (!($c % $cols)) {
1366 $item .= '<tr>';
1367 }
1368 $cBP = $this->checkBoxParams($PA['itemFormElName'], $thisValue, $c, count($selItems), implode('', $PA['fieldChangeFunc']));
1369 $cBName = $PA['itemFormElName'] . '_' . $c;
1370 $cBID = $PA['itemFormElID'] . '_' . $c;
1371 $item .= '<td nowrap="nowrap">' .
1372 '<input type="checkbox"' . $this->insertDefStyle('check') . ' value="1" name="' . $cBName . '"' . $cBP . $disabled . ' id="' . $cBID . '" />' .
1373 $this->wrapLabels('<label for="' . $cBID . '">' . htmlspecialchars($p[0]) . '</label>&nbsp;') .
1374 '</td>';
1375 if (($c % $cols) + 1 == $cols) {
1376 $item .= '</tr>';
1377 }
1378 }
1379 if ($c % $cols) {
1380 $rest = $cols - ($c % $cols);
1381 for ($c = 0; $c < $rest; $c++) {
1382 $item .= '<td></td>';
1383 }
1384 if ($c > 0) {
1385 $item .= '</tr>';
1386 }
1387 }
1388 $item .= '</table>';
1389 } else {
1390 for ($c = 0; $c < count($selItems); $c++) {
1391 $p = $selItems[$c];
1392 $cBP = $this->checkBoxParams($PA['itemFormElName'], $thisValue, $c, count($selItems), implode('', $PA['fieldChangeFunc']));
1393 $cBName = $PA['itemFormElName'] . '_' . $c;
1394 $cBID = $PA['itemFormElID'] . '_' . $c;
1395 $item .= ($c > 0 ? '<br />' : '') .
1396 '<input type="checkbox"' . $this->insertDefStyle('check') . ' value="1" name="' . $cBName . '"' . $cBP . $PA['onFocus'] . $disabled . ' id="' . $cBID . '" />' .
1397 $this->wrapLabels('<label for="' . $cBID . '">' . htmlspecialchars($p[0]) . '</label>');
1398 }
1399 }
1400 if (!$disabled) {
1401 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($thisValue) . '" />';
1402 }
1403
1404 return $item;
1405 }
1406
1407 /**
1408 * Generation of TCEform elements of the type "radio"
1409 * This will render a series of radio buttons.
1410 *
1411 * @param string $table The table name of the record
1412 * @param string $field The field name which this element is supposed to edit
1413 * @param array $row The record data array where the value(s) for the field can be found
1414 * @param array $PA An array with additional configuration options.
1415 * @return string The HTML code for the TCEform field
1416 */
1417 function getSingleField_typeRadio($table, $field, $row, &$PA) {
1418 $config = $PA['fieldConf']['config'];
1419
1420 $item = '';
1421 $disabled = '';
1422 if ($this->renderReadonly || $config['readOnly']) {
1423 $disabled = ' disabled="disabled"';
1424 }
1425
1426 // Get items for the array:
1427 $selItems = $this->initItemArray($PA['fieldConf']);
1428 if ($config['itemsProcFunc']) {
1429 $selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
1430 }
1431
1432 // Traverse the items, making the form elements:
1433 for ($c = 0; $c < count($selItems); $c++) {
1434 $p = $selItems[$c];
1435 $rID = $PA['itemFormElID'] . '_' . $c;
1436 $rOnClick = implode('', $PA['fieldChangeFunc']);
1437 $rChecked = (!strcmp($p[1], $PA['itemFormElValue']) ? ' checked="checked"' : '');
1438 $item .= '<input type="radio"' . $this->insertDefStyle('radio') . ' name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($p[1]) . '" onclick="' . htmlspecialchars($rOnClick) . '"' . $rChecked . $PA['onFocus'] . $disabled . ' id="' . $rID . '" />
1439 <label for="' . $rID . '">' . htmlspecialchars($p[0]) . '</label>
1440 <br />';
1441 }
1442
1443 return $item;
1444 }
1445
1446 /**
1447 * Generation of TCEform elements of the type "select"
1448 * This will render a selector box element, or possibly a special construction with two selector boxes. That depends on configuration.
1449 *
1450 * @param string $table The table name of the record
1451 * @param string $field The field name which this element is supposed to edit
1452 * @param array $row The record data array where the value(s) for the field can be found
1453 * @param array $PA An array with additional configuration options.
1454 * @return string The HTML code for the TCEform field
1455 */
1456 function getSingleField_typeSelect($table, $field, $row, &$PA) {
1457
1458 // Field configuration from TCA:
1459 $config = $PA['fieldConf']['config'];
1460
1461 $disabled = '';
1462 if ($this->renderReadonly || $config['readOnly']) {
1463 $disabled = ' disabled="disabled"';
1464 }
1465
1466 // "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/.
1467 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1468
1469 // Getting the selector box items from the system
1470 $selItems = $this->addSelectOptionsToItemArray(
1471 $this->initItemArray($PA['fieldConf']),
1472 $PA['fieldConf'],
1473 $this->setTSconfig($table, $row),
1474 $field
1475 );
1476 // Possibly filter some items:
1477 $keepItemsFunc = create_function('$value', 'return $value[1];');
1478 $selItems = t3lib_div::keepItemsInArray($selItems, $PA['fieldTSConfig']['keepItems'], $keepItemsFunc);
1479 // Possibly add some items:
1480 $selItems = $this->addItems($selItems, $PA['fieldTSConfig']['addItems.']);
1481 // Process items by a user function:
1482 if (isset($config['itemsProcFunc']) && $config['itemsProcFunc']) {
1483 $selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
1484 }
1485
1486 // Possibly remove some items:
1487 $removeItems = t3lib_div::trimExplode(',', $PA['fieldTSConfig']['removeItems'], 1);
1488 foreach ($selItems as $tk => $p) {
1489
1490 // Checking languages and authMode:
1491 $languageDeny = $GLOBALS['TCA'][$table]['ctrl']['languageField']
1492 && !strcmp($GLOBALS['TCA'][$table]['ctrl']['languageField'], $field)
1493 && !$GLOBALS['BE_USER']->checkLanguageAccess($p[1]);
1494 $authModeDeny = $config['form_type'] == 'select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table, $field, $p[1], $config['authMode']);
1495 if (in_array($p[1], $removeItems) || $languageDeny || $authModeDeny) {
1496 unset($selItems[$tk]);
1497 } elseif (isset($PA['fieldTSConfig']['altLabels.'][$p[1]])) {
1498 $selItems[$tk][0] = $this->sL($PA['fieldTSConfig']['altLabels.'][$p[1]]);
1499 }
1500
1501 // Removing doktypes with no access:
1502 if (($table === 'pages' || $table === 'pages_language_overlay') && $field === 'doktype') {
1503 if (!($GLOBALS['BE_USER']->isAdmin() || t3lib_div::inList($GLOBALS['BE_USER']->groupData['pagetypes_select'], $p[1]))) {
1504 unset($selItems[$tk]);
1505 }
1506 }
1507 }
1508
1509 // Creating the label for the "No Matching Value" entry.
1510 $nMV_label = isset($PA['fieldTSConfig']['noMatchingValue_label']) ? $this->sL($PA['fieldTSConfig']['noMatchingValue_label']) : '[ ' . $this->getLL('l_noMatchingValue') . ' ]';
1511
1512 // Prepare some values:
1513 $maxitems = intval($config['maxitems']);
1514
1515 // If a SINGLE selector box...
1516 if ($maxitems <= 1 && $config['renderMode'] !== 'tree') {
1517 $item = $this->getSingleField_typeSelect_single($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1518 } elseif (!strcmp($config['renderMode'], 'checkbox')) { // Checkbox renderMode
1519 $item = $this->getSingleField_typeSelect_checkbox($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1520 } elseif (!strcmp($config['renderMode'], 'singlebox')) { // Single selector box renderMode
1521 $item = $this->getSingleField_typeSelect_singlebox($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1522 } elseif (!strcmp($config['renderMode'], 'tree')) { // Tree renderMode
1523 $treeClass = t3lib_div::makeInstance('t3lib_TCEforms_Tree', $this);
1524 $item = $treeClass->renderField($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1525
1526 // Register the required number of elements
1527 $minitems = t3lib_utility_Math::forceIntegerInRange($config['minitems'], 0);
1528 $this->registerRequiredProperty('range', $PA['itemFormElName'], array($minitems, $maxitems, 'imgName' => $table . '_' . $row['uid'] . '_' . $field));
1529 } else { // Traditional multiple selector box:
1530 $item = $this->getSingleField_typeSelect_multiple($table, $field, $row, $PA, $config, $selItems, $nMV_label);
1531 }
1532
1533 // Wizards:
1534 if (!$disabled) {
1535 $altItem = '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
1536 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf);
1537 }
1538
1539 return $item;
1540 }
1541
1542 /**
1543 * Creates a single-selector box
1544 * (Render function for getSingleField_typeSelect())
1545 *
1546 * @param string $table See getSingleField_typeSelect()
1547 * @param string $field See getSingleField_typeSelect()
1548 * @param array $row See getSingleField_typeSelect()
1549 * @param array $PA See getSingleField_typeSelect()
1550 * @param array $config (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1551 * @param array $selItems Items available for selection
1552 * @param string $nMV_label Label for no-matching-value
1553 * @return string The HTML code for the item
1554 * @see getSingleField_typeSelect()
1555 */
1556 function getSingleField_typeSelect_single($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
1557 // check against inline uniqueness
1558 $inlineParent = $this->inline->getStructureLevel(-1);
1559 if (is_array($inlineParent) && $inlineParent['uid']) {
1560 if ($inlineParent['config']['foreign_table'] == $table && $inlineParent['config']['foreign_unique'] == $field) {
1561 $uniqueIds = $this->inline->inlineData['unique'][$this->inline->inlineNames['object'] . t3lib_TCEforms_inline::Structure_Separator . $table]['used'];
1562 $PA['fieldChangeFunc']['inlineUnique'] = "inline.updateUnique(this,'" . $this->inline->inlineNames['object'] . t3lib_TCEforms_inline::Structure_Separator . $table . "','" . $this->inline->inlineNames['form'] . "','" . $row['uid'] . "');";
1563 }
1564 // hide uid of parent record for symmetric relations
1565 if ($inlineParent['config']['foreign_table'] == $table && ($inlineParent['config']['foreign_field'] == $field || $inlineParent['config']['symmetric_field'] == $field)) {
1566 $uniqueIds[] = $inlineParent['uid'];
1567 }
1568 }
1569
1570 // Initialization:
1571 $c = 0;
1572 $sI = 0;
1573 $noMatchingValue = 1;
1574 $opt = array();
1575 $selicons = array();
1576 $onlySelectedIconShown = 0;
1577 $size = intval($config['size']);
1578 // Style set on <select/>
1579 $selectedStyle = '';
1580
1581 $item = '';
1582 $disabled = '';
1583 // TODO: icon is used but never assigned
1584 $onChangeIcon = '';
1585
1586 if ($this->renderReadonly || $config['readOnly']) {
1587 $disabled = ' disabled="disabled"';
1588 $onlySelectedIconShown = 1;
1589 }
1590
1591 // Icon configuration:
1592 if ($config['suppress_icons'] == 'IF_VALUE_FALSE') {
1593 $suppressIcons = !$PA['itemFormElValue'] ? 1 : 0;
1594 } elseif ($config['suppress_icons'] == 'ONLY_SELECTED') {
1595 $suppressIcons = 0;
1596 $onlySelectedIconShown = 1;
1597 } elseif ($config['suppress_icons']) {
1598 $suppressIcons = 1;
1599 } else {
1600 $suppressIcons = 0;
1601 }
1602
1603 // Traverse the Array of selector box items:
1604 $optGroupStart = array();
1605 $optGroupOpen = FALSE;
1606 $classesForSelectTag = array();
1607 foreach ($selItems as $p) {
1608 $sM = (!strcmp($PA['itemFormElValue'], $p[1]) ? ' selected="selected"' : '');
1609 if ($sM) {
1610 $sI = $c;
1611 $noMatchingValue = 0;
1612 }
1613
1614 // Getting style attribute value (for icons):
1615 if ($config['iconsInOptionTags']) {
1616 $styleAttrValue = $this->optionTagStyle($p[2]);
1617 if ($sM) {
1618 list($selectIconFile, $selectIconInfo) = $this->getIcon($p[2]);
1619 if (!empty($selectIconInfo)) {
1620 $selectedStyle = ' style="background-image:url(' . $selectIconFile . ');"';
1621 $classesForSelectTag[] = 'typo3-TCEforms-select-selectedItemWithBackgroundImage';
1622 }
1623 }
1624 }
1625
1626 // Compiling the <option> tag:
1627 if (!($p[1] != $PA['itemFormElValue'] && is_array($uniqueIds) && in_array($p[1], $uniqueIds))) {
1628 if (!strcmp($p[1], '--div--')) {
1629 $optGroupStart[0] = $p[0];
1630 if ($config['iconsInOptionTags']) {
1631 $optGroupStart[1] = $this->optgroupTagStyle($p[2]);
1632 } else {
1633 $optGroupStart[1] = $styleAttrValue;
1634 }
1635
1636 } else {
1637 if (count($optGroupStart)) {
1638 // Closing last optgroup before next one starts
1639 if ($optGroupOpen) {
1640 $opt[] = '</optgroup>' . LF;
1641 }
1642 $opt[] = '<optgroup label="' . t3lib_div::deHSCentities(htmlspecialchars($optGroupStart[0])) . '"' .
1643 ($optGroupStart[1] ? ' style="' . htmlspecialchars($optGroupStart[1]) . '"' : '') .
1644 ' class="c-divider">' . LF;
1645 $optGroupOpen = TRUE;
1646 $c--;
1647 $optGroupStart = array();
1648 }
1649 $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' .
1650 $sM .
1651 ($styleAttrValue ? ' style="' . htmlspecialchars($styleAttrValue) . '"' : '') .
1652 '>' . t3lib_div::deHSCentities(($p[0])) . '</option>' . LF;
1653 }
1654 }
1655
1656 // If there is an icon for the selector box (rendered in selicon-table below)...:
1657 // if there is an icon ($p[2]), icons should be shown, and, if only selected are visible, is it selected
1658 if ($p[2] && !$suppressIcons && (!$onlySelectedIconShown || $sM)) {
1659 list($selIconFile, $selIconInfo) = $this->getIcon($p[2]);
1660 if (!empty($selIconInfo)) {
1661 $iOnClick = $this->elName($PA['itemFormElName']) . '.selectedIndex=' . $c . '; ' .
1662 $this->elName($PA['itemFormElName']) . '.style.backgroundImage=' . $this->elName($PA['itemFormElName']) . '.options[' . $c . '].style.backgroundImage; ' .
1663 implode('', $PA['fieldChangeFunc']) . $this->blur() . 'return false;';
1664 } else {
1665 $iOnClick = $this->elName($PA['itemFormElName']) . '.selectedIndex=' . $c . '; ' .
1666 $this->elName($PA['itemFormElName']) . '.className=' . $this->elName($PA['itemFormElName']) . '.options[' . $c . '].className; ' .
1667 implode('', $PA['fieldChangeFunc']) . $this->blur() . 'return false;';
1668 }
1669 $selicons[] = array(
1670 (!$onlySelectedIconShown ? '<a href="#" onclick="' . htmlspecialchars($iOnClick) . '">' : '') .
1671 $this->getIconHtml($p[2], htmlspecialchars($p[0]), htmlspecialchars($p[0])) .
1672 (!$onlySelectedIconShown ? '</a>' : ''),
1673 $c, $sM);
1674 }
1675 $c++;
1676 }
1677
1678 // Closing optgroup if open
1679 if ($optGroupOpen) {
1680 $opt[] = '</optgroup>';
1681 $optGroupOpen = FALSE;
1682 }
1683
1684 // No-matching-value:
1685 if ($PA['itemFormElValue'] && $noMatchingValue && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1686 $nMV_label = @sprintf($nMV_label, $PA['itemFormElValue']);
1687 $opt[] = '<option value="' . htmlspecialchars($PA['itemFormElValue']) . '" selected="selected">' . htmlspecialchars($nMV_label) . '</option>';
1688 }
1689
1690 // Create item form fields:
1691 $sOnChange = 'if (this.options[this.selectedIndex].value==\'--div--\') {this.selectedIndex=' . $sI . ';} ' . implode('', $PA['fieldChangeFunc']);
1692 if (!$disabled) {
1693 // MUST be inserted before the selector - else is the value of the hiddenfield here mysteriously submitted...
1694 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '_selIconVal" value="' . htmlspecialchars($sI) . '" />';
1695 }
1696 if ($config['iconsInOptionTags']) {
1697 $classesForSelectTag[] = 'icon-select';
1698 }
1699 $item .= '<select' . $selectedStyle . ' id="' . uniqid('tceforms-select-') . '" name="' . $PA['itemFormElName'] . '"' .
1700 $this->insertDefStyle('select', implode(' ', $classesForSelectTag)) .
1701 ($size ? ' size="' . $size . '"' : '') .
1702 ' onchange="' . htmlspecialchars($onChangeIcon . $sOnChange) . '"' .
1703 $PA['onFocus'] . $disabled . '>';
1704 $item .= implode('', $opt);
1705 $item .= '</select>';
1706
1707 // Create icon table:
1708 if (count($selicons) && !$config['noIconsBelowSelect']) {
1709 $item .= '<table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-selectIcons">';
1710 $selicon_cols = intval($config['selicon_cols']);
1711 if (!$selicon_cols) {
1712 $selicon_cols = count($selicons);
1713 }
1714 $sR = ceil(count($selicons) / $selicon_cols);
1715 $selicons = array_pad($selicons, $sR * $selicon_cols, '');
1716 for ($sa = 0; $sa < $sR; $sa++) {
1717 $item .= '<tr>';
1718 for ($sb = 0; $sb < $selicon_cols; $sb++) {
1719 $sk = ($sa * $selicon_cols + $sb);
1720 $imgN = 'selIcon_' . $table . '_' . $row['uid'] . '_' . $field . '_' . $selicons[$sk][1];
1721 $imgS = ($selicons[$sk][2] ? $this->backPath . 'gfx/content_selected.gif' : 'clear.gif');
1722 $item .= '<td><img name="' . htmlspecialchars($imgN) . '" src="' . $imgS . '" width="7" height="10" alt="" /></td>';
1723 $item .= '<td>' . $selicons[$sk][0] . '</td>';
1724 }
1725 $item .= '</tr>';
1726 }
1727 $item .= '</table>';
1728 }
1729
1730 return $item;
1731 }
1732
1733 /**
1734 * Creates a checkbox list (renderMode = "checkbox")
1735 * (Render function for getSingleField_typeSelect())
1736 *
1737 * @param string $table See getSingleField_typeSelect()
1738 * @param string $field See getSingleField_typeSelect()
1739 * @param array $row See getSingleField_typeSelect()
1740 * @param array $PA See getSingleField_typeSelect()
1741 * @param array $config (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1742 * @param array $selItems Items available for selection
1743 * @param string $nMV_label Label for no-matching-value
1744 * @return string The HTML code for the item
1745 * @see getSingleField_typeSelect()
1746 */
1747 function getSingleField_typeSelect_checkbox($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
1748
1749 if (empty($selItems)) {
1750 return '';
1751 }
1752
1753 // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
1754 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
1755
1756 $item = '';
1757 $disabled = '';
1758 if ($this->renderReadonly || $config['readOnly']) {
1759 $disabled = ' disabled="disabled"';
1760 }
1761
1762 // Traverse the Array of selector box items:
1763 $tRows = array();
1764 $c = 0;
1765 if (!$disabled) {
1766 $sOnChange = implode('', $PA['fieldChangeFunc']);
1767 // Used to accumulate the JS needed to restore the original selection.
1768 $setAll = array();
1769 $unSetAll = array();
1770 foreach ($selItems as $p) {
1771 // Non-selectable element:
1772 if (!strcmp($p[1], '--div--')) {
1773 $selIcon = '';
1774 if (isset($p[2]) && $p[2] != 'empty-emtpy') {
1775 $selIcon = $this->getIconHtml($p[2]);
1776 }
1777 $tRows[] = '
1778 <tr class="c-header">
1779 <td colspan="3">' . $selIcon . htmlspecialchars($p[0]) . '</td>
1780 </tr>';
1781 } else {
1782 // Selected or not by default:
1783 $sM = '';
1784 if (isset($itemArray[$p[1]])) {
1785 $sM = ' checked="checked"';
1786 unset($itemArray[$p[1]]);
1787 }
1788
1789 // Icon:
1790 if ($p[2]) {
1791 $selIcon = $p[2];
1792 } else {
1793 $selIcon = t3lib_iconWorks::getSpriteIcon('empty-empty');
1794 }
1795
1796 // Compile row:
1797 $rowId = uniqid('select_checkbox_row_');
1798 $onClickCell = $this->elName($PA['itemFormElName'] . '[' . $c . ']') . '.checked=!' . $this->elName($PA['itemFormElName'] . '[' . $c . ']') . '.checked;';
1799 $onClick = 'this.attributes.getNamedItem("class").nodeValue = ' . $this->elName($PA['itemFormElName'] . '[' . $c . ']') . '.checked ? "c-selectedItem" : "c-unselectedItem";';
1800 $setAll[] = $this->elName($PA['itemFormElName'] . '[' . $c . ']') . '.checked=1;';
1801 $setAll[] .= '$(\'' . $rowId . '\').removeClassName(\'c-unselectedItem\');$(\'' . $rowId . '\').addClassName(\'c-selectedItem\');';
1802 $unSetAll[] = $this->elName($PA['itemFormElName'] . '[' . $c . ']') . '.checked=0;';
1803 $unSetAll[] .= '$(\'' . $rowId . '\').removeClassName(\'c-selectedItem\');$(\'' . $rowId . '\').addClassName(\'c-unselectedItem\');';
1804 $restoreCmd[] = $this->elName($PA['itemFormElName'] . '[' . $c . ']') . '.checked=' . ($sM ? 1 : 0) . ';' .
1805 '$(\'' . $rowId . '\').removeClassName(\'c-selectedItem\');$(\'' . $rowId . '\').removeClassName(\'c-unselectedItem\');' .
1806 '$(\'' . $rowId . '\').addClassName(\'c-' . ($sM ? '' : 'un') . 'selectedItem\');';
1807
1808 // Check if some help text is available
1809 // Since TYPO3 4.5 help text is expected to be an associative array
1810 // with two key, "title" and "description"
1811 // For the sake of backwards compatibility, we test if the help text
1812 // is a string and use it as a description (this could happen if items
1813 // are modified with an itemProcFunc)
1814 $hasHelp = FALSE;
1815 $help = '';
1816 $helpArray = array();
1817 if ((is_array($p[3]) && count($p[3]) > 0) || !empty($p[3])) {
1818 $hasHelp = TRUE;
1819 if (is_array($p[3])) {
1820 $helpArray = $p[3];
1821 } else {
1822 $helpArray['description'] = $p[3];
1823 }
1824 }
1825
1826 $label = t3lib_div::deHSCentities(htmlspecialchars($p[0]));
1827 if ($hasHelp) {
1828 $help = t3lib_BEfunc::wrapInHelp('', '', '', $helpArray);
1829 }
1830
1831 $tRows[] = '
1832 <tr id="' . $rowId . '" class="' . ($sM ? 'c-selectedItem' : 'c-unselectedItem') . '" onclick="' . htmlspecialchars($onClick) . '" style="cursor: pointer;">
1833 <td class="c-checkbox"><input type="checkbox"' . $this->insertDefStyle('check') . ' name="' . htmlspecialchars($PA['itemFormElName'] . '[' . $c . ']') . '" value="' . htmlspecialchars($p[1]) . '"' . $sM . ' onclick="' . htmlspecialchars($sOnChange) . '"' . $PA['onFocus'] . ' /></td>
1834 <td class="c-labelCell" onclick="' . htmlspecialchars($onClickCell) . '">' .
1835 $this->getIconHtml($selIcon) .
1836 $label .
1837 '</td>
1838 <td class="c-descr" onclick="' . htmlspecialchars($onClickCell) . '">' . ((empty($help)) ? '' : $help) . '</td>
1839 </tr>';
1840 $c++;
1841 }
1842 }
1843 }
1844
1845 // Remaining values (invalid):
1846 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1847 foreach ($itemArray as $theNoMatchValue => $temp) {
1848 // Compile <checkboxes> tag:
1849 array_unshift($tRows, '
1850 <tr class="c-invalidItem">
1851 <td class="c-checkbox"><input type="checkbox"' . $this->insertDefStyle('check') . ' name="' . htmlspecialchars($PA['itemFormElName'] . '[' . $c . ']') . '" value="' . htmlspecialchars($theNoMatchValue) . '" checked="checked" onclick="' . htmlspecialchars($sOnChange) . '"' . $PA['onFocus'] . $disabled . ' /></td>
1852 <td class="c-labelCell">' .
1853 t3lib_div::deHSCentities(htmlspecialchars(@sprintf($nMV_label, $theNoMatchValue))) .
1854 '</td><td>&nbsp;</td>
1855 </tr>');
1856 $c++;
1857 }
1858 }
1859
1860 // Add an empty hidden field which will send a blank value if all items are unselected.
1861 $item .= '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="" />';
1862
1863 // Remaining checkboxes will get their set-all link:
1864 if (count($setAll)) {
1865 $tableHead = '<thead>
1866 <tr class="c-header-checkbox-controls t3-row-header">
1867 <td class="c-checkbox">
1868 <input type="checkbox" class="checkbox" onclick="if (checked) {' . htmlspecialchars(implode('', $setAll) . '} else {' . implode('', $unSetAll) . '}') . '">
1869 </td>
1870 <td colspan="2">
1871 </td>
1872 </tr></thead>';
1873 }
1874 // Implode rows in table:
1875 $item .= '
1876 <table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-select-checkbox">' .
1877 $tableHead .
1878 '<tbody>' . implode('', $tRows) . '</tbody>
1879 </table>
1880 ';
1881
1882 // Add revert icon
1883 if (is_array($restoreCmd)) {
1884 $item .= '<a href="#" onclick="' . implode('', $restoreCmd) . ' return false;' . '">' .
1885 t3lib_iconWorks::getSpriteIcon('actions-edit-undo', array('title' => htmlspecialchars($this->getLL('l_revertSelection')))) . '</a>';
1886 }
1887
1888 return $item;
1889 }
1890
1891 /**
1892 * Creates a selectorbox list (renderMode = "singlebox")
1893 * (Render function for getSingleField_typeSelect())
1894 *
1895 * @param string $table See getSingleField_typeSelect()
1896 * @param string $field See getSingleField_typeSelect()
1897 * @param array $row See getSingleField_typeSelect()
1898 * @param array $PA See getSingleField_typeSelect()
1899 * @param array $config (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1900 * @param array $selItems Items available for selection
1901 * @param string $nMV_label Label for no-matching-value
1902 * @return string The HTML code for the item
1903 * @see getSingleField_typeSelect()
1904 */
1905 function getSingleField_typeSelect_singlebox($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
1906
1907 // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
1908 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
1909
1910 $item = '';
1911 $disabled = '';
1912 if ($this->renderReadonly || $config['readOnly']) {
1913 $disabled = ' disabled="disabled"';
1914 }
1915
1916 // Traverse the Array of selector box items:
1917 $opt = array();
1918 // Used to accumulate the JS needed to restore the original selection.
1919 $restoreCmd = array();
1920 $c = 0;
1921 foreach ($selItems as $p) {
1922 // Selected or not by default:
1923 $sM = '';
1924 if (isset($itemArray[$p[1]])) {
1925 $sM = ' selected="selected"';
1926 $restoreCmd[] = $this->elName($PA['itemFormElName'] . '[]') . '.options[' . $c . '].selected=1;';
1927 unset($itemArray[$p[1]]);
1928 }
1929
1930 // Non-selectable element:
1931 $nonSel = '';
1932 if (!strcmp($p[1], '--div--')) {
1933 $nonSel = ' onclick="this.selected=0;" class="c-divider"';
1934 }
1935
1936 // Icon style for option tag:
1937 if ($config['iconsInOptionTags']) {
1938 $styleAttrValue = $this->optionTagStyle($p[2]);
1939 }
1940
1941 // Compile <option> tag:
1942 $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' .
1943 $sM .
1944 $nonSel .
1945 ($styleAttrValue ? ' style="' . htmlspecialchars($styleAttrValue) . '"' : '') .
1946 '>' . t3lib_div::deHSCentities(htmlspecialchars($p[0])) . '</option>';
1947 $c++;
1948 }
1949
1950 // Remaining values:
1951 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
1952 foreach ($itemArray as $theNoMatchValue => $temp) {
1953 // Compile <option> tag:
1954 array_unshift($opt, '<option value="' . htmlspecialchars($theNoMatchValue) . '" selected="selected">' . t3lib_div::deHSCentities(htmlspecialchars(@sprintf($nMV_label, $theNoMatchValue))) . '</option>');
1955 }
1956 }
1957
1958 // Compile selector box:
1959 $sOnChange = implode('', $PA['fieldChangeFunc']);
1960 $selector_itemListStyle = isset($config['itemListStyle']) ? ' style="' . htmlspecialchars($config['itemListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle . '"';
1961 $size = intval($config['size']);
1962 $cssPrefix = ($size === 1) ? 'tceforms-select' : 'tceforms-multiselect';
1963 $size = $config['autoSizeMax'] ? t3lib_utility_Math::forceIntegerInRange(count($selItems) + 1, t3lib_utility_Math::forceIntegerInRange($size, 1), $config['autoSizeMax']) : $size;
1964 $selectBox = '<select id="' . uniqid($cssPrefix) . '" name="' . $PA['itemFormElName'] . '[]"' .
1965 $this->insertDefStyle('select', $cssPrefix) .
1966 ($size ? ' size="' . $size . '"' : '') .
1967 ' multiple="multiple" onchange="' . htmlspecialchars($sOnChange) . '"' .
1968 $PA['onFocus'] .
1969 $selector_itemListStyle .
1970 $disabled . '>
1971 ' .
1972 implode('
1973 ', $opt) . '
1974 </select>';
1975
1976 // Add an empty hidden field which will send a blank value if all items are unselected.
1977 if (!$disabled) {
1978 $item .= '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="" />';
1979 }
1980
1981 // Put it all into a table:
1982 $item .= '
1983 <table border="0" cellspacing="0" cellpadding="0" width="1" class="typo3-TCEforms-select-singlebox">
1984 <tr>
1985 <td>
1986 ' . $selectBox . '
1987 <br/>
1988 <em>' .
1989 htmlspecialchars($this->getLL('l_holdDownCTRL')) .
1990 '</em>
1991 </td>
1992 <td valign="top">
1993 <a href="#" onclick="' . htmlspecialchars($this->elName($PA['itemFormElName'] . '[]') . '.selectedIndex=-1;' . implode('', $restoreCmd) . ' return false;') . '" title="' . htmlspecialchars($this->getLL('l_revertSelection')) . '">' .
1994 t3lib_iconWorks::getSpriteIcon('actions-edit-undo') .
1995 '</a>
1996 </td>
1997 </tr>
1998 </table>
1999 ';
2000
2001 return $item;
2002 }
2003
2004 /**
2005 * Creates a multiple-selector box (two boxes, side-by-side)
2006 * (Render function for getSingleField_typeSelect())
2007 *
2008 * @param string $table See getSingleField_typeSelect()
2009 * @param string $field See getSingleField_typeSelect()
2010 * @param array $row See getSingleField_typeSelect()
2011 * @param array $PA See getSingleField_typeSelect()
2012 * @param array $config (Redundant) content of $PA['fieldConf']['config'] (for convenience)
2013 * @param array $selItems Items available for selection
2014 * @param string $nMV_label Label for no-matching-value
2015 * @return string The HTML code for the item
2016 * @see getSingleField_typeSelect()
2017 */
2018 function getSingleField_typeSelect_multiple($table, $field, $row, &$PA, $config, $selItems, $nMV_label) {
2019
2020 $item = '';
2021 $disabled = '';
2022 if ($this->renderReadonly || $config['readOnly']) {
2023 $disabled = ' disabled="disabled"';
2024 }
2025
2026 // Setting this hidden field (as a flag that JavaScript can read out)
2027 if (!$disabled) {
2028 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '_mul" value="' . ($config['multiple'] ? 1 : 0) . '" />';
2029 }
2030
2031 // Set max and min items:
2032 $maxitems = t3lib_utility_Math::forceIntegerInRange($config['maxitems'], 0);
2033 if (!$maxitems) {
2034 $maxitems = 100000;
2035 }
2036 $minitems = t3lib_utility_Math::forceIntegerInRange($config['minitems'], 0);
2037
2038 // Register the required number of elements:
2039 $this->registerRequiredProperty('range', $PA['itemFormElName'], array($minitems, $maxitems, 'imgName' => $table . '_' . $row['uid'] . '_' . $field));
2040
2041 // Get "removeItems":
2042 $removeItems = t3lib_div::trimExplode(',', $PA['fieldTSConfig']['removeItems'], 1);
2043
2044 // Get the array with selected items:
2045 $itemArray = t3lib_div::trimExplode(',', $PA['itemFormElValue'], 1);
2046
2047 // Possibly filter some items:
2048 $keepItemsFunc = create_function('$value', '$parts=explode(\'|\',$value,2); return rawurldecode($parts[0]);');
2049 $itemArray = t3lib_div::keepItemsInArray($itemArray, $PA['fieldTSConfig']['keepItems'], $keepItemsFunc);
2050
2051 // Perform modification of the selected items array:
2052 foreach ($itemArray as $tk => $tv) {
2053 $tvP = explode('|', $tv, 2);
2054 $evalValue = $tvP[0];
2055 $isRemoved = in_array($evalValue, $removeItems) || ($config['form_type'] == 'select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table, $field, $evalValue, $config['authMode']));
2056 if ($isRemoved && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
2057 $tvP[1] = rawurlencode(@sprintf($nMV_label, $evalValue));
2058 } elseif (isset($PA['fieldTSConfig']['altLabels.'][$evalValue])) {
2059 $tvP[1] = rawurlencode($this->sL($PA['fieldTSConfig']['altLabels.'][$evalValue]));
2060 }
2061 if ($tvP[1] == '') {
2062 // Case: flexform, default values supplied, no label provided (bug #9795)
2063 foreach ($selItems as $selItem) {
2064 if ($selItem[1] == $tvP[0]) {
2065 $tvP[1] = html_entity_decode($selItem[0]);
2066 break;
2067 }
2068 }
2069 }
2070 $itemArray[$tk] = implode('|', $tvP);
2071 }
2072 $itemsToSelect = '';
2073
2074 if (!$disabled) {
2075 // Create option tags:
2076 $opt = array();
2077 $styleAttrValue = '';
2078 foreach ($selItems as $p) {
2079 if ($config['iconsInOptionTags']) {
2080 $styleAttrValue = $this->optionTagStyle($p[2]);
2081 }
2082 $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' .
2083 ($styleAttrValue ? ' style="' . htmlspecialchars($styleAttrValue) . '"' : '') .
2084 ' title="' . $p[0] . '">' . $p[0] . '</option>';
2085 }
2086
2087 // Put together the selector box:
2088 $selector_itemListStyle = isset($config['itemListStyle']) ? ' style="' . htmlspecialchars($config['itemListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle . '"';
2089 $size = intval($config['size']);
2090 $size = $config['autoSizeMax'] ? t3lib_utility_Math::forceIntegerInRange(count($itemArray) + 1, t3lib_utility_Math::forceIntegerInRange($size, 1), $config['autoSizeMax']) : $size;
2091 if ($config['exclusiveKeys']) {
2092 $sOnChange = 'setFormValueFromBrowseWin(\'' . $PA['itemFormElName']
2093 . '\',this.options[this.selectedIndex].value, this.options[this.selectedIndex].text, this.options[this.selectedIndex].title,\''
2094 . $config['exclusiveKeys'] . '\'); ';
2095 } else {
2096 $sOnChange = 'setFormValueFromBrowseWin(\'' . $PA['itemFormElName']
2097 . '\',this.options[this.selectedIndex].value, this.options[this.selectedIndex].text, this.options[this.selectedIndex].title); ';
2098 }
2099 $sOnChange .= implode('', $PA['fieldChangeFunc']);
2100 $itemsToSelect = '
2101 <select id="' . uniqid('tceforms-multiselect-') . '" name="' . $PA['itemFormElName'] . '_sel"' .
2102 $this->insertDefStyle('select', 'tceforms-multiselect tceforms-itemstoselect') .
2103 ($size ? ' size="' . $size . '"' : '') .
2104 ' onchange="' . htmlspecialchars($sOnChange) . '"' .
2105 $PA['onFocus'] .
2106 $selector_itemListStyle . '>
2107 ' . implode('
2108 ', $opt) . '
2109 </select>';
2110 }
2111
2112 // Pass to "dbFileIcons" function:
2113 $params = array(
2114 'size' => $size,
2115 'autoSizeMax' => t3lib_utility_Math::forceIntegerInRange($config['autoSizeMax'], 0),
2116 'style' => isset($config['selectedListStyle']) ? ' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle . '"',
2117 'dontShowMoveIcons' => ($maxitems <= 1),
2118 'maxitems' => $maxitems,
2119 'info' => '',
2120 'headers' => array(
2121 'selector' => $this->getLL('l_selected') . ':<br />',
2122 'items' => $this->getLL('l_items') . ':<br />'
2123 ),
2124 'noBrowser' => 1,
2125 'thumbnails' => $itemsToSelect,
2126 'readOnly' => $disabled
2127 );
2128 $item .= $this->dbFileIcons($PA['itemFormElName'], '', '', $itemArray, '', $params, $PA['onFocus']);
2129
2130 return $item;
2131 }
2132
2133 /**
2134 * Generation of TCEform elements of the type "group"
2135 * This will render a selectorbox into which elements from either the file system or database can be inserted. Relations.
2136 *
2137 * @param string $table The table name of the record
2138 * @param string $field The field name which this element is supposed to edit
2139 * @param array $row The record data array where the value(s) for the field can be found
2140 * @param array $PA An array with additional configuration options.
2141 * @return string The HTML code for the TCEform field
2142 */
2143 function getSingleField_typeGroup($table, $field, $row, &$PA) {
2144 // Init:
2145 $config = $PA['fieldConf']['config'];
2146 $internal_type = $config['internal_type'];
2147 $show_thumbs = $config['show_thumbs'];
2148 $size = intval($config['size']);
2149 $maxitems = t3lib_utility_Math::forceIntegerInRange($config['maxitems'], 0);
2150 if (!$maxitems) {
2151 $maxitems = 100000;
2152 }
2153 $minitems = t3lib_utility_Math::forceIntegerInRange($config['minitems'], 0);
2154 $allowed = trim($config['allowed']);
2155 $disallowed = trim($config['disallowed']);
2156
2157 $item = '';
2158 $disabled = '';
2159 if ($this->renderReadonly || $config['readOnly']) {
2160 $disabled = ' disabled="disabled"';
2161 }
2162
2163 $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '_mul" value="' . ($config['multiple'] ? 1 : 0) . '"' . $disabled . ' />';
2164 $this->registerRequiredProperty('range', $PA['itemFormElName'], array($minitems, $maxitems, 'imgName' => $table . '_' . $row['uid'] . '_' . $field));
2165 $info = '';
2166
2167 // "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/.
2168 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
2169
2170 $PA['itemFormElID_file'] = $PA['itemFormElID'] . '_files';
2171
2172 // whether the list and delete controls should be disabled
2173 $noList = isset($config['disable_controls']) && t3lib_div::inList($config['disable_controls'], 'list');
2174 $noDelete = isset($config['disable_controls']) && t3lib_div::inList($config['disable_controls'], 'delete');
2175
2176 // if maxitems==1 then automatically replace the current item (in list and file selector)
2177 if ($maxitems === 1) {
2178 $this->additionalJS_post[] = "TBE_EDITOR.clearBeforeSettingFormValueFromBrowseWin['" . $PA['itemFormElName'] . "'] = {
2179 itemFormElID_file: '" . $PA['itemFormElID_file'] . "'
2180 }";
2181 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = "setFormValueManipulate('" . $PA['itemFormElName'] . "', 'Remove'); " . $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'];
2182 } elseif ($noList) {
2183 // If the list controls have been removed and the maximum number is reached, remove the first entry to avoid "write once" field
2184 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = "setFormValueManipulate('" . $PA['itemFormElName'] . "', 'RemoveFirstIfFull', '" . $maxitems . "'); " . $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'];
2185 }
2186
2187 // Acting according to either "file" or "db" type:
2188 switch ((string) $config['internal_type']) {
2189 case 'file_reference':
2190 $config['uploadfolder'] = '';
2191 // Fall through
2192 // If the element is of the internal type "file":
2193 case 'file':
2194 // Creating string showing allowed types:
2195 $tempFT = t3lib_div::trimExplode(',', $allowed, TRUE);
2196 if (!count($tempFT)) {
2197 $info .= '*';
2198 }
2199 foreach ($tempFT as $ext) {
2200 if ($ext) {
2201 $info .= strtoupper($ext) . ' ';
2202 }
2203 }
2204 // Creating string, showing disallowed types:
2205 $tempFT_dis = t3lib_div::trimExplode(',', $disallowed, TRUE);
2206 if (count($tempFT_dis)) {
2207 $info .= '<br />';
2208 }
2209 foreach ($tempFT_dis as $ext) {
2210 if ($ext) {
2211 $info .= '-' . strtoupper($ext) . ' ';
2212 }
2213 }
2214
2215 // Making the array of file items:
2216 $itemArray = t3lib_div::trimExplode(',', $PA['itemFormElValue'], TRUE);
2217
2218 $fileFactory = t3lib_file_Factory::getInstance();
2219
2220 // Correct the filename for the FAL items
2221 foreach ($itemArray as &$fileItem) {
2222 list($fileUid, $fileLabel) = explode('|', $fileItem);
2223 if (t3lib_utility_Math::canBeInterpretedAsInteger($fileUid)) {
2224 $fileObject = $fileFactory->getFileObject($fileUid);
2225 $fileLabel = $fileObject->getName();
2226 }
2227
2228 $fileItem = $fileUid . '|' . $fileLabel;
2229 }
2230
2231 // Showing thumbnails:
2232 $thumbsnail = '';
2233 if ($show_thumbs) {
2234 $imgs = array();
2235 foreach ($itemArray as $imgRead) {
2236 $imgP = explode('|', $imgRead);
2237 $imgPath = rawurldecode($imgP[0]);
2238
2239 // FAL icon production
2240 if (t3lib_utility_Math::canBeInterpretedAsInteger($imgP[0])) {
2241 $fileObject = $fileFactory->getFileObject($imgP[0]);
2242
2243 if (t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileObject->getExtension())) {
2244 $imageUrl = $fileObject->process(t3lib_file_ProcessedFile::CONTEXT_IMAGEPREVIEW, array())->getPublicUrl(TRUE);
2245 $imgTag = '<img src="' . $imageUrl . '" alt="' . htmlspecialchars($fileObject->getName()) . '" />';
2246 } else {
2247 // Icon
2248 $imgTag = t3lib_iconWorks::getSpriteIconForFile(
2249 strtolower($fileObject->getExtension()),
2250 array('title' => $fileObject->getName())
2251 );
2252 }
2253
2254 $imgs[] = '<span class="nobr">' . $imgTag . htmlspecialchars($fileObject->getName()) . '</span>';
2255 } else {
2256 $rowCopy = array();
2257 $rowCopy[$field] = $imgPath;
2258
2259 $thumbnailCode = t3lib_BEfunc::thumbCode(
2260 $rowCopy,
2261 $table,
2262 $field,
2263 $this->backPath,
2264 'thumbs.php',
2265 $config['uploadfolder'],
2266 0,
2267 ' align="middle"'
2268 );
2269 $imgs[] = '<span class="nobr">' . $thumbnailCode . $imgPath . '</span>';
2270 }
2271
2272 }
2273 $thumbsnail = implode('<br />', $imgs);
2274 }
2275
2276 // Creating the element:
2277 $params = array(
2278 'size' => $size,
2279 'dontShowMoveIcons' => ($maxitems <= 1),
2280 'autoSizeMax' => t3lib_utility_Math::forceIntegerInRange($config['autoSizeMax'], 0),
2281 'maxitems' => $maxitems,
2282 'style' => isset($config['selectedListStyle']) ? ' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle . '"',
2283 'info' => $info,
2284 'thumbnails' => $thumbsnail,
2285 'readOnly' => $disabled,
2286 'noBrowser' => $noList || (isset($config['disable_controls']) && t3lib_div::inList($config['disable_controls'], 'browser')),
2287 'noList' => $noList,
2288 'noDelete' => $noDelete,
2289 );
2290 $item .= $this->dbFileIcons($PA['itemFormElName'], 'file', implode(',', $tempFT), $itemArray, '', $params, $PA['onFocus'], '', '', '', $config);
2291
2292 if (!$disabled && !(isset($config['disable_controls']) && t3lib_div::inList($config['disable_controls'], 'upload'))) {
2293 // Adding the upload field:
2294 if ($this->edit_docModuleUpload && $config['uploadfolder']) {
2295
2296 // Insert the multiple attribute to enable HTML5 multiple file upload
2297 $multipleAttribute = '';
2298 $multipleFilenameSuffix = '';
2299 if (isset($config['maxitems']) && $config['maxitems'] > 1) {
2300 $multipleAttribute = ' multiple="multiple"';
2301 $multipleFilenameSuffix = '[]';
2302 }
2303
2304 $item .= '<div id="' . $PA['itemFormElID_file'] . '"><input type="file"'. $multipleAttribute .' name="' . $PA['itemFormElName_file'] . $multipleFilenameSuffix . '" size="35" onchange="' . implode('', $PA['fieldChangeFunc']) . '" /></div>';
2305
2306 }
2307 }
2308 break;
2309 case 'folder': // If the element is of the internal type "folder":
2310
2311 // Array of folder items:
2312 $itemArray = t3lib_div::trimExplode(',', $PA['itemFormElValue'], 1);
2313
2314 // Creating the element:
2315 $params = array(
2316 'size' => $size,
2317 'dontShowMoveIcons' => ($maxitems <= 1),
2318 'autoSizeMax' => t3lib_utility_Math::forceIntegerInRange($config['autoSizeMax'], 0),
2319 'maxitems' => $maxitems,
2320 'style' => isset($config['selectedListStyle']) ?
2321 ' style="' . htmlspecialchars($config['selectedListStyle']) . '"'
2322 : ' style="' . $this->defaultMultipleSelectorStyle . '"',
2323 'info' => $info,
2324 'readOnly' => $disabled,
2325 'noBrowser' => $noList || (isset($config['disable_controls']) && t3lib_div::inList($config['disable_controls'], 'browser')),
2326 'noList' => $noList,
2327 );
2328
2329 $item .= $this->dbFileIcons(
2330 $PA['itemFormElName'],
2331 'folder',
2332 '',
2333 $itemArray,
2334 '',
2335 $params,
2336 $PA['onFocus']
2337 );
2338 break;
2339 case 'db': // If the element is of the internal type "db":
2340
2341 // Creating string showing allowed types:
2342 $tempFT = t3lib_div::trimExplode(',', $allowed, TRUE);
2343 if (!strcmp(trim($tempFT[0]), '*')) {
2344 $onlySingleTableAllowed = FALSE;
2345 $info .= '<span class="nobr">' .
2346 htmlspecialchars($this->getLL('l_allTables')) .
2347 '</span><br />';
2348 } elseif ($tempFT) {
2349 $onlySingleTableAllowed = (count($tempFT) == 1);
2350 foreach ($tempFT as $theT) {
2351 $info .= '<span class="nobr">' .
2352 t3lib_iconWorks::getSpriteIconForRecord($theT, array()) .
2353 htmlspecialchars($this->sL($GLOBALS['TCA'][$theT]['ctrl']['title'])) .
2354 '</span><br />';
2355 }
2356 }
2357
2358 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
2359 $itemArray = array();
2360 $imgs = array();
2361
2362 // Thumbnails:
2363 $temp_itemArray = t3lib_div::trimExplode(',', $PA['itemFormElValue'], 1);
2364 foreach ($temp_itemArray as $dbRead) {
2365 $recordParts = explode('|', $dbRead);
2366 list($this_table, $this_uid) = t3lib_BEfunc::splitTable_Uid($recordParts[0]);
2367 // For the case that no table was found and only a single table is defined to be allowed, use that one:
2368 if (!$this_table && $onlySingleTableAllowed) {
2369 $this_table = $allowed;
2370 }
2371 $itemArray[] = array('table' => $this_table, 'id' => $this_uid);
2372 if (!$disabled && $show_thumbs) {
2373 $rr = t3lib_BEfunc::getRecordWSOL($this_table, $this_uid);
2374 $imgs[] = '<span class="nobr">' .
2375 $this->getClickMenu(
2376 t3lib_iconWorks::getSpriteIconForRecord(
2377 $this_table,
2378 $rr,
2379 array(
2380 'style' => 'vertical-align:top',
2381 'title' => htmlspecialchars(t3lib_BEfunc::getRecordPath($rr['pid'], $perms_clause, 15) . ' [UID: ' . $rr['uid'] . ']')
2382 )
2383 ),
2384 $this_table,
2385 $this_uid
2386 ) .
2387 '&nbsp;' .
2388 t3lib_BEfunc::getRecordTitle($this_table, $rr, TRUE) . ' <span class="typo3-dimmed"><em>[' . $rr['uid'] . ']</em></span>' .
2389 '</span>';
2390 }
2391 }
2392 $thumbsnail = '';
2393 if (!$disabled && $show_thumbs) {
2394 $thumbsnail = implode('<br />', $imgs);
2395 }
2396
2397 // Creating the element:
2398 $params = array(
2399 'size' => $size,
2400 'dontShowMoveIcons' => ($maxitems <= 1),
2401 'autoSizeMax' => t3lib_utility_Math::forceIntegerInRange($config['autoSizeMax'], 0),
2402 'maxitems' => $maxitems,
2403 'style' => isset($config['selectedListStyle']) ? ' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle . '"',
2404 'info' => $info,
2405 'thumbnails' => $thumbsnail,
2406 'readOnly' => $disabled,
2407 'noBrowser' => $noList || (isset($config['disable_controls']) && t3lib_div::inList($config['disable_controls'], 'browser')),
2408 'noList' => $noList,
2409 );
2410 $item .= $this->dbFileIcons($PA['itemFormElName'], 'db', implode(',', $tempFT), $itemArray, '', $params, $PA['onFocus'], $table, $field, $row['uid'], $config);
2411
2412 break;
2413 }
2414
2415 // Wizards:
2416 $altItem = '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
2417 if (!$disabled) {
2418 $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf);
2419 }
2420
2421 return $item;
2422 }
2423
2424 /**
2425 * Generation of TCEform elements of the type "none"
2426 * This will render a non-editable display of the content of the field.
2427 *
2428 * @param string $table The table name of the record
2429 * @param string $field The field name which this element is supposed to edit
2430 * @param array $row The record data array where the value(s) for the field can be found
2431 * @param array $PA An array with additional configuration options.
2432 * @return string The HTML code for the TCEform field
2433 */
2434 function getSingleField_typeNone($table, $field, $row, &$PA) {
2435 // Init:
2436 $config = $PA['fieldConf']['config'];
2437 $itemValue = $PA['itemFormElValue'];
2438
2439 return $this->getSingleField_typeNone_render($config, $itemValue);
2440 }
2441
2442 /**
2443 * HTML rendering of a value which is not editable.
2444 *
2445 * @param array $config Configuration for the display
2446 * @param string $itemValue The value to display
2447 * @return string The HTML code for the display
2448 * @see getSingleField_typeNone();
2449 */
2450 function getSingleField_typeNone_render($config, $itemValue) {
2451
2452 // Is colorScheme[0] the right value?
2453 $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;';
2454
2455 if ($config['format']) {
2456 $itemValue = $this->formatValue($config, $itemValue);
2457 }
2458
2459 $rows = intval($config['rows']);
2460 if ($rows > 1) {
2461 if (!$config['pass_content']) {
2462 $itemValue = nl2br(htmlspecialchars($itemValue));
2463 }
2464 // Like textarea
2465 $cols = t3lib_utility_Math::forceIntegerInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
2466 if (!$config['fixedRows']) {
2467 $origRows = $rows = t3lib_utility_Math::forceIntegerInRange($rows, 1, 20);
2468 if (strlen($itemValue) > $this->charsPerRow * 2) {
2469 $cols = $this->maxTextareaWidth;
2470 $rows = t3lib_utility_Math::forceIntegerInRange(round(strlen($itemValue) / $this->charsPerRow), count(explode(LF, $itemValue)), 20);
2471 if ($rows < $origRows) {
2472 $rows = $origRows;
2473 }
2474 }
2475 }
2476
2477 if ($this->docLarge) {
2478 $cols = round($cols * $this->form_largeComp);
2479 }
2480 $width = ceil($cols * $this->form_rowsToStylewidth);
2481 // Hardcoded: 12 is the height of the font
2482 $height = $rows * 12;
2483
2484 $item = '
2485 <div style="' . htmlspecialchars($divStyle . ' overflow:auto; height:' . $height . 'px; width:' . $width . 'px;') . '" class="' . htmlspecialchars($this->formElClass('none')) . '">' .
2486 $itemValue .
2487 '</div>';
2488 } else {
2489 if (!$config['pass_content']) {
2490 $itemValue = htmlspecialchars($itemValue);
2491 }
2492
2493 $cols = $config['cols'] ? $config['cols'] : ($config['size'] ? $config['size'] : $this->maxInputWidth);
2494 if ($this->docLarge) {
2495 $cols = round($cols * $this->form_largeComp);
2496 }
2497 $width = ceil($cols * $this->form_rowsToStylewidth);
2498
2499 // Overflow:auto crashes mozilla here. Title tag is usefull when text is longer than the div box (overflow:hidden).
2500 $item = '
2501 <div style="' . htmlspecialchars($divStyle . ' overflow:hidden; width:' . $width . 'px;') . '" class="' . htmlspecialchars($this->formElClass('none')) . '" title="' . $itemValue . '">' .
2502 '<span class="nobr">' . (strcmp($itemValue, '') ? $itemValue : '&nbsp;') . '</span>' .
2503 '</div>';
2504 }
2505
2506 return $item;
2507 }
2508
2509 /**
2510 * Handler for Flex Forms
2511 *
2512 * @param string $table The table name of the record
2513 * @param string $field The field name which this element is supposed to edit
2514 * @param array $row The record data array where the value(s) for the field can be found
2515 * @param array $PA An array with additional configuration options.
2516 * @return string The HTML code for the TCEform field
2517 */
2518 function getSingleField_typeFlex($table, $field, $row, &$PA) {
2519
2520 // Data Structure:
2521 $dataStructArray = t3lib_BEfunc::getFlexFormDS($PA['fieldConf']['config'], $row, $table);
2522 $item = '';
2523
2524 // Manipulate Flexform DS via TSConfig and group access lists
2525 if (is_array($dataStructArray)) {
2526 $flexFormHelper = t3lib_div::makeInstance('t3lib_TCEforms_Flexforms');
2527 $dataStructArray = $flexFormHelper->modifyFlexFormDS($dataStructArray, $table, $field, $row, $PA['fieldConf']);
2528 unset($flexFormHelper);
2529 }
2530
2531 // Get data structure:
2532 if (is_array($dataStructArray)) {
2533
2534 // Get data:
2535 $xmlData = $PA['itemFormElValue'];
2536 $xmlHeaderAttributes = t3lib_div::xmlGetHeaderAttribs($xmlData);
2537 $storeInCharset = strtolower($xmlHeaderAttributes['encoding']);
2538 if ($storeInCharset) {
2539 $currentCharset = $GLOBALS['LANG']->charSet;
2540 $xmlData = $GLOBALS['LANG']->csConvObj->conv($xmlData, $storeInCharset, $currentCharset, 1);
2541 }
2542 $editData = t3lib_div::xml2array($xmlData);
2543 // Must be XML parsing error...
2544 if (!is_array($editData)) {
2545 $editData = array();
2546 } elseif (!isset($editData['meta']) || !is_array($editData['meta'])) {
2547 $editData['meta'] = array();
2548 }
2549
2550 // Find the data structure if sheets are found:
2551 $sheet = $editData['meta']['currentSheetId'] ? $editData['meta']['currentSheetId'] : 'sDEF'; // Sheet to display
2552
2553 // Create language menu:
2554 $langChildren = $dataStructArray['meta']['langChildren'] ? 1 : 0;
2555 $langDisabled = $dataStructArray['meta']['langDisable'] ? 1 : 0;
2556
2557 $editData['meta']['currentLangId'] = array();
2558
2559 // Look up page overlays:
2560 $checkPageLanguageOverlay = $GLOBALS['BE_USER']->getTSConfigVal('options.checkPageLanguageOverlay') ? TRUE : FALSE;
2561 if ($checkPageLanguageOverlay) {
2562 $pageOverlays = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
2563 '*',
2564 'pages_language_overlay',
2565 'pid=' . intval($row['pid']) .
2566 t3lib_BEfunc::deleteClause('pages_language_overlay') .
2567 t3lib_BEfunc::versioningPlaceholderClause('pages_language_overlay'),
2568 '',
2569 '',
2570 '',
2571 'sys_language_uid'
2572 );
2573 }
2574 $languages = $this->getAvailableLanguages();
2575
2576 foreach ($languages as $lInfo) {
2577 if ($GLOBALS['BE_USER']->checkLanguageAccess($lInfo['uid']) && (!$checkPageLanguageOverlay || $lInfo['uid'] <= 0 || is_array($pageOverlays[$lInfo['uid']]))) {
2578 $editData['meta']['currentLangId'][] = $lInfo['ISOcode'];
2579 }
2580 }
2581 if (!is_array($editData['meta']['currentLangId']) || !count($editData['meta']['currentLangId'])) {
2582 $editData['meta']['currentLangId'] = array('DEF');
2583 }
2584
2585 $editData['meta']['currentLangId'] = array_unique($editData['meta']['currentLangId']);
2586
2587 $PA['_noEditDEF'] = FALSE;
2588 if ($langChildren || $langDisabled) {
2589 $rotateLang = array('DEF');
2590 } else {
2591 if (!in_array('DEF', $editData['meta']['currentLangId'])) {
2592 array_unshift($editData['meta']['currentLangId'], 'DEF');
2593 $PA['_noEditDEF'] = TRUE;
2594 }
2595 $rotateLang = $editData['meta']['currentLangId'];
2596 }
2597
2598 // Tabs sheets
2599 if (is_array($dataStructArray['sheets'])) {
2600 $tabsToTraverse = array_keys($dataStructArray['sheets']);
2601 } else {
2602 $tabsToTraverse = array($sheet);
2603 }
2604
2605 foreach ($rotateLang as $lKey) {
2606 if (!$langChildren && !$langDisabled) {
2607 $item .= '<strong>' . $this->getLanguageIcon($table, $row, 'v' . $lKey) . $lKey . ':</strong>';
2608 }
2609 // Default language, other options are "lUK" or whatever country code (independant of system!!!)
2610 $lang = 'l' . $lKey;
2611
2612 $tabParts = array();
2613 foreach ($tabsToTraverse as $sheet) {
2614 list ($dataStruct, $sheet) = t3lib_div::resolveSheetDefInDS($dataStructArray, $sheet);
2615
2616 // If sheet has displayCond
2617 if ($dataStruct['ROOT']['TCEforms']['displayCond']) {
2618 $splittedCondition = t3lib_div::trimExplode(':', $dataStruct['ROOT']['TCEforms']['displayCond']);
2619 $skipCondition = FALSE;
2620 $fakeRow = array();
2621 switch ($splittedCondition[0]) {
2622 case 'FIELD':
2623 list($sheetName, $fieldName) = t3lib_div::trimExplode('.', $splittedCondition[1]);
2624 $fieldValue = $editData['data'][$sheetName][$lang][$fieldName];
2625 $splittedCondition[1] = $fieldName;
2626 $dataStruct['ROOT']['TCEforms']['displayCond'] = join(':', $splittedCondition);
2627 $fakeRow = array($fieldName => $fieldValue);
2628 break;
2629 case 'HIDE_FOR_NON_ADMINS':
2630 case 'VERSION':
2631 case 'HIDE_L10N_SIBLINGS':
2632 case 'EXT':
2633 break;
2634 case 'REC':
2635 $fakeRow = array('uid' => $row['uid']);
2636 break;
2637 default:
2638 $skipCondition = TRUE;
2639 break;
2640 }
2641
2642 // If sheets displayCond leads to false
2643 if (!$skipCondition && !$this->isDisplayCondition($dataStruct['ROOT']['TCEforms']['displayCond'], $fakeRow, 'vDEF')) {
2644 // Don't create this sheet
2645 continue;
2646 }
2647 }
2648
2649 // Render sheet:
2650 if (is_array($dataStruct['ROOT']) && is_array($dataStruct['ROOT']['el'])) {
2651 // Default language, other options are "lUK" or whatever country code (independant of system!!!)
2652 $PA['_valLang'] = $langChildren && !$langDisabled ? $editData['meta']['currentLangId'] : 'DEF';
2653 $PA['_lang'] = $lang;
2654 // Assemble key for loading the correct CSH file
2655 $dsPointerFields = t3lib_div::trimExplode(',', $GLOBALS['TCA'][$table]['columns'][$field]['config']['ds_pointerField'], TRUE);
2656 $PA['_cshKey'] = $table . '.' . $field;
2657 foreach ($dsPointerFields as $key) {
2658 $PA['_cshKey'] .= '.' . $row[$key];
2659 }
2660
2661 // Push the sheet level tab to DynNestedStack
2662 if (is_array($dataStructArray['sheets'])) {
2663 $tabIdentString = $GLOBALS['TBE_TEMPLATE']->getDynTabMenuId('TCEFORMS:flexform:' . $PA['itemFormElName'] . $PA['_lang']);
2664 $this->pushToDynNestedStack('tab', $tabIdentString . '-' . (count($tabParts) + 1));
2665 }
2666 // Render flexform:
2667 $tRows = $this->getSingleField_typeFlex_draw(
2668 $dataStruct['ROOT']['el'],
2669 $editData['data'][$sheet][$lang],
2670 $table,
2671 $field,
2672 $row,
2673 $PA,
2674 '[data][' . $sheet . '][' . $lang . ']'
2675 );
2676 $sheetContent = '<div class="typo3-TCEforms-flexForm">' . $tRows . '</div>';
2677
2678 // Pop the sheet level tab from DynNestedStack
2679 if (is_array($dataStructArray['sheets'])) {
2680 $this->popFromDynNestedStack('tab', $tabIdentString . '-' . (count($tabParts) + 1));
2681