[ Index ]
 

Code source de Typo3 4.1.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/t3lib/ -> class.t3lib_tceforms.php (source)

   1  <?php
   2  /***************************************************************
   3  *  Copyright notice
   4  *
   5  *  (c) 1999-2006 Kasper Skaarhoj (kasperYYYY@typo3.com)
   6  *  All rights reserved
   7  *
   8  *  This script is part of the TYPO3 project. The TYPO3 project is
   9  *  free software; you can redistribute it and/or modify
  10  *  it under the terms of the GNU General Public License as published by
  11  *  the Free Software Foundation; either version 2 of the License, or
  12  *  (at your option) any later version.
  13  *
  14  *  The GNU General Public License can be found at
  15  *  http://www.gnu.org/copyleft/gpl.html.
  16  *  A copy is found in the textfile GPL.txt and important notices to the license
  17  *  from the author is found in LICENSE.txt distributed with these scripts.
  18  *
  19  *
  20  *  This script is distributed in the hope that it will be useful,
  21  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  22  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  23  *  GNU General Public License for more details.
  24  *
  25  *  This copyright notice MUST APPEAR in all copies of the script!
  26  ***************************************************************/
  27  /**
  28   * Contains TYPO3 Core Form generator - AKA "TCEforms"
  29   *
  30   * $Id: class.t3lib_tceforms.php 2607 2007-10-22 19:33:53Z ingmars $
  31   * Revised for TYPO3 3.6 August/2003 by Kasper Skaarhoj
  32   * XHTML compliant
  33   *
  34   * @author    Kasper Skaarhoj <kasperYYYY@typo3.com>
  35   */
  36  /**
  37   * [CLASS/FUNCTION INDEX of SCRIPT]
  38   *
  39   *
  40   *
  41   *  196: class t3lib_TCEforms
  42   *  302:     function t3lib_TCEforms()
  43   *  338:     function initDefaultBEmode()
  44   *
  45   *              SECTION: Rendering the forms, fields etc
  46   *  385:     function getSoloField($table,$row,$theFieldToReturn)
  47   *  424:     function getMainFields($table,$row,$depth=0)
  48   *  618:     function getListedFields($table,$row,$list)
  49   *  660:     function getPaletteFields($table,$row,$palette,$header='',$itemList='',$collapsedHeader='')
  50   *  737:     function getSingleField($table,$field,$row,$altName='',$palette=0,$extra='',$pal=0)
  51   *  900:     function getSingleField_SW($table,$field,$row,&$PA)
  52   *
  53   *              SECTION: Rendering of each TCEform field type
  54   *  976:     function getSingleField_typeInput($table,$field,$row,&$PA)
  55   * 1057:     function getSingleField_typeText($table,$field,$row,&$PA)
  56   * 1178:     function getSingleField_typeCheck($table,$field,$row,&$PA)
  57   * 1244:     function getSingleField_typeRadio($table,$field,$row,&$PA)
  58   * 1279:     function getSingleField_typeSelect($table,$field,$row,&$PA)
  59   * 1359:     function getSingleField_typeSelect_single($table,$field,$row,&$PA,$config,$selItems,$nMV_label)
  60   * 1490:     function getSingleField_typeSelect_checkbox($table,$field,$row,&$PA,$config,$selItems,$nMV_label)
  61   * 1609:     function getSingleField_typeSelect_singlebox($table,$field,$row,&$PA,$config,$selItems,$nMV_label)
  62   * 1719:     function getSingleField_typeSelect_multiple($table,$field,$row,&$PA,$config,$selItems,$nMV_label)
  63   * 1823:     function getSingleField_typeGroup($table,$field,$row,&$PA)
  64   * 1992:     function getSingleField_typeNone($table,$field,$row,&$PA)
  65   * 2008:     function getSingleField_typeNone_render($config,$itemValue)
  66   * 2070:     function getSingleField_typeFlex($table,$field,$row,&$PA)
  67   * 2205:     function getSingleField_typeFlex_langMenu($languages,$elName,$selectedLanguage,$multi=1)
  68   * 2224:     function getSingleField_typeFlex_sheetMenu($sArr,$elName,$sheetKey)
  69   * 2259:     function getSingleField_typeFlex_draw($dataStruct,$editData,$cmdData,$table,$field,$row,&$PA,$formPrefix='',$level=0,$tRows=array())
  70   * 2452:     function getSingleField_typeUnknown($table,$field,$row,&$PA)
  71   * 2467:     function getSingleField_typeUser($table,$field,$row,&$PA)
  72   *
  73   *              SECTION: Field content processing
  74   * 2496:     function formatValue ($config, $itemValue)
  75   *
  76   *              SECTION: "Configuration" fetching/processing functions
  77   * 2588:     function getRTypeNum($table,$row)
  78   * 2614:     function rearrange($fields)
  79   * 2640:     function getExcludeElements($table,$row,$typeNum)
  80   * 2688:     function getFieldsToAdd($table,$row,$typeNum)
  81   * 2713:     function mergeFieldsWithAddedFields($fields,$fieldsToAdd)
  82   * 2745:     function setTSconfig($table,$row,$field='')
  83   * 2767:     function getSpecConfForField($table,$row,$field)
  84   * 2788:     function getSpecConfFromString($extraString, $defaultExtras)
  85   *
  86   *              SECTION: Display of localized content etc.
  87   * 2816:     function registerDefaultLanguageData($table,$rec)
  88   * 2848:     function getLanguageOverlayRawValue($table, $row, $field, $fieldConf)
  89   * 2876:     function renderDefaultLanguageContent($table,$field,$row,$item)
  90   * 2899:     function renderDefaultLanguageDiff($table,$field,$row,$item)
  91   *
  92   *              SECTION: Form element helper functions
  93   * 2955:     function dbFileIcons($fName,$mode,$allowed,$itemArray,$selector='',$params=array(),$onFocus='')
  94   * 3108:     function getClipboardElements($allowed,$mode)
  95   * 3157:     function getClickMenu($str,$table,$uid='')
  96   * 3178:     function renderWizards($itemKinds,$wizConf,$table,$row,$field,&$PA,$itemName,$specConf,$RTE=0)
  97   * 3382:     function getIcon($icon)
  98   * 3409:     function optionTagStyle($iconString)
  99   * 3425:     function extractValuesOnlyFromValueLabelList($itemFormElValue)
 100   * 3447:     function wrapOpenPalette($header,$table,$row,$palette,$retFunc=0)
 101   * 3471:     function checkBoxParams($itemName,$thisValue,$c,$iCount,$addFunc='')
 102   * 3485:     function elName($itemName)
 103   * 3496:     function noTitle($str,$wrapParts=array())
 104   * 3505:     function blur()
 105   * 3514:     function thisReturnUrl()
 106   * 3527:     function getSingleHiddenField($table,$field,$row)
 107   * 3549:     function formWidth($size=48,$textarea=0)
 108   * 3576:     function formWidthText($size=48,$wrap='')
 109   * 3592:     function formElStyle($type)
 110   * 3603:     function formElClass($type)
 111   * 3614:     function formElStyleClassValue($type, $class=FALSE)
 112   * 3638:     function insertDefStyle($type)
 113   * 3657:     function getDynTabMenu($parts, $idString)
 114   *
 115   *              SECTION: Item-array manipulation functions (check/select/radio)
 116   * 3696:     function initItemArray($fieldValue)
 117   * 3714:     function addItems($items,$iArray)
 118   * 3736:     function procItems($items,$iArray,$config,$table,$row,$field)
 119   * 3760:     function addSelectOptionsToItemArray($items,$fieldValue,$TSconfig,$field)
 120   * 3980:     function addSelectOptionsToItemArray_makeModuleData($value)
 121   * 4002:     function foreignTable($items,$fieldValue,$TSconfig,$field,$pFFlag=0)
 122   *
 123   *              SECTION: Template functions
 124   * 4083:     function setNewBEDesign()
 125   * 4138:     function intoTemplate($inArr,$altTemplate='')
 126   * 4162:     function addUserTemplateMarkers($marker,$table,$field,$row,&$PA)
 127   * 4173:     function wrapLabels($str)
 128   * 4186:     function wrapTotal($c,$rec,$table)
 129   * 4199:     function replaceTableWrap($arr,$rec,$table)
 130   * 4236:     function wrapBorder(&$out_array,&$out_pointer)
 131   * 4258:     function rplColorScheme($inTemplate)
 132   * 4278:     function getDivider()
 133   * 4288:     function printPalette($palArr)
 134   * 4339:     function helpTextIcon($table,$field,$force=0)
 135   * 4359:     function helpText($table,$field)
 136   * 4380:     function setColorScheme($scheme)
 137   * 4404:     function resetSchemes()
 138   * 4415:     function storeSchemes()
 139   * 4427:     function restoreSchemes()
 140   *
 141   *              SECTION: JavaScript related functions
 142   * 4457:     function JStop()
 143   * 4508:     function JSbottom($formname='forms[0]')
 144   * 4835:     function dbFileCon($formObj='document.forms[0]')
 145   * 5053:     function printNeededJSFunctions()
 146   * 5080:     function printNeededJSFunctions_top()
 147   *
 148   *              SECTION: Various helper functions
 149   * 5128:     function getDefaultRecord($table,$pid=0)
 150   * 5167:     function getRecordPath($table,$rec)
 151   * 5181:     function readPerms()
 152   * 5195:     function sL($str)
 153   * 5208:     function getLL($str)
 154   * 5229:     function isPalettesCollapsed($table,$palette)
 155   * 5245:     function isDisplayCondition($displayCond,$row,$ffValueKey='')
 156   * 5349:     function getTSCpid($table,$uid,$pid)
 157   * 5363:     function doLoadTableDescr($table)
 158   * 5375:     function getAvailableLanguages($onlyIsoCoded=1,$setDefault=1)
 159   *
 160   *
 161   * 5417: class t3lib_TCEforms_FE extends t3lib_TCEforms
 162   * 5425:     function wrapLabels($str)
 163   * 5435:     function printPalette($palArr)
 164   * 5460:     function setFancyDesign()
 165   *
 166   * TOTAL FUNCTIONS: 100
 167   * (This index is automatically created/updated by the extension "extdeveval")
 168   *
 169   */
 170  
 171  
 172  
 173  
 174  
 175  
 176  
 177  
 178  
 179  
 180  
 181  
 182  
 183  require_once(PATH_t3lib.'class.t3lib_diff.php');
 184  require_once(PATH_t3lib.'class.t3lib_tceforms_inline.php');
 185  
 186  
 187  
 188  /**
 189   * 'TCEforms' - Class for creating the backend editing forms.
 190   *
 191   * @author    Kasper Skaarhoj <kasperYYYY@typo3.com>
 192   * @coauthor    Rene Fritz <r.fritz@colorcube.de>
 193   * @package TYPO3
 194   * @subpackage t3lib
 195   */
 196  class t3lib_TCEforms    {
 197  
 198          // variables not commented yet.... (do so...)
 199      var $palFieldArr = array();
 200      var $disableWizards = 0;
 201      var $isPalettedoc = 0;
 202      var $paletteMargin = 1;
 203      var $defStyle = ''; // 'font-family:Verdana;font-size:10px;';
 204      var $cachedTSconfig = array();
 205      var $cachedTSconfig_fieldLevel = array();
 206      var $cachedLanguageFlag = array();
 207      var $cachedAdditionalPreviewLanguages = NULL;
 208      var $transformedRow = array();
 209      var $extJSCODE = '';
 210      var $printNeededJS = array();
 211      var $hiddenFieldAccum=array();
 212      var $TBE_EDITOR_fieldChanged_func='';
 213      var $loadMD5_JS=1;
 214      var $prevBorderStyle='[nothing here...]';    // Something unique...
 215      var $allowUpload=0;                 // If set direct upload fields will be shown
 216      var $titleLen=15;                     // @deprecated: $BE_USER->uc['titleLen'] but what is default??
 217      var $defaultLanguageData = array();    // Array where records in the default language is stored. (processed by transferdata)
 218      var $defaultLanguageData_diff = array();    // Array where records in the default language is stored (raw without any processing. used for making diff)
 219      var $additionalPreviewLanguageData = array();
 220  
 221  
 222          // EXTERNAL, static
 223      var $backPath='';                    // Set this to the 'backPath' pointing back to the typo3 admin directory from the script where this form is displayed.
 224      var $returnUrl='';                    // Alternative return URL path (default is t3lib_div::linkThisScript())
 225      var $doSaveFieldName='';            // Can be set to point to a field name in the form which will be set to '1' when the form is submitted with a *save* button. This way the recipient script can determine that the form was submitted for save and not "close" for example.
 226      var $palettesCollapsed=0;            // Can be set true/false to whether palettes (secondary options) are in the topframe or in form. True means they are NOT IN-form. So a collapsed palette is one, which is shown in the top frame, not in the page.
 227      var $disableRTE=0;                    // If set, the RTE is disabled (from form display, eg. by checkbox in the bottom of the page!)
 228      var $globalShowHelp=1;                // If false, then all CSH will be disabled, regardless of settings in $this->edit_showFieldHelp
 229      var $localizationMode='';        // If true, the forms are rendering only localization relevant fields of the records.
 230      var $fieldOrder='';                    // Overrule the field order set in TCA[types][showitem], eg for tt_content this value, 'bodytext,image', would make first the 'bodytext' field, then the 'image' field (if set for display)... and then the rest in the old order.
 231      var $doPrintPalette=1;                // If set to false, palettes will NEVER be rendered.
 232      var $clipObj=FALSE;                    // Set to initialized clipboard object; Then the element browser will offer a link to paste in records from clipboard.
 233      var $enableClickMenu=FALSE;            // Enable click menu on reference icons.
 234      var $enableTabMenu = FALSE;            // Enable Tab Menus. If set to true, the JavaScript content from template::getDynTabMenuJScode() must be included in the document.
 235      var $renderReadonly = FALSE;         // When enabled all fields are rendered non-editable.
 236  
 237      var $form_rowsToStylewidth = 9.58;    // Form field width compensation: Factor from NN4 form field widths to style-aware browsers (like NN6+ and MSIE, with the $CLIENT[FORMSTYLE] value set)
 238      var $form_largeComp = 1.33;            // Form field width compensation: Compensation for large documents, doc-tab (editing)
 239      var $charsPerRow=40;                // The number of chars expected per row when the height of a text area field is automatically calculated based on the number of characters found in the field content.
 240      var $maxTextareaWidth=48;            // The maximum abstract value for textareas
 241      var $maxInputWidth=48;                // The maximum abstract value for input fields
 242      var $defaultMultipleSelectorStyle='width:250px;';    // Default style for the selector boxes used for multiple items in "select" and "group" types.
 243  
 244  
 245          // INTERNAL, static
 246      var $prependFormFieldNames = 'data';        // The string to prepend formfield names with.
 247      var $prependCmdFieldNames = 'cmd';            // The string to prepend commands for tcemain::process_cmdmap with.
 248      var $prependFormFieldNames_file = 'data_files';        // The string to prepend FILE form field names with.
 249      var $formName = 'editform';                    // The name attribute of the form.
 250      var $allowOverrideMatrix = array();            // Whitelist that allows TCA field configuration to be overridden by TSconfig, @see overrideFieldConf()
 251  
 252  
 253  
 254          // INTERNAL, dynamic
 255      var $perms_clause='';                        // Set by readPerms()  (caching)
 256      var $perms_clause_set=0;                    // Set by readPerms()  (caching-flag)
 257      var $edit_showFieldHelp='';                    // Used to indicate the mode of CSH (Context Sensitive Help), whether it should be icons-only ('icon'), full description ('text') or not at all (blank).
 258      var $docLarge=0;                            // If set, the forms will be rendered a little wider, more precisely with a factor of $this->form_largeComp.
 259      var $clientInfo=array();                    // Loaded with info about the browser when class is instantiated.
 260      var $RTEenabled=0;                            // True, if RTE is possible for the current user (based on result from BE_USER->isRTE())
 261      var $RTEenabled_notReasons='';                // If $this->RTEenabled was false, you can find the reasons listed in this array which is filled with reasons why the RTE could not be loaded)
 262      var $RTEcounter = 0;                        // Counter that is incremented before an RTE is created. Can be used for unique ids etc.
 263  
 264      var $colorScheme;                            // Contains current color scheme
 265      var $classScheme;                            // Contains current class scheme
 266      var $defColorScheme;                        // Contains the default color scheme
 267      var $defClassScheme;                        // Contains the default class scheme
 268      var $fieldStyle;                            // Contains field style values
 269      var $borderStyle;                            // Contains border style values.
 270  
 271      var $commentMessages=array();                // An accumulation of messages from the class.
 272  
 273          // INTERNAL, templates
 274      var $totalWrap='<hr />|<hr />';                // Total wrapping for the table rows.
 275      var $fieldTemplate='<b>###FIELD_NAME###</b><br />###FIELD_ITEM###<hr />';    // Field template
 276      var $sectionWrap='';                        // Wrapping template code for a section
 277      var $palFieldTemplateHeader='';                // Template for palette headers
 278      var $palFieldTemplate='';                    // Template for palettes
 279  
 280          // INTERNAL, working memory
 281      var $excludeElements='';                    // Set to the fields NOT to display, if any.
 282      var $palettesRendered=array();                // During rendering of forms this will keep track of which palettes has already been rendered (so they are not rendered twice by mistake)
 283      var $hiddenFieldListArr = array();            // This array of fields will be set as hidden-fields instead of rendered normally! For instance palette fields edited in the top frame are set as hidden fields since the main form has to submit the values. The top frame actually just sets the value in the main form!
 284      var $requiredFields=array();                // Used to register input-field names, which are required. (Done during rendering of the fields). This information is then used later when the JavaScript is made.
 285      var $requiredElements=array();                // Used to register the min and max number of elements for selectorboxes where that apply (in the "group" type for instance)
 286      var $renderDepth=0;                            // Keeps track of the rendering depth of nested records.
 287      var $savedSchemes=array();                    // Color scheme buffer.
 288      var $dynNestedStack = array();                // holds the path an element is nested in (e.g. required for RTEhtmlarea)
 289  
 290          // Internal, registers for user defined functions etc.
 291      var $additionalCode_pre = array();            // Additional HTML code, printed before the form.
 292      var $additionalJS_pre = array();            // Additional JavaScript, printed before the form
 293      var $additionalJS_post = array();            // Additional JavaScript printed after the form
 294      var $additionalJS_submit = array();            // Additional JavaScript executed on submit; If you set "OK" variable it will raise an error about RTEs not being loaded and offer to block further submission.
 295  
 296      var $inline;                                // Instance of t3lib_tceforms_inline
 297      var $hookObjectsMainFields = array();            // Array containing hook class instances called once for a form
 298      var $hookObjectsSingleField = array();            // Array containing hook class instances called for each field
 299      var $extraFormHeaders = array();            // Rows gettings inserted into the alt_doc headers (when called from alt_doc.php)
 300  
 301  
 302  
 303  
 304  
 305      /**
 306       * Constructor function, setting internal variables, loading the styles used.
 307       *
 308       * @return    void
 309       */
 310  	function t3lib_TCEforms()    {
 311          global $CLIENT, $TYPO3_CONF_VARS;
 312  
 313          $this->clientInfo = t3lib_div::clientInfo();
 314  
 315          $this->RTEenabled = $GLOBALS['BE_USER']->isRTE();
 316          if (!$this->RTEenabled)    {
 317              $this->RTEenabled_notReasons = implode(chr(10),$GLOBALS['BE_USER']->RTE_errors);
 318              $this->commentMessages[] = 'RTE NOT ENABLED IN SYSTEM due to:'.chr(10).$this->RTEenabled_notReasons;
 319          }
 320  
 321              // Default color+class scheme
 322          $this->defColorScheme = array(
 323              $GLOBALS['SOBE']->doc->bgColor,    // Background for the field AND palette
 324              t3lib_div::modifyHTMLColorAll($GLOBALS['SOBE']->doc->bgColor,-20),    // Background for the field header
 325              t3lib_div::modifyHTMLColorAll($GLOBALS['SOBE']->doc->bgColor,-10),    // Background for the palette field header
 326              'black',    // Field header font color
 327              '#666666'    // Palette field header font color
 328          );
 329          $this->defColorScheme = array();
 330  
 331              // Override / Setting defaults from TBE_STYLES array
 332          $this->resetSchemes();
 333  
 334              // Setting the current colorScheme to default.
 335          $this->defColorScheme = $this->colorScheme;
 336          $this->defClassScheme = $this->classScheme;
 337  
 338              // Define whitelist that allows TCA field configuration to be overridden by TSconfig, @see overrideFieldConf():
 339          $this->allowOverrideMatrix = array(
 340              'input' => array('size', 'max'),
 341              'text' => array('cols', 'rows', 'wrap'),
 342              'check' => array('cols', 'showIfRTE'),
 343              'select' => array('size', 'autoSizeMax', 'maxitems', 'minitems'),
 344              'group' => array('size', 'autoSizeMax', 'max_size', 'show_thumbs', 'maxitems', 'minitems'),
 345              'inline' => array('appearance', 'foreign_label', 'foreign_selector', 'foreign_unique', 'maxitems', 'minitems', 'size', 'autoSizeMax', 'symmetric_label'),
 346          );
 347  
 348          $this->inline = t3lib_div::makeInstance('t3lib_TCEforms_inline');
 349  
 350              // Prepare user defined objects (if any) for hooks which extend this function:
 351          $this->hookObjectsMainFields = array();
 352          if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass']))    {
 353              foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'] as $classRef)    {
 354                  $this->hookObjectsMainFields[] = &t3lib_div::getUserObj($classRef);
 355              }
 356          }
 357          $this->hookObjectsSingleField = array();
 358          if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getSingleFieldClass']))    {
 359              foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getSingleFieldClass'] as $classRef)    {
 360                  $this->hookObjectsSingleField[] = &t3lib_div::getUserObj($classRef);
 361              }
 362          }
 363  
 364      }
 365  
 366      /**
 367       * Initialize various internal variables.
 368       *
 369       * @return    void
 370       */
 371  	function initDefaultBEmode()    {
 372          global $BE_USER;
 373          $this->prependFormFieldNames = 'data';
 374          $this->formName = 'editform';
 375          $this->setNewBEDesign();
 376          $this->docLarge = $BE_USER->uc['edit_wideDocument'] ? 1 : 0;
 377          $this->edit_showFieldHelp = $BE_USER->uc['edit_showFieldHelp'];
 378  
 379          $this->edit_docModuleUpload = $BE_USER->uc['edit_docModuleUpload'];
 380          $this->titleLen = $BE_USER->uc['titleLen'];        // @deprecated
 381  
 382          $this->inline->init($this);
 383      }
 384  
 385  
 386  
 387  
 388  
 389  
 390  
 391  
 392  
 393  
 394  
 395  
 396  
 397  
 398  
 399  
 400  
 401      /*******************************************************
 402       *
 403       * Rendering the forms, fields etc
 404       *
 405       *******************************************************/
 406  
 407      /**
 408       * Will return the TCEform element for just a single field from a record.
 409       * The field must be listed in the currently displayed fields (as found in [types][showitem]) for the record.
 410       * This also means that the $table/$row supplied must be complete so the list of fields to show can be found correctly
 411       *
 412       * @param    string        The table name
 413       * @param    array        The record from the table for which to render a field.
 414       * @param    string        The field name to return the TCEform element for.
 415       * @return    string        HTML output
 416       * @see getMainFields()
 417       */
 418  	function getSoloField($table,$row,$theFieldToReturn)    {
 419          global $TCA;
 420  
 421          if ($TCA[$table])    {
 422              t3lib_div::loadTCA($table);
 423              $typeNum = $this->getRTypeNum($table,$row);
 424              if ($TCA[$table]['types'][$typeNum])    {
 425                  $itemList = $TCA[$table]['types'][$typeNum]['showitem'];
 426                  if ($itemList)    {
 427                      $fields = t3lib_div::trimExplode(',',$itemList,1);
 428                      $excludeElements = $this->excludeElements = $this->getExcludeElements($table,$row,$typeNum);
 429  
 430                      reset($fields);
 431                      while(list(,$fieldInfo)=each($fields))    {
 432                          $parts = explode(';',$fieldInfo);
 433  
 434                          $theField = trim($parts[0]);
 435                          if (!in_array($theField,$excludeElements) && !strcmp($theField,$theFieldToReturn))    {
 436                              if ($TCA[$table]['columns'][$theField])    {
 437                                  $sField = $this->getSingleField($table,$theField,$row,$parts[1],1,$parts[3],$parts[2]);
 438                                  return $sField['ITEM'];
 439                              }
 440                          }
 441                      }
 442                  }
 443              }
 444          }
 445      }
 446  
 447      /**
 448       * Based on the $table and $row of content, this displays the complete TCEform for the record.
 449       * 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.
 450       *
 451       * @param    string        The table name
 452       * @param    array        The record from the table for which to render a field.
 453       * @param    integer        Depth level
 454       * @return    string        HTML output
 455       * @see getSoloField()
 456       */
 457  	function getMainFields($table,$row,$depth=0)    {
 458          global $TCA, $TYPO3_CONF_VARS;
 459  
 460          $this->renderDepth=$depth;
 461  
 462              // Init vars:
 463          $out_array = array(array());
 464          $out_array_meta = array(array(
 465              'title' => $this->getLL('l_generalTab')
 466          ));
 467  
 468          $out_pointer=0;
 469          $out_sheet=0;
 470          $this->palettesRendered=array();
 471          $this->palettesRendered[$this->renderDepth][$table]=array();
 472  
 473              // Hook: getMainFields_preProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
 474          foreach ($this->hookObjectsMainFields as $hookObj)    {
 475              if (method_exists($hookObj,'getMainFields_preProcess'))    {
 476                  $hookObj->getMainFields_preProcess($table,$row,$this);
 477              }
 478          }
 479  
 480          if ($TCA[$table])    {
 481  
 482                  // Load the full TCA for the table.
 483              t3lib_div::loadTCA($table);
 484  
 485                  // Load the description content for the table.
 486              if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table))    {
 487                  $GLOBALS['LANG']->loadSingleTableDescription($table);
 488              }
 489                  // Get the current "type" value for the record.
 490              $typeNum = $this->getRTypeNum($table,$row);
 491  
 492                  // Find the list of fields to display:
 493              if ($TCA[$table]['types'][$typeNum])    {
 494                  $itemList = $TCA[$table]['types'][$typeNum]['showitem'];
 495                  if ($itemList)    {    // If such a list existed...
 496                          // Explode the field list and possibly rearrange the order of the fields, if configured for
 497                      $fields = t3lib_div::trimExplode(',',$itemList,1);
 498                      if ($this->fieldOrder)    {
 499                          $fields = $this->rearrange($fields);
 500                      }
 501  
 502                          // Get excluded fields, added fiels and put it together:
 503                      $excludeElements = $this->excludeElements = $this->getExcludeElements($table,$row,$typeNum);
 504                      $fields = $this->mergeFieldsWithAddedFields($fields,$this->getFieldsToAdd($table,$row,$typeNum));
 505  
 506                          // If TCEforms will render a tab menu in the next step, push the name to the tab stack:
 507                      $tabIdentString = '';
 508                      $tabIdentStringMD5 = '';
 509                      if (strstr($itemList, '--div--') !== false && $this->enableTabMenu && $TCA[$table]['ctrl']['dividers2tabs']) {
 510                          $tabIdentString = 'TCEforms:'.$table.':'.$row['uid'];
 511                          $tabIdentStringMD5 = $GLOBALS['TBE_TEMPLATE']->getDynTabMenuId($tabIdentString);
 512                              // Remember that were currently working on the general tab:
 513                          if (isset($fields[0]) && strpos($fields[0], '--div--') !== 0) {
 514                              $this->pushToDynNestedStack('tab', $tabIdentStringMD5.'-1');
 515                          }
 516                      }
 517  
 518                          // Traverse the fields to render:
 519                      $cc=0;
 520                      foreach($fields as $fieldInfo)    {
 521                              // Exploding subparts of the field configuration:
 522                          $parts = explode(';',$fieldInfo);
 523  
 524                              // Getting the style information out:
 525                          $color_style_parts = t3lib_div::trimExplode('-',$parts[4]);
 526                          if (strcmp($color_style_parts[0],''))    {
 527                              $this->setColorScheme($GLOBALS['TBE_STYLES']['colorschemes'][intval($color_style_parts[0])]);
 528                          }
 529                          if (strcmp($color_style_parts[1],''))    {
 530                              $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][intval($color_style_parts[1])];
 531                              if (!isset($this->fieldStyle))    $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][0];
 532                          }
 533                          if (strcmp($color_style_parts[2],''))    {
 534                              $this->wrapBorder($out_array[$out_sheet],$out_pointer);
 535                              $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][intval($color_style_parts[2])];
 536                              if (!isset($this->borderStyle))    $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][0];
 537                          }
 538  
 539                              // Render the field:
 540                          $theField = $parts[0];
 541                          if (!in_array($theField,$excludeElements))    {
 542                              if ($TCA[$table]['columns'][$theField])    {
 543                                  $sFieldPal='';
 544  
 545                                  if ($parts[2] && !isset($this->palettesRendered[$this->renderDepth][$table][$parts[2]]))    {
 546                                      $sFieldPal=$this->getPaletteFields($table,$row,$parts[2]);
 547                                      $this->palettesRendered[$this->renderDepth][$table][$parts[2]] = 1;
 548                                  }
 549                                  $sField = $this->getSingleField($table,$theField,$row,$parts[1],0,$parts[3],$parts[2]);
 550                                  if ($sField)    { $sField.= $sFieldPal; }
 551  
 552                                  $out_array[$out_sheet][$out_pointer].= $sField;
 553                              } elseif ($theField=='--div--')    {
 554                                  if ($cc>0)    {
 555                                      $out_array[$out_sheet][$out_pointer].=$this->getDivider();
 556  
 557                                      if ($this->enableTabMenu && $TCA[$table]['ctrl']['dividers2tabs'])    {
 558                                          $this->wrapBorder($out_array[$out_sheet],$out_pointer);
 559                                              // Remove last tab entry from the dynNestedStack:
 560                                          $out_sheet++;
 561                                              // Remove the previous sheet from stack (if any):
 562                                          $this->popFromDynNestedStack('tab', $tabIdentStringMD5.'-'.($out_sheet));
 563                                              // Remember on which sheet we're currently working:
 564                                          $this->pushToDynNestedStack('tab', $tabIdentStringMD5.'-'.($out_sheet+1));
 565                                          $out_array[$out_sheet] = array();
 566                                          $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
 567                                      }
 568                                  } else {    // Setting alternative title for "General" tab if "--div--" is the very first element.
 569                                      $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
 570                                          // Only add the first tab to the dynNestedStack if there are more tabs:
 571                                      if ($tabIdentString && strpos($itemList, '--div--', strlen($fieldInfo))) {
 572                                          $this->pushToDynNestedStack('tab', $tabIdentStringMD5.'-1');
 573                                      }
 574                                  }
 575                              } elseif($theField=='--palette--')    {
 576                                  if ($parts[2] && !isset($this->palettesRendered[$this->renderDepth][$table][$parts[2]]))    {
 577                                          // render a 'header' if not collapsed
 578                                      if ($TCA[$table]['palettes'][$parts[2]]['canNotCollapse'] AND $parts[1]) {
 579                                          $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$parts[2],$this->sL($parts[1]));
 580                                      } else {
 581                                          $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$parts[2],'','',$this->sL($parts[1]));
 582                                      }
 583                                      $this->palettesRendered[$this->renderDepth][$table][$parts[2]] = 1;
 584                                  }
 585                              }
 586                          }
 587  
 588                          $cc++;
 589                      }
 590                  }
 591              }
 592          }
 593  
 594              // Hook: getMainFields_postProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
 595          foreach ($this->hookObjectsMainFields as $hookObj)    {
 596              if (method_exists($hookObj,'getMainFields_postProcess'))    {
 597                  $hookObj->getMainFields_postProcess($table,$row,$this);
 598              }
 599          }
 600  
 601              // Wrapping a border around it all:
 602          $this->wrapBorder($out_array[$out_sheet],$out_pointer);
 603  
 604              // Resetting styles:
 605          $this->resetSchemes();
 606  
 607              // Rendering Main palettes, if any
 608          $mParr = t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['mainpalette']);
 609          $i = 0;
 610          if (count($mParr))    {
 611              foreach ($mParr as $mP)    {
 612                  if (!isset($this->palettesRendered[$this->renderDepth][$table][$mP]))    {
 613                      $temp_palettesCollapsed=$this->palettesCollapsed;
 614                      $this->palettesCollapsed=0;
 615                      $label = ($i==0?$this->getLL('l_generalOptions'):$this->getLL('l_generalOptions_more'));
 616                      $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$mP,$label);
 617                      $this->palettesCollapsed=$temp_palettesCollapsed;
 618                      $this->palettesRendered[$this->renderDepth][$table][$mP] = 1;
 619                  }
 620                  $this->wrapBorder($out_array[$out_sheet],$out_pointer);
 621                  $i++;
 622                  if ($this->renderDepth)    {
 623                      $this->renderDepth--;
 624                  }
 625              }
 626          }
 627  
 628              // Return the imploded $out_array:
 629          if ($out_sheet>0)    {    // There were --div-- dividers around...
 630  
 631                  // Create parts array for the tab menu:
 632              $parts = array();
 633              foreach ($out_array as $idx => $sheetContent)    {
 634                  $parts[] = array(
 635                      'label' => $out_array_meta[$idx]['title'],
 636                      'content' => '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.
 637                              implode('',$sheetContent).
 638                          '</table>'
 639                  );
 640              }
 641  
 642                  // Unset the current level of tab menus:
 643              $this->popFromDynNestedStack('tab', $tabIdentStringMD5.'-'.($out_sheet+1));
 644  
 645              return '
 646                  <tr>
 647                      <td colspan="2">
 648                      '.$this->getDynTabMenu($parts, $tabIdentString).'
 649                      </td>
 650                  </tr>';
 651          } else {    // Only one, so just implode:
 652              return implode('',$out_array[$out_sheet]);
 653          }
 654      }
 655  
 656      /**
 657       * Will return the TCEform elements for a pre-defined list of fields.
 658       * 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.
 659       * Used for displaying forms for the frontend edit icons for instance.
 660       *
 661       * @param    string        The table name
 662       * @param    array        The record array.
 663       * @param    string        Commalist of fields from the table. These will be shown in the specified order in a form.
 664       * @return    string        TCEform elements in a string.
 665       */
 666  	function getListedFields($table,$row,$list)    {
 667          global $TCA;
 668  
 669          t3lib_div::loadTCA($table);
 670          if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table))    {
 671              $GLOBALS['LANG']->loadSingleTableDescription($table);
 672          }
 673  
 674          $out = '';
 675          $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table,$row,1);
 676  
 677          $editFieldList=array_unique(t3lib_div::trimExplode(',',$list,1));
 678          foreach($editFieldList as $theFieldC)    {
 679              list($theField,$palFields) = split('\[|\]',$theFieldC);
 680              $theField = trim($theField);
 681              $palFields = trim($palFields);
 682              if ($TCA[$table]['columns'][$theField])    {
 683                  $parts = t3lib_div::trimExplode(';',$types_fieldConfig[$theField]['origString']);
 684                  $sField = $this->getSingleField($table,$theField,$row,$parts[1],0,$parts[3],0);    // Don't sent palette pointer - there are no options anyways for a field-list.
 685                  $out.= $sField;
 686              } elseif($theField=='--div--')    {
 687                  $out.= $this->getDivider();
 688              }
 689              if ($palFields)    {
 690                  $out.= $this->getPaletteFields($table,$row,'','',implode(',',t3lib_div::trimExplode('|',$palFields,1)));
 691              }
 692          }
 693  
 694          return $out;
 695      }
 696  
 697      /**
 698       * Creates a palette (collection of secondary options).
 699       *
 700       * @param    string        The table name
 701       * @param    array        The row array
 702       * @param    string        The palette number/pointer
 703       * @param    string        Header string for the palette (used when in-form). If not set, no header item is made.
 704       * @param    string        Optional alternative list of fields for the palette
 705       * @param    string        Optional Link text for activating a palette (when palettes does not have another form element to belong to).
 706       * @return    string        HTML code.
 707       */
 708  	function getPaletteFields($table,$row,$palette,$header='',$itemList='',$collapsedHeader='')    {
 709          global $TCA;
 710          if (!$this->doPrintPalette)    return '';
 711  
 712          $out='';
 713          $palParts = array();
 714          t3lib_div::loadTCA($table);
 715  
 716              // Getting excludeElements, if any.
 717          if (!is_array($this->excludeElements))    {
 718              $this->excludeElements = $this->getExcludeElements($table,$row,$this->getRTypeNum($table,$row));
 719          }
 720  
 721              // Render the palette TCEform elements.
 722          if ($TCA[$table] && (is_array($TCA[$table]['palettes'][$palette]) || $itemList))    {
 723              $itemList = $itemList?$itemList:$TCA[$table]['palettes'][$palette]['showitem'];
 724              if ($itemList)    {
 725                  $fields = t3lib_div::trimExplode(',',$itemList,1);
 726                  reset($fields);
 727                  while(list(,$fieldInfo)=each($fields))    {
 728                      $parts = t3lib_div::trimExplode(';',$fieldInfo);
 729                      $theField = $parts[0];
 730  
 731                      if (!in_array($theField,$this->excludeElements) && $TCA[$table]['columns'][$theField])    {
 732                          $this->palFieldArr[$palette][] = $theField;
 733                          if ($this->isPalettesCollapsed($table,$palette))    {
 734                              $this->hiddenFieldListArr[] = $theField;
 735                          }
 736  
 737                          $part = $this->getSingleField($table,$theField,$row,$parts[1],1,'',$parts[2]);
 738                          if (is_array($part))    {
 739                              $palParts[] = $part;
 740                          }
 741                      }
 742                  }
 743              }
 744          }
 745              // Put palette together if there are fields in it:
 746          if (count($palParts))    {
 747              if ($header)    {
 748                  $out.= $this->intoTemplate(array(
 749                                  'HEADER' => htmlspecialchars($header)
 750                              ),
 751                              $this->palFieldTemplateHeader
 752                          );
 753              }
 754              $out.= $this->intoTemplate(array(
 755                              'PALETTE' => $this->printPalette($palParts)
 756                          ),
 757                          $this->palFieldTemplate
 758                      );
 759          }
 760              // If a palette is collapsed (not shown in form, but in top frame instead) AND a collapse header string is given, then make that string a link to activate the palette.
 761          if ($this->isPalettesCollapsed($table,$palette) && $collapsedHeader)    {
 762              $pC = $this->intoTemplate(array(
 763                              'PALETTE' => $this->wrapOpenPalette('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/options.gif','width="18" height="16"').' border="0" title="'.htmlspecialchars($this->getLL('l_moreOptions')).'" align="top" alt="" /><strong>'.$collapsedHeader.'</strong>',$table,$row,$palette),
 764                          ),
 765                          $this->palFieldTemplate
 766                      );
 767              $out.= $pC;
 768          }
 769  
 770          return $out;
 771      }
 772  
 773      /**
 774       * Returns the form HTML code for a database table field.
 775       *
 776       * @param    string        The table name
 777       * @param    string        The field name
 778       * @param    array        The record to edit from the database table.
 779       * @param    string        Alternative field name label to show.
 780       * @param    boolean        Set this if the field is on a palette (in top frame), otherwise not. (if set, field will render as a hidden field).
 781       * @param    string        The "extra" options from "Part 4" of the field configurations found in the "types" "showitem" list. Typically parsed by $this->getSpecConfFromString() in order to get the options as an associative array.
 782       * @param    integer        The palette pointer.
 783       * @return    mixed        String (normal) or array (palettes)
 784       */
 785  	function getSingleField($table,$field,$row,$altName='',$palette=0,$extra='',$pal=0)    {
 786          global $TCA,$BE_USER;
 787  
 788              // Hook: getSingleField_preProcess
 789          foreach ($this->hookObjectsSingleField as $hookObj)    {
 790              if (method_exists($hookObj,'getSingleField_preProcess'))    {
 791                  $hookObj->getSingleField_preProcess($table, $field, $row, $altName, $palette, $extra, $pal, $this);
 792              }
 793          }
 794  
 795          $out = '';
 796          $PA = array();
 797          $PA['altName'] = $altName;
 798          $PA['palette'] = $palette;
 799          $PA['extra'] = $extra;
 800          $PA['pal'] = $pal;
 801  
 802              // Make sure to load full $TCA array for the table:
 803          t3lib_div::loadTCA($table);
 804  
 805              // Get the TCA configuration for the current field:
 806          $PA['fieldConf'] = $TCA[$table]['columns'][$field];
 807          $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
 808  
 809          $skipThisField = $this->inline->skipField($table, $field, $row, $PA['fieldConf']['config']);
 810  
 811              // Now, check if this field is configured and editable (according to excludefields + other configuration)
 812          if (    is_array($PA['fieldConf']) &&
 813                  !$skipThisField &&
 814                  (!$PA['fieldConf']['exclude'] || $BE_USER->check('non_exclude_fields',$table.':'.$field)) &&
 815                  $PA['fieldConf']['config']['form_type']!='passthrough' &&
 816                  ($this->RTEenabled || !$PA['fieldConf']['config']['showIfRTE']) &&
 817                  (!$PA['fieldConf']['displayCond'] || $this->isDisplayCondition($PA['fieldConf']['displayCond'],$row)) &&
 818                  (!$TCA[$table]['ctrl']['languageField'] || $PA['fieldConf']['l10n_display'] || strcmp($PA['fieldConf']['l10n_mode'],'exclude') || $row[$TCA[$table]['ctrl']['languageField']]<=0) &&
 819                  (!$TCA[$table]['ctrl']['languageField'] || !$this->localizationMode || $this->localizationMode===$PA['fieldConf']['l10n_cat'])
 820              )    {
 821  
 822  
 823  
 824                  // Fetching the TSconfig for the current table/field. This includes the $row which means that
 825              $PA['fieldTSConfig'] = $this->setTSconfig($table,$row,$field);
 826  
 827                  // If the field is NOT disabled from TSconfig (which it could have been) then render it
 828              if (!$PA['fieldTSConfig']['disabled'])    {
 829                      // Override fieldConf by fieldTSconfig:
 830                  $PA['fieldConf']['config'] = $this->overrideFieldConf($PA['fieldConf']['config'], $PA['fieldTSConfig']);
 831  
 832                      // Init variables:
 833                  $PA['itemFormElName']=$this->prependFormFieldNames.'['.$table.']['.$row['uid'].']['.$field.']';        // Form field name
 834                  $PA['itemFormElName_file']=$this->prependFormFieldNames_file.'['.$table.']['.$row['uid'].']['.$field.']';    // Form field name, in case of file uploads
 835                  $PA['itemFormElValue']=$row[$field];        // The value to show in the form field.
 836                  $PA['itemFormElID']=$this->prependFormFieldNames.'_'.$table.'_'.$row['uid'].'_'.$field;
 837  
 838                      // set field to read-only if configured for translated records to show default language content as readonly
 839                  if ($PA['fieldConf']['l10n_display'] AND t3lib_div::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly') AND $row[$TCA[$table]['ctrl']['languageField']]) {
 840                      $PA['fieldConf']['config']['readOnly'] =  true;
 841                      $PA['itemFormElValue'] = $this->defaultLanguageData[$table.':'.$row['uid']][$field];
 842                  }
 843  
 844                      // 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"
 845                  if (
 846                      ($TCA[$table]['ctrl']['type'] && !strcmp($field,$TCA[$table]['ctrl']['type'])) ||
 847                      ($TCA[$table]['ctrl']['requestUpdate'] && t3lib_div::inList($TCA[$table]['ctrl']['requestUpdate'],$field))) {
 848                      if($GLOBALS['BE_USER']->jsConfirmation(1))    {
 849                          $alertMsgOnChange = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
 850                      } else {
 851                          $alertMsgOnChange = 'if (TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
 852                      }
 853                  } else {
 854                      $alertMsgOnChange = '';
 855                  }
 856  
 857                      // Render as a hidden field?
 858                  if (in_array($field,$this->hiddenFieldListArr))    {
 859                      $this->hiddenFieldAccum[]='<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
 860                  } else {    // Render as a normal field:
 861  
 862                          // 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.
 863                      if (!$PA['palette'])    {
 864                          if ($PA['pal'] && $this->isPalettesCollapsed($table,$PA['pal']))    {
 865                              list($thePalIcon,$palJSfunc) = $this->wrapOpenPalette('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/options.gif','width="18" height="16"').' border="0" title="'.htmlspecialchars($this->getLL('l_moreOptions')).'" alt="" />',$table,$row,$PA['pal'],1);
 866                          } else {
 867                              $thePalIcon = '';
 868                              $palJSfunc = '';
 869                          }
 870                      }
 871                          // onFocus attribute to add to the field:
 872                      $PA['onFocus'] = ($palJSfunc && !$BE_USER->uc['dontShowPalettesOnFocusInAB']) ? ' onfocus="'.htmlspecialchars($palJSfunc).'"' : '';
 873  
 874                          // Find item
 875                      $item='';
 876                      $PA['label'] = $PA['altName'] ? $PA['altName'] : $PA['fieldConf']['label'];
 877                      $PA['label'] = $this->sL($PA['label']);
 878                          // JavaScript code for event handlers:
 879                      $PA['fieldChangeFunc']=array();
 880                      $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = "TBE_EDITOR.fieldChanged('".$table."','".$row['uid']."','".$field."','".$PA['itemFormElName']."');";
 881                      $PA['fieldChangeFunc']['alert']=$alertMsgOnChange;
 882                          // if this is the child of an inline type and it is the field creating the label
 883                      if ($this->inline->isInlineChildAndLabelField($table, $field)) {
 884                          $PA['fieldChangeFunc']['inline'] = "inline.handleChangedField('".$PA['itemFormElName']."','".$this->inline->inlineNames['object']."[$table][".$row['uid']."]');";
 885                      }
 886  
 887                          // Based on the type of the item, call a render function:
 888                      $item = $this->getSingleField_SW($table,$field,$row,$PA);
 889  
 890                          // Add language + diff
 891                      if ($PA['fieldConf']['l10n_display'] && (t3lib_div::inList($PA['fieldConf']['l10n_display'], 'hideDiff') || t3lib_div::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly'))) {
 892                          $renderLanguageDiff = false;
 893                      } else {
 894                          $renderLanguageDiff = true;
 895                      }
 896  
 897                      if ($renderLanguageDiff) {
 898                          $item = $this->renderDefaultLanguageContent($table,$field,$row,$item);
 899                          $item = $this->renderDefaultLanguageDiff($table,$field,$row,$item);
 900                      }
 901  
 902                          // 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
 903                      $PA['label'] = t3lib_div::deHSCentities(htmlspecialchars($PA['label']));
 904                      if (t3lib_div::testInt($row['uid']) && $PA['fieldTSConfig']['linkTitleToSelf'])    {
 905                          $lTTS_url = $this->backPath.'alt_doc.php?edit['.$table.']['.$row['uid'].']=edit&columnsOnly='.$field.
 906                                      ($PA['fieldTSConfig']['linkTitleToSelf.']['returnUrl']?'&returnUrl='.rawurlencode($this->thisReturnUrl()):'');
 907                          $PA['label'] = '<a href="'.htmlspecialchars($lTTS_url).'">'.$PA['label'].'</a>';
 908                      }
 909  
 910                          // Create output value:
 911                      if ($PA['fieldConf']['config']['form_type']=='user' && $PA['fieldConf']['config']['noTableWrapping'])    {
 912                          $out = $item;
 913                      } elseif ($PA['palette'])    {
 914                              // Array:
 915                          $out=array(
 916                              'NAME'=>$PA['label'],
 917                              'ID'=>$row['uid'],
 918                              'FIELD'=>$field,
 919                              'TABLE'=>$table,
 920                              'ITEM'=>$item,
 921                              'HELP_ICON' => $this->helpTextIcon($table,$field,1)
 922                          );
 923                          $out = $this->addUserTemplateMarkers($out,$table,$field,$row,$PA);
 924                      } else {
 925                              // String:
 926                          $out=array(
 927                              'NAME'=>$PA['label'],
 928                              'ITEM'=>$item,
 929                              'TABLE'=>$table,
 930                              'ID'=>$row['uid'],
 931                              'HELP_ICON'=>$this->helpTextIcon($table,$field),
 932                              'HELP_TEXT'=>$this->helpText($table,$field),
 933                              'PAL_LINK_ICON'=>$thePalIcon,
 934                              'FIELD'=>$field
 935                          );
 936                          $out = $this->addUserTemplateMarkers($out,$table,$field,$row,$PA);
 937                              // String:
 938                          $out=$this->intoTemplate($out);
 939                      }
 940                  }
 941              } else $this->commentMessages[]=$this->prependFormFieldNames.'['.$table.']['.$row['uid'].']['.$field.']: Disabled by TSconfig';
 942          }
 943              // Hook: getSingleField_postProcess
 944          foreach ($this->hookObjectsSingleField as $hookObj)    {
 945              if (method_exists($hookObj,'getSingleField_postProcess'))    {
 946                  $hookObj->getSingleField_postProcess($table, $field, $row, $out, $PA, $this);
 947              }
 948          }
 949              // Return value (string or array)
 950          return $out;
 951      }
 952  
 953      /**
 954       * Rendering a single item for the form
 955       *
 956       * @param    string        Table name of record
 957       * @param    string        Fieldname to render
 958       * @param    array        The record
 959       * @param    array        parameters array containing a lot of stuff. Value by Reference!
 960       * @return    string        Returns the item as HTML code to insert
 961       * @access private
 962       * @see getSingleField(), getSingleField_typeFlex_draw()
 963       */
 964  	function getSingleField_SW($table,$field,$row,&$PA)    {
 965          $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
 966  
 967          switch($PA['fieldConf']['config']['form_type'])    {
 968              case 'input':
 969                  $item = $this->getSingleField_typeInput($table,$field,$row,$PA);
 970              break;
 971              case 'text':
 972                  $item = $this->getSingleField_typeText($table,$field,$row,$PA);
 973              break;
 974              case 'check':
 975                  $item = $this->getSingleField_typeCheck($table,$field,$row,$PA);
 976              break;
 977              case 'radio':
 978                  $item = $this->getSingleField_typeRadio($table,$field,$row,$PA);
 979              break;
 980              case 'select':
 981                  $item = $this->getSingleField_typeSelect($table,$field,$row,$PA);
 982              break;
 983              case 'group':
 984                  $item = $this->getSingleField_typeGroup($table,$field,$row,$PA);
 985              break;
 986              case 'inline':
 987                  $item = $this->inline->getSingleField_typeInline($table,$field,$row,$PA);
 988              break;
 989              case 'none':
 990                  $item = $this->getSingleField_typeNone($table,$field,$row,$PA);
 991              break;
 992              case 'user':
 993                  $item = $this->getSingleField_typeUser($table,$field,$row,$PA);
 994              break;
 995              case 'flex':
 996                  $item = $this->getSingleField_typeFlex($table,$field,$row,$PA);
 997              break;
 998              default:
 999                  $item = $this->getSingleField_typeUnknown($table,$field,$row,$PA);
1000              break;
1001          }
1002  
1003          return $item;
1004      }
1005  
1006  
1007  
1008  
1009  
1010  
1011  
1012  
1013  
1014  
1015  
1016  
1017  
1018  
1019  
1020  
1021  
1022  
1023  
1024      /**********************************************************
1025       *
1026       * Rendering of each TCEform field type
1027       *
1028       ************************************************************/
1029  
1030      /**
1031       * Generation of TCEform elements of the type "input"
1032       * This will render a single-line input form field, possibly with various control/validation features
1033       *
1034       * @param    string        The table name of the record
1035       * @param    string        The field name which this element is supposed to edit
1036       * @param    array        The record data array where the value(s) for the field can be found
1037       * @param    array        An array with additional configuration options.
1038       * @return    string        The HTML code for the TCEform field
1039       */
1040  	function getSingleField_typeInput($table,$field,$row,&$PA)    {
1041          // typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue)
1042          // typo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off)
1043  
1044          $config = $PA['fieldConf']['config'];
1045  
1046  #        $specConf = $this->getSpecConfForField($table,$row,$field);
1047          $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1048          $size = t3lib_div::intInRange($config['size']?$config['size']:30,5,$this->maxInputWidth);
1049          $evalList = t3lib_div::trimExplode(',',$config['eval'],1);
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('date',$evalList))    {
1057                  $config['format'] = 'date';
1058              } elseif (in_array('datetime',$evalList))    {
1059                  $config['format'] = 'datetime';
1060              } elseif (in_array('time',$evalList))    {
1061                  $config['format'] = 'time';
1062              }
1063              if (in_array('password',$evalList))    {
1064                  $itemFormElValue = $itemFormElValue ? '*********' : '';
1065              }
1066              return $this->getSingleField_typeNone_render($config, $itemFormElValue);
1067          }
1068  
1069          if (in_array('required',$evalList))    {
1070              $this->requiredFields[$table.'_'.$row['uid'].'_'.$field]=$PA['itemFormElName'];
1071          }
1072  
1073          $paramsList = "'".$PA['itemFormElName']."','".implode(',',$evalList)."','".trim($config['is_in'])."',".(isset($config['checkbox'])?1:0).",'".$config['checkbox']."'";
1074          if (isset($config['checkbox']))    {
1075                  // Setting default "click-checkbox" values for eval types "date" and "datetime":
1076              $thisMidnight = mktime(0,0,0);
1077              $checkSetValue = in_array('date',$evalList) ? $thisMidnight : '';
1078              $checkSetValue = in_array('datetime',$evalList) ? time() : $checkSetValue;
1079  
1080              $cOnClick = 'typo3form.fieldGet('.$paramsList.',1,\''.$checkSetValue.'\');'.implode('',$PA['fieldChangeFunc']);
1081              $item.='<input type="checkbox"'.$this->insertDefStyle('check').' name="'.$PA['itemFormElName'].'_cb" onclick="'.htmlspecialchars($cOnClick).'" />';
1082          }
1083  
1084          $PA['fieldChangeFunc'] = array_merge(array('typo3form.fieldGet'=>'typo3form.fieldGet('.$paramsList.');'), $PA['fieldChangeFunc']);
1085          $mLgd = ($config['max']?$config['max']:256);
1086          $iOnChange = implode('',$PA['fieldChangeFunc']);
1087          $item.='<input type="text" name="'.$PA['itemFormElName'].'_hr" value=""'.$this->formWidth($size).' maxlength="'.$mLgd.'" onchange="'.htmlspecialchars($iOnChange).'"'.$PA['onFocus'].' />';    // This is the EDITABLE form field.
1088          $item.='<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';            // This is the ACTUAL form field - values from the EDITABLE field must be transferred to this field which is the one that is written to the database.
1089          $this->extJSCODE.='typo3form.fieldSet('.$paramsList.');';
1090  
1091              // going through all custom evaluations configured for this field
1092          foreach ($evalList as $evalData) {
1093              if (substr($evalData, 0, 3) == 'tx_')    {
1094                  $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$evalData].':&'.$evalData);
1095                  if(is_object($evalObj) && method_exists($evalObj, 'returnFieldJS'))    {
1096                      $this->extJSCODE .= "\n\nfunction ".$evalData."(value) {\n".$evalObj->returnFieldJS()."\n}\n";
1097                  }
1098              }
1099          }
1100  
1101              // Creating an alternative item without the JavaScript handlers.
1102          $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'_hr" value="" />';
1103          $altItem.= '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
1104  
1105              // Wrap a wizard around the item?
1106          $item= $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'].'_hr',$specConf);
1107  
1108          return $item;
1109      }
1110  
1111      /**
1112       * Generation of TCEform elements of the type "text"
1113       * This will render a <textarea> OR RTE area form field, possibly with various control/validation features
1114       *
1115       * @param    string        The table name of the record
1116       * @param    string        The field name which this element is supposed to edit
1117       * @param    array        The record data array where the value(s) for the field can be found
1118       * @param    array        An array with additional configuration options.
1119       * @return    string        The HTML code for the TCEform field
1120       */
1121  	function getSingleField_typeText($table,$field,$row,&$PA)    {
1122  
1123              // Init config:
1124          $config = $PA['fieldConf']['config'];
1125  
1126          if($this->renderReadonly || $config['readOnly'])  {
1127              return $this->getSingleField_typeNone_render($config, $PA['itemFormElValue']);
1128          }
1129  
1130              // Setting columns number:
1131          $cols = t3lib_div::intInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
1132  
1133              // Setting number of rows:
1134          $origRows = $rows = t3lib_div::intInRange($config['rows'] ? $config['rows'] : 5, 1, 20);
1135          if (strlen($PA['itemFormElValue']) > $this->charsPerRow*2)    {
1136              $cols = $this->maxTextareaWidth;
1137              $rows = t3lib_div::intInRange(round(strlen($PA['itemFormElValue'])/$this->charsPerRow), count(explode(chr(10),$PA['itemFormElValue'])), 20);
1138              if ($rows<$origRows)    $rows = $origRows;
1139          }
1140  
1141              // Init RTE vars:
1142          $RTEwasLoaded = 0;                // Set true, if the RTE is loaded; If not a normal textarea is shown.
1143          $RTEwouldHaveBeenLoaded = 0;    // Set true, if the RTE would have been loaded if it wasn't for the disable-RTE flag in the bottom of the page...
1144  
1145              // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. Traditionally, this is where RTE configuration has been found.
1146          $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1147  
1148              // Setting up the altItem form field, which is a hidden field containing the value
1149          $altItem = '<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
1150  
1151              // If RTE is generally enabled (TYPO3_CONF_VARS and user settings)
1152          if ($this->RTEenabled) {
1153              $p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
1154              if (isset($specConf['richtext']) && (!$p['flag'] || !$row[$p['flag']]))    {    // If the field is configured for RTE and if any flag-field is not set to disable it.
1155                  t3lib_BEfunc::fixVersioningPid($table,$row);
1156                  list($tscPID,$thePidValue) = $this->getTSCpid($table,$row['uid'],$row['pid']);
1157  
1158                      // If the pid-value is not negative (that is, a pid could NOT be fetched)
1159                  if ($thePidValue >= 0)    {
1160                      $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($tscPID));
1161                      $RTEtypeVal = t3lib_BEfunc::getTCAtypeValue($table,$row);
1162                      $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$table,$field,$RTEtypeVal);
1163  
1164                      if (!$thisConfig['disabled'])    {
1165                          if (!$this->disableRTE)    {
1166                              $this->RTEcounter++;
1167  
1168                                  // Find alternative relative path for RTE images/links:
1169                              $eFile = t3lib_parsehtml_proc::evalWriteFile($specConf['static_write'], $row);
1170                              $RTErelPath = is_array($eFile) ? dirname($eFile['relEditFile']) : '';
1171  
1172                                  // Get RTE object, draw form and set flag:
1173                              $RTEobj = &t3lib_BEfunc::RTEgetObj();
1174                              $item = $RTEobj->drawRTE($this,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue);
1175  
1176                                  // Wizard:
1177                              $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf,1);
1178  
1179                              $RTEwasLoaded = 1;
1180                          } else {
1181                              $RTEwouldHaveBeenLoaded = 1;
1182                              $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!)';
1183                          }
1184                      } else $this->commentMessages[] = $PA['itemFormElName'].': RTE is disabled by the Page TSconfig, "RTE"-key (eg. by RTE.default.disabled=0 or such)';
1185                  } else $this->commentMessages[] = $PA['itemFormElName'].': PID value could NOT be fetched. Rare error, normally with new records.';
1186              } else {
1187                  if (!isset($specConf['richtext']))    $this->commentMessages[] = $PA['itemFormElName'].': RTE was not configured for this field in TCA-types';
1188                  if (!(!$p['flag'] || !$row[$p['flag']]))     $this->commentMessages[] = $PA['itemFormElName'].': Field-flag ('.$PA['flag'].') has been set to disable RTE!';
1189              }
1190          }
1191  
1192              // Display ordinary field if RTE was not loaded.
1193          if (!$RTEwasLoaded) {
1194              if ($specConf['rte_only'])    {    // Show message, if no RTE (field can only be edited with RTE!)
1195                  $item = '<p><em>'.htmlspecialchars($this->getLL('l_noRTEfound')).'</em></p>';
1196              } else {
1197                  if ($specConf['nowrap'])    {
1198                      $wrap = 'off';
1199                  } else {
1200                      $wrap = ($config['wrap'] ? $config['wrap'] : 'virtual');
1201                  }
1202  
1203                  $classes = array();
1204                  if ($specConf['fixed-font'])    { $classes[] = 'fixed-font'; }
1205                  if ($specConf['enable-tab'])    { $classes[] = 'enable-tab'; }
1206  
1207                  $formWidthText = $this->formWidthText($cols,$wrap);
1208  
1209                      // Extract class attributes from $formWidthText (otherwise it would be added twice to the output)
1210                  if (preg_match('/ class="(.+?)"/',$formWidthText,$res))    {
1211                      $formWidthText = str_replace(' class="'.$res[1].'"','',$formWidthText);
1212                      $classes = array_merge($classes, explode(' ',$res[1]));
1213                  }
1214  
1215                  if (count($classes))    {
1216                      $class = ' class="'.implode(' ',$classes).'"';
1217                  } else $class='';
1218  
1219                  $iOnChange = implode('',$PA['fieldChangeFunc']);
1220                  $item.= '
1221                              <textarea name="'.$PA['itemFormElName'].'"'.$formWidthText.$class.' rows="'.$rows.'" wrap="'.$wrap.'" onchange="'.htmlspecialchars($iOnChange).'"'.$PA['onFocus'].'>'.
1222                              t3lib_div::formatForTextarea($PA['itemFormElValue']).
1223                              '</textarea>';
1224                  $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf,$RTEwouldHaveBeenLoaded);
1225              }
1226          }
1227  
1228              // Return field HTML:
1229          return $item;
1230      }
1231  
1232      /**
1233       * Generation of TCEform elements of the type "check"
1234       * This will render a check-box OR an array of checkboxes
1235       *
1236       * @param    string        The table name of the record
1237       * @param    string        The field name which this element is supposed to edit
1238       * @param    array        The record data array where the value(s) for the field can be found
1239       * @param    array        An array with additional configuration options.
1240       * @return    string        The HTML code for the TCEform field
1241       */
1242  	function getSingleField_typeCheck($table,$field,$row,&$PA)    {
1243          $config = $PA['fieldConf']['config'];
1244  
1245          $disabled = '';
1246          if($this->renderReadonly || $config['readOnly'])  {
1247              $disabled = ' disabled="disabled"';
1248          }
1249  
1250              // Traversing the array of items:
1251          $selItems = $this->initItemArray($PA['fieldConf']);
1252          if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
1253  
1254          if (!count($selItems))    {
1255              $selItems[]=array('','');
1256          }
1257          $thisValue = intval($PA['itemFormElValue']);
1258  
1259          $cols = intval($config['cols']);
1260          if ($cols > 1)    {
1261              $item.= '<table border="0" cellspacing="0" cellpadding="0" class="typo3-TCEforms-checkboxArray">';
1262              for ($c=0;$c<count($selItems);$c++) {
1263                  $p = $selItems[$c];
1264                  if(!($c%$cols))    { $item.='<tr>'; }
1265                  $cBP = $this->checkBoxParams($PA['itemFormElName'],$thisValue,$c,count($selItems),implode('',$PA['fieldChangeFunc']));
1266                  $cBName = $PA['itemFormElName'].'_'.$c;
1267                  $cBID = $PA['itemFormElID'].'_'.$c;
1268                  $item.= '<td nowrap="nowrap">'.
1269                          '<input type="checkbox"'.$this->insertDefStyle('check').' value="1" name="'.$cBName.'"'.$cBP.$disabled.' id="'.$cBID.'" />'.
1270                          $this->wrapLabels('<label for="'.$cBID.'">'.htmlspecialchars($p[0]).'</label>&nbsp;').
1271                          '</td>';
1272                  if(($c%$cols)+1==$cols)    {$item.='</tr>';}
1273              }
1274              if ($c%$cols)    {
1275                  $rest=$cols-($c%$cols);
1276                  for ($c=0;$c<$rest;$c++) {
1277                      $item.= '<td></td>';
1278                  }
1279                  if ($c>0)    { $item.= '</tr>'; }
1280              }
1281              $item.= '</table>';
1282          } else {
1283              for ($c=0;$c<count($selItems);$c++) {
1284                  $p = $selItems[$c];
1285                  $cBP = $this->checkBoxParams($PA['itemFormElName'],$thisValue,$c,count($selItems),implode('',$PA['fieldChangeFunc']));
1286                  $cBName = $PA['itemFormElName'].'_'.$c;
1287                  $cBID = $PA['itemFormElID'].'_'.$c;
1288                  $item.= ($c>0?'<br />':'').
1289                          '<input type="checkbox"'.$this->insertDefStyle('check').' value="1" name="'.$cBName.'"'.$cBP.$PA['onFocus'].$disabled.' id="'.$cBID.'" />'.
1290                          htmlspecialchars($p[0]);
1291              }
1292          }
1293          if (!$disabled) {
1294              $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($thisValue).'" />';
1295          }
1296  
1297          return $item;
1298      }
1299  
1300      /**
1301       * Generation of TCEform elements of the type "radio"
1302       * This will render a series of radio buttons.
1303       *
1304       * @param    string        The table name of the record
1305       * @param    string        The field name which this element is supposed to edit
1306       * @param    array        The record data array where the value(s) for the field can be found
1307       * @param    array        An array with additional configuration options.
1308       * @return    string        The HTML code for the TCEform field
1309       */
1310  	function getSingleField_typeRadio($table,$field,$row,&$PA)    {
1311          $config = $PA['fieldConf']['config'];
1312  
1313          $disabled = '';
1314          if($this->renderReadonly || $config['readOnly'])  {
1315              $disabled = ' disabled="disabled"';
1316          }
1317  
1318              // Get items for the array:
1319          $selItems = $this->initItemArray($PA['fieldConf']);
1320          if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
1321  
1322              // Traverse the items, making the form elements:
1323          for ($c=0;$c<count($selItems);$c++) {
1324              $p = $selItems[$c];
1325              $rID = $PA['itemFormElID'].'_'.$c;
1326              $rOnClick = implode('',$PA['fieldChangeFunc']);
1327              $rChecked = (!strcmp($p[1],$PA['itemFormElValue'])?' checked="checked"':'');
1328              $item.= '<input type="radio"'.$this->insertDefStyle('radio').' name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($p[1]).'" onclick="'.htmlspecialchars($rOnClick).'"'.$rChecked.$PA['onFocus'].$disabled.' id="'.$rID.'" />
1329                      <label for="'.$rID.'">'.htmlspecialchars($p[0]).'</label>
1330                      <br />';
1331          }
1332  
1333          return $item;
1334      }
1335  
1336      /**
1337       * Generation of TCEform elements of the type "select"
1338       * This will render a selector box element, or possibly a special construction with two selector boxes. That depends on configuration.
1339       *
1340       * @param    string        The table name of the record
1341       * @param    string        The field name which this element is supposed to edit
1342       * @param    array        The record data array where the value(s) for the field can be found
1343       * @param    array        An array with additional configuration options.
1344       * @return    string        The HTML code for the TCEform field
1345       */
1346  	function getSingleField_typeSelect($table,$field,$row,&$PA)    {
1347          global $TCA;
1348  
1349              // Field configuration from TCA:
1350          $config = $PA['fieldConf']['config'];
1351  
1352          $disabled = '';
1353          if($this->renderReadonly || $config['readOnly'])  {
1354              $disabled = ' disabled="disabled"';
1355          }
1356  
1357              // "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/.
1358          $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1359  
1360              // Getting the selector box items from the system
1361          $selItems = $this->addSelectOptionsToItemArray($this->initItemArray($PA['fieldConf']),$PA['fieldConf'],$this->setTSconfig($table,$row),$field);
1362          $selItems = $this->addItems($selItems,$PA['fieldTSConfig']['addItems.']);
1363          if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
1364  
1365              // Possibly remove some items:
1366          $removeItems = t3lib_div::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
1367          foreach($selItems as $tk => $p)    {
1368  
1369                  // Checking languages and authMode:
1370              $languageDeny = $TCA[$table]['ctrl']['languageField'] && !strcmp($TCA[$table]['ctrl']['languageField'], $field) && !$GLOBALS['BE_USER']->checkLanguageAccess($p[1]);
1371              $authModeDeny = $config['form_type']=='select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table,$field,$p[1],$config['authMode']);
1372              if (in_array($p[1],$removeItems) || $languageDeny || $authModeDeny)    {
1373                  unset($selItems[$tk]);
1374              } elseif (isset($PA['fieldTSConfig']['altLabels.'][$p[1]])) {
1375                  $selItems[$tk][0]=$this->sL($PA['fieldTSConfig']['altLabels.'][$p[1]]);
1376              }
1377  
1378                  // Removing doktypes with no access:
1379              if ($table.'.'.$field == 'pages.doktype')    {
1380                  if (!($GLOBALS['BE_USER']->isAdmin() || t3lib_div::inList($GLOBALS['BE_USER']->groupData['pagetypes_select'],$p[1])))    {
1381                      unset($selItems[$tk]);
1382                  }
1383              }
1384          }
1385  
1386              // Creating the label for the "No Matching Value" entry.
1387          $nMV_label = isset($PA['fieldTSConfig']['noMatchingValue_label']) ? $this->sL($PA['fieldTSConfig']['noMatchingValue_label']) : '[ '.$this->getLL('l_noMatchingValue').' ]';
1388  
1389              // Prepare some values:
1390          $maxitems = intval($config['maxitems']);
1391  
1392              // If a SINGLE selector box...
1393          if ($maxitems<=1)    {
1394              $item = $this->getSingleField_typeSelect_single($table,$field,$row,$PA,$config,$selItems,$nMV_label);
1395          } elseif (!strcmp($config['renderMode'],'checkbox'))    {    // Checkbox renderMode
1396              $item = $this->getSingleField_typeSelect_checkbox($table,$field,$row,$PA,$config,$selItems,$nMV_label);
1397          } elseif (!strcmp($config['renderMode'],'singlebox'))    {    // Single selector box renderMode
1398              $item = $this->getSingleField_typeSelect_singlebox($table,$field,$row,$PA,$config,$selItems,$nMV_label);
1399          } else {    // Traditional multiple selector box:
1400              $item = $this->getSingleField_typeSelect_multiple($table,$field,$row,$PA,$config,$selItems,$nMV_label);
1401          }
1402  
1403              // Wizards:
1404          if (!$disabled) {
1405              $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
1406              $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf);
1407          }
1408  
1409          return $item;
1410      }
1411  
1412      /**
1413       * Creates a single-selector box
1414       * (Render function for getSingleField_typeSelect())
1415       *
1416       * @param    string        See getSingleField_typeSelect()
1417       * @param    string        See getSingleField_typeSelect()
1418       * @param    array        See getSingleField_typeSelect()
1419       * @param    array        See getSingleField_typeSelect()
1420       * @param    array        (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1421       * @param    array        Items available for selection
1422       * @param    string        Label for no-matching-value
1423       * @return    string        The HTML code for the item
1424       * @see getSingleField_typeSelect()
1425       */
1426  	function getSingleField_typeSelect_single($table,$field,$row,&$PA,$config,$selItems,$nMV_label)    {
1427              // check against inline uniqueness
1428          $inlineParent = $this->inline->getStructureLevel(-1);
1429          if(is_array($inlineParent) && $inlineParent['uid']) {
1430              if ($inlineParent['config']['foreign_table'] == $table && $inlineParent['config']['foreign_unique'] == $field) {
1431                  $uniqueIds = $this->inline->inlineData['unique'][$this->inline->inlineNames['object'].'['.$table.']']['used'];
1432                  $PA['fieldChangeFunc']['inlineUnique'] = "inline.updateUnique(this,'".$this->inline->inlineNames['object'].'['.$table."]','".$this->inline->inlineNames['form']."','".$row['uid']."');";
1433              }
1434                  // hide uid of parent record for symmetric relations
1435              if ($inlineParent['config']['foreign_table'] == $table && ($inlineParent['config']['foreign_field'] == $field || $inlineParent['config']['symmetric_field'] == $field)) {
1436                  $uniqueIds[] = $inlineParent['uid'];
1437              }
1438          }
1439  
1440              // Initialization:
1441          $c = 0;
1442          $sI = 0;
1443          $noMatchingValue = 1;
1444          $opt = array();
1445          $selicons = array();
1446          $onlySelectedIconShown = 0;
1447          $size = intval($config['size']);
1448  
1449          $disabled = '';
1450          if($this->renderReadonly || $config['readOnly'])  {
1451              $disabled = ' disabled="disabled"';
1452              $onlySelectedIconShown = 1;
1453          }
1454  
1455              // Icon configuration:
1456          if ($config['suppress_icons']=='IF_VALUE_FALSE')    {
1457              $suppressIcons = !$PA['itemFormElValue'] ? 1 : 0;
1458          } elseif ($config['suppress_icons']=='ONLY_SELECTED')    {
1459              $suppressIcons=0;
1460              $onlySelectedIconShown=1;
1461          } elseif ($config['suppress_icons'])     {
1462              $suppressIcons = 1;
1463          } else $suppressIcons = 0;
1464  
1465              // Traverse the Array of selector box items:
1466          foreach($selItems as $p)    {
1467              $sM = (!strcmp($PA['itemFormElValue'],$p[1])?' selected="selected"':'');
1468              if ($sM)    {
1469                  $sI = $c;
1470                  $noMatchingValue = 0;
1471              }
1472  
1473                  // Getting style attribute value (for icons):
1474              if ($config['iconsInOptionTags'])    {
1475                  $styleAttrValue = $this->optionTagStyle($p[2]);
1476              }
1477  
1478                  // Compiling the <option> tag:
1479              if (!($p[1] != $PA['itemFormElValue'] && is_array($uniqueIds) && in_array($p[1], $uniqueIds))) {
1480                  $opt[]= '<option value="'.htmlspecialchars($p[1]).'"'.
1481                              $sM.
1482                              ($styleAttrValue ? ' style="'.htmlspecialchars($styleAttrValue).'"' : '').
1483                              (!strcmp($p[1],'--div--') ? ' class="c-divider"' : '').
1484                              '>'.t3lib_div::deHSCentities(htmlspecialchars($p[0])).'</option>';
1485              }
1486  
1487                  // If there is an icon for the selector box (rendered in table under)...:
1488              if ($p[2] && !$suppressIcons && (!$onlySelectedIconShown || $sM))    {
1489                  list($selIconFile,$selIconInfo)=$this->getIcon($p[2]);
1490                  $iOnClick = $this->elName($PA['itemFormElName']).'.selectedIndex='.$c.'; '.implode('',$PA['fieldChangeFunc']).$this->blur().'return false;';
1491                  $selicons[]=array(
1492                      (!$onlySelectedIconShown ? '<a href="#" onclick="'.htmlspecialchars($iOnClick).'">' : '').
1493                      '<img src="'.$selIconFile.'" '.$selIconInfo[3].' vspace="2" border="0" title="'.htmlspecialchars($p[0]).'" alt="'.htmlspecialchars($p[0]).'" />'.
1494                      (!$onlySelectedIconShown ? '</a>' : ''),
1495                      $c,$sM);
1496              }
1497              $c++;
1498          }
1499  
1500              // No-matching-value:
1501          if ($PA['itemFormElValue'] && $noMatchingValue && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement'])    {
1502              $nMV_label = @sprintf($nMV_label, $PA['itemFormElValue']);
1503              $opt[]= '<option value="'.htmlspecialchars($PA['itemFormElValue']).'" selected="selected">'.htmlspecialchars($nMV_label).'</option>';
1504          }
1505  
1506              // Create item form fields:
1507          $sOnChange = 'if (this.options[this.selectedIndex].value==\'--div--\') {this.selectedIndex='.$sI.';} '.implode('',$PA['fieldChangeFunc']);
1508          if(!$disabled) {
1509              $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'_selIconVal" value="'.htmlspecialchars($sI).'" />';    // MUST be inserted before the selector - else is the value of the hiddenfield here mysteriously submitted...
1510          }
1511          $item.= '<select name="'.$PA['itemFormElName'].'"'.
1512                      $this->insertDefStyle('select').
1513                      ($size?' size="'.$size.'"':'').
1514                      ' onchange="'.htmlspecialchars($sOnChange).'"'.
1515                      $PA['onFocus'].$disabled.'>';
1516          $item.= implode('',$opt);
1517          $item.= '</select>';
1518  
1519              // Create icon table:
1520          if (count($selicons))    {
1521              $item.='<table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-selectIcons">';
1522              $selicon_cols = intval($config['selicon_cols']);
1523              if (!$selicon_cols)    $selicon_cols=count($selicons);
1524              $sR = ceil(count($selicons)/$selicon_cols);
1525              $selicons = array_pad($selicons,$sR*$selicon_cols,'');
1526              for($sa=0;$sa<$sR;$sa++)    {
1527                  $item.='<tr>';
1528                  for($sb=0;$sb<$selicon_cols;$sb++)    {
1529                      $sk=($sa*$selicon_cols+$sb);
1530                      $imgN = 'selIcon_'.$table.'_'.$row['uid'].'_'.$field.'_'.$selicons[$sk][1];
1531                      $imgS = ($selicons[$sk][2]?$this->backPath.'gfx/content_selected.gif':'clear.gif');
1532                      $item.='<td><img name="'.htmlspecialchars($imgN).'" src="'.$imgS.'" width="7" height="10" alt="" /></td>';
1533                      $item.='<td>'.$selicons[$sk][0].'</td>';
1534                  }
1535                  $item.='</tr>';
1536              }
1537              $item.='</table>';
1538          }
1539  
1540          return $item;
1541      }
1542  
1543      /**
1544       * Creates a checkbox list (renderMode = "checkbox")
1545       * (Render function for getSingleField_typeSelect())
1546       *
1547       * @param    string        See getSingleField_typeSelect()
1548       * @param    string        See getSingleField_typeSelect()
1549       * @param    array        See getSingleField_typeSelect()
1550       * @param    array        See getSingleField_typeSelect()
1551       * @param    array        (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1552       * @param    array        Items available for selection
1553       * @param    string        Label for no-matching-value
1554       * @return    string        The HTML code for the item
1555       * @see getSingleField_typeSelect()
1556       */
1557  	function getSingleField_typeSelect_checkbox($table,$field,$row,&$PA,$config,$selItems,$nMV_label)    {
1558  
1559              // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
1560          $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
1561  
1562          $disabled = '';
1563          if($this->renderReadonly || $config['readOnly'])  {
1564              $disabled = ' disabled="disabled"';
1565          }
1566  
1567              // Traverse the Array of selector box items:
1568          $tRows = array();
1569          $c=0;
1570          if (!$disabled) {
1571              $sOnChange = implode('',$PA['fieldChangeFunc']);
1572              $setAll = array();    // Used to accumulate the JS needed to restore the original selection.
1573              foreach($selItems as $p)    {
1574                      // Non-selectable element:
1575                  if (!strcmp($p[1],'--div--'))    {
1576                      if (count($setAll))    {
1577                              $tRows[] = '
1578                                  <tr>
1579                                      <td colspan="2">'.
1580                                      '<a href="#" onclick="'.htmlspecialchars(implode('',$setAll).' return false;').'">'.
1581                                      htmlspecialchars($this->getLL('l_setAllCheckboxes')).
1582                                      '</a></td>
1583                                  </tr>';
1584                              $setAll = array();
1585                      }
1586  
1587                      $tRows[] = '
1588                          <tr class="c-header">
1589                              <td colspan="2">'.htmlspecialchars($p[0]).'</td>
1590                          </tr>';
1591                  } else {
1592                          // Selected or not by default:
1593                      $sM = '';
1594                      if (isset($itemArray[$p[1]]))    {
1595                          $sM = ' checked="checked"';
1596                          unset($itemArray[$p[1]]);
1597                      }
1598  
1599                          // Icon:
1600                      $selIconFile = '';
1601                      if ($p[2])    {
1602                          list($selIconFile,$selIconInfo) = $this->getIcon($p[2]);
1603                      }
1604  
1605                          // Compile row:
1606                      $onClickCell = $this->elName($PA['itemFormElName'].'['.$c.']').'.checked=!'.$this->elName($PA['itemFormElName'].'['.$c.']').'.checked;';
1607                      $onClick = 'this.attributes.getNamedItem("class").nodeValue = '.$this->elName($PA['itemFormElName'].'['.$c.']').'.checked ? "c-selectedItem" : "";';
1608                      $setAll[] = $this->elName($PA['itemFormElName'].'['.$c.']').'.checked=1;';
1609                      $tRows[] = '
1610                          <tr class="'.($sM ? 'c-selectedItem' : '').'" onclick="'.htmlspecialchars($onClick).'" style="cursor: pointer;">
1611                              <td><input type="checkbox"'.$this->insertDefStyle('check').' name="'.htmlspecialchars($PA['itemFormElName'].'['.$c.']').'" value="'.htmlspecialchars($p[1]).'"'.$sM.' onclick="'.htmlspecialchars($sOnChange).'"'.$PA['onFocus'].' /></td>
1612                              <td class="c-labelCell" onclick="'.htmlspecialchars($onClickCell).'">'.
1613                                  ($selIconFile ? '<img src="'.$selIconFile.'" '.$selIconInfo[3].' vspace="2" border="0" class="absmiddle" style="margin-right: 4px;" alt="" />' : '').
1614                                  t3lib_div::deHSCentities(htmlspecialchars($p[0])).
1615                                  (strcmp($p[3],'') ? '<br/><p class="c-descr">'.nl2br(trim(htmlspecialchars($p[3]))).'</p>' : '').
1616                                  '</td>
1617                          </tr>';
1618                      $c++;
1619                  }
1620              }
1621  
1622                  // Remaining checkboxes will get their set-all link:
1623              if (count($setAll))    {
1624                      $tRows[] = '
1625                          <tr>
1626                              <td colspan="2">'.
1627                              '<a href="#" onclick="'.htmlspecialchars(implode('',$setAll).' return false;').'">'.
1628                              htmlspecialchars($this->getLL('l_setAllCheckboxes')).
1629                              '</a></td>
1630                          </tr>';
1631              }
1632          }
1633  
1634              // Remaining values (invalid):
1635          if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement'])    {
1636              foreach($itemArray as $theNoMatchValue => $temp)    {
1637                      // Compile <checkboxes> tag:
1638                  array_unshift($tRows,'
1639                          <tr class="c-invalidItem">
1640                              <td><input type="checkbox"'.$this->insertDefStyle('check').' name="'.htmlspecialchars($PA['itemFormElName'].'['.$c.']').'" value="'.htmlspecialchars($theNoMatchValue).'" checked="checked" onclick="'.htmlspecialchars($sOnChange).'"'.$PA['onFocus'].$disabled.' /></td>
1641                              <td class="c-labelCell">'.
1642                                  t3lib_div::deHSCentities(htmlspecialchars(@sprintf($nMV_label, $theNoMatchValue))).
1643                                  '</td>
1644                          </tr>');
1645                  $c++;
1646              }
1647          }
1648  
1649              // Add an empty hidden field which will send a blank value if all items are unselected.
1650          $item.='<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="" />';
1651  
1652              // Implode rows in table:
1653          $item.= '
1654              <table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-select-checkbox">'.
1655                  implode('',$tRows).'
1656              </table>
1657              ';
1658  
1659          return $item;
1660      }
1661  
1662      /**
1663       * Creates a selectorbox list (renderMode = "singlebox")
1664       * (Render function for getSingleField_typeSelect())
1665       *
1666       * @param    string        See getSingleField_typeSelect()
1667       * @param    string        See getSingleField_typeSelect()
1668       * @param    array        See getSingleField_typeSelect()
1669       * @param    array        See getSingleField_typeSelect()
1670       * @param    array        (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1671       * @param    array        Items available for selection
1672       * @param    string        Label for no-matching-value
1673       * @return    string        The HTML code for the item
1674       * @see getSingleField_typeSelect()
1675       */
1676  	function getSingleField_typeSelect_singlebox($table,$field,$row,&$PA,$config,$selItems,$nMV_label)    {
1677  
1678              // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
1679          $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
1680  
1681          $disabled = '';
1682          if($this->renderReadonly || $config['readOnly'])  {
1683              $disabled = ' disabled="disabled"';
1684          }
1685  
1686              // Traverse the Array of selector box items:
1687          $opt = array();
1688          $restoreCmd = array();    // Used to accumulate the JS needed to restore the original selection.
1689          $c = 0;
1690          foreach($selItems as $p)    {
1691                  // Selected or not by default:
1692              $sM = '';
1693              if (isset($itemArray[$p[1]]))    {
1694                  $sM = ' selected="selected"';
1695                  $restoreCmd[] = $this->elName($PA['itemFormElName'].'[]').'.options['.$c.'].selected=1;';
1696                  unset($itemArray[$p[1]]);
1697              }
1698  
1699                  // Non-selectable element:
1700              $nonSel = '';
1701              if (!strcmp($p[1],'--div--'))    {
1702                  $nonSel = ' onclick="this.selected=0;" class="c-divider"';
1703              }
1704  
1705                  // Icon style for option tag:
1706              if ($config['iconsInOptionTags']) {
1707                  $styleAttrValue = $this->optionTagStyle($p[2]);
1708              }
1709  
1710                  // Compile <option> tag:
1711              $opt[] = '<option value="'.htmlspecialchars($p[1]).'"'.
1712                          $sM.
1713                          $nonSel.
1714                          ($styleAttrValue ? ' style="'.htmlspecialchars($styleAttrValue).'"' : '').
1715                          '>'.t3lib_div::deHSCentities(htmlspecialchars($p[0])).'</option>';
1716              $c++;
1717          }
1718  
1719              // Remaining values:
1720          if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement'])    {
1721              foreach($itemArray as $theNoMatchValue => $temp)    {
1722                      // Compile <option> tag:
1723                  array_unshift($opt,'<option value="'.htmlspecialchars($theNoMatchValue).'" selected="selected">'.t3lib_div::deHSCentities(htmlspecialchars(@sprintf($nMV_label, $theNoMatchValue))).'</option>');
1724              }
1725          }
1726  
1727              // Compile selector box:
1728          $sOnChange = implode('',$PA['fieldChangeFunc']);
1729          $selector_itemListStyle = isset($config['itemListStyle']) ? ' style="'.htmlspecialchars($config['itemListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"';
1730          $size = intval($config['size']);
1731          $size = $config['autoSizeMax'] ? t3lib_div::intInRange(count($selItems)+1,t3lib_div::intInRange($size,1),$config['autoSizeMax']) : $size;
1732          $selectBox = '<select name="'.$PA['itemFormElName'].'[]"'.
1733                          $this->insertDefStyle('select').
1734                          ($size ? ' size="'.$size.'"' : '').
1735                          ' multiple="multiple" onchange="'.htmlspecialchars($sOnChange).'"'.
1736                          $PA['onFocus'].
1737                          $selector_itemListStyle.
1738                          $disabled.'>
1739                          '.
1740                      implode('
1741                          ',$opt).'
1742                      </select>';
1743  
1744              // Add an empty hidden field which will send a blank value if all items are unselected.
1745          if (!$disabled) {
1746              $item.='<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="" />';
1747          }
1748  
1749              // Put it all into a table:
1750          $item.= '
1751              <table border="0" cellspacing="0" cellpadding="0" width="1" class="typo3-TCEforms-select-singlebox">
1752                  <tr>
1753                      <td>
1754                      '.$selectBox.'
1755                      <br/>
1756                      <em>'.
1757                          htmlspecialchars($this->getLL('l_holdDownCTRL')).
1758                          '</em>
1759                      </td>
1760                      <td valign="top">
1761                      <a href="#" onclick="'.htmlspecialchars($this->elName($PA['itemFormElName'].'[]').'.selectedIndex=-1;'.implode('',$restoreCmd).' return false;').'">'.
1762                          '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/history.gif','width="13" height="12"').' title="'.htmlspecialchars($this->getLL('l_revertSelection')).'" alt="" />'.
1763                          '</a>
1764                      </td>
1765                  </tr>
1766              </table>
1767                  ';
1768  
1769          return $item;
1770      }
1771  
1772      /**
1773       * Creates a multiple-selector box (two boxes, side-by-side)
1774       * (Render function for getSingleField_typeSelect())
1775       *
1776       * @param    string        See getSingleField_typeSelect()
1777       * @param    string        See getSingleField_typeSelect()
1778       * @param    array        See getSingleField_typeSelect()
1779       * @param    array        See getSingleField_typeSelect()
1780       * @param    array        (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1781       * @param    array        Items available for selection
1782       * @param    string        Label for no-matching-value
1783       * @return    string        The HTML code for the item
1784       * @see getSingleField_typeSelect()
1785       */
1786  	function getSingleField_typeSelect_multiple($table,$field,$row,&$PA,$config,$selItems,$nMV_label)    {
1787  
1788          $disabled = '';
1789          if($this->renderReadonly || $config['readOnly'])  {
1790              $disabled = ' disabled="disabled"';
1791          }
1792  
1793              // Setting this hidden field (as a flag that JavaScript can read out)
1794          if (!$disabled) {
1795              $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'_mul" value="'.($config['multiple']?1:0).'" />';
1796          }
1797  
1798              // Set max and min items:
1799          $maxitems = t3lib_div::intInRange($config['maxitems'],0);
1800          if (!$maxitems)    $maxitems=100000;
1801          $minitems = t3lib_div::intInRange($config['minitems'],0);
1802  
1803              // Register the required number of elements:
1804          $this->requiredElements[$PA['itemFormElName']] = array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field);
1805  
1806              // Get "removeItems":
1807          $removeItems = t3lib_div::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
1808  
1809              // Perform modification of the selected items array:
1810          $itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
1811          foreach($itemArray as $tk => $tv) {
1812              $tvP = explode('|',$tv,2);
1813              $evalValue = rawurldecode($tvP[0]);
1814              $isRemoved = in_array($evalValue,$removeItems)  || ($config['form_type']=='select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table,$field,$evalValue,$config['authMode']));
1815              if ($isRemoved && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement'])    {
1816                  $tvP[1] = rawurlencode(@sprintf($nMV_label, $evalValue));
1817              } elseif (isset($PA['fieldTSConfig']['altLabels.'][$evalValue])) {
1818                  $tvP[1] = rawurlencode($this->sL($PA['fieldTSConfig']['altLabels.'][$evalValue]));
1819              }
1820              $itemArray[$tk] = implode('|',$tvP);
1821          }
1822          $itemsToSelect = '';
1823  
1824          if(!$disabled) {
1825                  // Create option tags:
1826              $opt = array();
1827              $styleAttrValue = '';
1828              foreach($selItems as $p)    {
1829                  if ($config['iconsInOptionTags'])    {
1830                      $styleAttrValue = $this->optionTagStyle($p[2]);
1831                  }
1832                  $opt[]= '<option value="'.htmlspecialchars($p[1]).'"'.
1833                                  ($styleAttrValue ? ' style="'.htmlspecialchars($styleAttrValue).'"' : '').
1834                                  '>'.htmlspecialchars($p[0]).'</option>';
1835              }
1836  
1837                  // Put together the selector box:
1838              $selector_itemListStyle = isset($config['itemListStyle']) ? ' style="'.htmlspecialchars($config['itemListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"';
1839              $size = intval($config['size']);
1840              $size = $config['autoSizeMax'] ? t3lib_div::intInRange(count($itemArray)+1,t3lib_div::intInRange($size,1),$config['autoSizeMax']) : $size;
1841              if ($config['exclusiveKeys'])    {
1842                  $sOnChange = 'setFormValueFromBrowseWin(\''.$PA['itemFormElName'].'\',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text,\''.$config['exclusiveKeys'].'\'); ';
1843              } else {
1844                  $sOnChange = 'setFormValueFromBrowseWin(\''.$PA['itemFormElName'].'\',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text); ';
1845              }
1846              $sOnChange .= implode('',$PA['fieldChangeFunc']);
1847              $itemsToSelect = '
1848                  <select name="'.$PA['itemFormElName'].'_sel"'.
1849                              $this->insertDefStyle('select').
1850                              ($size ? ' size="'.$size.'"' : '').
1851                              ' onchange="'.htmlspecialchars($sOnChange).'"'.
1852                              $PA['onFocus'].
1853                              $selector_itemListStyle.'>
1854                      '.implode('
1855                      ',$opt).'
1856                  </select>';
1857          }
1858  
1859              // Pass to "dbFileIcons" function:
1860          $params = array(
1861              'size' => $size,
1862              'autoSizeMax' => t3lib_div::intInRange($config['autoSizeMax'],0),
1863              'style' => isset($config['selectedListStyle']) ? ' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"',
1864              'dontShowMoveIcons' => ($maxitems<=1),
1865              'maxitems' => $maxitems,
1866              'info' => '',
1867              'headers' => array(
1868                  'selector' => $this->getLL('l_selected').':<br />',
1869                  'items' => $this->getLL('l_items').':<br />'
1870              ),
1871              'noBrowser' => 1,
1872              'thumbnails' => $itemsToSelect,
1873              'readOnly' => $disabled
1874          );
1875          $item.= $this->dbFileIcons($PA['itemFormElName'],'','',$itemArray,'',$params,$PA['onFocus']);
1876  
1877          return $item;
1878      }
1879  
1880      /**
1881       * Generation of TCEform elements of the type "group"
1882       * This will render a selectorbox into which elements from either the file system or database can be inserted. Relations.
1883       *
1884       * @param    string        The table name of the record
1885       * @param    string        The field name which this element is supposed to edit
1886       * @param    array        The record data array where the value(s) for the field can be found
1887       * @param    array        An array with additional configuration options.
1888       * @return    string        The HTML code for the TCEform field
1889       */
1890  	function getSingleField_typeGroup($table,$field,$row,&$PA)    {
1891              // Init:
1892          $config = $PA['fieldConf']['config'];
1893          $internal_type = $config['internal_type'];
1894          $show_thumbs = $config['show_thumbs'];
1895          $size = intval($config['size']);
1896          $maxitems = t3lib_div::intInRange($config['maxitems'],0);
1897          if (!$maxitems)    $maxitems=100000;
1898          $minitems = t3lib_div::intInRange($config['minitems'],0);
1899          $allowed = $config['allowed'];
1900          $disallowed = $config['disallowed'];
1901  
1902          $disabled = '';
1903          if($this->renderReadonly || $config['readOnly'])  {
1904              $disabled = ' disabled="disabled"';
1905          }
1906  
1907          $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'_mul" value="'.($config['multiple']?1:0).'"'.$disabled.' />';
1908          $this->requiredElements[$PA['itemFormElName']] = array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field);
1909          $info='';
1910  
1911              // "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/.
1912          $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
1913  
1914              // Acting according to either "file" or "db" type:
1915          switch((string)$config['internal_type'])    {
1916              case 'file':    // If the element is of the internal type "file":
1917  
1918                      // Creating string showing allowed types:
1919                  $tempFT = t3lib_div::trimExplode(',',$allowed,1);
1920                  if (!count($tempFT))    {$info.='*';}
1921                  foreach($tempFT as $ext)    {
1922                      if ($ext)    {
1923                          $info.=strtoupper($ext).' ';
1924                      }
1925                  }
1926                      // Creating string, showing disallowed types:
1927                  $tempFT_dis = t3lib_div::trimExplode(',',$disallowed,1);
1928                  if (count($tempFT_dis))    {$info.='<br />';}
1929                  foreach($tempFT_dis as $ext)    {
1930                      if ($ext)    {
1931                          $info.='-'.strtoupper($ext).' ';
1932                      }
1933                  }
1934  
1935                      // Making the array of file items:
1936                  $itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
1937  
1938                      // Showing thumbnails:
1939                  $thumbsnail = '';
1940                  if ($show_thumbs)    {
1941                      $imgs = array();
1942                      foreach($itemArray as $imgRead)    {
1943                          $imgP = explode('|',$imgRead);
1944                          $imgPath = rawurldecode($imgP[0]);
1945  
1946                          $rowCopy = array();
1947                          $rowCopy[$field] = $imgPath;
1948  
1949                              // Icon + clickmenu:
1950                          $absFilePath = t3lib_div::getFileAbsFileName($config['uploadfolder'].'/'.$imgPath);
1951  
1952                          $fI = pathinfo($imgPath);
1953                          $fileIcon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
1954                          $fileIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/fileicons/'.$fileIcon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].($absFilePath && @is_file($absFilePath) ? ' ('.t3lib_div::formatSize(filesize($absFilePath)).'bytes)' : ' - FILE NOT FOUND!')).'" alt="" />';
1955  
1956                          $imgs[] = '<span class="nobr">'.t3lib_BEfunc::thumbCode($rowCopy,$table,$field,$this->backPath,'thumbs.php',$config['uploadfolder'],0,' align="middle"').
1957                                      ($absFilePath ? $this->getClickMenu($fileIcon, $absFilePath) : $fileIcon).
1958                                      $imgPath.
1959                                      '</span>';
1960                      }
1961                      $thumbsnail = implode('<br />',$imgs);
1962                  }
1963  
1964                      // Creating the element:
1965                  $params = array(
1966                      'size' => $size,
1967                      'dontShowMoveIcons' => ($maxitems<=1),
1968                      'autoSizeMax' => t3lib_div::intInRange($config['autoSizeMax'],0),
1969                      'maxitems' => $maxitems,
1970                      'style' => isset($config['selectedListStyle']) ? ' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"',
1971                      'info' => $info,
1972                      'thumbnails' => $thumbsnail,
1973                      'readOnly' => $disabled
1974                  );
1975                  $item.= $this->dbFileIcons($PA['itemFormElName'],'file',implode(',',$tempFT),$itemArray,'',$params,$PA['onFocus']);
1976  
1977                  if(!$disabled) {
1978                          // Adding the upload field:
1979                      if ($this->edit_docModuleUpload)    $item.='<input type="file" name="'.$PA['itemFormElName_file'].'"'.$this->formWidth().' size="60" />';
1980                  }
1981              break;
1982              case 'db':    // If the element is of the internal type "db":
1983  
1984                      // Creating string showing allowed types:
1985                  $tempFT = t3lib_div::trimExplode(',',$allowed,1);
1986                  if (!strcmp(trim($tempFT[0]),'*'))    {
1987                      $info.='<span class="nobr">&nbsp;&nbsp;&nbsp;&nbsp;'.
1988                              htmlspecialchars($this->getLL('l_allTables')).
1989                              '</span><br />';
1990                  } else {
1991                      while(list(,$theT)=each($tempFT))    {
1992                          if ($theT)    {
1993                              $info.='<span class="nobr">&nbsp;&nbsp;&nbsp;&nbsp;'.
1994                                      t3lib_iconWorks::getIconImage($theT,array(),$this->backPath,'align="top"').
1995                                      htmlspecialchars($this->sL($GLOBALS['TCA'][$theT]['ctrl']['title'])).
1996                                      '</span><br />';
1997                          }
1998                      }
1999                  }
2000  
2001                  $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
2002                  $itemArray = array();
2003                  $imgs = array();
2004  
2005                      // Thumbnails:
2006                  $temp_itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
2007                  foreach($temp_itemArray as $dbRead)    {
2008                      $recordParts = explode('|',$dbRead);
2009                      list($this_table,$this_uid) = t3lib_BEfunc::splitTable_Uid($recordParts[0]);
2010                      $itemArray[] = array('table'=>$this_table, 'id'=>$this_uid);
2011                      if (!$disabled && $show_thumbs)    {
2012                          $rr = t3lib_BEfunc::getRecordWSOL($this_table,$this_uid);
2013                          $imgs[] = '<span class="nobr">'.
2014                                  $this->getClickMenu(t3lib_iconWorks::getIconImage($this_table,$rr,$this->backPath,'align="top" title="'.htmlspecialchars(t3lib_BEfunc::getRecordPath($rr['pid'],$perms_clause,15)).' [UID: '.$rr['uid'].']"'),$this_table, $this_uid).
2015                                  '&nbsp;'.
2016                                  t3lib_BEfunc::getRecordTitle($this_table,$rr,TRUE).' <span class="typo3-dimmed"><em>['.$rr['uid'].']</em></span>'.
2017                                  '</span>';
2018                      }
2019                  }
2020                  $thumbsnail='';
2021                  if (!$disabled && $show_thumbs)    {
2022                      $thumbsnail = implode('<br />',$imgs);
2023                  }
2024  
2025                      // Creating the element:
2026                  $params = array(
2027                      'size' => $size,
2028                      'dontShowMoveIcons' => ($maxitems<=1),
2029                      'autoSizeMax' => t3lib_div::intInRange($config['autoSizeMax'],0),
2030                      'maxitems' => $maxitems,
2031                      'style' => isset($config['selectedListStyle']) ? ' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"',
2032                      'info' => $info,
2033                      'thumbnails' => $thumbsnail,
2034                      'readOnly' => $disabled
2035                  );
2036                  $item.= $this->dbFileIcons($PA['itemFormElName'],'db',implode(',',$tempFT),$itemArray,'',$params,$PA['onFocus'],$table,$field,$row['uid']);
2037  
2038              break;
2039          }
2040  
2041              // Wizards:
2042          $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
2043          if (!$disabled) {
2044              $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf);
2045          }
2046  
2047          return $item;
2048      }
2049  
2050      /**
2051       * Generation of TCEform elements of the type "none"
2052       * This will render a non-editable display of the content of the field.
2053       *
2054       * @param    string        The table name of the record
2055       * @param    string        The field name which this element is supposed to edit
2056       * @param    array        The record data array where the value(s) for the field can be found
2057       * @param    array        An array with additional configuration options.
2058       * @return    string        The HTML code for the TCEform field
2059       */
2060  	function getSingleField_typeNone($table,$field,$row,&$PA)    {
2061              // Init:
2062          $config = $PA['fieldConf']['config'];
2063          $itemValue = $PA['itemFormElValue'];
2064  
2065          return $this->getSingleField_typeNone_render($config,$itemValue);
2066      }
2067  
2068      /**
2069       * HTML rendering of a value which is not editable.
2070       *
2071       * @param    array        Configuration for the display
2072       * @param    string        The value to display
2073       * @return    string        The HTML code for the display
2074       * @see getSingleField_typeNone();
2075       */
2076  	function getSingleField_typeNone_render($config,$itemValue)    {
2077  
2078                  // is colorScheme[0] the right value?
2079          $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;';
2080  
2081          if ($config['format'])    {
2082              $itemValue = $this->formatValue($config, $itemValue);
2083          }
2084  
2085          $rows = intval($config['rows']);
2086          if ($rows > 1) {
2087              if(!$config['pass_content']) {
2088                  $itemValue = nl2br(htmlspecialchars($itemValue));
2089              }
2090                  // like textarea
2091              $cols = t3lib_div::intInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
2092              if (!$config['fixedRows']) {
2093                  $origRows = $rows = t3lib_div::intInRange($rows, 1, 20);
2094                  if (strlen($itemValue)>$this->charsPerRow*2)    {
2095                      $cols = $this->maxTextareaWidth;
2096                      $rows = t3lib_div::intInRange(round(strlen($itemValue)/$this->charsPerRow),count(explode(chr(10),$itemValue)),20);
2097                      if ($rows<$origRows)    $rows=$origRows;
2098                  }
2099              }
2100  
2101              if ($this->docLarge)    $cols = round($cols*$this->form_largeComp);
2102              $width = ceil($cols*$this->form_rowsToStylewidth);
2103                  // hardcoded: 12 is the height of the font
2104              $height=$rows*12;
2105  
2106              $item='
2107                  <div style="'.htmlspecialchars($divStyle.' overflow:auto; height:'.$height.'px; width:'.$width.'px;').'" class="'.htmlspecialchars($this->formElClass('none')).'">'.
2108                  $itemValue.
2109                  '</div>';
2110          } else {
2111              if(!$config['pass_content']) {
2112                  $itemValue = htmlspecialchars($itemValue);
2113              }
2114  
2115              $cols = $config['cols']?$config['cols']:($config['size']?$config['size']:$this->maxInputWidth);
2116              if ($this->docLarge)    $cols = round($cols*$this->form_largeComp);
2117              $width = ceil($cols*$this->form_rowsToStylewidth);
2118  
2119                  // overflow:auto crashes mozilla here. Title tag is usefull when text is longer than the div box (overflow:hidden).
2120              $item = '
2121                  <div style="'.htmlspecialchars($divStyle.' overflow:hidden; width:'.$width.'px;').'" class="'.htmlspecialchars($this->formElClass('none')).'" title="'.$itemValue.'">'.
2122                  '<span class="nobr">'.(strcmp($itemValue,'')?$itemValue:'&nbsp;').'</span>'.
2123                  '</div>';
2124          }
2125  
2126          return $item;
2127      }
2128  
2129      /**
2130       * Handler for Flex Forms
2131       *
2132       * @param    string        The table name of the record
2133       * @param    string        The field name which this element is supposed to edit
2134       * @param    array        The record data array where the value(s) for the field can be found
2135       * @param    array        An array with additional configuration options.
2136       * @return    string        The HTML code for the TCEform field
2137       */
2138  	function getSingleField_typeFlex($table,$field,$row,&$PA)    {
2139  
2140              // Data Structure:
2141          $dataStructArray = t3lib_BEfunc::getFlexFormDS($PA['fieldConf']['config'],$row,$table);
2142  
2143              // Get data structure:
2144          if (is_array($dataStructArray))    {
2145  
2146                  // Get data:
2147              $xmlData = $PA['itemFormElValue'];
2148              $xmlHeaderAttributes = t3lib_div::xmlGetHeaderAttribs($xmlData);
2149              $storeInCharset = strtolower($xmlHeaderAttributes['encoding']);
2150              if ($storeInCharset)    {
2151                  $currentCharset=$GLOBALS['LANG']->charSet;
2152                  $xmlData = $GLOBALS['LANG']->csConvObj->conv($xmlData,$storeInCharset,$currentCharset,1);
2153              }
2154              $editData=t3lib_div::xml2array($xmlData);
2155              if (!is_array($editData))    {    // Must be XML parsing error...
2156                  $editData=array();
2157              } elseif (!isset($editData['meta']) || !is_array($editData['meta']))    {
2158                  $editData['meta'] = array();
2159              }
2160  
2161                  // Find the data structure if sheets are found:
2162              $sheet = $editData['meta']['currentSheetId'] ? $editData['meta']['currentSheetId'] : 'sDEF';    // Sheet to display
2163  
2164                  // Create sheet menu:
2165  //            if (is_array($dataStructArray['sheets']))    {
2166  //                #$item.=$this->getSingleField_typeFlex_sheetMenu($dataStructArray['sheets'], $PA['itemFormElName'].'[meta][currentSheetId]', $sheet).'<br />';
2167  //            }
2168  
2169                  // Create language menu:
2170              $langChildren = $dataStructArray['meta']['langChildren'] ? 1 : 0;
2171              $langDisabled = $dataStructArray['meta']['langDisable'] ? 1 : 0;
2172  
2173              $editData['meta']['currentLangId']=array();
2174              $languages = $this->getAvailableLanguages();
2175  
2176              foreach($languages as $lInfo)    {
2177                  if ($GLOBALS['BE_USER']->checkLanguageAccess($lInfo['uid']))    {
2178                      $editData['meta']['currentLangId'][] =     $lInfo['ISOcode'];
2179                  }
2180              }
2181              if (!is_array($editData['meta']['currentLangId']) || !count($editData['meta']['currentLangId']))    {
2182                  $editData['meta']['currentLangId']=array('DEF');
2183              }
2184  
2185              $editData['meta']['currentLangId'] = array_unique($editData['meta']['currentLangId']);
2186  
2187  
2188  //            if (!$langDisabled && count($languages) > 1)    {
2189  //                $item.=$this->getSingleField_typeFlex_langMenu($languages, $PA['itemFormElName'].'[meta][currentLangId]', $editData['meta']['currentLangId']).'<br />';
2190  //            }
2191  
2192              $PA['_noEditDEF'] = FALSE;
2193              if ($langChildren || $langDisabled)    {
2194                  $rotateLang = array('DEF');
2195              } else {
2196                  if (!in_array('DEF',$editData['meta']['currentLangId']))    {
2197                      array_unshift($editData['meta']['currentLangId'],'DEF');
2198                      $PA['_noEditDEF'] = TRUE;
2199                  }
2200                  $rotateLang = $editData['meta']['currentLangId'];
2201              }
2202  
2203                  // Tabs sheets
2204              if (is_array($dataStructArray['sheets']))    {
2205                  $tabsToTraverse = array_keys($dataStructArray['sheets']);
2206              } else {
2207                  $tabsToTraverse = array($sheet);
2208              }
2209  
2210              foreach ($rotateLang as $lKey)    {
2211                  if (!$langChildren && !$langDisabled)    {
2212                      $item.= '<b>'.$this->getLanguageIcon($table,$row,'v'.$lKey).$lKey.':</b>';
2213                  }
2214  
2215                  $tabParts = array();
2216                  foreach ($tabsToTraverse as $sheet)    {
2217                      $sheetCfg = $dataStructArray['sheets'][$sheet];
2218                      list ($dataStruct, $sheet) = t3lib_div::resolveSheetDefInDS($dataStructArray,$sheet);
2219  
2220                          // Render sheet:
2221                      if (is_array($dataStruct['ROOT']) && is_array($dataStruct['ROOT']['el']))        {
2222                          $cmdData = t3lib_div::_GP('flexFormsCmdData');
2223                          $lang = 'l'.$lKey;    // Default language, other options are "lUK" or whatever country code (independant of system!!!)
2224                          $PA['_valLang'] = $langChildren && !$langDisabled ? $editData['meta']['currentLangId'] : 'DEF';    // Default language, other options are "lUK" or whatever country code (independant of system!!!)
2225                          $PA['_lang'] = $lang;
2226  
2227                              // Render flexform:
2228                          $tRows = $this->getSingleField_typeFlex_draw(
2229                                      $dataStruct['ROOT']['el'],
2230                                      $editData['data'][$sheet][$lang],
2231                                      $cmdData['data'][$sheet][$lang],
2232                                      $table,
2233                                      $field,
2234                                      $row,
2235                                      $PA,
2236                                      '[data]['.$sheet.']['.$lang.']'
2237                                  );
2238                          $sheetContent= '<table border="0" cellpadding="1" cellspacing="1" class="typo3-TCEforms-flexForm">'.implode('',$tRows).'</table>';
2239  
2240              #            $item = '<div style=" position:absolute;">'.$item.'</div>';
2241                          //visibility:hidden;
2242                      } else $sheetContent='Data Structure ERROR: No ROOT element found for sheet "'.$sheet.'".';
2243  
2244                          // Add to tab:
2245                      $tabParts[] = array(
2246                          'label' => ($sheetCfg['ROOT']['TCEforms']['sheetTitle'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetTitle']) : $sheet),
2247                          'description' => ($sheetCfg['ROOT']['TCEforms']['sheetDescription'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetDescription']) : ''),
2248                          'linkTitle' => ($sheetCfg['ROOT']['TCEforms']['sheetShortDescr'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetShortDescr']) : ''),
2249                          'content' => $sheetContent
2250                      );
2251                  }
2252  
2253                  if (is_array($dataStructArray['sheets']))    {
2254                      $item.= $this->getDynTabMenu($tabParts,'TCEFORMS:flexform:'.$PA['itemFormElName'].$PA['_lang']);
2255                  } else {
2256                      $item.= $sheetContent;
2257                  }
2258              }
2259          } else $item='Data Structure ERROR: '.$dataStructArray;
2260  
2261          return $item;
2262      }
2263  
2264      /**
2265       * Creates the language menu for FlexForms:
2266       *
2267       * @param    [type]        $languages: ...
2268       * @param    [type]        $elName: ...
2269       * @param    [type]        $selectedLanguage: ...
2270       * @param    [type]        $multi: ...
2271       * @return    string        HTML for menu
2272       */
2273  	function getSingleField_typeFlex_langMenu($languages,$elName,$selectedLanguage,$multi=1)    {
2274          $opt=array();
2275          foreach($languages as $lArr)    {
2276              $opt[]='<option value="'.htmlspecialchars($lArr['ISOcode']).'"'.(in_array($lArr['ISOcode'],$selectedLanguage)?' selected="selected"':'').'>'.htmlspecialchars($lArr['title']).'</option>';
2277          }
2278  
2279          $output = '<select name="'.$elName.'[]"'.($multi ? ' multiple="multiple" size="'.count($languages).'"' : '').'>'.implode('',$opt).'</select>';
2280  
2281          return $output;
2282      }
2283  
2284      /**
2285       * Creates the menu for selection of the sheets:
2286       *
2287       * @param    array        Sheet array for which to render the menu
2288       * @param    string        Form element name of the field containing the sheet pointer
2289       * @param    string        Current sheet key
2290       * @return    string        HTML for menu
2291       */
2292  	function getSingleField_typeFlex_sheetMenu($sArr,$elName,$sheetKey)    {
2293  
2294          $tCells =array();
2295          $pct = round(100/count($sArr));
2296          foreach($sArr as $sKey => $sheetCfg)    {
2297              if ($GLOBALS['BE_USER']->jsConfirmation(1))    {
2298                  $onClick = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){'.$this->elName($elName).".value='".$sKey."'; TBE_EDITOR.submitForm()};";
2299              } else {
2300                  $onClick = 'if(TBE_EDITOR.checkSubmit(-1)){ '.$this->elName($elName).".value='".$sKey."'; TBE_EDITOR.submitForm();}";
2301              }
2302  
2303  
2304              $tCells[]='<td width="'.$pct.'%" style="'.($sKey==$sheetKey ? 'background-color: #9999cc; font-weight: bold;' : 'background-color: #aaaaaa;').' cursor: hand;" onclick="'.htmlspecialchars($onClick).'" align="center">'.
2305                      ($sheetCfg['ROOT']['TCEforms']['sheetTitle'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetTitle']) : $sKey).
2306                      '</td>';
2307          }
2308  
2309          return '<table border="0" cellpadding="0" cellspacing="2" class="typo3-TCEforms-flexForm-sheetMenu"><tr>'.implode('',$tCells).'</tr></table>';
2310      }
2311  
2312      /**
2313       * [Describe function...]
2314       *
2315       * @param    [type]        $dataStruct: ...
2316       * @param    [type]        $editData: ...
2317       * @param    [type]        $cmdData: ...
2318       * @param    [type]        $table: ...
2319       * @param    [type]        $field: ...
2320       * @param    [type]        $row: ...
2321       * @param    [type]        $PA: ...
2322       * @param    [type]        $formPrefix: ...
2323       * @param    [type]        $level: ...
2324       * @param    [type]        $tRows: ...
2325       * @return    [type]        ...
2326       */
2327  	function getSingleField_typeFlex_draw($dataStruct,$editData,$cmdData,$table,$field,$row,&$PA,$formPrefix='',$level=0,$tRows=array())    {
2328  
2329              // Data Structure array must be ... and array of course...
2330          if (is_array($dataStruct))    {
2331              foreach($dataStruct as $key => $value)    {
2332                  if (is_array($value))    {    // The value of each entry must be an array.
2333  
2334                          // ********************
2335                          // Making the row:
2336                          // ********************
2337                      $rowCells=array();
2338  
2339                          // Icon:
2340                      $rowCells['title'] = '<img src="clear.gif" width="'.($level*16).'" height="1" alt="" /><strong>'.htmlspecialchars(t3lib_div::fixed_lgd_cs($this->sL($value['tx_templavoila']['title']),30)).'</strong>';;
2341  
2342                      $rowCells['formEl']='';
2343                      if ($value['type']=='array')    {
2344                          if ($value['section'])    {
2345                                  // Render "NEW [container]" selectorbox:
2346                              if (is_array($value['el']))    {
2347                                  $opt=array();
2348                                  $opt[]='<option value=""></option>';
2349                                  foreach($value['el'] as $kk => $vv)    {
2350                                      $opt[]='<option value="'.$kk.'">'.htmlspecialchars($this->getLL('l_new') . ' "'.$this->sL($value['el'][$kk]['tx_templavoila']['title']).'"').'</option>';
2351                                  }
2352                                  $rowCells['formEl']='<select name="flexFormsCmdData'.$formPrefix.'['.$key.'][value]">'.implode('',$opt).'</select>';
2353                              }
2354  
2355                                  // Put row together
2356                              $tRows[]='<tr class="bgColor2">
2357                                  <td nowrap="nowrap" valign="top">'.$rowCells['title'].'</td>
2358                                  <td>'.$rowCells['formEl'].'</td>
2359                              </tr>';
2360  
2361                              $cc=0;
2362                              if (is_array($editData[$key]['el']))    {
2363                                  foreach ($editData[$key]['el'] as $k3 => $v3)    {
2364                                      $cc=$k3;
2365                                      $theType = key($v3);
2366                                      $theDat = $v3[$theType];
2367                                      $newSectionEl = $value['el'][$theType];
2368                                      if (is_array($newSectionEl))    {
2369                                          $tRows = $this->getSingleField_typeFlex_draw(
2370                                              array($theType => $newSectionEl),
2371                                              array($theType => $theDat),
2372                                              $cmdData[$key]['el'][$cc],
2373                                              $table,
2374                                              $field,
2375                                              $row,
2376                                              $PA,
2377                                              $formPrefix.'['.$key.'][el]['.$cc.']',
2378                                              $level+1,
2379                                              $tRows
2380                                          );
2381                                      }
2382                                  }
2383                              }
2384  
2385  
2386  
2387                                  // New form?
2388                              if ($cmdData[$key]['value'])    {
2389                                  $newSectionEl = $value['el'][$cmdData[$key]['value']];
2390                                  if (is_array($newSectionEl))    {
2391                                      $tRows = $this->getSingleField_typeFlex_draw(
2392                                          array($cmdData[$key]['value'] => $newSectionEl),
2393                                          array(),
2394                                          array(),
2395                                          $table,
2396                                          $field,
2397                                          $row,
2398                                          $PA,
2399                                          $formPrefix.'['.$key.'][el]['.($cc+1).']',
2400                                          $level+1,
2401                                          $tRows
2402                                      );
2403                                  }
2404                              }
2405                          } else {
2406                              $idTagPrefix = uniqid('id',true); // ID attributes are used for the move and delete checkboxes for referencing to them in the label tag (<label for="the form field id">) that's rendered around the icons
2407  
2408                                  // Put row together
2409                              $tRows[]='<tr class="bgColor2">
2410                                  <td nowrap="nowrap" valign="top">'.
2411                                  '<input name="_DELETE_FLEX_FORM'.$PA['itemFormElName'].$formPrefix.'" id="'.$idTagPrefix.'-del" type="checkbox"'.$this->insertDefStyle('check').' value="1" /><label for="'.$idTagPrefix.'-del"><img src="'.$this->backPath.'gfx/garbage.gif" border="0" alt="" /></label>'.
2412                                  '<input name="_MOVEUP_FLEX_FORM'.$PA['itemFormElName'].$formPrefix.'" id="'.$idTagPrefix.'-mvup" type="checkbox"'.$this->insertDefStyle('check').' value="1" /><label for="'.$idTagPrefix.'-mvup"><img src="'.$this->backPath.'gfx/button_up.gif" border="0" alt="" /></label>'.
2413                                  '<input name="_MOVEDOWN_FLEX_FORM'.$PA['itemFormElName'].$formPrefix.'" id="'.$idTagPrefix.'-mvdown" type="checkbox"'.$this->insertDefStyle('check').' value="1" /><label for="'.$idTagPrefix.'-mvdown"><img src="'.$this->backPath.'gfx/button_down.gif" border="0" alt="" /></label>'.
2414                                  $rowCells['title'].'</td>
2415                                  <td>'.$rowCells['formEl'].'</td>
2416                              </tr>';
2417  
2418                              $tRows = $this->getSingleField_typeFlex_draw(
2419                                  $value['el'],
2420                                  $editData[$key]['el'],
2421                                  $cmdData[$key]['el'],
2422                                  $table,
2423                                  $field,
2424                                  $row,
2425                                  $PA,
2426                                  $formPrefix.'['.$key.'][el]',
2427                                  $level+1,
2428                                  $tRows
2429                              );
2430                          }
2431  
2432                      } elseif (is_array($value['TCEforms']['config'])) {    // Rendering a single form element:
2433  
2434                          if (is_array($PA['_valLang']))    {
2435                              $rotateLang = $PA['_valLang'];
2436                          } else {
2437                              $rotateLang = array($PA['_valLang']);
2438                          }
2439  
2440                          foreach($rotateLang as $vDEFkey)    {
2441                              $vDEFkey = 'v'.$vDEFkey;
2442  
2443                              if (!$value['TCEforms']['displayCond'] || $this->isDisplayCondition($value['TCEforms']['displayCond'],$editData,$vDEFkey)) {
2444                                  $fakePA=array();
2445                                  $fakePA['fieldConf']=array(
2446                                      'label' => $this->sL(trim($value['TCEforms']['label'])),
2447                                      'config' => $value['TCEforms']['config'],
2448                                      'defaultExtras' => $value['TCEforms']['defaultExtras'],
2449                                      'onChange' => $value['TCEforms']['onChange']
2450                                  );
2451                                  if ($PA['_noEditDEF'] && $PA['_lang']==='lDEF') {
2452                                      $fakePA['fieldConf']['config'] = array(
2453                                          'type' => 'none',
2454                                          'rows' => 2
2455                                      );
2456                                  }
2457  
2458                                  if (
2459                                      $fakePA['fieldConf']['onChange'] == 'reload' ||
2460                                      ($GLOBALS['TCA'][$table]['ctrl']['type'] && !strcmp($key,$GLOBALS['TCA'][$table]['ctrl']['type'])) ||
2461                                      ($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'] && t3lib_div::inList($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'],$key))) {
2462                                      if ($GLOBALS['BE_USER']->jsConfirmation(1))    {
2463                                          $alertMsgOnChange = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
2464                                      } else {
2465                                          $alertMsgOnChange = 'if(TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm();}';
2466                                      }
2467                                  } else {
2468                                      $alertMsgOnChange = '';
2469                                  }
2470  
2471                                  $fakePA['fieldChangeFunc']=$PA['fieldChangeFunc'];
2472                                  if (strlen($alertMsgOnChange)) {
2473                                      $fakePA['fieldChangeFunc']['alert']=$alertMsgOnChange;
2474                                  }
2475                                  $fakePA['onFocus']=$PA['onFocus'];
2476                                  $fakePA['label']=$PA['label'];
2477  
2478                                  $fakePA['itemFormElName']=$PA['itemFormElName'].$formPrefix.'['.$key.']['.$vDEFkey.']';
2479                                  $fakePA['itemFormElName_file']=$PA['itemFormElName_file'].$formPrefix.'['.$key.']['.$vDEFkey.']';
2480  
2481                                  if(isset($editData[$key][$vDEFkey])) {
2482                                      $fakePA['itemFormElValue']=$editData[$key][$vDEFkey];
2483                                  } else {
2484                                      $fakePA['itemFormElValue']=$fakePA['fieldConf']['config']['default'];
2485                                  }
2486  
2487                                  $rowCells['formEl']= $this->getSingleField_SW($table,$field,$row,$fakePA);
2488                                  $rowCells['title']= htmlspecialchars($fakePA['fieldConf']['label']);
2489  
2490                                  if (!in_array('DEF',$rotateLang))    {
2491                                      $defInfo = '<div class="typo3-TCEforms-originalLanguageValue">'.$this->getLanguageIcon($table,$row,0).$this->previewFieldValue($editData[$key]['vDEF'], $fakePA['fieldConf']).'&nbsp;</div>';
2492                                  } else {
2493                                      $defInfo = '';
2494                                  }
2495                                  
2496                                  if (!$PA['_noEditDEF'])    {
2497                                      $prLang = $this->getAdditionalPreviewLanguages();
2498                                      foreach($prLang as $prL)    {
2499                                          $defInfo.= '<div class="typo3-TCEforms-originalLanguageValue">'.$this->getLanguageIcon($table,$row,'v'.$prL['ISOcode']).$this->previewFieldValue($editData[$key]['v'.$prL['ISOcode']], $fakePA['fieldConf']).'&nbsp;</div>';
2500                                      }
2501                                  }
2502  
2503                                      // Put row together
2504                                  $tRows[]='<tr>
2505                                      <td nowrap="nowrap" valign="top" class="bgColor5">'.($vDEFkey=='vDEF' ? '' : $this->getLanguageIcon($table,$row,$vDEFkey)).$rowCells['title'].'</td>
2506                                      <td class="bgColor4">'.$rowCells['formEl'].$defInfo.'</td>
2507                                  </tr>';
2508                              }
2509                          }
2510                      }
2511                  }
2512              }
2513          }
2514  
2515          return $tRows;
2516      }
2517  
2518      /**
2519       * Handler for unknown types.
2520       *
2521       * @param    string        The table name of the record
2522       * @param    string        The field name which this element is supposed to edit
2523       * @param    array        The record data array where the value(s) for the field can be found
2524       * @param    array        An array with additional configuration options.
2525       * @return    string        The HTML code for the TCEform field
2526       */
2527  	function getSingleField_typeUnknown($table,$field,$row,&$PA)    {
2528          $item='Unknown type: '.$PA['fieldConf']['config']['form_type'].'<br />';
2529  
2530          return $item;
2531      }
2532  
2533      /**
2534       * User defined field type
2535       *
2536       * @param    string        The table name of the record
2537       * @param    string        The field name which this element is supposed to edit
2538       * @param    array        The record data array where the value(s) for the field can be found
2539       * @param    array        An array with additional configuration options.
2540       * @return    string        The HTML code for the TCEform field
2541       */
2542  	function getSingleField_typeUser($table,$field,$row,&$PA)    {
2543          $PA['table']=$table;
2544          $PA['field']=$field;
2545          $PA['row']=$row;
2546  
2547          $PA['pObj']=&$this;
2548  
2549          return t3lib_div::callUserFunction($PA['fieldConf']['config']['userFunc'],$PA,$this);
2550      }
2551  
2552  
2553  
2554  
2555  
2556  
2557      /************************************************************
2558       *
2559       * Field content processing
2560       *
2561       ************************************************************/
2562  
2563      /**
2564       * Format field content of various types if $config['format'] is set to date, filesize, ..., user
2565       * This is primarily for the field type none but can be used for user field types for example
2566       *
2567       * @param    array        Configuration for the display
2568       * @param    string        The value to display
2569       * @return    string        Formatted Field content
2570       */
2571  	function formatValue ($config, $itemValue)    {
2572          $format = trim($config['format']);
2573          switch($format)    {
2574              case 'date':
2575                  if ($itemValue)    {
2576                      $option = trim($config['format.']['option']);
2577                      if ($option)    {
2578                          if ($config['format.']['strftime'])    {
2579                              $value = strftime($option,$itemValue);
2580                          } else {
2581                              $value = date($option,$itemValue);
2582                          }
2583                      } else {
2584                          $value = date('d-m-Y',$itemValue);
2585                      }
2586                  } else {
2587                      $value = '';
2588                  }
2589                  if ($config['format.']['appendAge'])    {
2590                      $value .= ' ('.t3lib_BEfunc::calcAge((time()-$itemValue), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')).')';
2591                  }
2592                  $itemValue = $value;
2593                  break;
2594              case 'datetime':    // compatibility with "eval" (type "input")
2595                  $itemValue = date('H:i d-m-Y',$itemValue);
2596                  break;
2597              case 'time':    // compatibility with "eval" (type "input")
2598                  $itemValue = date('H:i',$itemValue);
2599                  break;
2600              case 'timesec':    // compatibility with "eval" (type "input")
2601                  $itemValue = date('H:i:s',$itemValue);
2602                  break;
2603              case 'year':    // compatibility with "eval" (type "input")
2604                  $itemValue = date('Y',$itemValue);
2605                  break;
2606              case 'int':
2607                  $baseArr = array('dec'=>'d','hex'=>'x','HEX'=>'X','oct'=>'o','bin'=>'b');
2608                  $base = trim($config['format.']['base']);
2609                  $format = $baseArr[$base] ? $baseArr[$base] : 'd';
2610                  $itemValue = sprintf('%'.$format,$itemValue);
2611                  break;
2612              case 'float':
2613                  $precision = t3lib_div::intInRange($config['format.']['precision'],1,10,2);
2614                  $itemValue = sprintf('%.'.$precision.'f',$itemValue);
2615                  break;
2616              case 'number':
2617                  $format = trim($config['format.']['option']);
2618                  $itemValue = sprintf('%'.$format,$itemValue);
2619                  break;
2620              case 'md5':
2621                  $itemValue = md5($itemValue);
2622                  break;
2623              case 'filesize':
2624                  $value = t3lib_div::formatSize(intval($itemValue));
2625                  if ($config['format.']['appendByteSize'])    {
2626                      $value .= ' ('.$itemValue.')';
2627                  }
2628                  $itemValue = $value;
2629                  break;
2630              case 'user':
2631                  $func = trim($config['format.']['userFunc']);
2632                  if ($func)    {
2633                      $params = array(
2634                          'value' => $itemValue,
2635                          'args' => $config['format.']['userFunc'],
2636                          'config' => $config,
2637                          'pObj' => &$this
2638                      );
2639                      $itemValue = t3lib_div::callUserFunction($func,$params,$this);
2640                  }
2641                  break;
2642              default:
2643              break;
2644          }
2645  
2646          return $itemValue;
2647      }
2648  
2649  
2650  
2651  
2652  
2653  
2654      /************************************************************
2655       *
2656       * "Configuration" fetching/processing functions
2657       *
2658       ************************************************************/
2659  
2660      /**
2661       * Calculate and return the current "types" pointer value for a record
2662       *
2663       * @param    string        The table name. MUST be in $TCA
2664       * @param    array        The row from the table, should contain at least the "type" field, if applicable.
2665       * @return    string        Return the "type" value for this record, ready to pick a "types" configuration from the $TCA array.
2666       */
2667  	function getRTypeNum($table,$row)    {
2668          global $TCA;
2669              // If there is a "type" field configured...
2670          if ($TCA[$table]['ctrl']['type'])    {
2671              $typeFieldName = $TCA[$table]['ctrl']['type'];
2672              $typeNum=$row[$typeFieldName];    // Get value of the row from the record which contains the type value.
2673              if (!strcmp($typeNum,''))    $typeNum=0;            // If that value is an empty string, set it to "0" (zero)
2674          } else {
2675              $typeNum = 0;    // If no "type" field, then set to "0" (zero)
2676          }
2677  
2678          $typeNum = (string)$typeNum;        // Force to string. Necessary for eg '-1' to be recognized as a type value.
2679          if (!$TCA[$table]['types'][$typeNum])    {    // However, if the type "0" is not found in the "types" array, then default to "1" (for historical reasons)
2680              $typeNum = 1;
2681          }
2682  
2683          return $typeNum;
2684      }
2685  
2686      /**
2687       * Used to adhoc-rearrange the field order normally set in the [types][showitem] list
2688       *
2689       * @param    array        A [types][showitem] list of fields, exploded by ","
2690       * @return    array        Returns rearranged version (keys are changed around as well.)
2691       * @see getMainFields()
2692       */
2693  	function rearrange($fields)    {
2694          $fO = array_flip(t3lib_div::trimExplode(',',$this->fieldOrder,1));
2695          reset($fields);
2696          $newFields=array();
2697          while(list($cc,$content)=each($fields))    {
2698              $cP = t3lib_div::trimExplode(';',$content);
2699              if (isset($fO[$cP[0]]))    {
2700                  $newFields[$fO[$cP[0]]] = $content;
2701                  unset($fields[$cc]);
2702              }
2703          }
2704          ksort($newFields);
2705          $fields=array_merge($newFields,$fields);        // Candidate for t3lib_div::array_merge() if integer-keys will some day make trouble...
2706          return $fields;
2707      }
2708  
2709      /**
2710       * Producing an array of field names NOT to display in the form, based on settings from subtype_value_field, bitmask_excludelist_bits etc.
2711       * Notice, this list is in NO way related to the "excludeField" flag
2712       *
2713       * @param    string        Table name, MUST be in $TCA
2714       * @param    array        A record from table.
2715       * @param    string        A "type" pointer value, probably the one calculated based on the record array.
2716       * @return    array        Array with fieldnames as values. The fieldnames are those which should NOT be displayed "anyways"
2717       * @see getMainFields()
2718       */
2719  	function getExcludeElements($table,$row,$typeNum)    {
2720          global $TCA;
2721  
2722              // Init:
2723          $excludeElements=array();
2724  
2725              // If a subtype field is defined for the type
2726          if ($TCA[$table]['types'][$typeNum]['subtype_value_field'])    {
2727              $sTfield = $TCA[$table]['types'][$typeNum]['subtype_value_field'];
2728              if (trim($TCA[$table]['types'][$typeNum]['subtypes_excludelist'][$row[$sTfield]]))    {
2729                  $excludeElements=t3lib_div::trimExplode(',',$TCA[$table]['types'][$typeNum]['subtypes_excludelist'][$row[$sTfield]],1);
2730              }
2731          }
2732  
2733              // If a bitmask-value field has been configured, then find possible fields to exclude based on that:
2734          if ($TCA[$table]['types'][$typeNum]['bitmask_value_field'])    {
2735              $sTfield = $TCA[$table]['types'][$typeNum]['bitmask_value_field'];
2736              $sTValue = t3lib_div::intInRange($row[$sTfield],0);
2737              if (is_array($TCA[$table]['types'][$typeNum]['bitmask_excludelist_bits']))    {
2738                  reset($TCA[$table]['types'][$typeNum]['bitmask_excludelist_bits']);
2739                  while(list($bitKey,$eList)=each($TCA[$table]['types'][$typeNum]['bitmask_excludelist_bits']))    {
2740                      $bit=substr($bitKey,1);
2741                      if (t3lib_div::testInt($bit))    {
2742                          $bit = t3lib_div::intInRange($bit,0,30);
2743                          if (
2744                                  (substr($bitKey,0,1)=='-' && !($sTValue&pow(2,$bit))) ||
2745                                  (substr($bitKey,0,1)=='+' && ($sTValue&pow(2,$bit)))
2746                              )    {
2747                              $excludeElements = array_merge($excludeElements,t3lib_div::trimExplode(',',$eList,1));
2748                          }
2749                      }
2750                  }
2751              }
2752          }
2753  
2754              // Return the array of elements:
2755          return $excludeElements;
2756      }
2757  
2758      /**
2759       * Finds possible field to add to the form, based on subtype fields.
2760       *
2761       * @param    string        Table name, MUST be in $TCA
2762       * @param    array        A record from table.
2763       * @param    string        A "type" pointer value, probably the one calculated based on the record array.
2764       * @return    array        An array containing two values: 1) Another array containing fieldnames to add and 2) the subtype value field.
2765       * @see getMainFields()
2766       */
2767  	function getFieldsToAdd($table,$row,$typeNum)    {
2768          global $TCA;
2769  
2770              // Init:
2771          $addElements=array();
2772  
2773              // If a subtype field is defined for the type
2774          if ($TCA[$table]['types'][$typeNum]['subtype_value_field'])    {
2775              $sTfield = $TCA[$table]['types'][$typeNum]['subtype_value_field'];
2776              if (trim($TCA[$table]['types'][$typeNum]['subtypes_addlist'][$row[$sTfield]]))    {
2777                  $addElements=t3lib_div::trimExplode(',',$TCA[$table]['types'][$typeNum]['subtypes_addlist'][$row[$sTfield]],1);
2778              }
2779          }
2780              // Return the return
2781          return array($addElements,$sTfield);
2782      }
2783  
2784      /**
2785       * Merges the current [types][showitem] array with the array of fields to add for the current subtype field of the "type" value.
2786       *
2787       * @param    array        A [types][showitem] list of fields, exploded by ","
2788       * @param    array        The output from getFieldsToAdd()
2789       * @return    array        Return the modified $fields array.
2790       * @see getMainFields(),getFieldsToAdd()
2791       */
2792  	function mergeFieldsWithAddedFields($fields,$fieldsToAdd)    {
2793          if (count($fieldsToAdd[0]))    {
2794              reset($fields);
2795              $c=0;
2796              while(list(,$fieldInfo)=each($fields))    {
2797                  $parts = explode(';',$fieldInfo);
2798                  if (!strcmp(trim($parts[0]),$fieldsToAdd[1]))    {
2799                      array_splice(
2800                          $fields,
2801                          $c+1,
2802                          0,
2803                          $fieldsToAdd[0]
2804                      );
2805                      break;
2806                  }
2807                  $c++;
2808              }
2809          }
2810          return $fields;
2811      }
2812  
2813  
2814      /**
2815       * Returns TSconfig for table/row
2816       * Multiple requests to this function will return cached content so there is no performance loss in calling this many times since the information is looked up only once.
2817       *
2818       * @param    string        The table name
2819       * @param    array        The table row (Should at least contain the "uid" value, even if "NEW..." string. The "pid" field is important as well, and negative values will be intepreted as pointing to a record from the same table.)
2820       * @param    string        Optionally you can specify the field name as well. In that case the TSconfig for the field is returned.
2821       * @return    mixed        The TSconfig values (probably in an array)
2822       * @see t3lib_BEfunc::getTCEFORM_TSconfig()
2823       */
2824  	function setTSconfig($table,$row,$field='')    {
2825          $mainKey = $table.':'.$row['uid'];
2826          if (!isset($this->cachedTSconfig[$mainKey]))    {
2827              $this->cachedTSconfig[$mainKey]=t3lib_BEfunc::getTCEFORM_TSconfig($table,$row);
2828          }
2829          if ($field)    {
2830              return $this->cachedTSconfig[$mainKey][$field];
2831          } else {
2832              return $this->cachedTSconfig[$mainKey];
2833          }
2834      }
2835  
2836      /**
2837       * Overrides the TCA field configuration by TSconfig settings.
2838       * 
2839       * Example TSconfig: TCEform.<table>.<field>.config.appearance.useSortable = 1
2840       * This overrides the setting in $TCA[<table>]['columns'][<field>]['config']['appearance']['useSortable'].
2841       *
2842       * @param    array        $fieldConfig: TCA field configuration
2843       * @param    array        $TSconfig: TSconfig
2844       * @return    array        Changed TCA field configuration
2845       */
2846  	function overrideFieldConf($fieldConfig, $TSconfig) {
2847          if (is_array($TSconfig)) {
2848              $TSconfig = t3lib_div::removeDotsFromTS($TSconfig);
2849              $type = $fieldConfig['type'];
2850              if (is_array($TSconfig['config']) && is_array($this->allowOverrideMatrix[$type])) {
2851                      // Check if the keys in TSconfig['config'] are allowed to override TCA field config:            
2852                  foreach (array_keys($TSconfig['config']) as $key) {
2853                      if (!in_array($key, $this->allowOverrideMatrix[$type], true)) {
2854                          unset($TSconfig['config'][$key]);
2855                      }
2856                  }
2857                      // Override TCA field config by remaining TSconfig['config']:
2858                  if (count($TSconfig['config'])) {
2859                      $fieldConfig = array_merge($fieldConfig, $TSconfig['config']);
2860                  }
2861              }
2862          }
2863  
2864          return $fieldConfig;
2865      }
2866  
2867      /**
2868       * Returns the "special" configuration (from the "types" "showitem" list) for a fieldname based on input table/record
2869       * (Not used anywhere...?)
2870       *
2871       * @param    string        The table name
2872       * @param    array        The table row (Should at least contain the "uid" value, even if "NEW..." string. The "pid" field is important as well, and negative values will be intepreted as pointing to a record from the same table.)
2873       * @param    string        Specify the field name.
2874       * @return    array
2875       * @see getSpecConfFromString(), t3lib_BEfunc::getTCAtypes()
2876       */
2877  	function getSpecConfForField($table,$row,$field)    {
2878              // Finds the current "types" configuration for the table/row:
2879          $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table,$row);
2880  
2881              // If this is an array, then traverse it:
2882          if (is_array($types_fieldConfig))    {
2883              foreach($types_fieldConfig as $vconf)    {
2884                      // If the input field name matches one found in the 'types' list, then return the 'special' configuration.
2885                  if ($vconf['field']==$field)    return $vconf['spec'];
2886              }
2887          }
2888      }
2889  
2890      /**
2891       * Returns the "special" configuration of an "extra" string (non-parsed)
2892       *
2893       * @param    string        The "Part 4" of the fields configuration in "types" "showitem" lists.
2894       * @param    string        The ['defaultExtras'] value from field configuration
2895       * @return    array        An array with the special options in.
2896       * @see getSpecConfForField(), t3lib_BEfunc::getSpecConfParts()
2897       */
2898  	function getSpecConfFromString($extraString, $defaultExtras)    {
2899          return t3lib_BEfunc::getSpecConfParts($extraString, $defaultExtras);
2900      }
2901  
2902  
2903  
2904  
2905  
2906  
2907  
2908  
2909  
2910  
2911      /************************************************************
2912       *
2913       * Display of localized content etc.
2914       *
2915       ************************************************************/
2916  
2917      /**
2918       * Will register data from original language records if the current record is a translation of another.
2919       * The original data is shown with the edited record in the form. The information also includes possibly diff-views of what changed in the original record.
2920       * Function called from outside (see alt_doc.php + quick edit) before rendering a form for a record
2921       *
2922       * @param    string        Table name of the record being edited
2923       * @param    array        Record array of the record being edited
2924       * @return    void
2925       */
2926  	function registerDefaultLanguageData($table,$rec)    {
2927          global $TCA;
2928  
2929              // Add default language:
2930          if ($TCA[$table]['ctrl']['languageField']
2931                  && $rec[$TCA[$table]['ctrl']['languageField']] > 0
2932                  && $TCA[$table]['ctrl']['transOrigPointerField']
2933                  && intval($rec[$TCA[$table]['ctrl']['transOrigPointerField']]) > 0)    {
2934  
2935              $lookUpTable = $TCA[$table]['ctrl']['transOrigPointerTable'] ? $TCA[$table]['ctrl']['transOrigPointerTable'] : $table;
2936  
2937                  // Get data formatted:
2938              $this->defaultLanguageData[$table.':'.$rec['uid']] = t3lib_BEfunc::getRecordWSOL($lookUpTable, intval($rec[$TCA[$table]['ctrl']['transOrigPointerField']]));
2939  
2940                  // Get data for diff:
2941              if ($TCA[$table]['ctrl']['transOrigDiffSourceField'])    {
2942                  $this->defaultLanguageData_diff[$table.':'.$rec['uid']] = unserialize($rec[$TCA[$table]['ctrl']['transOrigDiffSourceField']]);
2943              }
2944  
2945                  // If there are additional preview languages, load information for them also:
2946              $prLang = $this->getAdditionalPreviewLanguages();
2947              foreach($prLang as $prL)    {
2948                  $t8Tools = t3lib_div::makeInstance('t3lib_transl8tools');
2949                  $tInfo = $t8Tools->translationInfo($lookUpTable,intval($rec[$TCA[$table]['ctrl']['transOrigPointerField']]),$prL['uid']);
2950                  if (is_array($tInfo['translations'][$prL['uid']]))    {
2951                      $this->additionalPreviewLanguageData[$table.':'.$rec['uid']][$prL['uid']] = t3lib_BEfunc::getRecordWSOL($lookUpTable, intval($tInfo['translations'][$prL['uid']]['uid']));
2952                  }
2953              }
2954          }
2955      }
2956  
2957      /**
2958       * Creates language-overlay for a field value
2959       * This means the requested field value will be overridden with the data from the default language.
2960       * Can be used to render read only fields for example.
2961       *
2962       * @param    string        Table name of the record being edited
2963       * @param    string        Field name represented by $item
2964       * @param    array        Record array of the record being edited in current language
2965       * @param    array        Content of $PA['fieldConf']
2966       * @return    string        Unprocessed field value merged with default language data if needed
2967       */
2968  	function getLanguageOverlayRawValue($table, $row, $field, $fieldConf)    {
2969          global $TCA;
2970  
2971          $value = $row[$field];
2972  
2973          if (is_array($this->defaultLanguageData[$table.':'.$row['uid']]))    {
2974  
2975              if ($fieldConf['l10n_mode']=='exclude'
2976                      || ($fieldConf['l10n_mode']=='mergeIfNotBlank' && strcmp(trim($this->defaultLanguageData[$table.':'.$row['uid']][$field]),'')))    {
2977                  $value = $this->defaultLanguageData[$table.':'.$row['uid']][$field];
2978              }
2979  
2980          }
2981  
2982          return $value;
2983      }
2984  
2985      /**
2986       * Renders the display of default language record content around current field.
2987       * Will render content if any is found in the internal array, $this->defaultLanguageData, depending on registerDefaultLanguageData() being called prior to this.
2988       *
2989       * @param    string        Table name of the record being edited
2990       * @param    string        Field name represented by $item
2991       * @param    array        Record array of the record being edited
2992       * @param    string        HTML of the form field. This is what we add the content to.
2993       * @return    string        Item string returned again, possibly with the original value added to.
2994       * @see getSingleField(), registerDefaultLanguageData()
2995       */
2996  	function renderDefaultLanguageContent($table,$field,$row,$item)    {
2997          if (is_array($this->defaultLanguageData[$table.':'.$row['uid']]))    {
2998              $dLVal = t3lib_BEfunc::getProcessedValue($table,$field,$this->defaultLanguageData[$table.':'.$row['uid']][$field],0,1);
2999              $fCfg = $GLOBALS['TCA'][$table]['columns'][$field];
3000  
3001              if (strcmp($dLVal,''))    {
3002                  $item.='<div class="typo3-TCEforms-originalLanguageValue">'.$this->getLanguageIcon($table,$row,0).$this->previewFieldValue($dLVal,$fCfg).'&nbsp;</div>';
3003              }
3004              
3005              $prLang = $this->getAdditionalPreviewLanguages();
3006              foreach($prLang as $prL)    {
3007                  $dlVal = t3lib_BEfunc::getProcessedValue($table,$field,$this->additionalPreviewLanguageData[$table.':'.$row['uid']][$prL['uid']][$field],0,1);
3008                  $item.= '<div class="typo3-TCEforms-originalLanguageValue">'.$this->getLanguageIcon($table,$row,'v'.$prL['ISOcode']).$this->previewFieldValue($dlVal, $fCfg).'&nbsp;</div>';
3009              }
3010              
3011          }
3012  
3013          return $item;
3014      }
3015  
3016      /**
3017       * Renders the diff-view of default language record content compared with what the record was originally translated from.
3018       * Will render content if any is found in the internal array, $this->defaultLanguageData, depending on registerDefaultLanguageData() being called prior to this.
3019       *
3020       * @param    string        Table name of the record being edited
3021       * @param    string        Field name represented by $item
3022       * @param    array        Record array of the record being edited
3023       * @param    string        HTML of the form field. This is what we add the content to.
3024       * @return    string        Item string returned again, possibly with the original value added to.
3025       * @see getSingleField(), registerDefaultLanguageData()
3026       */
3027  	function renderDefaultLanguageDiff($table,$field,$row,$item)    {
3028          if (is_array($this->defaultLanguageData_diff[$table.':'.$row['uid']]))    {
3029  
3030                  // Initialize:
3031              $dLVal = array(
3032                  'old' => $this->defaultLanguageData_diff[$table.':'.$row['uid']],
3033                  'new' => $this->defaultLanguageData[$table.':'.$row['uid']],
3034              );
3035  
3036              if (isset($dLVal['old'][$field]))    {    // There must be diff-data:
3037                   if (strcmp($dLVal['old'][$field],$dLVal['new'][$field]))    {
3038  
3039                          // Create diff-result:
3040                      $t3lib_diff_Obj = t3lib_div::makeInstance('t3lib_diff');
3041                      $diffres = $t3lib_diff_Obj->makeDiffDisplay(
3042                          t3lib_BEfunc::getProcessedValue($table,$field,$dLVal['old'][$field],0,1),
3043                          t3lib_BEfunc::getProcessedValue($table,$field,$dLVal['new'][$field],0,1)
3044                      );
3045  
3046                      $item.='<div class="typo3-TCEforms-diffBox">'.
3047                          '<div class="typo3-TCEforms-diffBox-header">'.htmlspecialchars($this->getLL('l_changeInOrig')).':</div>'.
3048                          $diffres.
3049                      '</div>';
3050                  }
3051              }
3052          }
3053  
3054          return $item;
3055      }
3056  
3057  
3058  
3059  
3060  
3061  
3062  
3063  
3064  
3065      /************************************************************
3066       *
3067       * Form element helper functions
3068       *
3069       ************************************************************/
3070  
3071      /**
3072       * Prints the selector box form-field for the db/file/select elements (multiple)
3073       *
3074       * @param    string        Form element name
3075       * @param    string        Mode "db", "file" (internal_type for the "group" type) OR blank (then for the "select" type)
3076       * @param    string        Commalist of "allowed"
3077       * @param    array        The array of items. For "select" and "group"/"file" this is just a set of value. For "db" its an array of arrays with table/uid pairs.
3078       * @param    string        Alternative selector box.
3079       * @param    array        An array of additional parameters, eg: "size", "info", "headers" (array with "selector" and "items"), "noBrowser", "thumbnails"
3080       * @param    string        On focus attribute string
3081       * @param    string        $table: (optional) Table name processing for
3082       * @param    string        $field: (optional) Field of table name processing for
3083       * @param    string        $uid:    (optional) uid of table record processing for
3084       * @return    string        The form fields for the selection.
3085       */
3086  	function dbFileIcons($fName,$mode,$allowed,$itemArray,$selector='',$params=array(),$onFocus='',$table='',$field='',$uid='')    {
3087  
3088  
3089          $disabled = '';
3090          if($this->renderReadonly || $params['readOnly'])  {
3091              $disabled = ' disabled="disabled"';
3092          }
3093  
3094              // Sets a flag which means some JavaScript is included on the page to support this element.
3095          $this->printNeededJS['dbFileIcons']=1;
3096  
3097              // INIT
3098          $uidList=array();
3099          $opt=array();
3100          $itemArrayC=0;
3101  
3102              // Creating <option> elements:
3103          if (is_array($itemArray))    {
3104              $itemArrayC=count($itemArray);
3105              reset($itemArray);
3106              switch($mode)    {
3107                  case 'db':
3108                      while(list(,$pp)=each($itemArray))    {
3109                          $pRec = t3lib_BEfunc::getRecordWSOL($pp['table'],$pp['id']);
3110                          if (is_array($pRec))    {
3111                              $pTitle = t3lib_BEfunc::getRecordTitle($pp['table'], $pRec, FALSE, TRUE);
3112                              $pUid = $pp['table'].'_'.$pp['id'];
3113                              $uidList[]=$pUid;
3114                              $opt[]='<option value="'.htmlspecialchars($pUid).'">'.htmlspecialchars($pTitle).'</option>';
3115                          }
3116                      }
3117                  break;
3118                  case 'file':
3119                      while(list(,$pp)=each($itemArray))    {
3120                          $pParts = explode('|',$pp);
3121                          $uidList[]=$pUid=$pTitle = $pParts[0];
3122                          $opt[]='<option value="'.htmlspecialchars(rawurldecode($pParts[0])).'">'.htmlspecialchars(rawurldecode($pParts[0])).'</option>';
3123                      }
3124                  break;
3125                  default:
3126                      while(list(,$pp)=each($itemArray))    {
3127                          $pParts = explode('|',$pp, 2);
3128                          $uidList[]=$pUid=$pParts[0];
3129                          $pTitle = $pParts[1];
3130                          $opt[]='<option value="'.htmlspecialchars(rawurldecode($pUid)).'">'.htmlspecialchars(rawurldecode($pTitle)).'</option>';
3131                      }
3132                  break;
3133              }
3134          }
3135  
3136              // Create selector box of the options
3137          $sSize = $params['autoSizeMax'] ? t3lib_div::intInRange($itemArrayC+1,t3lib_div::intInRange($params['size'],1),$params['autoSizeMax']) : $params['size'];
3138          if (!$selector)    {
3139              $selector = '<select size="'.$sSize.'"'.$this->insertDefStyle('group').' multiple="multiple" name="'.$fName.'_list" '.$onFocus.$params['style'].$disabled.'>'.implode('',$opt).'</select>';
3140          }
3141  
3142  
3143          $icons = array(
3144              'L' => array(),
3145              'R' => array(),
3146          );
3147          if (!$params['readOnly']) {
3148              if (!$params['noBrowser'])    {
3149                      // check against inline uniqueness
3150                  $inlineParent = $this->inline->getStructureLevel(-1);
3151                  if(is_array($inlineParent) && $inlineParent['uid']) {
3152                      if ($inlineParent['config']['foreign_table'] == $table && $inlineParent['config']['foreign_unique'] == $field) {
3153                          $objectPrefix = $this->inline->inlineNames['object'].'['.$table.']';
3154                          $aOnClickInline = $objectPrefix.'|inline.checkUniqueElement|inline.setUniqueElement';
3155                          $rOnClickInline = 'inline.revertUnique(\''.$objectPrefix.'\',null,\''.$uid.'\');';
3156                      }
3157                  }
3158                  $aOnClick='setFormValueOpenBrowser(\''.$mode.'\',\''.($fName.'|||'.$allowed.'|'.$aOnClickInline).'\'); return false;';
3159                  $icons['R'][]='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
3160                          '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/insert3.gif','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib($this->getLL('l_browse_'.($mode=='file'?'file':'db'))).' />'.
3161                          '</a>';
3162              }
3163              if (!$params['dontShowMoveIcons'])    {
3164                  if ($sSize>=5)    {
3165                      $icons['L'][]='<a href="#" onclick="setFormValueManipulate(\''.$fName.'\',\'Top\'); return false;">'.
3166                              '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/group_totop.gif','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib($this->getLL('l_move_to_top')).' />'.
3167                              '</a>';
3168                  }
3169                  $icons['L'][]='<a href="#" onclick="setFormValueManipulate(\''.$fName.'\',\'Up\'); return false;">'.
3170                          '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/up.gif','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib($this->getLL('l_move_up')).' />'.
3171                          '</a>';
3172                  $icons['L'][]='<a href="#" onclick="setFormValueManipulate(\''.$fName.'\',\'Down\'); return false;">'.
3173                          '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/down.gif','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib($this->getLL('l_move_down')).' />'.
3174                          '</a>';
3175                  if ($sSize>=5)    {
3176                      $icons['L'][]='<a href="#" onclick="setFormValueManipulate(\''.$fName.'\',\'Bottom\'); return false;">'.
3177                              '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/group_tobottom.gif','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib($this->getLL('l_move_to_bottom')).' />'.
3178                              '</a>';
3179                  }
3180              }
3181  
3182              $clipElements = $this->getClipboardElements($allowed,$mode);
3183              if (count($clipElements))    {
3184                  $aOnClick = '';
3185      #            $counter = 0;
3186                  foreach($clipElements as $elValue)    {
3187                      if ($mode=='file')    {
3188                          $itemTitle = 'unescape(\''.rawurlencode(basename($elValue)).'\')';
3189                      } else {    // 'db' mode assumed
3190                          list($itemTable,$itemUid) = explode('|', $elValue);
3191                          $itemTitle = $GLOBALS['LANG']->JScharCode(t3lib_BEfunc::getRecordTitle($itemTable, t3lib_BEfunc::getRecordWSOL($itemTable,$itemUid)));
3192                          $elValue = $itemTable.'_'.$itemUid;
3193                      }
3194                      $aOnClick.= 'setFormValueFromBrowseWin(\''.$fName.'\',unescape(\''.rawurlencode(str_replace('%20',' ',$elValue)).'\'),'.$itemTitle.');';
3195  
3196      #                $counter++;
3197      #                if ($params['maxitems'] && $counter >= $params['maxitems'])    {    break;    }    // Makes sure that no more than the max items are inserted... for convenience.
3198                  }
3199                  $aOnClick.= 'return false;';
3200                  $icons['R'][]='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
3201                          '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/insert5.png','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib(sprintf($this->getLL('l_clipInsert_'.($mode=='file'?'file':'db')),count($clipElements))).' />'.
3202                          '</a>';
3203              }
3204              $rOnClick = $rOnClickInline.'setFormValueManipulate(\''.$fName.'\',\'Remove\'); return false';
3205              $icons['L'][]='<a href="#" onclick="'.htmlspecialchars($rOnClick).'">'.
3206                      '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/group_clear.gif','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib($this->getLL('l_remove_selected')).' />'.
3207                      '</a>';
3208          }
3209  
3210          $str='<table border="0" cellpadding="0" cellspacing="0" width="1">
3211              '.($params['headers']?'
3212                  <tr>
3213                      <td>'.$this->wrapLabels($params['headers']['selector']).'</td>
3214                      <td></td>
3215                      <td></td>
3216                      <td></td>
3217                      <td>'.($params['thumbnails'] ? $this->wrapLabels($params['headers']['items']) : '').'</td>
3218                  </tr>':'').
3219              '
3220              <tr>
3221                  <td valign="top">'.
3222                      $selector.'<br />'.
3223                      $this->wrapLabels($params['info']).
3224                  '</td>
3225                  <td valign="top">'.
3226                      implode('<br />',$icons['L']).'</td>
3227                  <td valign="top">'.
3228                      implode('<br />',$icons['R']).'</td>
3229                  <td><img src="clear.gif" width="5" height="1" alt="" /></td>
3230                  <td valign="top">'.
3231                      $this->wrapLabels($params['thumbnails']).
3232                  '</td>
3233              </tr>
3234          </table>';
3235  
3236              // Creating the hidden field which contains the actual value as a comma list.
3237          $str.='<input type="hidden" name="'.$fName.'" value="'.htmlspecialchars(implode(',',$uidList)).'" />';
3238  
3239          return $str;
3240      }
3241  
3242      /**
3243       * Returns array of elements from clipboard to insert into GROUP element box.
3244       *
3245       * @param    string        Allowed elements, Eg "pages,tt_content", "gif,jpg,jpeg,png"
3246       * @param    string        Mode of relations: "db" or "file"
3247       * @return    array        Array of elements in values (keys are insignificant), if none found, empty array.
3248       */
3249  	function getClipboardElements($allowed,$mode)    {
3250  
3251          $output = array();
3252  
3253          if (is_object($this->clipObj))    {
3254              switch($mode)    {
3255                  case 'file':
3256                      $elFromTable = $this->clipObj->elFromTable('_FILE');
3257                      $allowedExts = t3lib_div::trimExplode(',', $allowed, 1);
3258  
3259                      if ($allowedExts)    {    // If there are a set of allowed extensions, filter the content:
3260                          foreach($elFromTable as $elValue)    {
3261                              $pI = pathinfo($elValue);
3262                              $ext = strtolower($pI['extension']);
3263                              if (in_array($ext, $allowedExts))    {
3264                                  $output[] = $elValue;
3265                              }
3266                          }
3267                      } else {    // If all is allowed, insert all: (This does NOT respect any disallowed extensions, but those will be filtered away by the backend TCEmain)
3268                          $output = $elFromTable;
3269                      }
3270                  break;
3271                  case 'db':
3272                      $allowedTables = t3lib_div::trimExplode(',', $allowed, 1);
3273                      if (!strcmp(trim($allowedTables[0]),'*'))    {    // All tables allowed for relation:
3274                          $output = $this->clipObj->elFromTable('');
3275                      } else {    // Only some tables, filter them:
3276                          foreach($allowedTables as $tablename)    {
3277                              $elFromTable = $this->clipObj->elFromTable($tablename);
3278                              $output = array_merge($output,$elFromTable);
3279                          }
3280                      }
3281                      $output = array_keys($output);
3282                  break;
3283              }
3284          }
3285  
3286          return $output;
3287      }
3288  
3289      /**
3290       * Wraps the icon of a relation item (database record or file) in a link opening the context menu for the item.
3291       * Icons will be wrapped only if $this->enableClickMenu is set. This must be done only if a global SOBE object exists and if the necessary JavaScript for displaying the context menus has been added to the page properties.
3292       *
3293       * @param    string        The icon HTML to wrap
3294       * @param    string        Table name (eg. "pages" or "tt_content") OR the absolute path to the file
3295       * @param    integer        The uid of the record OR if file, just blank value.
3296       * @return    string        HTML
3297       */
3298  	function getClickMenu($str,$table,$uid='')    {
3299          if ($this->enableClickMenu)    {
3300              $onClick = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($str,$table,$uid,1,'','+copy,info,edit,view', TRUE);
3301              return '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.$str.'</a>';
3302          }
3303      }
3304  
3305      /**
3306       * Rendering wizards for form fields.
3307       *
3308       * @param    array        Array with the real item in the first value, and an alternative item in the second value.
3309       * @param    array        The "wizard" key from the config array for the field (from TCA)
3310       * @param    string        Table name
3311       * @param    array        The record array
3312       * @param    string        The field name
3313       * @param    array        Additional configuration array. (passed by reference!)
3314       * @param    string        The field name
3315       * @param    array        Special configuration if available.
3316       * @param    boolean        Whether the RTE could have been loaded.
3317       * @return    string        The new item value.
3318       */
3319  	function renderWizards($itemKinds,$wizConf,$table,$row,$field,&$PA,$itemName,$specConf,$RTE=0)    {
3320  
3321              // Init:
3322          $fieldChangeFunc = $PA['fieldChangeFunc'];
3323          $item = $itemKinds[0];
3324          $outArr = array();
3325          $colorBoxLinks = array();
3326          $fName = '['.$table.']['.$row['uid'].']['.$field.']';
3327          $md5ID = 'ID'.t3lib_div::shortmd5($itemName);
3328          $listFlag = '_list';
3329  
3330              // Manipulate the field name (to be the true form field name) and remove a suffix-value if the item is a selector box with renderMode "singlebox":
3331          if ($PA['fieldConf']['config']['form_type']=='select')    {
3332              if ($PA['fieldConf']['config']['maxitems']<=1)    {    // Single select situation:
3333                  $listFlag = '';
3334              } elseif ($PA['fieldConf']['config']['renderMode']=='singlebox')    {
3335                  $itemName.='[]';
3336                  $listFlag = '';
3337              }
3338          }
3339  
3340              // traverse wizards:
3341          if (is_array($wizConf) && !$this->disableWizards)    {
3342              foreach($wizConf as $wid => $wConf)    {
3343                  if (substr($wid,0,1)!='_'
3344                          && (!$wConf['enableByTypeConfig'] || @in_array($wid,$specConf['wizards']['parameters']))
3345                          && ($RTE || !$wConf['RTEonly'])
3346                      )    {
3347  
3348                          // Title / icon:
3349                      $iTitle = htmlspecialchars($this->sL($wConf['title']));
3350                      if ($wConf['icon'])    {
3351                          $iDat = $this->getIcon($wConf['icon']);
3352                          $icon = '<img src="'.$iDat[0].'" '.$iDat[1][3].' border="0"'.t3lib_BEfunc::titleAltAttrib($iTitle).' />';
3353                      } else {
3354                          $icon = $iTitle;
3355                      }
3356  
3357                          //
3358                      switch((string)$wConf['type'])    {
3359                          case 'userFunc':
3360                          case 'script':
3361                          case 'popup':
3362                          case 'colorbox':
3363                              if (!$wConf['notNewRecords'] || t3lib_div::testInt($row['uid']))    {
3364  
3365                                      // Setting &P array contents:
3366                                  $params = array();
3367                                  $params['params'] = $wConf['params'];
3368                                  $params['exampleImg'] = $wConf['exampleImg'];
3369                                  $params['table'] = $table;
3370                                  $params['uid'] = $row['uid'];
3371                                  $params['pid'] = $row['pid'];
3372                                  $params['field'] = $field;
3373                                  $params['md5ID'] = $md5ID;
3374                                  $params['returnUrl'] = $this->thisReturnUrl();
3375  
3376                                      // Resolving script filename and setting URL.
3377                                  if (!strcmp(substr($wConf['script'],0,4), 'EXT:')) {
3378                                      $wScript = t3lib_div::getFileAbsFileName($wConf['script']);
3379                                      if ($wScript)    {
3380                                          $wScript = '../'.substr($wScript,strlen(PATH_site));
3381                                      } else break;
3382                                  } else {
3383                                      $wScript = $wConf['script'];
3384                                  }
3385                                  $url = $this->backPath.$wScript.(strstr($wScript,'?') ? '' : '?');
3386  
3387                                      // If there is no script and the type is "colorbox", break right away:
3388                                  if ((string)$wConf['type']=='colorbox' && !$wConf['script'])    { break; }
3389  
3390                                      // If "script" type, create the links around the icon:
3391                                  if ((string)$wConf['type']=='script')    {
3392                                      $aUrl = $url.t3lib_div::implodeArrayForUrl('',array('P'=>$params));
3393                                      $outArr[]='<a href="'.htmlspecialchars($aUrl).'" onclick="'.$this->blur().'return !TBE_EDITOR.isFormChanged();">'.
3394                                          $icon.
3395                                          '</a>';
3396                                  } else {
3397  
3398                                          // ... else types "popup", "colorbox" and "userFunc" will need additional parameters:
3399                                      $params['formName'] = $this->formName;
3400                                      $params['itemName'] = $itemName;
3401                                      $params['fieldChangeFunc'] = $fieldChangeFunc;
3402  
3403                                      switch((string)$wConf['type'])    {
3404                                          case 'popup':
3405                                          case 'colorbox':
3406                                                  // Current form value is passed as P[currentValue]!
3407                                              $addJS = $wConf['popup_onlyOpenIfSelected']?'if (!TBE_EDITOR.curSelected(\''.$itemName.$listFlag.'\')){alert('.$GLOBALS['LANG']->JScharCode($this->getLL('m_noSelItemForEdit')).'); return false;}':'';
3408                                              $curSelectedValues='+\'&P[currentSelectedValues]=\'+TBE_EDITOR.curSelected(\''.$itemName.$listFlag.'\')';
3409                                              $aOnClick=    $this->blur().
3410                                                          $addJS.
3411                                                          'vHWin=window.open(\''.$url.t3lib_div::implodeArrayForUrl('',array('P'=>$params)).'\'+\'&P[currentValue]=\'+TBE_EDITOR.rawurlencode('.$this->elName($itemName).'.value,200)'.$curSelectedValues.',\'popUp'.$md5ID.'\',\''.$wConf['JSopenParams'].'\');'.
3412                                                          'vHWin.focus();return false;';
3413                                                  // Setting "colorBoxLinks" - user LATER to wrap around the color box as well:
3414                                              $colorBoxLinks = Array('<a href="#" onclick="'.htmlspecialchars($aOnClick).'">','</a>');
3415                                              if ((string)$wConf['type']=='popup')    {
3416                                                  $outArr[] = $colorBoxLinks[0].$icon.$colorBoxLinks[1];
3417                                              }
3418                                          break;
3419                                          case 'userFunc':
3420                                              $params['item'] = &$item;    // Reference set!
3421                                              $params['icon'] = $icon;
3422                                              $params['iTitle'] = $iTitle;
3423                                              $params['wConf'] = $wConf;
3424                                              $params['row'] = $row;
3425                                              $outArr[] = t3lib_div::callUserFunction($wConf['userFunc'],$params,$this);
3426                                          break;
3427                                      }
3428                                  }
3429  
3430                                      // Hide the real form element?
3431                                  if (is_array($wConf['hideParent']) || $wConf['hideParent'])    {
3432                                      $item = $itemKinds[1];    // Setting the item to a hidden-field.
3433                                      if (is_array($wConf['hideParent']))    {
3434                                          $item.= $this->getSingleField_typeNone_render($wConf['hideParent'], $PA['itemFormElValue']);
3435                                      }
3436                                  }
3437                              }
3438                          break;
3439                          case 'select':
3440                              $fieldValue = array('config' => $wConf);
3441                              $TSconfig = $this->setTSconfig($table, $row);
3442                              $TSconfig[$field] = $TSconfig[$field]['wizards.'][$wid.'.'];
3443                              $selItems = $this->addSelectOptionsToItemArray($this->initItemArray($fieldValue), $fieldValue, $TSconfig, $field);
3444  
3445                              $opt = array();
3446                              $opt[] = '<option>'.$iTitle.'</option>';
3447                              foreach($selItems as $p)    {
3448                                  $opt[] = '<option value="'.htmlspecialchars($p[1]).'">'.htmlspecialchars($p[0]).'</option>';
3449                              }
3450                              if ($wConf['mode']=='append')    {
3451                                  $assignValue = $this->elName($itemName).'.value=\'\'+this.options[this.selectedIndex].value+'.$this->elName($itemName).'.value';
3452                              } elseif ($wConf['mode']=='prepend')    {
3453                                  $assignValue = $this->elName($itemName).'.value+=\'\'+this.options[this.selectedIndex].value';
3454                              } else {
3455                                  $assignValue = $this->elName($itemName).'.value=this.options[this.selectedIndex].value';
3456                              }
3457                              $sOnChange = $assignValue.';this.selectedIndex=0;'.implode('',$fieldChangeFunc);
3458                              $outArr[] = '<select name="_WIZARD'.$fName.'" onchange="'.htmlspecialchars($sOnChange).'">'.implode('',$opt).'</select>';
3459                          break;
3460                      }
3461  
3462                          // Color wizard colorbox:
3463                      if ((string)$wConf['type']=='colorbox')    {
3464                          $dim = t3lib_div::intExplode('x',$wConf['dim']);
3465                          $dX = t3lib_div::intInRange($dim[0],1,200,20);
3466                          $dY = t3lib_div::intInRange($dim[1],1,200,20);
3467                          $color = $PA['itemFormElValue'] ? ' bgcolor="'.htmlspecialchars($PA['itemFormElValue']).'"' : '';
3468                          $outArr[] = '<table border="0" cellpadding="0" cellspacing="0" id="'.$md5ID.'"'.$color.' style="'.htmlspecialchars($wConf['tableStyle']).'">
3469                                      <tr>
3470                                          <td>'.
3471                                              $colorBoxLinks[0].
3472                                              '<img src="clear.gif" width="'.$dX.'" height="'.$dY.'"'.t3lib_BEfunc::titleAltAttrib(trim($iTitle.' '.$PA['itemFormElValue'])).' border="0" />'.
3473                                              $colorBoxLinks[1].
3474                                              '</td>
3475                                      </tr>
3476                                  </table>';
3477                      }
3478                  }
3479              }
3480  
3481                  // For each rendered wizard, put them together around the item.
3482              if (count($outArr))    {
3483                  if ($wizConf['_HIDDENFIELD'])    $item = $itemKinds[1];
3484  
3485                  $outStr = '';
3486                  $vAlign = $wizConf['_VALIGN'] ? ' valign="'.$wizConf['_VALIGN'].'"' : '';
3487                  if (count($outArr)>1 || $wizConf['_PADDING'])    {
3488                      $dist = intval($wizConf['_DISTANCE']);
3489                      if ($wizConf['_VERTICAL'])    {
3490                          $dist = $dist ? '<tr><td><img src="clear.gif" width="1" height="'.$dist.'" alt="" /></td></tr>' : '';
3491                          $outStr = '<tr><td>'.implode('</td></tr>'.$dist.'<tr><td>',$outArr).'</td></tr>';
3492                      } else {
3493                          $dist = $dist ? '<td><img src="clear.gif" height="1" width="'.$dist.'" alt="" /></td>' : '';
3494                          $outStr = '<tr><td'.$vAlign.'>'.implode('</td>'.$dist.'<td'.$vAlign.'>',$outArr).'</td></tr>';
3495                      }
3496                      $outStr = '<table border="0" cellpadding="'.intval($wizConf['_PADDING']).'" cellspacing="0">'.$outStr.'</table>';
3497                  } else {
3498                      $outStr = implode('',$outArr);
3499                  }
3500  
3501                  if (!strcmp($wizConf['_POSITION'],'left'))    {
3502                      $outStr = '<tr><td'.$vAlign.'>'.$outStr.'</td><td'.$vAlign.'>'.$item.'</td></tr>';
3503                  } elseif (!strcmp($wizConf['_POSITION'],'top'))    {
3504                      $outStr = '<tr><td>'.$outStr.'</td></tr><tr><td>'.$item.'</td></tr>';
3505                  } elseif (!strcmp($wizConf['_POSITION'],'bottom'))    {
3506                      $outStr = '<tr><td>'.$item.'</td></tr><tr><td>'.$outStr.'</td></tr>';
3507                  } else {
3508                      $outStr = '<tr><td'.$vAlign.'>'.$item.'</td><td'.$vAlign.'>'.$outStr.'</td></tr>';
3509                  }
3510  
3511                  $item = '<table border="0" cellpadding="0" cellspacing="0">'.$outStr.'</table>';
3512              }
3513          }
3514          return $item;
3515      }
3516  
3517      /**
3518       * Get icon (for example for selector boxes)
3519       *
3520       * @param    string        Icon reference
3521       * @return    array        Array with two values; the icon file reference (relative to PATH_typo3 minus backPath), the icon file information array (getimagesize())
3522       */
3523  	function getIcon($icon)    {
3524          if (substr($icon,0,4)=='EXT:')    {
3525              $file = t3lib_div::getFileAbsFileName($icon);
3526              if ($file)    {
3527                  $file = substr($file,strlen(PATH_site));
3528                  $selIconFile = $this->backPath.'../'.$file;
3529                  $selIconInfo = @getimagesize(PATH_site.$file);
3530              }
3531          } elseif (substr($icon,0,3)=='../')    {
3532              $selIconFile = $this->backPath.t3lib_div::resolveBackPath($icon);
3533              $selIconInfo = @getimagesize(PATH_site.t3lib_div::resolveBackPath(substr($icon,3)));
3534          } elseif (substr($icon,0,4)=='ext/' || substr($icon,0,7)=='sysext/') {
3535              $selIconFile = $this->backPath.$icon;
3536              $selIconInfo = @getimagesize(PATH_typo3.$icon);
3537          } else {
3538              $selIconFile = t3lib_iconWorks::skinImg($this->backPath,'gfx/'.$icon,'',1);
3539              $selIconInfo = @getimagesize(PATH_typo3.$selIconFile);
3540          }
3541          return array($selIconFile,$selIconInfo);
3542      }
3543  
3544      /**
3545       * Creates style attribute content for option tags in a selector box, primarily setting it up to show the icon of an element as background image (works in mozilla)
3546       *
3547       * @param    string        Icon string for option item
3548       * @return    string        Style attribute content, if any
3549       */
3550  	function optionTagStyle($iconString)    {
3551          if ($iconString)    {
3552              list($selIconFile,$selIconInfo) = $this->getIcon($iconString);
3553              $padTop = t3lib_div::intInRange(($selIconInfo[1]-12)/2,0);
3554              $styleAttr = 'background-image: url('.$selIconFile.'); background-repeat: no-repeat; height: '.t3lib_div::intInRange(($selIconInfo[1]+2)-$padTop,0).'px; padding-top: '.$padTop.'px; padding-left: '.($selIconInfo[0]+4).'px;';
3555              return $styleAttr;
3556          }
3557      }
3558  
3559      /**
3560       * Extracting values from a value/label list (as made by transferData class)
3561       *
3562       * @param    string        Value string where values are comma separated, intermixed with labels and rawurlencoded (this is what is delivered to TCEforms normally!)
3563       * @param    array        Values in an array
3564       * @return    array        Input string exploded with comma and for each value only the label part is set in the array. Keys are numeric
3565       */
3566  	function extractValuesOnlyFromValueLabelList($itemFormElValue)    {
3567              // Get values of selected items:
3568          $itemArray = t3lib_div::trimExplode(',',$itemFormElValue,1);
3569          foreach($itemArray as $tk => $tv) {
3570              $tvP = explode('|',$tv,2);
3571              $tvP[0] = rawurldecode($tvP[0]);
3572  
3573              $itemArray[$tk] = $tvP[0];
3574          }
3575          return $itemArray;
3576      }
3577  
3578      /**
3579       * Wraps a string with a link to the palette.
3580       *
3581       * @param    string        The string to wrap in an A-tag
3582       * @param    string        The table name for which to open the palette.
3583       * @param    array        The record array
3584       * @param    integer        The palette pointer.
3585       * @param    boolean        Determines the output type of the function.
3586       * @return    mixed        If $retFunc is set, then returns an array with icon code and palette JavaScript function. Otherwise just the icon code.
3587       */
3588  	function wrapOpenPalette($header,$table,$row,$palette,$retFunc=0)    {
3589          $fieldL=array();
3590          if (!is_array($this->palFieldArr[$palette]))    {$this->palFieldArr[$palette]=array();}
3591          $palFieldN = is_array($this->palFieldArr[$palette]) ? count($this->palFieldArr[$palette]) : 0;
3592          $palJSFunc = 'TBE_EDITOR.palUrl(\''.($table.':'.$row['uid'].':'.$palette).'\',\''.implode(',',$this->palFieldArr[$palette]).'\','.$palFieldN.',\''.$table.'\',\''.$row['uid'].'\',1);';
3593  
3594          $aOnClick = $this->blur().substr($palJSFunc,0,-3).'0);return false;';
3595  
3596          $iconCode = '<a href="#" onclick="'.htmlspecialchars($aOnClick).'" title="'.htmlspecialchars($table).'">'.
3597                      $header.
3598                      '</a>';
3599          return $retFunc ? array($iconCode,$palJSFunc) : $iconCode;
3600      }
3601  
3602      /**
3603       * Creates checkbox parameters
3604       *
3605       * @param    string        Form element name
3606       * @param    integer        The value of the checkbox (representing checkboxes with the bits)
3607       * @param    integer        Checkbox # (0-9?)
3608       * @param    integer        Total number of checkboxes in the array.
3609       * @param    string        Additional JavaScript for the onclick handler.
3610       * @return    string        The onclick attribute + possibly the checked-option set.
3611       */
3612  	function checkBoxParams($itemName,$thisValue,$c,$iCount,$addFunc='')    {
3613          $onClick = $this->elName($itemName).'.value=this.checked?('.$this->elName($itemName).'.value|'.pow(2,$c).'):('.$this->elName($itemName).'.value&'.(pow(2,$iCount)-1-pow(2,$c)).');'.
3614                      $addFunc;
3615          $str = ' onclick="'.htmlspecialchars($onClick).'"'.
3616                  (($thisValue&pow(2,$c))?' checked="checked"':'');
3617          return $str;
3618      }
3619  
3620      /**
3621       * Returns element reference for form element name
3622       *
3623       * @param    string        Form element name
3624       * @return    string        Form element reference (JS)
3625       */
3626  	function elName($itemName)    {
3627          return 'document.'.$this->formName."['".$itemName."']";
3628      }
3629  
3630      /**
3631       * Returns the "No title" string if the input $str is empty.
3632       *
3633       * DEPRECATED: Use t3lib_BEfunc::getRecordTitle with the $forceResult flag set.
3634       *
3635       * @param    string        The string which - if empty - will become the no-title string.
3636       * @param    array        Array with wrappin parts for the no-title output (in keys [0]/[1])
3637       * @return    string
3638       * @deprecated
3639       */
3640  	function noTitle($str,$wrapParts=array())    {
3641          return strcmp($str,'') ? $str : $wrapParts[0].'['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title').']'.$wrapParts[1];
3642      }
3643  
3644      /**
3645       * Returns 'this.blur();' string, if supported.
3646       *
3647       * @return    string        If the current browser supports styles, the string 'this.blur();' is returned.
3648       */
3649  	function blur()    {
3650          return $GLOBALS['CLIENT']['FORMSTYLE'] ? 'this.blur();':'';
3651      }
3652  
3653      /**
3654       * Returns the "returnUrl" of the form. Can be set externally or will be taken from "t3lib_div::linkThisScript()"
3655       *
3656       * @return    string        Return URL of current script
3657       */
3658  	function thisReturnUrl()    {
3659          return $this->returnUrl ? $this->returnUrl : t3lib_div::linkThisScript();
3660      }
3661  
3662      /**
3663       * Returns the form field for a single HIDDEN field.
3664       * (Not used anywhere...?)
3665       *
3666       * @param    string        Table name
3667       * @param    string        Field name
3668       * @param    array        The row
3669       * @return    string        The hidden-field <input> tag.
3670       */
3671  	function getSingleHiddenField($table,$field,$row)    {
3672          global $TCA;
3673          $out='';
3674          t3lib_div::loadTCA($table);
3675          if ($TCA[$table]['columns'][$field])    {
3676  
3677              $uid=$row['uid'];
3678              $itemName=$this->prependFormFieldNames.'['.$table.']['.$uid.']['.$field.']';
3679              $itemValue=$row[$field];
3680              $item.='<input type="hidden" name="'.$itemName.'" value="'.htmlspecialchars($itemValue).'" />';
3681              $out = $item;
3682          }
3683          return $out;
3684      }
3685  
3686      /**
3687       * Returns parameters to set the width for a <input>/<textarea>-element
3688       *
3689       * @param    integer        The abstract size value (1-48)
3690       * @param    boolean        If this is for a text area.
3691       * @return    string        Either a "style" attribute string or "cols"/"size" attribute string.
3692       */
3693  	function formWidth($size=48,$textarea=0)    {
3694              // Input or text-field attribute (size or cols)
3695          if ($this->docLarge)    $size = round($size*$this->form_largeComp);
3696          $wAttrib = $textarea?'cols':'size';
3697          if (!$GLOBALS['CLIENT']['FORMSTYLE'])    {    // If not setting the width by style-attribute
3698              $retVal = ' '.$wAttrib.'="'.$size.'"';
3699          } else {    // Setting width by style-attribute. 'cols' MUST be avoided with NN6+
3700              $pixels = ceil($size*$this->form_rowsToStylewidth);
3701              $theStyle = 'width:'.$pixels.'px;'.$this->defStyle.$this->formElStyle($textarea?'text':'input');
3702              $retVal = ' style="'.htmlspecialchars($theStyle).'"';
3703  
3704              $class = $this->formElClass($textarea?'text':'input');
3705              if ($class)    {
3706                  $retVal.= ' class="'.htmlspecialchars($class).'"';
3707              }
3708          }
3709          return $retVal;
3710      }
3711  
3712      /**
3713       * Returns parameters to set with for a textarea field
3714       *
3715       * @param    integer        The abstract width (1-48)
3716       * @param    string        Empty or "off" (text wrapping in the field or not)
3717       * @return    string        The "cols" attribute string (or style from formWidth())
3718       * @see formWidth()
3719       */
3720  	function formWidthText($size=48,$wrap='')    {
3721          $wTags = $this->formWidth($size,1);
3722              // Netscape 6+ seems to have this ODD problem where there WILL ALWAYS be wrapping with the cols-attribute set and NEVER without the col-attribute...
3723          if (strtolower(trim($wrap))!='off' && $GLOBALS['CLIENT']['BROWSER']=='net' && $GLOBALS['CLIENT']['VERSION']>=5)    {
3724              $wTags.= ' cols="'.$size.'"';
3725          }
3726          return $wTags;
3727      }
3728  
3729      /**
3730       * Get style CSS values for the current field type.
3731       *
3732       * @param    string        Field type (eg. "check", "radio", "select")
3733       * @return    string        CSS attributes
3734       * @see formElStyleClassValue()
3735       */
3736  	function formElStyle($type)    {
3737          return $this->formElStyleClassValue($type);
3738      }
3739  
3740      /**
3741       * Get class attribute value for the current field type.
3742       *
3743       * @param    string        Field type (eg. "check", "radio", "select")
3744       * @return    string        CSS attributes
3745       * @see formElStyleClassValue()
3746       */
3747  	function formElClass($type)    {
3748          return $this->formElStyleClassValue($type, TRUE);
3749      }
3750  
3751      /**
3752       * Get style CSS values for the current field type.
3753       *
3754       * @param    string        Field type (eg. "check", "radio", "select")
3755       * @param    boolean        If set, will return value only if prefixed with CLASS, otherwise must not be prefixed "CLASS"
3756       * @return    string        CSS attributes
3757       */
3758  	function formElStyleClassValue($type, $class=FALSE)    {
3759              // Get value according to field:
3760          if (isset($this->fieldStyle[$type]))    {
3761              $style = trim($this->fieldStyle[$type]);
3762          } else {
3763              $style = trim($this->fieldStyle['all']);
3764          }
3765  
3766              // Check class prefixed:
3767          if (substr($style,0,6)=='CLASS:')    {
3768              $out = $class ? trim(substr($style,6)) : '';
3769          } else {
3770              $out = !$class ? $style : '';
3771          }
3772  
3773          return $out;
3774      }
3775  
3776      /**
3777       * Return default "style" / "class" attribute line.
3778       *
3779       * @param    string        Field type (eg. "check", "radio", "select")
3780       * @return    string        CSS attributes
3781       */
3782  	function insertDefStyle($type)    {
3783          $out = '';
3784  
3785          $style = trim($this->defStyle.$this->formElStyle($type));
3786          $out.= $style?' style="'.htmlspecialchars($style).'"':'';
3787  
3788          $class = $this->formElClass($type);
3789          $out.= $class?' class="'.htmlspecialchars($class).'"':'';
3790  
3791          return $out;
3792      }
3793  
3794      /**
3795       * Create dynamic tab menu
3796       *
3797       * @param    array        Parts for the tab menu, fed to template::getDynTabMenu()
3798       * @param    string        ID string for the tab menu
3799       * @return    string        HTML for the menu
3800       */
3801  	function getDynTabMenu($parts, $idString) {
3802          if (is_object($GLOBALS['TBE_TEMPLATE']))    {
3803              return $GLOBALS['TBE_TEMPLATE']->getDynTabMenu($parts, $idString);
3804          } else {
3805              $output = '';
3806              foreach($parts as $singlePad)    {
3807                  $output.='
3808                  <h3>'.htmlspecialchars($singlePad['label']).'</h3>
3809                  '.($singlePad['description'] ? '<p class="c-descr">'.nl2br(htmlspecialchars($singlePad['description'])).'</p>' : '').'
3810                  '.$singlePad['content'];
3811              }
3812  
3813              return '<div class="typo3-dyntabmenu-divs">'.$output.'</div>';
3814          }
3815      }
3816  
3817  
3818  
3819  
3820  
3821  
3822  
3823  
3824  
3825  
3826  
3827      /************************************************************
3828       *
3829       * Item-array manipulation functions (check/select/radio)
3830       *
3831       ************************************************************/
3832  
3833      /**
3834       * Initialize item array (for checkbox, selectorbox, radio buttons)
3835       * Will resolve the label value.
3836       *
3837       * @param    array        The "columns" array for the field (from TCA)
3838       * @return    array        An array of arrays with three elements; label, value, icon
3839       */
3840  	function initItemArray($fieldValue)    {
3841          $items = array();
3842          if (is_array($fieldValue['config']['items']))    {
3843              reset ($fieldValue['config']['items']);
3844              while (list($itemName,$itemValue) = each($fieldValue['config']['items']))    {
3845                  $items[] = array($this->sL($itemValue[0]), $itemValue[1], $itemValue[2]);
3846              }
3847          }
3848          return $items;
3849      }
3850  
3851      /**
3852       * Merges items into an item-array
3853       *
3854       * @param    array        The existing item array
3855       * @param    array        An array of items to add. NOTICE: The keys are mapped to values, and the values and mapped to be labels. No possibility of adding an icon.
3856       * @return    array        The updated $item array
3857       */
3858  	function addItems($items,$iArray)    {
3859          global $TCA;
3860          if (is_array($iArray))    {
3861              reset($iArray);
3862              while(list($value,$label)=each($iArray))    {
3863                  $items[]=array($this->sl($label),$value);
3864              }
3865          }
3866          return $items;
3867      }
3868  
3869      /**
3870       * Perform user processing of the items arrays of checkboxes, selectorboxes and radio buttons.
3871       *
3872       * @param    array        The array of items (label,value,icon)
3873       * @param    array        The "itemsProcFunc." from fieldTSconfig of the field.
3874       * @param    array        The config array for the field.
3875       * @param    string        Table name
3876       * @param    array        Record row
3877       * @param    string        Field name
3878       * @return    array        The modified $items array
3879       */
3880  	function procItems($items,$iArray,$config,$table,$row,$field)    {
3881          global $TCA;
3882  
3883          $params=array();
3884          $params['items'] = &$items;
3885          $params['config'] = $config;
3886          $params['TSconfig'] = $iArray;
3887          $params['table'] = $table;
3888          $params['row'] = $row;
3889          $params['field'] = $field;
3890  
3891          t3lib_div::callUserFunction($config['itemsProcFunc'],$params,$this);
3892          return $items;
3893      }
3894  
3895      /**
3896       * Add selector box items of more exotic kinds.
3897       *
3898       * @param    array        The array of items (label,value,icon)
3899       * @param    array        The "columns" array for the field (from TCA)
3900       * @param    array        TSconfig for the table/row
3901       * @param    string        The fieldname
3902       * @return    array        The $items array modified.
3903       */
3904  	function addSelectOptionsToItemArray($items,$fieldValue,$TSconfig,$field)    {
3905          global $TCA;
3906  
3907              // Values from foreign tables:
3908          if ($fieldValue['config']['foreign_table'])    {
3909              $items = $this->foreignTable($items,$fieldValue,$TSconfig,$field);
3910              if ($fieldValue['config']['neg_foreign_table'])    {
3911                  $items = $this->foreignTable($items,$fieldValue,$TSconfig,$field,1);
3912              }
3913          }
3914  
3915              // Values from a file folder:
3916          if ($fieldValue['config']['fileFolder'])    {
3917              $fileFolder = t3lib_div::getFileAbsFileName($fieldValue['config']['fileFolder']);
3918              if (@is_dir($fileFolder))    {
3919  
3920                      // Configurations:
3921                  $extList = $fieldValue['config']['fileFolder_extList'];
3922                  $recursivityLevels = isset($fieldValue['config']['fileFolder_recursions']) ? t3lib_div::intInRange($fieldValue['config']['fileFolder_recursions'],0,99) : 99;
3923  
3924                      // Get files:
3925                  $fileFolder = ereg_replace('\/$','',$fileFolder).'/';
3926                  $fileArr = t3lib_div::getAllFilesAndFoldersInPath(array(),$fileFolder,$extList,0,$recursivityLevels);
3927                  $fileArr = t3lib_div::removePrefixPathFromList($fileArr, $fileFolder);
3928  
3929                  foreach($fileArr as $fileRef)    {
3930                      $fI = pathinfo($fileRef);
3931                      $icon = t3lib_div::inList('gif,png,jpeg,jpg', strtolower($fI['extension'])) ? '../'.substr($fileFolder,strlen(PATH_site)).$fileRef : '';
3932                      $items[] = array(
3933                          $fileRef,
3934                          $fileRef,
3935                          $icon
3936                      );
3937                  }
3938              }
3939          }
3940  
3941              // If 'special' is configured:
3942          if ($fieldValue['config']['special'])    {
3943              switch ($fieldValue['config']['special'])    {
3944                  case 'tables':
3945                      $temp_tc = array_keys($TCA);
3946                      $descr = '';
3947  
3948                      foreach($temp_tc as $theTableNames)    {
3949                          if (!$TCA[$theTableNames]['ctrl']['adminOnly'])    {
3950  
3951                                  // Icon:
3952                              $icon = '../'.TYPO3_mainDir.t3lib_iconWorks::skinImg($this->backPath,t3lib_iconWorks::getIcon($theTableNames, array()),'',1);
3953  
3954                                  // Add description texts:
3955                              if ($this->edit_showFieldHelp)    {
3956                                  $GLOBALS['LANG']->loadSingleTableDescription($theTableNames);
3957                                  $fDat = $GLOBALS['TCA_DESCR'][$theTableNames]['columns'][''];
3958                                  $descr = $fDat['description'];
3959                              }
3960  
3961                                  // Item configuration:
3962                              $items[] = array(
3963                                  $this->sL($TCA[$theTableNames]['ctrl']['title']),
3964                                  $theTableNames,
3965                                  $icon,
3966                                  $descr
3967                              );
3968                          }
3969                      }
3970                  break;
3971                  case 'pagetypes':
3972                      $theTypes = $TCA['pages']['columns']['doktype']['config']['items'];
3973  
3974                      foreach($theTypes as $theTypeArrays)    {
3975                              // Icon:
3976                          $icon = $theTypeArrays[1]!='--div--' ? '../'.TYPO3_mainDir.t3lib_iconWorks::skinImg($this->backPath,t3lib_iconWorks::getIcon('pages', array('doktype' => $theTypeArrays[1])),'',1) : '';
3977  
3978                              // Item configuration:
3979                          $items[] = array(
3980                              $this->sL($theTypeArrays[0]),
3981                              $theTypeArrays[1],
3982                              $icon
3983                          );
3984                      }
3985                  break;
3986                  case 'exclude':
3987                      $theTypes = t3lib_BEfunc::getExcludeFields();
3988                      $descr = '';
3989  
3990                      foreach($theTypes as $theTypeArrays)    {
3991                          list($theTable, $theField) = explode(':', $theTypeArrays[1]);
3992  
3993                              // Add description texts:
3994                          if ($this->edit_showFieldHelp)    {
3995                              $GLOBALS['LANG']->loadSingleTableDescription($theTable);
3996                              $fDat = $GLOBALS['TCA_DESCR'][$theTable]['columns'][$theField];
3997                              $descr = $fDat['description'];
3998                          }
3999  
4000                              // Item configuration:
4001                          $items[] = array(
4002                              ereg_replace(':$','',$theTypeArrays[0]),
4003                              $theTypeArrays[1],
4004                              '',
4005                              $descr
4006                          );
4007                      }
4008                  break;
4009                  case 'explicitValues':
4010                      $theTypes = t3lib_BEfunc::getExplicitAuthFieldValues();
4011  
4012                              // Icons:
4013                      $icons = array(
4014                          'ALLOW' => '../'.TYPO3_mainDir.t3lib_iconWorks::skinImg($this->backPath,'gfx/icon_ok2.gif','',1),
4015                          'DENY' => '../'.TYPO3_mainDir.t3lib_iconWorks::skinImg($this->backPath,'gfx/icon_fatalerror.gif','',1),
4016                      );
4017  
4018                          // Traverse types:
4019                      foreach($theTypes as $tableFieldKey => $theTypeArrays)    {
4020  
4021                          if (is_array($theTypeArrays['items']))    {
4022                                  // Add header:
4023                              $items[] = array(
4024                                  $theTypeArrays['tableFieldLabel'],
4025                                  '--div--',
4026                              );
4027  
4028                                  // Traverse options for this field:
4029                              foreach($theTypeArrays['items'] as $itemValue => $itemContent)    {
4030                                      // Add item to be selected:
4031                                  $items[] = array(
4032                                      '['.$itemContent[2].'] '.$itemContent[1],
4033                                      $tableFieldKey.':'.ereg_replace('[:|,]','',$itemValue).':'.$itemContent[0],
4034                                      $icons[$itemContent[0]]
4035                                  );
4036                              }
4037                          }
4038                      }
4039                  break;
4040                  case 'languages':
4041                      $items = array_merge($items,t3lib_BEfunc::getSystemLanguages());
4042                  break;
4043                  case 'custom':
4044                          // Initialize:
4045                      $customOptions = $GLOBALS['TYPO3_CONF_VARS']['BE']['customPermOptions'];
4046                      if (is_array($customOptions))    {
4047                          foreach($customOptions as $coKey => $coValue) {
4048                              if (is_array($coValue['items']))    {
4049                                      // Add header:
4050                                  $items[] = array(
4051                                      $GLOBALS['LANG']->sl($coValue['header']),
4052                                      '--div--',
4053                                  );
4054  
4055                                      // Traverse items:
4056                                  foreach($coValue['items'] as $itemKey => $itemCfg)    {
4057                                          // Icon:
4058                                      if ($itemCfg[1])    {
4059                                          list($icon) = $this->getIcon($itemCfg[1]);
4060                                          if ($icon)    $icon = '../'.TYPO3_mainDir.$icon;
4061                                      } else $icon = '';
4062  
4063                                          // Add item to be selected:
4064                                      $items[] = array(
4065                                          $GLOBALS['LANG']->sl($itemCfg[0]),
4066                                          $coKey.':'.ereg_replace('[:|,]','',$itemKey),
4067                                          $icon,
4068                                          $GLOBALS['LANG']->sl($itemCfg[2]),
4069                                      );
4070                                  }
4071                              }
4072                          }
4073                      }
4074                  break;
4075                  case 'modListGroup':
4076                  case 'modListUser':
4077                      $loadModules = t3lib_div::makeInstance('t3lib_loadModules');
4078                      $loadModules->load($GLOBALS['TBE_MODULES']);
4079  
4080                      $modList = $fieldValue['config']['special']=='modListUser' ? $loadModules->modListUser : $loadModules->modListGroup;
4081                      if (is_array($modList))    {
4082                          $descr = '';
4083  
4084                          foreach($modList as $theMod)    {
4085  
4086                                  // Icon:
4087                              $icon = $GLOBALS['LANG']->moduleLabels['tabs_images'][$theMod.'_tab'];
4088                              if ($icon)    {
4089                                  $icon = '../'.substr($icon,strlen(PATH_site));
4090                              }
4091  
4092                                  // Description texts:
4093                              if ($this->edit_showFieldHelp)    {
4094                                  $descr = $GLOBALS['LANG']->moduleLabels['labels'][$theMod.'_tablabel'].
4095                                              chr(10).
4096                                              $GLOBALS['LANG']->moduleLabels['labels'][$theMod.'_tabdescr'];
4097                              }
4098  
4099                                  // Item configuration:
4100                              $items[] = array(
4101                                  $this->addSelectOptionsToItemArray_makeModuleData($theMod),
4102                                  $theMod,
4103                                  $icon,
4104                                  $descr
4105                              );
4106                          }
4107                      }
4108                  break;
4109              }
4110          }
4111  
4112              // Return the items:
4113          return $items;
4114      }
4115  
4116      /**
4117       * Creates value/label pair for a backend module (main and sub)
4118       *
4119       * @param    string        The module key
4120       * @return    string        The rawurlencoded 2-part string to transfer to interface
4121       * @access private
4122       * @see addSelectOptionsToItemArray()
4123       */
4124  	function addSelectOptionsToItemArray_makeModuleData($value)    {
4125          $label = '';
4126              // Add label for main module:
4127          $pp = explode('_',$value);
4128          if (count($pp)>1)    $label.=$GLOBALS['LANG']->moduleLabels['tabs'][$pp[0].'_tab'].'>';
4129              // Add modules own label now:
4130          $label.= $GLOBALS['LANG']->moduleLabels['tabs'][$value.'_tab'];
4131  
4132          return $label;
4133      }
4134  
4135      /**
4136       * Adds records from a foreign table (for selector boxes)
4137       *
4138       * @param    array        The array of items (label,value,icon)
4139       * @param    array        The 'columns' array for the field (from TCA)
4140       * @param    array        TSconfig for the table/row
4141       * @param    string        The fieldname
4142       * @param    boolean        If set, then we are fetching the 'neg_' foreign tables.
4143       * @return    array        The $items array modified.
4144       * @see addSelectOptionsToItemArray(), t3lib_BEfunc::exec_foreign_table_where_query()
4145       */
4146  	function foreignTable($items,$fieldValue,$TSconfig,$field,$pFFlag=0)    {
4147          global $TCA;
4148  
4149              // Init:
4150          $pF=$pFFlag?'neg_':'';
4151          $f_table = $fieldValue['config'][$pF.'foreign_table'];
4152          $uidPre = $pFFlag?'-':'';
4153  
4154              // Get query:
4155          $res = t3lib_BEfunc::exec_foreign_table_where_query($fieldValue,$field,$TSconfig,$pF);
4156  
4157              // Perform lookup
4158          if ($GLOBALS['TYPO3_DB']->sql_error())    {
4159              echo($GLOBALS['TYPO3_DB']->sql_error()."\n\nThis may indicate a table defined in tables.php is not existing in the database!");
4160              return array();
4161          }
4162  
4163              // Get label prefix.
4164          $lPrefix = $this->sL($fieldValue['config'][$pF.'foreign_table_prefix']);
4165  
4166              // Get icon field + path if any:
4167          $iField = $TCA[$f_table]['ctrl']['selicon_field'];
4168          $iPath = trim($TCA[$f_table]['ctrl']['selicon_field_path']);
4169  
4170              // Traverse the selected rows to add them:
4171          while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))    {
4172              t3lib_BEfunc::workspaceOL($f_table, $row);
4173                  // Prepare the icon if available:
4174              if ($iField && $iPath && $row[$iField])    {
4175                  $iParts = t3lib_div::trimExplode(',',$row[$iField],1);
4176                  $icon = '../'.$iPath.'/'.trim($iParts[0]);
4177              } elseif (t3lib_div::inList('singlebox,checkbox',$fieldValue['config']['renderMode'])) {
4178                  $icon = '../'.TYPO3_mainDir.t3lib_iconWorks::skinImg($this->backPath,t3lib_iconWorks::getIcon($f_table, $row),'',1);
4179              } else $icon = '';
4180  
4181                  // Add the item:
4182              $items[] = array(
4183                  $lPrefix.strip_tags(t3lib_BEfunc::getRecordTitle($f_table,$row)),
4184                  $uidPre.$row['uid'],
4185                  $icon
4186              );
4187          }
4188          return $items;
4189      }
4190  
4191  
4192  
4193  
4194  
4195  
4196  
4197  
4198  
4199  
4200  
4201  
4202  
4203  
4204  
4205  
4206  
4207  
4208  
4209  
4210  
4211  
4212  
4213  
4214  
4215      /********************************************
4216       *
4217       * Template functions
4218       *
4219       ********************************************/
4220  
4221      /**
4222       * Sets the design to the backend design.
4223       * Backend
4224       *
4225       * @return    void
4226       */
4227  	function setNewBEDesign()    {
4228  
4229              // Wrapping all table rows for a particular record being edited:
4230          $this->totalWrap='
4231          <table border="0" cellspacing="0" cellpadding="0" width="'.($this->docLarge ? 440+150 : 440).'" class="typo3-TCEforms">'.
4232              '<tr class="bgColor2">
4233                  <td>&nbsp;</td>
4234                  <td>###RECORD_ICON### <span class="typo3-TCEforms-recHeader">###TABLE_TITLE###</span> ###ID_NEW_INDICATOR### - ###RECORD_LABEL###</td>
4235              </tr>'.
4236              '|'.
4237              '<tr>
4238                  <td>&nbsp;</td>
4239                  <td><img src="clear.gif" width="'.($this->docLarge ? 440+150 : 440).'" height="1" alt="" /></td>
4240              </tr>
4241          </table>';
4242  
4243              // Wrapping a single field:
4244          $this->fieldTemplate='
4245              <tr ###BGCOLOR_HEAD######CLASSATTR_2###>
4246                  <td>###FIELD_HELP_ICON###</td>
4247                  <td width="99%"><span style="color:###FONTCOLOR_HEAD###;"###CLASSATTR_4###><b>###FIELD_NAME###</b></span>###FIELD_HELP_TEXT###</td>
4248              </tr>
4249              <tr ###BGCOLOR######CLASSATTR_1###>
4250                  <td nowrap="nowrap"><img name="req_###FIELD_TABLE###_###FIELD_ID###_###FIELD_FIELD###" src="clear.gif" width="10" height="10" alt="" /><img name="cm_###FIELD_TABLE###_###FIELD_ID###_###FIELD_FIELD###" src="clear.gif" width="7" height="10" alt="" /></td>
4251                  <td valign="top">###FIELD_ITEM######FIELD_PAL_LINK_ICON###</td>
4252              </tr>';
4253  
4254          $this->palFieldTemplate='
4255              <tr ###BGCOLOR######CLASSATTR_1###>
4256                  <td>&nbsp;</td>
4257                  <td nowrap="nowrap" valign="top">###FIELD_PALETTE###</td>
4258              </tr>';
4259          $this->palFieldTemplateHeader='
4260              <tr ###BGCOLOR_HEAD######CLASSATTR_2###>
4261                  <td>&nbsp;</td>
4262                  <td nowrap="nowrap" valign="top"><strong>###FIELD_HEADER###</strong></td>
4263              </tr>';
4264  
4265          $this->sectionWrap='
4266              <tr>
4267                  <td colspan="2"><img src="clear.gif" width="1" height="###SPACE_BEFORE###" alt="" /></td>
4268              </tr>
4269              <tr>
4270                  <td colspan="2"><table ###TABLE_ATTRIBS###>###CONTENT###</table></td>
4271              </tr>
4272              ';
4273      }
4274  
4275      /**
4276       * This inserts the content of $inArr into the field-template
4277       *
4278       * @param    array        Array with key/value pairs to insert in the template.
4279       * @param    string        Alternative template to use instead of the default.
4280       * @return    string
4281       */
4282  	function intoTemplate($inArr,$altTemplate='')    {
4283                  // Put into template_
4284          $fieldTemplateParts = explode('###FIELD_',$this->rplColorScheme($altTemplate?$altTemplate:$this->fieldTemplate));
4285          reset($fieldTemplateParts);
4286          $out=current($fieldTemplateParts);
4287          while(list(,$part)=each($fieldTemplateParts))    {
4288              list($key,$val)=explode('###',$part,2);
4289              $out.=$inArr[$key];
4290              $out.=$val;
4291          }
4292          return $out;
4293      }
4294  
4295      /**
4296       * Overwrite this function in own extended class to add own markers for output
4297       *
4298       * @param    array        Array with key/value pairs to insert in the template.
4299       * @param    string        The table name of the record
4300       * @param    string        The field name which this element is supposed to edit
4301       * @param    array        The record data array where the value(s) for the field can be found
4302       * @param    array        An array with additional configuration options.
4303       * @return    array        marker array for template output
4304       * @see function intoTemplate()
4305       */
4306  	function addUserTemplateMarkers($marker,$table,$field,$row,&$PA)    {
4307          return $marker;
4308      }
4309  
4310      /**
4311       * Wrapping labels
4312       * Currently not implemented - just returns input value.
4313       *
4314       * @param    string        Input string.
4315       * @return    string        Output string.
4316       */
4317  	function wrapLabels($str)    {
4318          return $str;
4319      }
4320  
4321      /**
4322       * Wraps all the table rows into a single table.
4323       * Used externally from scripts like alt_doc.php and db_layout.php (which uses TCEforms...)
4324       *
4325       * @param    string        Code to output between table-parts; table rows
4326       * @param    array        The record
4327       * @param    string        The table name
4328       * @return    string
4329       */
4330  	function wrapTotal($c,$rec,$table)    {
4331          $parts = $this->replaceTableWrap(explode('|',$this->totalWrap,2),$rec,$table);
4332          return $parts[0].$c.$parts[1].implode('',$this->hiddenFieldAccum);
4333      }
4334  
4335      /**
4336       * This replaces markers in the total wrap
4337       *
4338       * @param    array        An array of template parts containing some markers.
4339       * @param    array        The record
4340       * @param    string        The table name
4341       * @return    string
4342       */
4343  	function replaceTableWrap($arr,$rec,$table)    {
4344          global $TCA;
4345  
4346              // Make "new"-label
4347          if (strstr($rec['uid'],'NEW'))    {
4348              $newLabel = ' <span class="typo3-TCEforms-newToken">'.
4349                          $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.new',1).
4350                          '</span>';
4351  
4352              #t3lib_BEfunc::fixVersioningPid($table,$rec);    // Kasper: Should not be used here because NEW records are not offline workspace versions...
4353              $truePid = t3lib_BEfunc::getTSconfig_pidValue($table,$rec['uid'],$rec['pid']);
4354              $prec = t3lib_BEfunc::getRecordWSOL('pages',$truePid,'title');
4355              $rLabel = '<em>[PID: '.$truePid.'] '.htmlspecialchars(trim(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle('pages',$prec),40))).'</em>';
4356          } else {
4357              $newLabel = ' <span class="typo3-TCEforms-recUid">['.$rec['uid'].']</span>';
4358              $rLabel  = htmlspecialchars(trim(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table,$rec),40)));
4359          }
4360  
4361          foreach ($arr as $k => $v)    {
4362                  // Make substitutions:
4363              $arr[$k] = str_replace('###ID_NEW_INDICATOR###', $newLabel, $arr[$k]);
4364              $arr[$k] = str_replace('###RECORD_LABEL###',$rLabel,$arr[$k]);
4365              $arr[$k] = str_replace('###TABLE_TITLE###',htmlspecialchars($this->sL($TCA[$table]['ctrl']['title'])),$arr[$k]);
4366  
4367              $titleA=t3lib_BEfunc::titleAltAttrib($this->getRecordPath($table,$rec));
4368              $arr[$k]=str_replace('###RECORD_ICON###',t3lib_iconWorks::getIconImage($table,$rec,$this->backPath,'class="absmiddle"'.$titleA),$arr[$k]);
4369          }
4370          return $arr;
4371      }
4372  
4373      /**
4374       * Wraps an element in the $out_array with the template row for a "section" ($this->sectionWrap)
4375       *
4376       * @param    array        The array with form elements stored in (passed by reference and changed!)
4377       * @param    integer        The pointer to the entry in the $out_array  (passed by reference and incremented!)
4378       * @return    void
4379       */
4380  	function wrapBorder(&$out_array,&$out_pointer)    {
4381          if ($this->sectionWrap && $out_array[$out_pointer])    {
4382              $tableAttribs='';
4383              $tableAttribs.= $this->borderStyle[0] ? ' style="'.htmlspecialchars($this->borderStyle[0]).'"':'';
4384              $tableAttribs.= $this->borderStyle[2] ? ' background="'.htmlspecialchars($this->backPath.$this->borderStyle[2]).'"':'';
4385              $tableAttribs.= $this->borderStyle[3] ? ' class="'.htmlspecialchars($this->borderStyle[3]).'"':'';
4386              if ($tableAttribs)    {
4387                  $tableAttribs='border="0" cellspacing="0" cellpadding="0" width="100%"'.$tableAttribs;
4388                  $out_array[$out_pointer] = str_replace('###CONTENT###',$out_array[$out_pointer],
4389                      str_replace('###TABLE_ATTRIBS###',$tableAttribs,
4390                          str_replace('###SPACE_BEFORE###',intval($this->borderStyle[1]),$this->sectionWrap)));
4391              }
4392              $out_pointer++;
4393          }
4394      }
4395  
4396      /**
4397       * Replaces colorscheme markers in the template string
4398       *
4399       * @param    string        Template string with markers to be substituted.
4400       * @return    string
4401       */
4402  	function rplColorScheme($inTemplate)    {
4403              // Colors:
4404          $inTemplate = str_replace('###BGCOLOR###',$this->colorScheme[0]?' bgcolor="'.$this->colorScheme[0].'"':'',$inTemplate);
4405          $inTemplate = str_replace('###BGCOLOR_HEAD###',$this->colorScheme[1]?' bgcolor="'.$this->colorScheme[1].'"':'',$inTemplate);
4406          $inTemplate = str_replace('###FONTCOLOR_HEAD###',$this->colorScheme[3],$inTemplate);
4407  
4408              // Classes:
4409          $inTemplate = str_replace('###CLASSATTR_1###',$this->classScheme[0]?' class="'.$this->classScheme[0].'"':'',$inTemplate);
4410          $inTemplate = str_replace('###CLASSATTR_2###',$this->classScheme[1]?' class="'.$this->classScheme[1].'"':'',$inTemplate);
4411          $inTemplate = str_replace('###CLASSATTR_4###',$this->classScheme[3]?' class="'.$this->classScheme[3].'"':'',$inTemplate);
4412  
4413          return $inTemplate;
4414      }
4415  
4416      /**
4417       * Returns divider.
4418       * Currently not implemented and returns only blank value.
4419       *
4420       * @return    string
4421       */
4422  	function getDivider()    {
4423          //return "<hr />";
4424      }
4425  
4426      /**
4427       * Creates HTML output for a palette
4428       *
4429       * @param    array        The palette array to print
4430       * @return    string        HTML output
4431       */
4432  	function printPalette($palArr)    {
4433  
4434              // Init color/class attributes:
4435          $ccAttr2 = $this->colorScheme[2] ? ' bgcolor="'.$this->colorScheme[2].'"' : '';
4436          $ccAttr2.= $this->classScheme[2] ? ' class="'.$this->classScheme[2].'"' : '';
4437          $ccAttr4 = $this->colorScheme[4] ? ' style="color:'.$this->colorScheme[4].'"' : '';
4438          $ccAttr4.= $this->classScheme[4] ? ' class="'.$this->classScheme[4].'"' : '';
4439  
4440              // Traverse palette fields and render them into table rows:
4441          foreach($palArr as $content)    {
4442              $hRow[]='<td'.$ccAttr2.'>&nbsp;</td>
4443                      <td nowrap="nowrap"'.$ccAttr2.'>'.
4444                          '<span'.$ccAttr4.'>'.
4445                              $content['NAME'].
4446                          '</span>'.
4447                      '</td>';
4448              $iRow[]='<td valign="top">'.
4449                          '<img name="req_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="10" height="10" vspace="4" alt="" />'.
4450                          '<img name="cm_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="7" height="10" vspace="4" alt="" />'.
4451                      '</td>
4452                      <td nowrap="nowrap" valign="top">'.
4453                          $content['ITEM'].
4454                          $content['HELP_ICON'].
4455                      '</td>';
4456          }
4457  
4458              // Final wrapping into the table:
4459          $out='<table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-palette">
4460              <tr>
4461                  <td><img src="clear.gif" width="'.intval($this->paletteMargin).'" height="1" alt="" /></td>'.
4462                      implode('
4463                  ',$hRow).'
4464              </tr>
4465              <tr>
4466                  <td></td>'.
4467                      implode('
4468                  ',$iRow).'
4469              </tr>
4470          </table>';
4471  
4472          return $out;
4473      }
4474  
4475      /**
4476       * Returns help-text ICON if configured for.
4477       *
4478       * @param    string        The table name
4479       * @param    string        The field name
4480       * @param    boolean        Force the return of the help-text icon.
4481       * @return    string        HTML, <a>-tag with
4482       */
4483  	function helpTextIcon($table,$field,$force=0)    {
4484          if ($this->globalShowHelp && $GLOBALS['TCA_DESCR'][$table]['columns'][$field] && (($this->edit_showFieldHelp=='icon'&&!$this->doLoadTableDescr($table)) || $force))    {
4485              $aOnClick = 'vHWin=window.open(\''.$this->backPath.'view_help.php?tfID='.($table.'.'.$field).'\',\'viewFieldHelp\',\'height=400,width=600,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;';
4486              return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
4487                      '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/helpbubble.gif','width="14" height="14"').' hspace="2" border="0" class="absmiddle"'.($GLOBALS['CLIENT']['FORMSTYLE']?' style="cursor:help;"':'').' alt="" />'.
4488                      '</a>';
4489          } else {
4490                  // Detects fields with no CSH and outputs dummy line to insert into CSH locallang file:
4491              #debug(array("'".$field.".description' => '[FILL IN] ".$table."->".$field."',"),$table);
4492              return '<span class="nbsp">&nbsp;</span>';
4493          }
4494      }
4495  
4496      /**
4497       * Returns help text DESCRIPTION, if configured for.
4498       *
4499       * @param    string        The table name
4500       * @param    string        The field name
4501       * @return    string
4502       */
4503  	function helpText($table,$field)    {
4504          if ($this->globalShowHelp && $GLOBALS['TCA_DESCR'][$table]['columns'][$field] && ($this->edit_showFieldHelp=='text' || $this->doLoadTableDescr($table)))    {
4505              $fDat = $GLOBALS['TCA_DESCR'][$table]['columns'][$field];
4506              return '<table border="0" cellpadding="2" cellspacing="0" width="90%"><tr><td valign="top" width="14">'.
4507                      $this->helpTextIcon(
4508                          $table,
4509                          $field,
4510                          $fDat['details']||$fDat['syntax']||$fDat['image_descr']||$fDat['image']||$fDat['seeAlso']
4511                      ).
4512                      '</td><td valign="top"><span class="typo3-TCEforms-helpText">'.
4513                      $GLOBALS['LANG']->hscAndCharConv(strip_tags($fDat['description']),1).
4514                      '</span></td></tr></table>';
4515          }
4516      }
4517  
4518      /**
4519       * Setting the current color scheme ($this->colorScheme) based on $this->defColorScheme plus input string.
4520       *
4521       * @param    string        A color scheme string.
4522       * @return    void
4523       */
4524  	function setColorScheme($scheme)    {
4525          $this->colorScheme = $this->defColorScheme;
4526          $this->classScheme = $this->defClassScheme;
4527  
4528          $parts = t3lib_div::trimExplode(',',$scheme);
4529          foreach($parts as $key => $col)    {
4530                  // Split for color|class:
4531              list($color,$class) = t3lib_div::trimExplode('|',$col);
4532  
4533                  // Handle color values:
4534              if ($color)    $this->colorScheme[$key] = $color;
4535              if ($color=='-')    $this->colorScheme[$key] = '';
4536  
4537                  // Handle class values:
4538              if ($class)    $this->classScheme[$key] = $class;
4539              if ($class=='-')    $this->classScheme[$key] = '';
4540          }
4541      }
4542  
4543      /**
4544       * Reset color schemes.
4545       *
4546       * @return    void
4547       */
4548  	function resetSchemes()    {
4549          $this->setColorScheme($GLOBALS['TBE_STYLES']['colorschemes'][0]);
4550          $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][0];
4551          $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][0];
4552      }
4553  
4554      /**
4555       * Store current color scheme
4556       *
4557       * @return    void
4558       */
4559  	function storeSchemes()    {
4560          $this->savedSchemes['classScheme'] = $this->classScheme;
4561          $this->savedSchemes['colorScheme'] = $this->colorScheme;
4562          $this->savedSchemes['fieldStyle'] = $this->fieldStyle;
4563          $this->savedSchemes['borderStyle'] = $this->borderStyle;
4564      }
4565  
4566      /**
4567       * Restore the saved color scheme
4568       *
4569       * @return    void
4570       */
4571  	function restoreSchemes()    {
4572          $this->classScheme = $this->savedSchemes['classScheme'];
4573          $this->colorScheme = $this->savedSchemes['colorScheme'];
4574          $this->fieldStyle = $this->savedSchemes['fieldStyle'];
4575          $this->borderStyle = $this->savedSchemes['borderStyle'];
4576      }
4577  
4578  
4579  
4580  
4581  
4582  
4583  
4584  
4585  
4586  
4587  
4588  
4589  
4590      /********************************************
4591       *
4592       * JavaScript related functions
4593       *
4594       ********************************************/
4595  
4596      /**
4597       * JavaScript code added BEFORE the form is drawn:
4598       *
4599       * @return    string        A <script></script> section with JavaScript.
4600       */
4601  	function JStop()    {
4602  
4603          $out = '';
4604  
4605              // Additional top HTML:
4606          if (count($this->additionalCode_pre))    {
4607              $out.= implode('
4608  
4609                  <!-- NEXT: -->
4610              ',$this->additionalCode_pre);
4611          }
4612  
4613              // Additional top JavaScript
4614          if (count($this->additionalJS_pre))    {
4615              $out.='
4616  
4617  
4618          <!--
4619              JavaScript in top of page (before form):
4620          -->
4621  
4622          <script type="text/javascript">
4623              /*<![CDATA[*/
4624  
4625              '.implode('
4626  
4627                  // NEXT:
4628              ',$this->additionalJS_pre).'
4629  
4630              /*]]>*/
4631          </script>
4632              ';
4633          }
4634  
4635              // Return result:
4636          return $out;
4637      }
4638  
4639      /**
4640       * JavaScript code used for input-field evaluation.
4641       *
4642       *         Example use:
4643       *
4644       *         $msg.='Distribution time (hh:mm dd-mm-yy):<br /><input type="text" name="send_mail_datetime_hr" onchange="typo3form.fieldGet(\'send_mail_datetime\', \'datetime\', \'\', 0,0);"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' /><input type="hidden" value="'.time().'" name="send_mail_datetime" /><br />';
4645       *         $this->extJSCODE.='typo3form.fieldSet("send_mail_datetime", "datetime", "", 0,0);';
4646       *
4647       *         ... and then include the result of this function after the form
4648       *
4649       * @param    string        $formname: The identification of the form on the page.
4650       * @param    boolean        $update: Just extend/update existing settings, e.g. for AJAX call
4651       * @return    string        A section with JavaScript - if $update is false, embedded in <script></script>
4652       */
4653  	function JSbottom($formname='forms[0]', $update = false)    {
4654          $jsFile = array();
4655          $elements = array();
4656  
4657              // required:
4658          foreach ($this->requiredFields as $itemImgName => $itemName) {
4659              if (preg_match('/^(.+)\[((\w|\d|_)+)\]$/', $itemName, $match)) {
4660                  $record = $match[1];
4661                  $field = $match[2];
4662                  $elements[$record][$field]['required'] = 1;
4663                  $elements[$record][$field]['requiredImg'] = $itemImgName;
4664              }
4665          }
4666              // range:
4667          foreach ($this->requiredElements as $itemName => $range) {
4668              if (preg_match('/^(.+)\[((\w|\d|_)+)\]$/', $itemName, $match)) {
4669                  $record = $match[1];
4670                  $field = $match[2];
4671                  $elements[$record][$field]['range'] = array($range[0], $range[1]);
4672                  $elements[$record][$field]['rangeImg'] = $range['imgName'];
4673              }
4674          }
4675  
4676          $this->TBE_EDITOR_fieldChanged_func='TBE_EDITOR.fieldChanged_fName(fName,formObj[fName+"_list"]);';
4677  
4678          if (!$update) {
4679              if ($this->loadMD5_JS) {
4680                  $jsFile[] =    '<script type="text/javascript" src="'.$this->backPath.'md5.js"></script>';
4681              }
4682  
4683              $jsFile[] = '<script type="text/javascript" src="'.$this->backPath.'contrib/prototype/prototype.js"></script>';
4684              $jsFile[] =    '<script type="text/javascript" src="'.$this->backPath.'../t3lib/jsfunc.evalfield.js"></script>';
4685              $jsFile[] =    '<script type="text/javascript" src="'.$this->backPath.'jsfunc.tbe_editor.js"></script>';
4686  
4687                  // if IRRE fields were processed, add the JavaScript functions:
4688              if ($this->inline->inlineCount) {
4689                  $jsFile[] = '<script src="'.$this->backPath.'contrib/scriptaculous/scriptaculous.js" type="text/javascript"></script>';
4690                  $jsFile[] = '<script src="'.$this->backPath.'../t3lib/jsfunc.inline.js" type="text/javascript"></script>';
4691                  $out .= '
4692                  inline.setPrependFormFieldNames("'.$this->inline->prependNaming.'");
4693                  inline.setNoTitleString("'.addslashes(t3lib_BEfunc::getNoRecordTitle(true)).'");
4694                  ';
4695              }
4696  
4697              $out .= '
4698              TBE_EDITOR.images.req.src = "'.t3lib_iconWorks::skinImg($this->backPath,'gfx/required_h.gif','',1).'";
4699              TBE_EDITOR.images.cm.src = "'.t3lib_iconWorks::skinImg($this->backPath,'gfx/content_client.gif','',1).'";
4700              TBE_EDITOR.images.sel.src = "'.t3lib_iconWorks::skinImg($this->backPath,'gfx/content_selected.gif','',1).'";
4701              TBE_EDITOR.images.clear.src = "'.$this->backPath.'clear.gif";
4702  
4703              TBE_EDITOR.auth_timeout_field = '.intval($GLOBALS['BE_USER']->auth_timeout_field).';
4704              TBE_EDITOR.formname = "'.$formname.'";
4705              TBE_EDITOR.formnameUENC = "'.rawurlencode($formname).'";
4706              TBE_EDITOR.backPath = "'.addslashes($this->backPath).'";
4707              TBE_EDITOR.prependFormFieldNames = "'.$this->prependFormFieldNames.'";
4708              TBE_EDITOR.prependFormFieldNamesUENC = "'.rawurlencode($this->prependFormFieldNames).'";
4709              TBE_EDITOR.prependFormFieldNamesCnt = '.substr_count($this->prependFormFieldNames,'[').';
4710              TBE_EDITOR.isPalettedoc = '.($this->isPalettedoc ? addslashes($this->isPalettedoc) : 'null').';
4711              TBE_EDITOR.doSaveFieldName = "'.($this->doSaveFieldName ? addslashes($this->doSaveFieldName) : '').'";
4712              TBE_EDITOR.labels.fieldsChanged = '.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.fieldsChanged')).';
4713              TBE_EDITOR.labels.fieldsMissing = '.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.fieldsMissing')).';
4714              TBE_EDITOR.labels.refresh_login = '.$GLOBALS['LANG']->JScharCode($this->getLL('m_refresh_login')).';
4715              TBE_EDITOR.labels.onChangeAlert = '.$GLOBALS['LANG']->JScharCode($this->getLL('m_onChangeAlert')).';
4716              evalFunc.USmode = '.($GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat']?'1':'0').';
4717              ';
4718          }
4719  
4720              // add JS required for inline fields
4721          if (count($this->inline->inlineData)) {
4722              $out .=    '
4723              inline.addToDataArray('.$this->inline->getJSON($this->inline->inlineData).');
4724              ';
4725          }
4726              // elements which are required or have a range definition:
4727          if (count($elements)) {
4728              $out .= '
4729              TBE_EDITOR.addElements('.$this->inline->getJSON($elements).');
4730              TBE_EDITOR.initRequired()
4731              ';
4732          }
4733              // $this->additionalJS_post:
4734          if ($this->additionalJS_submit) {
4735              $additionalJS_submit = implode('', $this->additionalJS_submit);
4736              $additionalJS_submit = str_replace("\r", '', $additionalJS_submit);
4737              $additionalJS_submit = str_replace("\n", '', $additionalJS_submit);
4738              $out .= '
4739              TBE_EDITOR.addActionChecks("submit", "'.addslashes($additionalJS_submit).'");
4740              ';
4741          }
4742  
4743          $out .= chr(10).implode(chr(10),$this->additionalJS_post).chr(10).$this->extJSCODE;
4744          $out .= '
4745              TBE_EDITOR.loginRefreshed();
4746          ';
4747  
4748              // Regular direct output:
4749          if (!$update) {
4750              $spacer = chr(10).chr(9);
4751              $out  = $spacer.implode($spacer, $jsFile).t3lib_div::wrapJS($out);
4752          }
4753  
4754          return $out;
4755      }
4756  
4757      /**
4758       * Used to connect the db/file browser with this document and the formfields on it!
4759       *
4760       * @param    string        Form object reference (including "document.")
4761       * @return    string        JavaScript functions/code (NOT contained in a <script>-element)
4762       */
4763  	function dbFileCon($formObj='document.forms[0]')    {
4764              // @TODO: Export this to an own file, it is more static than dynamic JavaScript -- olly
4765          $str='
4766  
4767              // ***************
4768              // Used to connect the db/file browser with this document and the formfields on it!
4769              // ***************
4770  
4771              var browserWin="";
4772  
4773  			function setFormValueOpenBrowser(mode,params) {    //
4774                  var url = "'.$this->backPath.'browser.php?mode="+mode+"&bparams="+params;
4775  
4776                  browserWin = window.open(url,"Typo3WinBrowser","height=350,width="+(mode=="db"?650:600)+",status=0,menubar=0,resizable=1,scrollbars=1");
4777                  browserWin.focus();
4778              }
4779  			function setFormValueFromBrowseWin(fName,value,label,exclusiveValues)    {    //
4780                  var formObj = setFormValue_getFObj(fName)
4781                  if (formObj && value!="--div--")    {
4782                      fObj = formObj[fName+"_list"];
4783                      var len = fObj.length;
4784                          // Clear elements if exclusive values are found
4785                      if (exclusiveValues)    {
4786                          var m = new RegExp("(^|,)"+value+"($|,)");
4787                          if (exclusiveValues.match(m))    {
4788                                  // the new value is exclusive
4789                              for (a=len-1;a>=0;a--)    fObj[a] = null;
4790                              len = 0;
4791                          } else if (len == 1)    {
4792                              m = new RegExp("(^|,)"+fObj.options[0].value+"($|,)");
4793                              if (exclusiveValues.match(m))    {
4794                                      // the old value is exclusive
4795                                  fObj[0] = null;
4796                                  len = 0;
4797                              }
4798                          }
4799                      }
4800                          // Inserting element
4801                      var setOK = 1;
4802                      if (!formObj[fName+"_mul"] || formObj[fName+"_mul"].value==0)    {
4803                          for (a=0;a<len;a++)    {
4804                              if (fObj.options[a].value==value)    {
4805                                  setOK = 0;
4806                              }
4807                          }
4808                      }
4809                      if (setOK)    {
4810                          fObj.length++;
4811                          fObj.options[len].value = value;
4812                          fObj.options[len].text = unescape(label);
4813  
4814                              // Traversing list and set the hidden-field
4815                          setHiddenFromList(fObj,formObj[fName]);
4816                          '.$this->TBE_EDITOR_fieldChanged_func.'
4817                      }
4818                  }
4819              }
4820  			function setHiddenFromList(fObjSel,fObjHid)    {    //
4821                  l=fObjSel.length;
4822                  fObjHid.value="";
4823                  for (a=0;a<l;a++)    {
4824                      fObjHid.value+=fObjSel.options[a].value+",";
4825                  }
4826              }
4827  			function setFormValueManipulate(fName,type)    {    //
4828                  var formObj = setFormValue_getFObj(fName)
4829                  if (formObj)    {
4830                      var localArray_V = new Array();
4831                      var localArray_L = new Array();
4832                      var localArray_S = new Array();
4833                      var fObjSel = formObj[fName+"_list"];
4834                      var l=fObjSel.length;
4835                      var c=0;
4836                      if (type=="Remove" || type=="Top" || type=="Bottom")    {
4837                          if (type=="Top")    {
4838                              for (a=0;a<l;a++)    {
4839                                  if (fObjSel.options[a].selected==1)    {
4840                                      localArray_V[c]=fObjSel.options[a].value;
4841                                      localArray_L[c]=fObjSel.options[a].text;
4842                                      localArray_S[c]=1;
4843                                      c++;
4844                                  }
4845                              }
4846                          }
4847                          for (a=0;a<l;a++)    {
4848                              if (fObjSel.options[a].selected!=1)    {
4849                                  localArray_V[c]=fObjSel.options[a].value;
4850                                  localArray_L[c]=fObjSel.options[a].text;
4851                                  localArray_S[c]=0;
4852                                  c++;
4853                              }
4854                          }
4855                          if (type=="Bottom")    {
4856                              for (a=0;a<l;a++)    {
4857                                  if (fObjSel.options[a].selected==1)    {
4858                                      localArray_V[c]=fObjSel.options[a].value;
4859                                      localArray_L[c]=fObjSel.options[a].text;
4860                                      localArray_S[c]=1;
4861                                      c++;
4862                                  }
4863                              }
4864                          }
4865                      }
4866                      if (type=="Down")    {
4867                          var tC = 0;
4868                          var tA = new Array();
4869  
4870                          for (a=0;a<l;a++)    {
4871                              if (fObjSel.options[a].selected!=1)    {
4872                                      // Add non-selected element:
4873                                  localArray_V[c]=fObjSel.options[a].value;
4874                                  localArray_L[c]=fObjSel.options[a].text;
4875                                  localArray_S[c]=0;
4876                                  c++;
4877  
4878                                      // Transfer any accumulated and reset:
4879                                  if (tA.length > 0)    {
4880                                      for (aa=0;aa<tA.length;aa++)    {
4881                                          localArray_V[c]=fObjSel.options[tA[aa]].value;
4882                                          localArray_L[c]=fObjSel.options[tA[aa]].text;
4883                                          localArray_S[c]=1;
4884                                          c++;
4885                                      }
4886  
4887                                      var tC = 0;
4888                                      var tA = new Array();
4889                                  }
4890                              } else {
4891                                  tA[tC] = a;
4892                                  tC++;
4893                              }
4894                          }
4895                              // Transfer any remaining:
4896                          if (tA.length > 0)    {
4897                              for (aa=0;aa<tA.length;aa++)    {
4898                                  localArray_V[c]=fObjSel.options[tA[aa]].value;
4899                                  localArray_L[c]=fObjSel.options[tA[aa]].text;
4900                                  localArray_S[c]=1;
4901                                  c++;
4902                              }
4903                          }
4904                      }
4905                      if (type=="Up")    {
4906                          var tC = 0;
4907                          var tA = new Array();
4908                          var c = l-1;
4909  
4910                          for (a=l-1;a>=0;a--)    {
4911                              if (fObjSel.options[a].selected!=1)    {
4912  
4913                                      // Add non-selected element:
4914                                  localArray_V[c]=fObjSel.options[a].value;
4915                                  localArray_L[c]=fObjSel.options[a].text;
4916                                  localArray_S[c]=0;
4917                                  c--;
4918  
4919                                      // Transfer any accumulated and reset:
4920                                  if (tA.length > 0)    {
4921                                      for (aa=0;aa<tA.length;aa++)    {
4922                                          localArray_V[c]=fObjSel.options[tA[aa]].value;
4923                                          localArray_L[c]=fObjSel.options[tA[aa]].text;
4924                                          localArray_S[c]=1;
4925                                          c--;
4926                                      }
4927  
4928                                      var tC = 0;
4929                                      var tA = new Array();
4930                                  }
4931                              } else {
4932                                  tA[tC] = a;
4933                                  tC++;
4934                              }
4935                          }
4936                              // Transfer any remaining:
4937                          if (tA.length > 0)    {
4938                              for (aa=0;aa<tA.length;aa++)    {
4939                                  localArray_V[c]=fObjSel.options[tA[aa]].value;
4940                                  localArray_L[c]=fObjSel.options[tA[aa]].text;
4941                                  localArray_S[c]=1;
4942                                  c--;
4943                              }
4944                          }
4945                          c=l;    // Restore length value in "c"
4946                      }
4947  
4948                          // Transfer items in temporary storage to list object:
4949                      fObjSel.length = c;
4950                      for (a=0;a<c;a++)    {
4951                          fObjSel.options[a].value = localArray_V[a];
4952                          fObjSel.options[a].text = localArray_L[a];
4953                          fObjSel.options[a].selected = localArray_S[a];
4954                      }
4955                      setHiddenFromList(fObjSel,formObj[fName]);
4956  
4957                      '.$this->TBE_EDITOR_fieldChanged_func.'
4958                  }
4959              }
4960  			function setFormValue_getFObj(fName)    {    //
4961                  var formObj = '.$formObj.';
4962                  if (formObj)    {
4963                      if (formObj[fName] && formObj[fName+"_list"] && formObj[fName+"_list"].type=="select-multiple")    {
4964                          return formObj;
4965                      } else {
4966                          alert("Formfields missing:\n fName: "+formObj[fName]+"\n fName_list:"+formObj[fName+"_list"]+"\n type:"+formObj[fName+"_list"].type+"\n fName:"+fName);
4967                      }
4968                  }
4969                  return "";
4970              }
4971  
4972              // END: dbFileCon parts.
4973          ';
4974          return $str;
4975      }
4976  
4977      /**
4978       * Prints necessary JavaScript for TCEforms (after the form HTML).
4979       *
4980       * @return    void
4981       */
4982  	function printNeededJSFunctions()    {
4983              // JS evaluation:
4984          $out = $this->JSbottom($this->formName);
4985              // Integrate JS functions for the element browser if such fields or IRRE fields were processed:
4986          if ($this->printNeededJS['dbFileIcons'] || $this->inline->inlineCount)    {
4987              $out.= '
4988  
4989  
4990  
4991              <!--
4992                   JavaScript after the form has been drawn:
4993              -->
4994  
4995              <script type="text/javascript">
4996                  /*<![CDATA[*/
4997              '.$this->dbFileCon('document.'.$this->formName).'
4998                  /*]]>*/
4999              </script>';
5000          }
5001          return $out;
5002      }
5003  
5004      /**
5005       * Returns necessary JavaScript for the top
5006       *
5007       * @return    void
5008       */
5009  	function printNeededJSFunctions_top()    {
5010              // JS evaluation:
5011          $out = $this->JStop($this->formName);
5012          return $out;
5013      }
5014  
5015  
5016  
5017  
5018  
5019  
5020  
5021  
5022  
5023  
5024  
5025  
5026  
5027  
5028  
5029  
5030  
5031  
5032  
5033  
5034  
5035  
5036  
5037  
5038  
5039  
5040  
5041  
5042  
5043      /********************************************
5044       *
5045       * Various helper functions
5046       *
5047       ********************************************/
5048  
5049  
5050      /**
5051       * Gets default record. Maybe not used anymore. FE-editor?
5052       *
5053       * @param    string        Database Tablename
5054       * @param    integer        PID value (positive / negative)
5055       * @return    array        "default" row.
5056       */
5057  	function getDefaultRecord($table,$pid=0)    {
5058          global $TCA;
5059          if ($TCA[$table])    {
5060              t3lib_div::loadTCA($table);
5061              $row = array();
5062  
5063              if ($pid<0 && $TCA[$table]['ctrl']['useColumnsForDefaultValues'])    {
5064                      // Fetches the previous record:
5065                  $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'uid='.abs($pid).t3lib_BEfunc::deleteClause($table));
5066                  if ($drow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))    {
5067                          // Gets the list of fields to copy from the previous record.
5068                      $fArr = explode(',',$TCA[$table]['ctrl']['useColumnsForDefaultValues']);
5069                      foreach($fArr as $theF)    {
5070                          if ($TCA[$table]['columns'][$theF])    {
5071                              $row[$theF] = $drow[$theF];
5072                          }
5073                      }
5074                  }
5075                  $GLOBALS['TYPO3_DB']->sql_free_result($res);
5076              }
5077  
5078              foreach($TCA[$table]['columns'] as $field => $info)    {
5079                  if (isset($info['config']['default']))    {
5080                      $row[$field] = $info['config']['default'];
5081                  }
5082              }
5083  
5084              return $row;
5085          }
5086      }
5087  
5088      /**
5089       * Return record path (visually formatted, using t3lib_BEfunc::getRecordPath() )
5090       *
5091       * @param    string        Table name
5092       * @param    array        Record array
5093       * @return    string        The record path.
5094       * @see t3lib_BEfunc::getRecordPath()
5095       */
5096  	function getRecordPath($table,$rec)    {
5097          t3lib_BEfunc::fixVersioningPid($table,$rec);
5098          list($tscPID,$thePidValue)=$this->getTSCpid($table,$rec['uid'],$rec['pid']);
5099          if ($thePidValue>=0)    {
5100              return t3lib_BEfunc::getRecordPath($tscPID,$this->readPerms(),15);
5101          }
5102      }
5103  
5104      /**
5105       * Returns the select-page read-access SQL clause.
5106       * Returns cached string, so you can call this function as much as you like without performance loss.
5107       *
5108       * @return    string
5109       */
5110  	function readPerms()    {
5111          if (!$this->perms_clause_set)    {
5112              $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
5113              $this->perms_clause_set=1;
5114          }
5115          return $this->perms_clause;
5116      }
5117  
5118      /**
5119       * Fetches language label for key
5120       *
5121       * @param    string        Language label reference, eg. 'LLL:EXT:lang/locallang_core.php:labels.blablabla'
5122       * @return    string        The value of the label, fetched for the current backend language.
5123       */
5124      function sL($str)    {
5125          return $GLOBALS['LANG']->sL($str);
5126      }
5127  
5128      /**
5129       * Returns language label from locallang_core.php
5130       * Labels must be prefixed with either "l_" or "m_".
5131       * The prefix "l_" maps to the prefix "labels." inside locallang_core.php
5132       * The prefix "m_" maps to the prefix "mess." inside locallang_core.php
5133       *
5134       * @param    string        The label key
5135       * @return    string        The value of the label, fetched for the current backend language.
5136       */
5137  	function getLL($str)    {
5138          $content = '';
5139  
5140          switch(substr($str,0,2))    {
5141              case 'l_':
5142                  $content = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.'.substr($str,2));
5143              break;
5144              case 'm_':
5145                  $content = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.'.substr($str,2));
5146              break;
5147          }
5148          return $content;
5149      }
5150  
5151      /**
5152       * Returns true, if the palette, $palette, is collapsed (not shown, but found in top-frame) for the table.
5153       *
5154       * @param    string        The table name
5155       * @param    integer        The palette pointer/number
5156       * @return    boolean
5157       */
5158  	function isPalettesCollapsed($table,$palette)    {
5159          global $TCA;
5160  
5161          if ($TCA[$table]['ctrl']['canNotCollapse']) return 0;
5162          if (is_array($TCA[$table]['palettes'][$palette]) && $TCA[$table]['palettes'][$palette]['canNotCollapse'])    return 0;
5163          return $this->palettesCollapsed;
5164      }
5165  
5166      /**
5167       * Returns true, if the evaluation of the required-field code is OK.
5168       *
5169       * @param    string        The required-field code
5170       * @param    array        The record to evaluate
5171       * @param    string        FlexForm value key, eg. vDEF
5172       * @return    boolean
5173       */
5174  	function isDisplayCondition($displayCond,$row,$ffValueKey='')    {
5175          $output = FALSE;
5176  
5177          $parts = explode(':',$displayCond);
5178          switch((string)$parts[0])    {    // Type of condition:
5179              case 'FIELD':
5180                  $theFieldValue = $ffValueKey ? $row[$parts[1]][$ffValueKey] : $row[$parts[1]];
5181  
5182                  switch((string)$parts[2])    {
5183                      case 'REQ':
5184                          if (strtolower($parts[3])=='true')    {
5185                              $output = $theFieldValue ? TRUE : FALSE;
5186                          } elseif (strtolower($parts[3])=='false') {
5187                              $output = !$theFieldValue ? TRUE : FALSE;
5188                          }
5189                      break;
5190                      case '>':
5191                          $output = $theFieldValue > $parts[3];
5192                      break;
5193                      case '<':
5194                          $output = $theFieldValue < $parts[3];
5195                      break;
5196                      case '>=':
5197                          $output = $theFieldValue >= $parts[3];
5198                      break;
5199                      case '<=':
5200                          $output = $theFieldValue <= $parts[3];
5201                      break;
5202                      case '-':
5203                      case '!-':
5204                          $cmpParts = explode('-',$parts[3]);
5205                          $output = $theFieldValue >= $cmpParts[0] && $theFieldValue <= $cmpParts[1];
5206                          if ($parts[2]{0}=='!')    $output = !$output;
5207                      break;
5208                      case 'IN':
5209                      case '!IN':
5210                          $output = t3lib_div::inList($parts[3],$theFieldValue);
5211                          if ($parts[2]{0}=='!')    $output = !$output;
5212                      break;
5213                      case '=':
5214                      case '!=':
5215                          $output = t3lib_div::inList($parts[3],$theFieldValue);
5216                          if ($parts[2]{0}=='!')    $output = !$output;
5217                      break;
5218                  }
5219              break;
5220              case 'EXT':
5221                  switch((string)$parts[2])    {
5222                      case 'LOADED':
5223                          if (strtolower($parts[3])=='true')    {
5224                              $output = t3lib_extMgm::isLoaded($parts[1]) ? TRUE : FALSE;
5225                          } elseif (strtolower($parts[3])=='false') {
5226                              $output = !t3lib_extMgm::isLoaded($parts[1]) ? TRUE : FALSE;
5227                          }
5228                      break;
5229                  }
5230              break;
5231              case 'REC':
5232                  switch((string)$parts[1])    {
5233                      case 'NEW':
5234                          if (strtolower($parts[2])=='true')    {
5235                              $output = !(intval($row['uid']) > 0) ? TRUE : FALSE;
5236                          } elseif (strtolower($parts[2])=='false') {
5237                              $output = (intval($row['uid']) > 0) ? TRUE : FALSE;
5238                          }
5239                      break;
5240                  }
5241              break;
5242              case 'HIDE_L10N_SIBLINGS':
5243                  if ($ffValueKey==='vDEF')    {
5244                      $output = TRUE;
5245                  } elseif ($parts[1]==='except_admin' && $GLOBALS['BE_USER']->isAdmin())    {
5246                      $output = TRUE;
5247                  }
5248              break;
5249              case 'HIDE_FOR_NON_ADMINS':
5250                  $output = $GLOBALS['BE_USER']->isAdmin() ? TRUE : FALSE;
5251              break;
5252              case 'VERSION':
5253                  switch((string)$parts[1])    {
5254                      case 'IS':
5255                          if (strtolower($parts[2])=='true')    {
5256                              $output = intval($row['pid'])==-1 ? TRUE : FALSE;
5257                          } elseif (strtolower($parts[2])=='false') {
5258                              $output = !(intval($row['pid'])==-1) ? TRUE : FALSE;
5259                          }
5260                      break;
5261                  }
5262              break;
5263          }
5264  
5265          return $output;
5266      }
5267  
5268      /**
5269       * Return TSCpid (cached)
5270       * Using t3lib_BEfunc::getTSCpid()
5271       *
5272       * @param    string        Tablename
5273       * @param    string        UID value
5274       * @param    string        PID value
5275       * @return    integer        Returns the REAL pid of the record, if possible. If both $uid and $pid is strings, then pid=-1 is returned as an error indication.
5276       * @see t3lib_BEfunc::getTSCpid()
5277       */
5278  	function getTSCpid($table,$uid,$pid)    {
5279          $key = $table.':'.$uid.':'.$pid;
5280          if (!isset($this->cache_getTSCpid[$key]))    {
5281              $this->cache_getTSCpid[$key] = t3lib_BEfunc::getTSCpid($table,$uid,$pid);
5282          }
5283          return $this->cache_getTSCpid[$key];
5284      }
5285  
5286      /**
5287       * Returns true if descriptions should be loaded always
5288       *
5289       * @param    string        Table for which to check
5290       * @return    boolean
5291       */
5292  	function doLoadTableDescr($table)    {
5293          global $TCA;
5294          return $TCA[$table]['interface']['always_description'];
5295      }
5296  
5297      /**
5298       * Returns an array of available languages (to use for FlexForms)
5299       *
5300       * @param    boolean        If set, only languages which are paired with a static_info_table / static_language record will be returned.
5301       * @param    boolean        If set, an array entry for a default language is set.
5302       * @return    array
5303       */
5304  	function getAvailableLanguages($onlyIsoCoded=1,$setDefault=1)    {
5305          $isL = t3lib_extMgm::isLoaded('static_info_tables');
5306  
5307              // Find all language records in the system:
5308          $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('static_lang_isocode,title,uid', 'sys_language', 'pid=0 AND hidden=0'.t3lib_BEfunc::deleteClause('sys_language'), '', 'title');
5309  
5310              // Traverse them:
5311          $output=array();
5312          if ($setDefault)    {
5313              $output[0]=array(
5314                  'uid' => 0,
5315                  'title' => 'Default language',
5316                  'ISOcode' => 'DEF'
5317              );
5318          }
5319          while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))    {
5320              $output[$row['uid']]=$row;
5321  
5322              if ($isL && $row['static_lang_isocode'])    {
5323                  $rr = t3lib_BEfunc::getRecord('static_languages',$row['static_lang_isocode'],'lg_iso_2');
5324                  if ($rr['lg_iso_2'])    $output[$row['uid']]['ISOcode']=$rr['lg_iso_2'];
5325              }
5326  
5327              if ($onlyIsoCoded && !$output[$row['uid']]['ISOcode'])    unset($output[$row['uid']]);
5328          }
5329          return $output;
5330      }
5331      
5332      /**
5333       * Initializes language icons etc.
5334       *
5335       * param    string    Table name
5336       * param    array    Record
5337       * param    string    Sys language uid OR ISO language code prefixed with "v", eg. "vDA" 
5338       * @return    void
5339       */
5340  	function getLanguageIcon($table,$row,$sys_language_uid)    {
5341          global $TCA,$LANG;
5342  
5343          $mainKey = $table.':'.$row['uid'];
5344  
5345          if (!isset($this->cachedLanguageFlag[$mainKey]))    {
5346              t3lib_BEfunc::fixVersioningPid($table,$row);
5347              list($tscPID,$thePidValue) = $this->getTSCpid($table,$row['uid'],$row['pid']);
5348  
5349              $t8Tools = t3lib_div::makeInstance('t3lib_transl8tools');
5350              $this->cachedLanguageFlag[$mainKey] = $t8Tools->getSystemLanguages($tscPID, $this->backPath);
5351          }
5352  
5353              // Convert sys_language_uid to sys_language_uid if input was in fact a string (ISO code expected then)
5354          if (!t3lib_div::testInt($sys_language_uid))    {
5355              foreach($this->cachedLanguageFlag[$mainKey] as $rUid => $cD)    {
5356                  if ('v'.$cD['ISOcode']===$sys_language_uid)    {
5357                      $sys_language_uid = $rUid;
5358                  }
5359              }
5360          }
5361  
5362          return ($this->cachedLanguageFlag[$mainKey][$sys_language_uid]['flagIcon'] ? '<img src="'.$this->cachedLanguageFlag[$mainKey][$sys_language_uid]['flagIcon'].'" class="absmiddle" alt="" />' : ($this->cachedLanguageFlag[$mainKey][$sys_language_uid]['title'] ? '['.$this->cachedLanguageFlag[$mainKey][$sys_language_uid]['title'].']' : '')).'&nbsp;';
5363      }
5364  
5365      /**
5366       * Rendering preview output of a field value which is not shown as a form field but just outputted.
5367       *
5368       * @param    string        The value to output
5369       * @param    array        Configuration for field.
5370       * @return     string        HTML formatted output
5371       */
5372  	function previewFieldValue($value, $config)    {
5373          if ($config['config']['type']==='group' && $config['config']['internal_type'] === 'file')    {
5374              $show_thumbs = TRUE;
5375              $table = 'tt_content';
5376  
5377                  // Making the array of file items:
5378              $itemArray = t3lib_div::trimExplode(',',$value,1);
5379  
5380                  // Showing thumbnails:
5381              $thumbsnail = '';
5382              if ($show_thumbs)    {
5383                  $imgs = array();
5384                  foreach($itemArray as $imgRead)    {
5385                      $imgP = explode('|',$imgRead);
5386                      $imgPath = rawurldecode($imgP[0]);
5387  
5388                      $rowCopy = array();
5389                      $rowCopy[$field] = $imgPath;
5390  
5391                          // Icon + clickmenu:
5392                      $absFilePath = t3lib_div::getFileAbsFileName($config['config']['uploadfolder'].'/'.$imgPath);
5393  
5394                      $fI = pathinfo($imgPath);
5395                      $fileIcon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
5396                      $fileIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/fileicons/'.$fileIcon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].($absFilePath && @is_file($absFilePath) ? ' ('.t3lib_div::formatSize(filesize($absFilePath)).'bytes)' : ' - FILE NOT FOUND!')).'" alt="" />';
5397  
5398                      $imgs[] = '<span class="nobr">'.t3lib_BEfunc::thumbCode($rowCopy,$table,$field,$this->backPath,'thumbs.php',$config['config']['uploadfolder'],0,' align="middle"').
5399                                  ($absFilePath ? $this->getClickMenu($fileIcon, $absFilePath) : $fileIcon).
5400                                  $imgPath.
5401                                  '</span>';
5402                  }
5403                  $thumbsnail = implode('<br />',$imgs);
5404              }
5405  
5406              return $thumbsnail;
5407          } else {
5408              return nl2br(htmlspecialchars($value));
5409          }
5410      }
5411  
5412      /**
5413       * Generates and return information about which languages the current user should see in preview, configured by options.additionalPreviewLanguages
5414       *
5415       * return array    Array of additional languages to preview
5416       */
5417  	function getAdditionalPreviewLanguages()    {
5418          if (!isset($this->cachedAdditionalPreviewLanguages))     {
5419              if ($GLOBALS['BE_USER']->getTSConfigVal('options.additionalPreviewLanguages'))    {
5420                  $uids = t3lib_div::intExplode(',',$GLOBALS['BE_USER']->getTSConfigVal('options.additionalPreviewLanguages'));
5421                  foreach($uids as $uid)    {
5422                      if ($sys_language_rec = t3lib_BEfunc::getRecord('sys_language',$uid))    {
5423                          $this->cachedAdditionalPreviewLanguages[$uid] = array('uid' => $uid);
5424  
5425                          if ($sys_language_rec['static_lang_isocode'] && t3lib_extMgm::isLoaded('static_info_tables'))    {
5426                              $staticLangRow = t3lib_BEfunc::getRecord('static_languages',$sys_language_rec['static_lang_isocode'],'lg_iso_2');
5427                              if ($staticLangRow['lg_iso_2']) {
5428                                  $this->cachedAdditionalPreviewLanguages[$uid]['uid'] = $uid;
5429                                  $this->cachedAdditionalPreviewLanguages[$uid]['ISOcode'] = $staticLangRow['lg_iso_2'];
5430                              }
5431                          }
5432                      }
5433                  }
5434              } else {
5435                      // None:
5436                  $this->cachedAdditionalPreviewLanguages = array();
5437              }
5438          }
5439          return $this->cachedAdditionalPreviewLanguages;
5440      }
5441      
5442      /**
5443       * Push a new element to the dynNestedStack. Thus, every object know, if it's
5444       * nested in a tab or IRRE level and in which order this was processed.
5445       *
5446       * @param    string        $type: Type of the level, e.g. "tab" or "inline"
5447       * @param    string        $ident: Identifier of the level
5448       * @return    void
5449       */
5450  	function pushToDynNestedStack($type, $ident) {
5451          $this->dynNestedStack[] = array($type, $ident);
5452      }
5453  
5454      /**
5455       * Remove an element from the dynNestedStack. If $type and $ident
5456       * are set, the last element will only be removed, if it matches
5457       * what is expected to be removed.
5458       * 
5459       * @param    string        $type: Type of the level, e.g. "tab" or "inline"
5460       * @param    string        $ident: Identifier of the level
5461       * @return    void
5462       */
5463  	function popFromDynNestedStack($type=null, $ident=null) {
5464          if ($type!=null && $ident!=null) {
5465              $last = end($this->dynNestedStack);
5466              if ($type==$last[0] && $ident==$last[1]) {
5467                  array_pop($this->dynNestedStack);
5468              }
5469          } else {
5470              array_pop($this->dynNestedStack);
5471          }
5472      }
5473  
5474      /**
5475       * Get the dynNestedStack as associative array.
5476       * The result is e.g. ['tab','DTM-ABCD-1'], ['inline','data[13][table][uid][field]'], ['tab','DTM-DEFG-2'], ...
5477       *
5478       * @param    boolean        $json: Return a JSON string instead of an array - default: false
5479       * @param    boolean        $skipFirst: Skip the first element in the dynNestedStack - default: false
5480       * @return    mixed        Returns an associative array by default. If $json is true, it will be returned as JSON string.
5481       */
5482  	function getDynNestedStack($json=false, $skipFirst=false) {
5483          $result = $this->dynNestedStack;
5484          if ($skipFirst) {
5485              array_shift($result);
5486          }
5487          return ($json ? $this->inline->getJSON($result) : $result);
5488      }
5489  }
5490  
5491  
5492  
5493  
5494  
5495  
5496  
5497  
5498  
5499  /**
5500   * Extension class for the rendering of TCEforms in the frontend
5501   *
5502   * @author    Kasper Skaarhoj <kasperYYYY@typo3.com>
5503   */
5504  class t3lib_TCEforms_FE extends t3lib_TCEforms {
5505  
5506      /**
5507       * Function for wrapping labels.
5508       *
5509       * @param    string        The string to wrap
5510       * @return    string
5511       */
5512  	function wrapLabels($str)    {
5513          return '<font face="verdana" size="1" color="black">'.$str.'</font>';
5514      }
5515  
5516      /**
5517       * Prints the palette in the frontend editing (forms-on-page?)
5518       *
5519       * @param    array        The palette array to print
5520       * @return    string        HTML output
5521       */
5522  	function printPalette($palArr)    {
5523          $out='';
5524          reset($palArr);
5525          $bgColor=' bgcolor="#D6DAD0"';
5526          while(list(,$content)=each($palArr))    {
5527              $hRow[]='<td'.$bgColor.'><font face="verdana" size="1">&nbsp;</font></td><td nowrap="nowrap"'.$bgColor.'><font color="#666666" face="verdana" size="1">'.$content['NAME'].'</font></td>';
5528              $iRow[]='<td valign="top">'.
5529                          '<img name="req_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="10" height="10" alt="" />'.
5530                          '<img name="cm_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="7" height="10" alt="" />'.
5531                          '</td><td nowrap="nowrap" valign="top">'.$content['ITEM'].$content['HELP_ICON'].'</td>';
5532          }
5533          $out='<table border="0" cellpadding="0" cellspacing="0">
5534              <tr><td><img src="clear.gif" width="'.intval($this->paletteMargin).'" height="1" alt="" /></td>'.implode('',$hRow).'</tr>
5535              <tr><td></td>'.implode('',$iRow).'</tr>
5536          </table>';
5537  
5538          return $out;
5539      }
5540  
5541      /**
5542       * Sets the fancy front-end design of the editor.
5543       * Frontend
5544       *
5545       * @return    void
5546       */
5547  	function setFancyDesign()    {
5548          $this->fieldTemplate='
5549      <tr>
5550          <td nowrap="nowrap" bgcolor="#F6F2E6">###FIELD_HELP_ICON###<font face="verdana" size="1" color="black"><b>###FIELD_NAME###</b></font>###FIELD_HELP_TEXT###</td>
5551      </tr>
5552      <tr>
5553          <td nowrap="nowrap" bgcolor="#ABBBB4"><img name="req_###FIELD_TABLE###_###FIELD_ID###_###FIELD_FIELD###" src="clear.gif" width="10" height="10" alt="" /><img name="cm_###FIELD_TABLE###_###FIELD_ID###_###FIELD_FIELD###" src="clear.gif" width="7" height="10" alt="" /><font face="verdana" size="1" color="black">###FIELD_ITEM###</font>###FIELD_PAL_LINK_ICON###</td>
5554      </tr>    ';
5555  
5556          $this->totalWrap='<table border="0" cellpadding="1" cellspacing="0" bgcolor="black"><tr><td><table border="0" cellpadding="2" cellspacing="0">|</table></td></tr></table>';
5557  
5558          $this->palFieldTemplate='
5559      <tr>
5560          <td nowrap="nowrap" bgcolor="#ABBBB4"><font face="verdana" size="1" color="black">###FIELD_PALETTE###</font></td>
5561      </tr>    ';
5562          $this->palFieldTemplateHeader='
5563      <tr>
5564          <td nowrap="nowrap" bgcolor="#F6F2E6"><font face="verdana" size="1" color="black"><b>###FIELD_HEADER###</b></font></td>
5565      </tr>    ';
5566      }
5567  }
5568  
5569  if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tceforms.php'])    {
5570      include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tceforms.php']);
5571  }
5572  ?>


Généré le : Sun Nov 25 17:13:16 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics