Main Page | Directories | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages | Examples

class.t3lib_tceforms.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2004 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00179 require_once(PATH_t3lib.'class.t3lib_diff.php');
00180 
00181 
00182 
00191 class t3lib_TCEforms {
00192 
00193       // variables not commented yet.... (do so...)
00194    var $palFieldArr = array();
00195    var $disableWizards = 0;
00196    var $isPalettedoc = 0;
00197    var $paletteMargin = 1;
00198    var $defStyle = ''; // 'font-family:Verdana;font-size:10px;';
00199    var $cachedTSconfig = array();
00200    var $cachedTSconfig_fieldLevel = array();
00201    var $transformedRow = array();
00202    var $extJSCODE = '';
00203    var $printNeededJS = array();
00204    var $hiddenFieldAccum=array();
00205    var $TBE_EDITOR_fieldChanged_func='';
00206    var $loadMD5_JS=1;
00207    var $prevBorderStyle='[nothing here...]'; // Something unique...
00208    var $allowUpload=0;           // If set direct upload fields will be shown
00209    var $titleLen=15;                // $BE_USER->uc['titleLen'] but what is default??
00210    var $defaultLanguageData = array(); // Array where records in the default language is stored. (processed by transferdata)
00211    var $defaultLanguageData_diff = array();  // Array where records in the default language is stored (raw without any processing. used for making diff)
00212 
00213 
00214       // EXTERNAL, static
00215    var $backPath='';             // Set this to the 'backPath' pointing back to the typo3 admin directory from the script where this form is displayed.
00216    var $returnUrl='';               // Alternative return URL path (default is t3lib_div::linkThisScript())
00217    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.
00218    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.
00219    var $disableRTE=0;               // If set, the RTE is disabled (from form display, eg. by checkbox in the bottom of the page!)
00220    var $globalShowHelp=1;           // If false, then all CSH will be disabled, regardless of settings in $this->edit_showFieldHelp
00221    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.
00222    var $doPrintPalette=1;           // If set to false, palettes will NEVER be rendered.
00223    var $clipObj=FALSE;              // Set to initialized clipboard object; Then the element browser will offer a link to paste in records from clipboard.
00224    var $enableClickMenu=FALSE;         // Enable click menu on reference icons.
00225    var $enableTabMenu = FALSE;         // Enable Tab Menus. If set to true, the JavaScript content from template::getDynTabMenuJScode() must be included in the document.
00226 
00227    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)
00228    var $form_largeComp = 1.33;         // Form field width compensation: Compensation for large documents, doc-tab (editing)
00229    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.
00230    var $maxTextareaWidth=48;        // The maximum abstract value for textareas
00231    var $maxInputWidth=48;           // The maximum abstract value for input fields
00232    var $defaultMultipleSelectorStyle='width:250px;';  // Default style for the selector boxes used for multiple items in "select" and "group" types.
00233 
00234 
00235       // INTERNAL, static
00236    var $prependFormFieldNames = 'data';      // The string to prepend formfield names with.
00237    var $prependFormFieldNames_file = 'data_files';    // The string to prepend FILE form field names with.
00238    var $formName = 'editform';               // The name attribute of the form.
00239 
00240 
00241 
00242       // INTERNAL, dynamic
00243    var $perms_clause='';                  // Set by readPerms()  (caching)
00244    var $perms_clause_set=0;               // Set by readPerms()  (caching-flag)
00245    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).
00246    var $docLarge=0;                    // If set, the forms will be rendered a little wider, more precisely with a factor of $this->form_largeComp.
00247    var $clientInfo=array();               // Loaded with info about the browser when class is instantiated.
00248    var $RTEenabled=0;                     // True, if RTE is possible for the current user (based on result from BE_USER->isRTE())
00249    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)
00250    var $RTEcounter = 0;                // Counter that is incremented before an RTE is created. Can be used for unique ids etc.
00251 
00252    var $colorScheme;                   // Contains current color scheme
00253    var $classScheme;                   // Contains current class scheme
00254    var $defColorScheme;                // Contains the default color scheme
00255    var $defClassScheme;                // Contains the default class scheme
00256    var $fieldStyle;                    // Contains field style values
00257    var $borderStyle;                   // Contains border style values.
00258 
00259    var $commentMessages=array();          // An accumulation of messages from the class.
00260 
00261       // INTERNAL, templates
00262    var $totalWrap='<hr />|<hr />';           // Total wrapping for the table rows.
00263    var $fieldTemplate='<b>###FIELD_NAME###</b><br />###FIELD_ITEM###<hr />';  // Field template
00264    var $sectionWrap='';                // Wrapping template code for a section
00265    var $palFieldTemplateHeader='';           // Template for palette headers
00266    var $palFieldTemplate='';              // Template for palettes
00267 
00268       // INTERNAL, working memory
00269    var $excludeElements='';               // Set to the fields NOT to display, if any.
00270    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)
00271    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!
00272    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.
00273    var $requiredElements=array();            // Used to register the min and max number of elements for selectorboxes where that apply (in the "group" type for instance)
00274    var $renderDepth=0;                    // Keeps track of the rendering depth of nested records.
00275    var $savedSchemes=array();             // Color scheme buffer.
00276 
00277       // Internal, registers for user defined functions etc.
00278    var $additionalCode_pre = array();        // Additional HTML code, printed before the form.
00279    var $additionalJS_pre = array();       // Additional JavaScript, printed before the form
00280    var $additionalJS_post = array();         // Additional JavaScript printed after the form
00281    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.
00282 
00283 
00284 
00285 
00286 
00287 
00288 
00294    function t3lib_TCEforms()  {
00295       global $CLIENT;
00296 
00297       $this->clientInfo = t3lib_div::clientInfo();
00298 
00299       $this->RTEenabled = $GLOBALS['BE_USER']->isRTE();
00300       if (!$this->RTEenabled) {
00301          $this->RTEenabled_notReasons = implode(chr(10),$GLOBALS['BE_USER']->RTE_errors);
00302          $this->commentMessages[] = 'RTE NOT ENABLED IN SYSTEM due to:'.chr(10).$this->RTEenabled_notReasons;
00303       }
00304 
00305          // Default color+class scheme
00306       $this->defColorScheme = array(
00307          $GLOBALS['SOBE']->doc->bgColor,  // Background for the field AND palette
00308          t3lib_div::modifyHTMLColorAll($GLOBALS['SOBE']->doc->bgColor,-20),   // Background for the field header
00309          t3lib_div::modifyHTMLColorAll($GLOBALS['SOBE']->doc->bgColor,-10),   // Background for the palette field header
00310          'black', // Field header font color
00311          '#666666'   // Palette field header font color
00312       );
00313       $this->defColorScheme = array();
00314 
00315          // Override / Setting defaults from TBE_STYLES array
00316       $this->resetSchemes();
00317 
00318          // Setting the current colorScheme to default.
00319       $this->defColorScheme = $this->colorScheme;
00320       $this->defClassScheme = $this->classScheme;
00321    }
00322 
00328    function initDefaultBEmode()  {
00329       global $BE_USER;
00330       $this->prependFormFieldNames = 'data';
00331       $this->formName = 'editform';
00332       $this->setNewBEDesign();
00333       $this->docLarge = $BE_USER->uc['edit_wideDocument'] ? 1 : 0;
00334       $this->edit_showFieldHelp = $BE_USER->uc['edit_showFieldHelp'];
00335 
00336       $this->edit_docModuleUpload = $BE_USER->uc['edit_docModuleUpload'];
00337       $this->titleLen = $BE_USER->uc['titleLen'];
00338    }
00339 
00340 
00341 
00342 
00343 
00344 
00345 
00346 
00347 
00348 
00349 
00350 
00351 
00352 
00353 
00354 
00355 
00356    /*******************************************************
00357     *
00358     * Rendering the forms, fields etc
00359     *
00360     *******************************************************/
00361 
00373    function getSoloField($table,$row,$theFieldToReturn)  {
00374       global $TCA;
00375 
00376       if ($TCA[$table]) {
00377          t3lib_div::loadTCA($table);
00378          $typeNum = $this->getRTypeNum($table,$row);
00379          if ($TCA[$table]['types'][$typeNum])   {
00380             $itemList = $TCA[$table]['types'][$typeNum]['showitem'];
00381             if ($itemList) {
00382                $fields = t3lib_div::trimExplode(',',$itemList,1);
00383                $excludeElements = $this->excludeElements = $this->getExcludeElements($table,$row,$typeNum);
00384 
00385                reset($fields);
00386                while(list(,$fieldInfo)=each($fields)) {
00387                   $parts = explode(';',$fieldInfo);
00388 
00389                   $theField = trim($parts[0]);
00390                   if (!in_array($theField,$excludeElements) && !strcmp($theField,$theFieldToReturn))  {
00391                      if ($TCA[$table]['columns'][$theField])   {
00392                         $sField = $this->getSingleField($table,$theField,$row,$parts[1],1,$parts[3],$parts[2]);
00393                         return $sField['ITEM'];
00394                      }
00395                   }
00396                }
00397             }
00398          }
00399       }
00400    }
00401 
00412    function getMainFields($table,$row,$depth=0) {
00413       global $TCA;
00414 
00415       $this->renderDepth=$depth;
00416 
00417          // Init vars:
00418       $out_array = array(array());
00419       $out_array_meta = array(array(
00420          'title' => $this->getLL('l_generalTab')
00421       ));
00422 
00423       $out_pointer=0;
00424       $out_sheet=0;
00425       $this->palettesRendered=array();
00426       $this->palettesRendered[$this->renderDepth][$table]=array();
00427 
00428       if ($TCA[$table]) {
00429 
00430             // Load the full TCA for the table.
00431          t3lib_div::loadTCA($table);
00432 
00433             // Load the description content for the table.
00434          if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table)) {
00435             $GLOBALS['LANG']->loadSingleTableDescription($table);
00436          }
00437             // Get the current "type" value for the record.
00438          $typeNum = $this->getRTypeNum($table,$row);
00439 
00440             // Find the list of fields to display:
00441          if ($TCA[$table]['types'][$typeNum])   {
00442             $itemList = $TCA[$table]['types'][$typeNum]['showitem'];
00443             if ($itemList) {  // If such a list existed...
00444 
00445                   // Explode the field list and possibly rearrange the order of the fields, if configured for
00446                $fields = t3lib_div::trimExplode(',',$itemList,1);
00447                if ($this->fieldOrder)  {
00448                   $fields = $this->rearrange($fields);
00449                }
00450 
00451                   // Get excluded fields, added fiels and put it together:
00452                $excludeElements = $this->excludeElements = $this->getExcludeElements($table,$row,$typeNum);
00453                $fields = $this->mergeFieldsWithAddedFields($fields,$this->getFieldsToAdd($table,$row,$typeNum));
00454 
00455                   // Traverse the fields to render:
00456                $cc=0;
00457                foreach($fields as $fieldInfo)   {
00458                      // Exploding subparts of the field configuration:
00459                   $parts = explode(';',$fieldInfo);
00460 
00461                      // Getting the style information out:
00462                   $color_style_parts = t3lib_div::trimExplode('-',$parts[4]);
00463                   if (strcmp($color_style_parts[0],''))  {
00464                      $this->setColorScheme($GLOBALS['TBE_STYLES']['colorschemes'][intval($color_style_parts[0])]);
00465                   }
00466                   if (strcmp($color_style_parts[1],''))  {
00467                      $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][intval($color_style_parts[1])];
00468                      if (!isset($this->fieldStyle))   $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][0];
00469                   }
00470                   if (strcmp($color_style_parts[2],''))  {
00471                      $this->wrapBorder($out_array[$out_sheet],$out_pointer);
00472                      $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][intval($color_style_parts[2])];
00473                      if (!isset($this->borderStyle))  $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][0];
00474                   }
00475 
00476                      // Render the field:
00477                   $theField = $parts[0];
00478                   if (!in_array($theField,$excludeElements))   {
00479                      if ($TCA[$table]['columns'][$theField])   {
00480                         $sFieldPal='';
00481 
00482                         if ($parts[2] && !isset($this->palettesRendered[$this->renderDepth][$table][$parts[2]]))  {
00483                            $sFieldPal=$this->getPaletteFields($table,$row,$parts[2]);
00484                            $this->palettesRendered[$this->renderDepth][$table][$parts[2]] = 1;
00485                         }
00486                         $sField = $this->getSingleField($table,$theField,$row,$parts[1],0,$parts[3],$parts[2]);
00487                         if ($sField)   $sField.=$sFieldPal;
00488 
00489                         $out_array[$out_sheet][$out_pointer].= $sField;
00490                      } elseif($theField=='--div--')   {
00491                         if ($cc>0) {
00492                            $out_array[$out_sheet][$out_pointer].=$this->getDivider();
00493 
00494                            if ($this->enableTabMenu && $TCA[$table]['ctrl']['dividers2tabs'])   {
00495                               $this->wrapBorder($out_array[$out_sheet],$out_pointer);
00496                               $out_sheet++;
00497                               $out_array[$out_sheet] = array();
00498                               $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
00499                            }
00500                         } else { // Setting alternative title for "General" tab if "--div--" is the very first element.
00501                            $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
00502                         }
00503                      } elseif($theField=='--palette--')  {
00504                         if ($parts[2] && !isset($this->palettesRendered[$this->renderDepth][$table][$parts[2]]))  {
00505                               // render a 'header' if not collapsed
00506                            if ($TCA[$table]['palettes'][$parts[2]]['canNotCollapse'] AND $parts[1]) {
00507                               $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$parts[2],$this->sL($parts[1]));
00508                            } else {
00509                               $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$parts[2],'','',$this->sL($parts[1]));
00510                            }
00511                            $this->palettesRendered[$this->renderDepth][$table][$parts[2]] = 1;
00512                         }
00513                      }
00514                   }
00515 
00516                   $cc++;
00517                }
00518             }
00519          }
00520       }
00521 
00522          // Wrapping a border around it all:
00523       $this->wrapBorder($out_array[$out_sheet],$out_pointer);
00524 
00525          // Resetting styles:
00526       $this->resetSchemes();
00527 
00528          // Rendering Main palette, if any
00529       $mP = $TCA[$table]['ctrl']['mainpalette'];
00530       if ($mP && !isset($this->palettesRendered[$this->renderDepth][$table][$mP]))  {
00531          $temp_palettesCollapsed=$this->palettesCollapsed;
00532          $this->palettesCollapsed=0;
00533          $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$mP,$this->getLL('l_generalOptions'));
00534          $this->palettesCollapsed=$temp_palettesCollapsed;
00535          $this->palettesRendered[$this->renderDepth][$table][$mP] = 1;
00536       }
00537       $this->wrapBorder($out_array[$out_sheet],$out_pointer);
00538 
00539       if ($this->renderDepth) {
00540          $this->renderDepth--;
00541       }
00542 
00543 
00544          // Return the imploded $out_array:
00545       if ($out_sheet>0) {  // There were --div-- dividers around...
00546 
00547             // Create parts array for the tab menu:
00548          $parts = array();
00549          foreach($out_array as $idx => $sheetContent) {
00550             $parts[] = array(
00551                'label' => $out_array_meta[$idx]['title'],
00552                'content' => '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.
00553                      implode('',$sheetContent).
00554                   '</table>'
00555             );
00556          }
00557 
00558          return '
00559             <tr>
00560                <td colspan="2">
00561                '.$this->getDynTabMenu($parts, 'TCEforms:'.$table.':'.$row['uid']).'
00562                </td>
00563             </tr>';
00564       } else { // Only one, so just implode:
00565          return implode('',$out_array[$out_sheet]);
00566       }
00567    }
00568 
00579    function getListedFields($table,$row,$list)  {
00580       global $TCA;
00581 
00582       t3lib_div::loadTCA($table);
00583       if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table)) {
00584          $GLOBALS['LANG']->loadSingleTableDescription($table);
00585       }
00586 
00587       $out='';
00588       $types_fieldConfig=t3lib_BEfunc::getTCAtypes($table,$row,1);
00589 
00590       $editFieldList=array_unique(t3lib_div::trimExplode(',',$list,1));
00591       foreach($editFieldList as $theFieldC)  {
00592          list($theField,$palFields) = split('\[|\]',$theFieldC);
00593          $theField = trim($theField);
00594          $palFields = trim($palFields);
00595          if ($TCA[$table]['columns'][$theField])   {
00596             $parts = t3lib_div::trimExplode(';',$types_fieldConfig[$theField]['origString']);
00597             $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.
00598             $out.= $sField;
00599          } elseif($theField=='--div--')   {
00600             $out.=$this->getDivider();
00601          }
00602          if ($palFields)   {
00603             $out.=$this->getPaletteFields($table,$row,'','',implode(',',t3lib_div::trimExplode('|',$palFields,1)));
00604          }
00605       }
00606       return $out;
00607    }
00608 
00620    function getPaletteFields($table,$row,$palette,$header='',$itemList='',$collapsedHeader='')  {
00621       global $TCA;
00622       if (!$this->doPrintPalette)   return '';
00623 
00624       $out='';
00625       $palParts=array();
00626       t3lib_div::loadTCA($table);
00627 
00628          // Getting excludeElements, if any.
00629       if (!is_array($this->excludeElements)) {
00630          $this->excludeElements = $this->getExcludeElements($table,$row,$this->getRTypeNum($table,$row));
00631       }
00632 
00633          // Render the palette TCEform elements.
00634       if ($TCA[$table] && (is_array($TCA[$table]['palettes'][$palette]) || $itemList)) {
00635          $itemList = $itemList?$itemList:$TCA[$table]['palettes'][$palette]['showitem'];
00636          if ($itemList) {
00637             $fields = t3lib_div::trimExplode(',',$itemList,1);
00638             reset($fields);
00639             while(list(,$fieldInfo)=each($fields)) {
00640                $parts = t3lib_div::trimExplode(';',$fieldInfo);
00641                $theField = $parts[0];
00642 
00643                if (!in_array($theField,$this->excludeElements) && $TCA[$table]['columns'][$theField]) {
00644                   $this->palFieldArr[$palette][] = $theField;
00645                   if ($this->isPalettesCollapsed($table,$palette))   {
00646                      $this->hiddenFieldListArr[] = $theField;
00647                   }
00648 
00649                   $part=$this->getSingleField($table,$theField,$row,$parts[1],1,'',$parts[2]);
00650                   if (is_array($part)) {
00651                      $palParts[]=$part;
00652                   }
00653                }
00654             }
00655          }
00656       }
00657          // Put palette together if there are fields in it:
00658       if (count($palParts))   {
00659          if ($header)   {
00660             $out.=   $this->intoTemplate(array(
00661                         'HEADER' => htmlspecialchars($header)
00662                      ),
00663                      $this->palFieldTemplateHeader
00664                   );
00665          }
00666          $out.=   $this->intoTemplate(array(
00667                      'PALETTE' => $this->printPalette($palParts)
00668                   ),
00669                   $this->palFieldTemplate
00670                );
00671       }
00672          // 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.
00673       if ($this->isPalettesCollapsed($table,$palette) && $collapsedHeader) {
00674          $pC=  $this->intoTemplate(array(
00675                      '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),
00676                   ),
00677                   $this->palFieldTemplate
00678                );
00679          $out.=$pC;
00680       }
00681       return $out;
00682    }
00683 
00696    function getSingleField($table,$field,$row,$altName='',$palette=0,$extra='',$pal=0) {
00697       global $TCA,$BE_USER;
00698 
00699       $out = '';
00700       $PA = array();
00701       $PA['altName'] = $altName;
00702       $PA['palette'] = $palette;
00703       $PA['extra'] = $extra;
00704       $PA['pal'] = $pal;
00705 
00706          // Make sure to load full $TCA array for the table:
00707       t3lib_div::loadTCA($table);
00708 
00709          // Get the TCA configuration for the current field:
00710       $PA['fieldConf'] = $TCA[$table]['columns'][$field];
00711       $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ? $PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type'];
00712 
00713          // Now, check if this field is configured and editable (according to excludefields + other configuration)
00714       if (  is_array($PA['fieldConf']) &&
00715             (!$PA['fieldConf']['exclude'] || $BE_USER->check('non_exclude_fields',$table.':'.$field)) &&
00716             $PA['fieldConf']['config']['form_type']!='passthrough' &&
00717             ($this->RTEenabled || !$PA['fieldConf']['config']['showIfRTE']) &&
00718             (!$PA['fieldConf']['displayCond'] || $this->isDisplayCondition($PA['fieldConf']['displayCond'],$row)) &&
00719             (!$TCA[$table]['ctrl']['languageField'] || strcmp($PA['fieldConf']['l10n_mode'],'exclude') || $row[$TCA[$table]['ctrl']['languageField']]<=0)
00720          )  {
00721 
00722             // Fetching the TSconfig for the current table/field. This includes the $row which means that
00723          $PA['fieldTSConfig'] = $this->setTSconfig($table,$row,$field);
00724 
00725             // If the field is NOT disabled from TSconfig (which it could have been) then render it
00726          if (!$PA['fieldTSConfig']['disabled']) {
00727 
00728                // Init variables:
00729             $PA['itemFormElName']=$this->prependFormFieldNames.'['.$table.']['.$row['uid'].']['.$field.']';    // Form field name
00730             $PA['itemFormElName_file']=$this->prependFormFieldNames_file.'['.$table.']['.$row['uid'].']['.$field.']';   // Form field name, in case of file uploads
00731             $PA['itemFormElValue']=$row[$field];      // The value to show in the form field.
00732 
00733                // 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"
00734             if (
00735                   (($TCA[$table]['ctrl']['type'] && !strcmp($field,$TCA[$table]['ctrl']['type'])) ||
00736                   ($TCA[$table]['ctrl']['requestUpdate'] && t3lib_div::inList($TCA[$table]['ctrl']['requestUpdate'],$field)))
00737                   && !$BE_USER->uc['noOnChangeAlertInTypeFields'])   {
00738                $alertMsgOnChange = 'if (confirm('.$GLOBALS['LANG']->JScharCode($this->getLL('m_onChangeAlert')).') && TBE_EDITOR_checkSubmit(-1)){ TBE_EDITOR_submitForm() };';
00739             } else {$alertMsgOnChange='';}
00740 
00741                // Render as a hidden field?
00742             if (in_array($field,$this->hiddenFieldListArr)) {
00743                $this->hiddenFieldAccum[]='<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
00744             } else { // Render as a normal field:
00745 
00746                   // 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.
00747                if (!$PA['palette']) {
00748                   if ($PA['pal'] && $this->isPalettesCollapsed($table,$PA['pal']))  {
00749                      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);
00750                   } else {
00751                      $thePalIcon = '';
00752                      $palJSfunc = '';
00753                   }
00754                }
00755                   // onFocus attribute to add to the field:
00756                $PA['onFocus'] = ($palJSfunc && !$BE_USER->uc['dontShowPalettesOnFocusInAB']) ? ' onfocus="'.htmlspecialchars($palJSfunc).'"' : '';
00757 
00758                   // Find item
00759                $item='';
00760                $PA['label'] = $PA['altName'] ? $PA['altName'] : $PA['fieldConf']['label'];
00761                $PA['label'] = $this->sL($PA['label']);
00762                   // JavaScript code for event handlers:
00763                $PA['fieldChangeFunc']=array();
00764                $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = "TBE_EDITOR_fieldChanged('".$table."','".$row['uid']."','".$field."','".$PA['itemFormElName']."');";
00765                $PA['fieldChangeFunc']['alert']=$alertMsgOnChange;
00766 
00767                   // Based on the type of the item, call a render function:
00768                $item = $this->getSingleField_SW($table,$field,$row,$PA);
00769 
00770                   // Add language + diff
00771                $item = $this->renderDefaultLanguageContent($table,$field,$row,$item);
00772                $item = $this->renderDefaultLanguageDiff($table,$field,$row,$item);
00773 
00774                   // 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
00775                $PA['label'] = t3lib_div::deHSCentities(htmlspecialchars($PA['label']));
00776                if (t3lib_div::testInt($row['uid']) && $PA['fieldTSConfig']['linkTitleToSelf'])  {
00777                   $lTTS_url = $this->backPath.'alt_doc.php?edit['.$table.']['.$row['uid'].']=edit&columnsOnly='.$field.
00778                            ($PA['fieldTSConfig']['linkTitleToSelf.']['returnUrl']?'&returnUrl='.rawurlencode($this->thisReturnUrl()):'');
00779                   $PA['label'] = '<a href="'.htmlspecialchars($lTTS_url).'">'.$PA['label'].'</a>';
00780                }
00781 
00782                   // Create output value:
00783                if ($PA['fieldConf']['config']['form_type']=='user' && $PA['fieldConf']['config']['noTableWrapping']) {
00784                   $out = $item;
00785                } elseif ($PA['palette'])  {
00786                      // Array:
00787                   $out=array(
00788                      'NAME'=>$PA['label'],
00789                      'ID'=>$row['uid'],
00790                      'FIELD'=>$field,
00791                      'TABLE'=>$table,
00792                      'ITEM'=>$item,
00793                      'HELP_ICON' => $this->helpTextIcon($table,$field,1)
00794                   );
00795                   $out = $this->addUserTemplateMarkers($out,$table,$field,$row,$PA);
00796                } else {
00797                      // String:
00798                   $out=array(
00799                      'NAME'=>$PA['label'],
00800                      'ITEM'=>$item,
00801                      'TABLE'=>$table,
00802                      'ID'=>$row['uid'],
00803                      'HELP_ICON'=>$this->helpTextIcon($table,$field),
00804                      'HELP_TEXT'=>$this->helpText($table,$field),
00805                      'PAL_LINK_ICON'=>$thePalIcon,
00806                      'FIELD'=>$field
00807                   );
00808                   $out = $this->addUserTemplateMarkers($out,$table,$field,$row,$PA);
00809                      // String:
00810                   $out=$this->intoTemplate($out);
00811                }
00812             }
00813          } else $this->commentMessages[]=$this->prependFormFieldNames.'['.$table.']['.$row['uid'].']['.$field.']: Disabled by TSconfig';
00814       }
00815          // Return value (string or array)
00816       return $out;
00817    }
00818 
00830    function getSingleField_SW($table,$field,$row,&$PA)   {
00831       $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ? $PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type'];
00832 
00833       switch($PA['fieldConf']['config']['form_type']) {
00834          case 'input':
00835             $item = $this->getSingleField_typeInput($table,$field,$row,$PA);
00836          break;
00837          case 'text':
00838             $item = $this->getSingleField_typeText($table,$field,$row,$PA);
00839          break;
00840          case 'check':
00841             $item = $this->getSingleField_typeCheck($table,$field,$row,$PA);
00842          break;
00843          case 'radio':
00844             $item = $this->getSingleField_typeRadio($table,$field,$row,$PA);
00845          break;
00846          case 'select':
00847             $item = $this->getSingleField_typeSelect($table,$field,$row,$PA);
00848          break;
00849          case 'group':
00850             $item = $this->getSingleField_typeGroup($table,$field,$row,$PA);
00851          break;
00852          case 'none':
00853             $item = $this->getSingleField_typeNone($table,$field,$row,$PA);
00854          break;
00855          case 'user':
00856             $item = $this->getSingleField_typeUser($table,$field,$row,$PA);
00857          break;
00858          case 'flex':
00859             $item = $this->getSingleField_typeFlex($table,$field,$row,$PA);
00860          break;
00861          default:
00862             $item = $this->getSingleField_typeUnknown($table,$field,$row,$PA);
00863          break;
00864       }
00865 
00866       return $item;
00867    }
00868 
00869 
00870 
00871 
00872 
00873 
00874 
00875 
00876 
00877 
00878 
00879 
00880 
00881 
00882 
00883 
00884 
00885 
00886 
00887    /**********************************************************
00888     *
00889     * Rendering of each TCEform field type
00890     *
00891     ************************************************************/
00892 
00903    function getSingleField_typeInput($table,$field,$row,&$PA)  {
00904       // typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue)
00905       // typo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off)
00906 
00907       $config = $PA['fieldConf']['config'];
00908 #     $specConf = $this->getSpecConfForField($table,$row,$field);
00909       $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
00910       $size = t3lib_div::intInRange($config['size']?$config['size']:30,5,$this->maxInputWidth);
00911       $evalList = t3lib_div::trimExplode(',',$config['eval'],1);
00912 
00913       if (in_array('required',$evalList)) {
00914          $this->requiredFields[$table.'_'.$row['uid'].'_'.$field]=$PA['itemFormElName'];
00915       }
00916 
00917       $paramsList = "'".$PA['itemFormElName']."','".implode(',',$evalList)."','".trim($config['is_in'])."',".(isset($config['checkbox'])?1:0).",'".$config['checkbox']."'";
00918       if (isset($config['checkbox']))  {
00919             // Setting default "click-checkbox" values for eval types "date" and "datetime":
00920          $nextMidNight = mktime(0,0,0)+1*3600*24;
00921          $checkSetValue = in_array('date',$evalList) ? $nextMidNight : '';
00922          $checkSetValue = in_array('datetime',$evalList) ? time() : $checkSetValue;
00923 
00924          $cOnClick = 'typo3FormFieldGet('.$paramsList.',1,\''.$checkSetValue.'\');'.implode('',$PA['fieldChangeFunc']);
00925          $item.='<input type="checkbox" name="'.$PA['itemFormElName'].'_cb" onclick="'.htmlspecialchars($cOnClick).'" />';
00926       }
00927 
00928       $PA['fieldChangeFunc'] = array_merge(array('typo3FormFieldGet'=>'typo3FormFieldGet('.$paramsList.');'), $PA['fieldChangeFunc']);
00929       $mLgd = ($config['max']?$config['max']:256);
00930       $iOnChange = implode('',$PA['fieldChangeFunc']);
00931       $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.
00932       $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.
00933       $this->extJSCODE.='typo3FormFieldSet('.$paramsList.');';
00934 
00935          // Creating an alternative item without the JavaScript handlers.
00936       $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'_hr" value="" />';
00937       $altItem.= '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
00938 
00939          // Wrap a wizard around the item?
00940       $item= $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'].'_hr',$specConf);
00941 
00942       return $item;
00943    }
00944 
00955    function getSingleField_typeText($table,$field,$row,&$PA)   {
00956 
00957          // Init config:
00958       $config = $PA['fieldConf']['config'];
00959 
00960          // Setting columns number:
00961       $cols = t3lib_div::intInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
00962 
00963          // Setting number of rows:
00964       $origRows = $rows = t3lib_div::intInRange($config['rows'] ? $config['rows'] : 5, 1, 20);
00965       if (strlen($PA['itemFormElValue']) > $this->charsPerRow*2)  {
00966          $cols = $this->maxTextareaWidth;
00967          $rows = t3lib_div::intInRange(round(strlen($PA['itemFormElValue'])/$this->charsPerRow), count(explode(chr(10),$PA['itemFormElValue'])), 20);
00968          if ($rows<$origRows) $rows = $origRows;
00969       }
00970 
00971          // Init RTE vars:
00972       $RTEwasLoaded = 0;            // Set true, if the RTE is loaded; If not a normal textarea is shown.
00973       $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...
00974 
00975          // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. Traditionally, this is where RTE configuration has been found.
00976       $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
00977 
00978          // Setting up the altItem form field, which is a hidden field containing the value
00979       $altItem = '<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
00980 
00981          // If RTE is generally enabled (TYPO3_CONF_VARS and user settings)
00982       if ($this->RTEenabled) {
00983          $p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
00984          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.
00985             list($tscPID,$thePidValue) = $this->getTSCpid($table,$row['uid'],$row['pid']);
00986 
00987                // If the pid-value is not negative (that is, a pid could NOT be fetched)
00988             if ($thePidValue >= 0)  {
00989                $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($tscPID));
00990                $RTEtypeVal = t3lib_BEfunc::getTCAtypeValue($table,$row);
00991                $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$table,$field,$RTEtypeVal);
00992 
00993                if (!$thisConfig['disabled']) {
00994                   if (!$this->disableRTE) {
00995                      $this->RTEcounter++;
00996 
00997                         // Find alternative relative path for RTE images/links:
00998                      $eFile = t3lib_parsehtml_proc::evalWriteFile($specConf['static_write'], $row);
00999                      $RTErelPath = is_array($eFile) ? dirname($eFile['relEditFile']) : '';
01000 
01001                         // Get RTE object, draw form and set flag:
01002                      $RTEobj = &t3lib_BEfunc::RTEgetObj();
01003                      $item = $RTEobj->drawRTE($this,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue);
01004 
01005                         // Wizard:
01006                      $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf,1);
01007 
01008                      $RTEwasLoaded = 1;
01009                   } else {
01010                      $RTEwouldHaveBeenLoaded = 1;
01011                      $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!)';
01012                   }
01013                } else $this->commentMessages[] = $PA['itemFormElName'].': RTE is disabled by the Page TSconfig, "RTE"-key (eg. by RTE.default.disabled=0 or such)';
01014             } else $this->commentMessages[] = $PA['itemFormElName'].': PID value could NOT be fetched. Rare error, normally with new records.';
01015          } else {
01016             if (!isset($specConf['richtext']))  $this->commentMessages[] = $PA['itemFormElName'].': RTE was not configured for this field in TCA-types';
01017             if (!(!$p['flag'] || !$row[$p['flag']]))   $this->commentMessages[] = $PA['itemFormElName'].': Field-flag ('.$PA['flag'].') has been set to disable RTE!';
01018          }
01019       }
01020 
01021          // Display ordinary field if RTE was not loaded.
01022       if (!$RTEwasLoaded) {
01023          if ($specConf['rte_only']) {  // Show message, if no RTE (field can only be edited with RTE!)
01024             $item = '<p><em>'.htmlspecialchars($this->getLL('l_noRTEfound')).'</em></p>';
01025          } else {
01026             if ($specConf['nowrap'])   {
01027                $wrap = 'off';
01028             } else {
01029                $wrap = ($config['wrap'] ? $config['wrap'] : 'virtual');
01030             }
01031             $iOnChange = implode('',$PA['fieldChangeFunc']);
01032             $item.= '
01033                      <textarea name="'.$PA['itemFormElName'].'"'.$this->formWidthText($cols,$wrap).' rows="'.$rows.'" wrap="'.$wrap.'" onchange="'.htmlspecialchars($iOnChange).'"'.$PA['onFocus'].'>'.
01034                      t3lib_div::formatForTextarea($PA['itemFormElValue']).
01035                      '</textarea>';
01036             $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf,$RTEwouldHaveBeenLoaded);
01037          }
01038       }
01039 
01040          // Return field HTML:
01041       return $item;
01042    }
01043 
01054    function getSingleField_typeCheck($table,$field,$row,&$PA)  {
01055       $config = $PA['fieldConf']['config'];
01056 
01057          // Traversing the array of items:
01058       $selItems = $this->initItemArray($PA['fieldConf']);
01059       if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
01060 
01061       if (!count($selItems))  {
01062          $selItems[]=array('','');
01063       }
01064       $thisValue = intval($PA['itemFormElValue']);
01065 
01066       $cols = intval($config['cols']);
01067       if ($cols > 1) {
01068          $item.= '<table border="0" cellspacing="0" cellpadding="0" class="typo3-TCEforms-checkboxArray">';
01069          for ($c=0;$c<count($selItems);$c++) {
01070             $p = $selItems[$c];
01071             if(!($c%$cols))   { $item.='<tr>'; }
01072             $cBP = $this->checkBoxParams($PA['itemFormElName'],$thisValue,$c,count($selItems),implode('',$PA['fieldChangeFunc']));
01073             $cBName = $PA['itemFormElName'].'_'.$c;
01074             $item.= '<td nowrap="nowrap">'.
01075                   '<input type="checkbox"'.$this->insertDefStyle('check').' value="1" name="'.$cBName.'"'.$cBP.' />'.
01076                   $this->wrapLabels(htmlspecialchars($p[0]).'&nbsp;').
01077                   '</td>';
01078             if(($c%$cols)+1==$cols) {$item.='</tr>';}
01079          }
01080          if ($c%$cols)  {
01081             $rest=$cols-($c%$cols);
01082             for ($c=0;$c<$rest;$c++) {
01083                $item.= '<td></td>';
01084             }
01085             if ($c>0)   { $item.= '</tr>'; }
01086          }
01087          $item.= '</table>';
01088       } else {
01089          for ($c=0;$c<count($selItems);$c++) {
01090             $p = $selItems[$c];
01091             $cBP = $this->checkBoxParams($PA['itemFormElName'],$thisValue,$c,count($selItems),implode('',$PA['fieldChangeFunc']));
01092             $cBName = $PA['itemFormElName'].'_'.$c;
01093             $item.= ($c>0?'<br />':'').
01094                   '<input type="checkbox"'.$this->insertDefStyle('check').' value="1" name="'.$cBName.'"'.$cBP.$PA['onFocus'].' />'.
01095                   htmlspecialchars($p[0]);
01096          }
01097       }
01098       $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($thisValue).'" />';
01099 
01100       return $item;
01101    }
01102 
01113    function getSingleField_typeRadio($table,$field,$row,&$PA)  {
01114       $config = $PA['fieldConf']['config'];
01115 
01116          // Get items for the array:
01117       $selItems = $this->initItemArray($PA['fieldConf']);
01118       if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
01119 
01120          // Traverse the items, making the form elements:
01121       for ($c=0;$c<count($selItems);$c++) {
01122          $p = $selItems[$c];
01123          $rOnClick = implode('',$PA['fieldChangeFunc']);
01124          $rChecked = (!strcmp($p[1],$PA['itemFormElValue'])?' checked="checked"':'');
01125          $item.= '<input type="radio"'.$this->insertDefStyle('radio').' name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($p[1]).'" onclick="'.htmlspecialchars($rOnClick).'"'.$rChecked.$PA['onFocus'].' />'.
01126                htmlspecialchars($p[0]).
01127                '<br />';
01128       }
01129 
01130       return $item;
01131    }
01132 
01143    function getSingleField_typeSelect($table,$field,$row,&$PA) {
01144       global $TCA;
01145 
01146          // Field configuration from TCA:
01147       $config = $PA['fieldConf']['config'];
01148 
01149          // Getting the selector box items from the system
01150       $selItems = $this->addSelectOptionsToItemArray($this->initItemArray($PA['fieldConf']),$PA['fieldConf'],$this->setTSconfig($table,$row),$field);
01151       $selItems = $this->addItems($selItems,$PA['fieldTSConfig']['addItems.']);
01152       if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
01153 
01154          // Possibly remove some items:
01155       $removeItems = t3lib_div::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
01156       foreach($selItems as $tk => $p)  {
01157 
01158             // Checking languages and authMode:
01159          $languageDeny = $TCA[$table]['ctrl']['languageField'] && !strcmp($TCA[$table]['ctrl']['languageField'], $field) && !$GLOBALS['BE_USER']->checkLanguageAccess($p[1]);
01160          $authModeDeny = $config['type']=='select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table,$field,$p[1],$config['authMode']);
01161 
01162          if (in_array($p[1],$removeItems) || $languageDeny || $authModeDeny)  {
01163             unset($selItems[$tk]);
01164          } elseif (isset($PA['fieldTSConfig']['altLabels.'][$p[1]])) {
01165             $selItems[$tk][0]=$this->sL($PA['fieldTSConfig']['altLabels.'][$p[1]]);
01166          }
01167 
01168             // Removing doktypes with no access:
01169          if ($table.'.'.$field == 'pages.doktype') {
01170             if (!($GLOBALS['BE_USER']->isAdmin() || t3lib_div::inList($GLOBALS['BE_USER']->groupData['pagetypes_select'],$p[1])))   {
01171                unset($selItems[$tk]);
01172             }
01173          }
01174       }
01175 
01176          // Creating the label for the "No Matching Value" entry.
01177       $nMV_label = isset($PA['fieldTSConfig']['noMatchingValue_label']) ? $this->sL($PA['fieldTSConfig']['noMatchingValue_label']) : '[ '.$this->getLL('l_noMatchingValue').' ]';
01178 
01179          // Prepare some values:
01180       $maxitems = intval($config['maxitems']);
01181 
01182          // If a SINGLE selector box...
01183       if ($maxitems<=1) {
01184          $item = $this->getSingleField_typeSelect_single($table,$field,$row,$PA,$config,$selItems,$nMV_label);
01185       } elseif (!strcmp($config['renderMode'],'checkbox'))  {  // Checkbox renderMode
01186          $item = $this->getSingleField_typeSelect_checkbox($table,$field,$row,$PA,$config,$selItems,$nMV_label);
01187       } elseif (!strcmp($config['renderMode'],'singlebox')) {  // Single selector box renderMode
01188          $item = $this->getSingleField_typeSelect_singlebox($table,$field,$row,$PA,$config,$selItems,$nMV_label);
01189       } else { // Traditional multiple selector box:
01190          $item = $this->getSingleField_typeSelect_multiple($table,$field,$row,$PA,$config,$selItems,$nMV_label);
01191       }
01192 
01193          // Wizards:
01194       $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
01195       $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf);
01196 
01197       return $item;
01198    }
01199 
01214    function getSingleField_typeSelect_single($table,$field,$row,&$PA,$config,$selItems,$nMV_label) {
01215 
01216          // Initialization:
01217       $c = 0;
01218       $sI = 0;
01219       $noMatchingValue = 1;
01220       $opt = array();
01221       $selicons = array();
01222       $onlySelectedIconShown = 0;
01223       $size = intval($config['size']);
01224 
01225          // Icon configuration:
01226       if ($config['suppress_icons']=='IF_VALUE_FALSE')   {
01227          $suppressIcons = !$PA['itemFormElValue'] ? 1 : 0;
01228       } elseif ($config['suppress_icons']=='ONLY_SELECTED') {
01229          $suppressIcons=0;
01230          $onlySelectedIconShown=1;
01231       } elseif ($config['suppress_icons'])   {
01232          $suppressIcons = 1;
01233       } else $suppressIcons = 0;
01234 
01235          // Traverse the Array of selector box items:
01236       foreach($selItems as $p)   {
01237          $sM = (!strcmp($PA['itemFormElValue'],$p[1])?' selected="selected"':'');
01238          if ($sM) {
01239             $sI = $c;
01240             $noMatchingValue = 0;
01241          }
01242 
01243             // Getting style attribute value (for icons):
01244          if ($config['iconsInOptionTags'])   {
01245             $styleAttrValue = $this->optionTagStyle($p[2]);
01246          }
01247 
01248             // Compiling the <option> tag:
01249          $opt[]= '<option value="'.htmlspecialchars($p[1]).'"'.
01250                   $sM.
01251                   ($styleAttrValue ? ' style="'.htmlspecialchars($styleAttrValue).'"' : '').
01252                   (!strcmp($p[1],'--div--') ? ' class="c-divider"' : '').
01253                   '>'.t3lib_div::deHSCentities(htmlspecialchars($p[0])).'</option>';
01254 
01255             // If there is an icon for the selector box (rendered in table under)...:
01256          if ($p[2] && !$suppressIcons && (!$onlySelectedIconShown || $sM)) {
01257             list($selIconFile,$selIconInfo)=$this->getIcon($p[2]);
01258             $iOnClick = $this->elName($PA['itemFormElName']).'.selectedIndex='.$c.'; '.implode('',$PA['fieldChangeFunc']).$this->blur().'return false;';
01259             $selicons[]=array(
01260                (!$onlySelectedIconShown ? '<a href="#" onclick="'.htmlspecialchars($iOnClick).'">' : '').
01261                '<img src="'.$selIconFile.'" '.$selIconInfo[3].' vspace="2" border="0" title="'.htmlspecialchars($p[0]).'" alt="'.htmlspecialchars($p[0]).'" />'.
01262                (!$onlySelectedIconShown ? '</a>' : ''),
01263                $c,$sM);
01264          }
01265          $c++;
01266       }
01267 
01268          // No-matching-value:
01269       if ($PA['itemFormElValue'] && $noMatchingValue && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement'])   {
01270          $nMV_label = @sprintf($nMV_label, $PA['itemFormElValue']);
01271          $opt[]= '<option value="'.htmlspecialchars($PA['itemFormElValue']).'" selected="selected">'.htmlspecialchars($nMV_label).'</option>';
01272       }
01273 
01274          // Create item form fields:
01275       $sOnChange = 'if (this.options[this.selectedIndex].value==\'--div--\') {this.selectedIndex='.$sI.';} '.implode('',$PA['fieldChangeFunc']);
01276       $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...
01277       $item.= '<select name="'.$PA['itemFormElName'].'"'.
01278                $this->insertDefStyle('select').
01279                ($size?' size="'.$size.'"':'').
01280                ' onchange="'.htmlspecialchars($sOnChange).'"'.
01281                $PA['onFocus'].'>';
01282       $item.= implode('',$opt);
01283       $item.= '</select>';
01284 
01285          // Create icon table:
01286       if (count($selicons))   {
01287          $item.='<table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-selectIcons">';
01288          $selicon_cols = intval($config['selicon_cols']);
01289          if (!$selicon_cols)  $selicon_cols=count($selicons);
01290          $sR = ceil(count($selicons)/$selicon_cols);
01291          $selicons = array_pad($selicons,$sR*$selicon_cols,'');
01292          for($sa=0;$sa<$sR;$sa++)   {
01293             $item.='<tr>';
01294             for($sb=0;$sb<$selicon_cols;$sb++)  {
01295                $sk=($sa*$selicon_cols+$sb);
01296                $imgN = 'selIcon_'.$table.'_'.$row['uid'].'_'.$field.'_'.$selicons[$sk][1];
01297                $imgS = ($selicons[$sk][2]?$this->backPath.'gfx/content_selected.gif':'clear.gif');
01298                $item.='<td><img name="'.htmlspecialchars($imgN).'" src="'.$imgS.'" width="7" height="10" alt="" /></td>';
01299                $item.='<td>'.$selicons[$sk][0].'</td>';
01300             }
01301             $item.='</tr>';
01302          }
01303          $item.='</table>';
01304       }
01305 
01306       return $item;
01307    }
01308 
01323    function getSingleField_typeSelect_checkbox($table,$field,$row,&$PA,$config,$selItems,$nMV_label)  {
01324 
01325          // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
01326       $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
01327 
01328          // Traverse the Array of selector box items:
01329       $tRows = array();
01330       $sOnChange = implode('',$PA['fieldChangeFunc']);
01331       $c=0;
01332       $setAll = array();   // Used to accumulate the JS needed to restore the original selection.
01333       foreach($selItems as $p)   {
01334             // Non-selectable element:
01335          if (!strcmp($p[1],'--div--')) {
01336             if (count($setAll))  {
01337                   $tRows[] = '
01338                      <tr>
01339                         <td colspan="2">'.
01340                         '<a href="#" onclick="'.htmlspecialchars(implode('',$setAll).' return false;').'">'.
01341                         htmlspecialchars($this->getLL('l_setAllCheckboxes')).
01342                         '</a></td>
01343                      </tr>';
01344                   $setAll = array();
01345             }
01346 
01347             $tRows[] = '
01348                <tr class="c-header">
01349                   <td colspan="2">'.htmlspecialchars($p[0]).'</td>
01350                </tr>';
01351          } else {
01352                // Selected or not by default:
01353             $sM = '';
01354             if (isset($itemArray[$p[1]])) {
01355                $sM = ' checked="checked"';
01356                unset($itemArray[$p[1]]);
01357             }
01358 
01359                // Icon:
01360             $selIconFile = '';
01361             if ($p[2])  {
01362                list($selIconFile,$selIconInfo) = $this->getIcon($p[2]);
01363             }
01364 
01365                // Compile row:
01366             $onClickCell = $this->elName($PA['itemFormElName'].'['.$c.']').'.checked=!'.$this->elName($PA['itemFormElName'].'['.$c.']').'.checked;';
01367             $onClick = 'this.attributes.getNamedItem("class").nodeValue = '.$this->elName($PA['itemFormElName'].'['.$c.']').'.checked ? "c-selectedItem" : "";';
01368             $setAll[] = $this->elName($PA['itemFormElName'].'['.$c.']').'.checked=1;';
01369             $tRows[] = '
01370                <tr class="'.($sM ? 'c-selectedItem' : '').'" onclick="'.htmlspecialchars($onClick).'" style="cursor: pointer;">
01371                   <td><input type="checkbox" name="'.htmlspecialchars($PA['itemFormElName'].'['.$c.']').'" value="'.htmlspecialchars($p[1]).'"'.$sM.' onclick="'.htmlspecialchars($sOnChange).'"'.$PA['onFocus'].' /></td>
01372                   <td class="c-labelCell" onclick="'.htmlspecialchars($onClickCell).'">'.
01373                      ($selIconFile ? '<img src="'.$selIconFile.'" '.$selIconInfo[3].' vspace="2" border="0" class="absmiddle" style="margin-right: 4px;" alt="" />' : '').
01374                      t3lib_div::deHSCentities(htmlspecialchars($p[0])).
01375                      (strcmp($p[3],'') ? '<br/><p class="c-descr">'.nl2br(trim(htmlspecialchars($p[3]))).'</p>' : '').
01376                      '</td>
01377                </tr>';
01378             $c++;
01379          }
01380       }
01381 
01382          // Remaining checkboxes will get their set-all link:
01383       if (count($setAll))  {
01384             $tRows[] = '
01385                <tr>
01386                   <td colspan="2">'.
01387                   '<a href="#" onclick="'.htmlspecialchars(implode('',$setAll).' return false;').'">'.
01388                   htmlspecialchars($this->getLL('l_setAllCheckboxes')).
01389                   '</a></td>
01390                </tr>';
01391       }
01392 
01393          // Remaining values (invalid):
01394       if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
01395          foreach($itemArray as $theNoMatchValue => $temp)   {
01396                // Compile <checkboxes> tag:
01397             array_unshift($tRows,'
01398                   <tr class="c-invalidItem">
01399                      <td><input type="checkbox" name="'.htmlspecialchars($PA['itemFormElName'].'['.$c.']').'" value="'.htmlspecialchars($theNoMatchValue).'" checked="checked" onclick="'.htmlspecialchars($sOnChange).'"'.$PA['onFocus'].' /></td>
01400                      <td class="c-labelCell">'.
01401                         t3lib_div::deHSCentities(htmlspecialchars(@sprintf($nMV_label, $theNoMatchValue))).
01402                         '</td>
01403                   </tr>');
01404             $c++;
01405          }
01406       }
01407 
01408          // Add an empty hidden field which will send a blank value if all items are unselected.
01409       $item.='<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="" />';
01410 
01411          // Implode rows in table:
01412       $item.= '
01413          <table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-select-checkbox">'.
01414             implode('',$tRows).'
01415          </table>
01416          ';
01417 
01418       return $item;
01419    }
01420 
01435    function getSingleField_typeSelect_singlebox($table,$field,$row,&$PA,$config,$selItems,$nMV_label) {
01436 
01437          // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
01438       $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
01439 
01440          // Traverse the Array of selector box items:
01441       $opt = array();
01442       $restoreCmd = array();  // Used to accumulate the JS needed to restore the original selection.
01443       $c = 0;
01444       foreach($selItems as $p)   {
01445             // Selected or not by default:
01446          $sM = '';
01447          if (isset($itemArray[$p[1]])) {
01448             $sM = ' selected="selected"';
01449             $restoreCmd[] = $this->elName($PA['itemFormElName'].'[]').'.options['.$c.'].selected=1;';
01450             unset($itemArray[$p[1]]);
01451          }
01452 
01453             // Non-selectable element:
01454          $nonSel = '';
01455          if (!strcmp($p[1],'--div--')) {
01456             $nonSel = ' onclick="this.selected=0;" class="c-divider"';
01457          }
01458 
01459             // Icon style for option tag:
01460          if ($config['iconsInOptionTags']) {
01461             $styleAttrValue = $this->optionTagStyle($p[2]);
01462          }
01463 
01464             // Compile <option> tag:
01465          $opt[] = '<option value="'.htmlspecialchars($p[1]).'"'.
01466                   $sM.
01467                   $nonSel.
01468                   ($styleAttrValue ? ' style="'.htmlspecialchars($styleAttrValue).'"' : '').
01469                   '>'.t3lib_div::deHSCentities(htmlspecialchars($p[0])).'</option>';
01470          $c++;
01471       }
01472 
01473          // Remaining values:
01474       if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
01475          foreach($itemArray as $theNoMatchValue => $temp)   {
01476                // Compile <option> tag:
01477             array_unshift($opt,'<option value="'.htmlspecialchars($theNoMatchValue).'" selected="selected">'.t3lib_div::deHSCentities(htmlspecialchars(@sprintf($nMV_label, $theNoMatchValue))).'</option>');
01478          }
01479       }
01480 
01481          // Compile selector box:
01482       $sOnChange = implode('',$PA['fieldChangeFunc']);
01483       $selector_itemListStyle = isset($config['itemListStyle']) ? ' style="'.htmlspecialchars($config['itemListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"';
01484       $size = intval($config['size']);
01485       $size = $config['autoSizeMax'] ? t3lib_div::intInRange(count($selItems)+1,t3lib_div::intInRange($size,1),$config['autoSizeMax']) : $size;
01486       $selectBox = '<select name="'.$PA['itemFormElName'].'[]"'.
01487                   $this->insertDefStyle('select').
01488                   ($size ? ' size="'.$size.'"' : '').
01489                   ' multiple="multiple" onchange="'.htmlspecialchars($sOnChange).'"'.
01490                   $PA['onFocus'].
01491                   $selector_itemListStyle.'>
01492                   '.
01493                implode('
01494                   ',$opt).'
01495                </select>';
01496 
01497          // Add an empty hidden field which will send a blank value if all items are unselected.
01498       $item.='<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="" />';
01499 
01500          // Put it all into a table:
01501       $item.= '
01502          <table border="0" cellspacing="0" cellpadding="0" width="1" class="typo3-TCEforms-select-singlebox">
01503             <tr>
01504                <td>
01505                '.$selectBox.'
01506                <br/>
01507                <em>'.
01508                   htmlspecialchars($this->getLL('l_holdDownCTRL')).
01509                   '</em>
01510                </td>
01511                <td valign="top">
01512                <a href="#" onclick="'.htmlspecialchars($this->elName($PA['itemFormElName'].'[]').'.selectedIndex=-1;'.implode('',$restoreCmd).' return false;').'">'.
01513                   '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/history.gif','width="13" height="12"').' title="'.htmlspecialchars($this->getLL('l_revertSelection')).'" alt="" />'.
01514                   '</a>
01515                </td>
01516             </tr>
01517          </table>
01518             ';
01519 
01520       return $item;
01521    }
01522 
01537    function getSingleField_typeSelect_multiple($table,$field,$row,&$PA,$config,$selItems,$nMV_label)  {
01538 
01539          // Setting this hidden field (as a flag that JavaScript can read out)
01540       $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'_mul" value="'.($config['multiple']?1:0).'" />';
01541 
01542          // Set max and min items:
01543       $maxitems = t3lib_div::intInRange($config['maxitems'],0);
01544       if (!$maxitems)   $maxitems=100000;
01545       $minitems = t3lib_div::intInRange($config['minitems'],0);
01546 
01547          // Register the required number of elements:
01548       $this->requiredElements[$PA['itemFormElName']] = array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field);
01549 
01550          // Get "removeItems":
01551       $removeItems = t3lib_div::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
01552 
01553          // Perform modification of the selected items array:
01554       $itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
01555       foreach($itemArray as $tk => $tv) {
01556          $tvP = explode('|',$tv,2);
01557          $evalValue = rawurldecode($tvP[0]);
01558          $isRemoved = in_array($evalValue,$removeItems)  || ($config['type']=='select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table,$field,$evalValue,$config['authMode']));
01559          if ($isRemoved && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement'])  {
01560             $tvP[1] = rawurlencode(@sprintf($nMV_label, $evalValue));
01561          } elseif (isset($PA['fieldTSConfig']['altLabels.'][$evalValue])) {
01562             $tvP[1] = rawurlencode($this->sL($PA['fieldTSConfig']['altLabels.'][$evalValue]));
01563          } else {
01564             $tvP[1] = rawurlencode($this->sL(rawurldecode($tvP[1])));
01565          }
01566          $itemArray[$tk] = implode('|',$tvP);
01567       }
01568 
01569          // Create option tags:
01570       $opt = array();
01571       $styleAttrValue = '';
01572       foreach($selItems as $p)   {
01573          if ($config['iconsInOptionTags'])   {
01574             $styleAttrValue = $this->optionTagStyle($p[2]);
01575          }
01576          $opt[]= '<option value="'.htmlspecialchars($p[1]).'"'.
01577                      ($styleAttrValue ? ' style="'.htmlspecialchars($styleAttrValue).'"' : '').
01578                      '>'.htmlspecialchars($p[0]).'</option>';
01579       }
01580 
01581          // Put together the selector box:
01582       $selector_itemListStyle = isset($config['itemListStyle']) ? ' style="'.htmlspecialchars($config['itemListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"';
01583       $size = intval($config['size']);
01584       $size = $config['autoSizeMax'] ? t3lib_div::intInRange(count($itemArray)+1,t3lib_div::intInRange($size,1),$config['autoSizeMax']) : $size;
01585       $sOnChange = 'setFormValueFromBrowseWin(\''.$PA['itemFormElName'].'\',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text); '.implode('',$PA['fieldChangeFunc']);
01586       $itemsToSelect = '
01587          <select name="'.$PA['itemFormElName'].'_sel"'.
01588                   $this->insertDefStyle('select').
01589                   ($size ? ' size="'.$size.'"' : '').
01590                   ' onchange="'.htmlspecialchars($sOnChange).'"'.
01591                   $PA['onFocus'].
01592                   $selector_itemListStyle.'>
01593             '.implode('
01594             ',$opt).'
01595          </select>';
01596 
01597          // Pass to "dbFileIcons" function:
01598       $params = array(
01599          'size' => $size,
01600          'autoSizeMax' => t3lib_div::intInRange($config['autoSizeMax'],0),
01601          'style' => isset($config['selectedListStyle']) ? ' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"',
01602          'dontShowMoveIcons' => ($maxitems<=1),
01603          'maxitems' => $maxitems,
01604          'info' => '',
01605          'headers' => array(
01606             'selector' => $this->getLL('l_selected').':<br />',
01607             'items' => $this->getLL('l_items').':<br />'
01608          ),
01609          'noBrowser' => 1,
01610          'thumbnails' => $itemsToSelect
01611       );
01612       $item.= $this->dbFileIcons($PA['itemFormElName'],'','',$itemArray,'',$params,$PA['onFocus']);
01613 
01614       return $item;
01615    }
01616 
01627    function getSingleField_typeGroup($table,$field,$row,&$PA)  {
01628          // Init:
01629       $config = $PA['fieldConf']['config'];
01630       $internal_type = $config['internal_type'];
01631       $show_thumbs = $config['show_thumbs'];
01632       $size = intval($config['size']);
01633       $maxitems = t3lib_div::intInRange($config['maxitems'],0);
01634       if (!$maxitems)   $maxitems=100000;
01635       $minitems = t3lib_div::intInRange($config['minitems'],0);
01636       $allowed = $config['allowed'];
01637       $disallowed = $config['disallowed'];
01638 
01639       $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'_mul" value="'.($config['multiple']?1:0).'" />';
01640       $this->requiredElements[$PA['itemFormElName']] = array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field);
01641       $info='';
01642 
01643          // Acting according to either "file" or "db" type:
01644       switch((string)$config['internal_type'])  {
01645          case 'file':   // If the element is of the internal type "file":
01646 
01647                // Creating string showing allowed types:
01648             $tempFT = t3lib_div::trimExplode(',',$allowed,1);
01649             if (!count($tempFT)) {$info.='*';}
01650             foreach($tempFT as $ext)   {
01651                if ($ext)   {
01652                   $info.=strtoupper($ext).' ';
01653                }
01654             }
01655                // Creating string, showing disallowed types:
01656             $tempFT_dis = t3lib_div::trimExplode(',',$disallowed,1);
01657             if (count($tempFT_dis)) {$info.='<br />';}
01658             foreach($tempFT_dis as $ext)  {
01659                if ($ext)   {
01660                   $info.='-'.strtoupper($ext).' ';
01661                }
01662             }
01663 
01664                // Making the array of file items:
01665             $itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
01666 
01667                // Showing thumbnails:
01668             $thumbsnail = '';
01669             if ($show_thumbs) {
01670                $imgs = array();
01671                foreach($itemArray as $imgRead)  {
01672                   $imgP = explode('|',$imgRead);
01673 
01674                   $rowCopy = array();
01675                   $rowCopy[$field] = $imgP[0];
01676 
01677                      // Icon + clickmenu:
01678                   $absFilePath = t3lib_div::getFileAbsFileName($config['uploadfolder'].'/'.$imgP[0]);
01679 
01680                   $fI = pathinfo($imgP[0]);
01681                   $fileIcon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
01682                   $fileIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/fileicons/'.$fileIcon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].($absFilePath ? ' ('.t3lib_div::formatSize(filesize($absFilePath)).'bytes)' : ' - FILE NOT FOUND!')).'" alt="" />';
01683 
01684                   $imgs[] = '<span class="nobr">'.t3lib_BEfunc::thumbCode($rowCopy,$table,$field,$this->backPath,'thumbs.php',$config['uploadfolder'],0,' align="middle"').
01685                            ($absFilePath ? $this->getClickMenu($fileIcon, $absFilePath) : $fileIcon).
01686                            $imgP[0].
01687                            '</span>';
01688                }
01689                $thumbsnail = implode('<br />',$imgs);
01690             }
01691 
01692                // Creating the element:
01693             $params = array(
01694                'size' => $size,
01695                'dontShowMoveIcons' => ($maxitems<=1),
01696                'autoSizeMax' => t3lib_div::intInRange($config['autoSizeMax'],0),
01697                'maxitems' => $maxitems,
01698                'style' => isset($config['selectedListStyle']) ? ' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"',
01699                'info' => $info,
01700                'thumbnails' => $thumbsnail
01701             );
01702             $item.= $this->dbFileIcons($PA['itemFormElName'],'file',implode(',',$tempFT),$itemArray,'',$params,$PA['onFocus']);
01703 
01704                // Adding the upload field:
01705             if ($this->edit_docModuleUpload) $item.='<input type="file" name="'.$PA['itemFormElName_file'].'"'.$this->formWidth().' size="60" />';
01706          break;
01707          case 'db':  // If the element is of the internal type "db":
01708 
01709                // Creating string showing allowed types:
01710             $tempFT = t3lib_div::trimExplode(',',$allowed,1);
01711             if (!strcmp(trim($tempFT[0]),'*'))  {
01712                $info.='<span class="nobr">&nbsp;&nbsp;&nbsp;&nbsp;'.
01713                      htmlspecialchars($this->getLL('l_allTables')).
01714                      '</span><br />';
01715             } else {
01716                while(list(,$theT)=each($tempFT))   {
01717                   if ($theT)  {
01718                      $info.='<span class="nobr">&nbsp;&nbsp;&nbsp;&nbsp;'.
01719                            t3lib_iconWorks::getIconImage($theT,array(),$this->backPath,'align="top"').
01720                            htmlspecialchars($this->sL($GLOBALS['TCA'][$theT]['ctrl']['title'])).
01721                            '</span><br />';
01722                   }
01723                }
01724             }
01725 
01726             $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
01727             $itemArray = array();
01728             $imgs = array();
01729 
01730                // Thumbnails:
01731             $temp_itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
01732             foreach($temp_itemArray as $dbRead) {
01733                $recordParts = explode('|',$dbRead);
01734                list($this_table,$this_uid) = t3lib_BEfunc::splitTable_Uid($recordParts[0]);
01735                $itemArray[] = array('table'=>$this_table, 'id'=>$this_uid);
01736                if ($show_thumbs) {
01737                   $rr = t3lib_BEfunc::getRecord($this_table,$this_uid);
01738                   $imgs[] = '<span class="nobr">'.
01739                         $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).
01740                         '&nbsp;'.
01741                         $this->noTitle($rr[$GLOBALS['TCA'][$this_table]['ctrl']['label']],array('<em>','</em>')).
01742                         '</span>';
01743                }
01744             }
01745             $thumbsnail='';
01746             if ($show_thumbs) {
01747                $thumbsnail = implode('<br />',$imgs);
01748             }
01749 
01750                // Creating the element:
01751             $params = array(
01752                'size' => $size,
01753                'dontShowMoveIcons' => ($maxitems<=1),
01754                'autoSizeMax' => t3lib_div::intInRange($config['autoSizeMax'],0),
01755                'maxitems' => $maxitems,
01756                'style' => isset($config['selectedListStyle']) ? ' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"',
01757                'info' => $info,
01758                'thumbnails' => $thumbsnail
01759             );
01760             $item.= $this->dbFileIcons($PA['itemFormElName'],'db',implode(',',$tempFT),$itemArray,'',$params,$PA['onFocus']);
01761          break;
01762       }
01763 
01764          // Wizards:
01765       $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
01766       $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf);
01767 
01768       return $item;
01769    }
01770 
01781    function getSingleField_typeNone($table,$field,$row,&$PA)   {
01782          // Init:
01783       $config = $PA['fieldConf']['config'];
01784       $itemValue = $PA['itemFormElValue'];
01785 
01786       return $this->getSingleField_typeNone_render($config,$itemValue);
01787    }
01788 
01797    function getSingleField_typeNone_render($config,$itemValue) {
01798 
01799             // is colorScheme[0] the right value?
01800       $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;';
01801 
01802       if ($config['rows']>1) {
01803          if(!$config['pass_content']) {
01804             $itemValue = nl2br(htmlspecialchars($itemValue));
01805          }
01806             // like textarea
01807          $cols = t3lib_div::intInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
01808          if (!$config['fixedRows']) {
01809             $origRows = $rows = t3lib_div::intInRange($config['rows'] ? $config['rows'] : 5, 1, 20);
01810             if (strlen($itemValue)>$this->charsPerRow*2) {
01811                $cols = $this->maxTextareaWidth;
01812                $rows = t3lib_div::intInRange(round(strlen($itemValue)/$this->charsPerRow),count(explode(chr(10),$itemValue)),20);
01813                if ($rows<$origRows) $rows=$origRows;
01814             }
01815          } else {
01816             $rows = intval($config['rows']);
01817          }
01818 
01819          if ($this->docLarge) $cols = round($cols*$this->form_largeComp);
01820          $width = ceil($cols*$this->form_rowsToStylewidth);
01821             // hardcoded: 12 is the height of the font
01822          $height=$rows*12;
01823 
01824          $item='
01825             <div style="'.htmlspecialchars($divStyle.' overflow:auto; height:'.$height.'px; width:'.$width.'px;').'" class="'.htmlspecialchars($this->formElClass('none')).'">'.
01826             $itemValue.
01827             '</div>';
01828       } else {
01829          if(!$config['pass_content']) {
01830             $itemValue = htmlspecialchars($itemValue);
01831          }
01832 
01833          $cols = $config['cols']?$config['cols']:($config['size']?$config['size']:$this->maxInputWidth);
01834          if ($this->docLarge) $cols = round($cols*$this->form_largeComp);
01835          $width = ceil($cols*$this->form_rowsToStylewidth);
01836 
01837             // overflow:auto crashes mozilla here. Title tag is usefull when text is longer than the div box (overflow:hidden).
01838          $item = '
01839             <div style="'.htmlspecialchars($divStyle.' overflow:hidden; width:'.$width.'px;').'" class="'.htmlspecialchars($this->formElClass('none')).'" title="'.$itemValue.'">'.
01840             '<span class="nobr">'.(strcmp($itemValue,'')?$itemValue:'&nbsp;').'</span>'.
01841             '</div>';
01842       }
01843 
01844       return $item;
01845    }
01846 
01856    function getSingleField_typeFlex($table,$field,$row,&$PA)   {
01857 
01858          // Data Structure:
01859       $dataStructArray = t3lib_BEfunc::getFlexFormDS($PA['fieldConf']['config'],$row,$table);
01860 #debug($dataStructArray);
01861 
01862          // Get data structure:
01863       if (is_array($dataStructArray))  {
01864 #debug(array(str_replace(' ',chr(160),$PA['itemFormElValue'])));
01865 
01866             // Get data:
01867          $xmlData = $PA['itemFormElValue'];
01868          $xmlHeaderAttributes = t3lib_div::xmlGetHeaderAttribs($xmlData);
01869          $storeInCharset = strtolower($xmlHeaderAttributes['encoding']);
01870          if ($storeInCharset) {
01871             $currentCharset=$GLOBALS['LANG']->charSet;
01872             $xmlData = $GLOBALS['LANG']->csConvObj->conv($xmlData,$storeInCharset,$currentCharset,1);
01873          }
01874          $editData=t3lib_div::xml2array($xmlData);
01875          if (!is_array($editData))  {  // Must be XML parsing error...
01876 #debug(array($editData,$xmlData));
01877             $editData=array();
01878          }
01879 
01880             // Find the data structure if sheets are found:
01881          $sheet = $editData['meta']['currentSheetId'] ? $editData['meta']['currentSheetId'] : 'sDEF'; // Sheet to display
01882 #        $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'[meta][currentSheetId]" value="'.$sheet.'">';
01883 
01884             // Create sheet menu:
01885          if (is_array($dataStructArray['sheets'])) {
01886             #$item.=$this->getSingleField_typeFlex_sheetMenu($dataStructArray['sheets'], $PA['itemFormElName'].'[meta][currentSheetId]', $sheet).'<br />';
01887          }
01888 #debug($editData);
01889 
01890             // Create language menu:
01891          $langChildren = $dataStructArray['meta']['langChildren'] ? 1 : 0;
01892          $langDisabled = $dataStructArray['meta']['langDisable'] ? 1 : 0;
01893 
01894          $languages = $this->getAvailableLanguages();
01895 
01896          if (!is_array($editData['meta']['currentLangId']) || !count($editData['meta']['currentLangId']))   {
01897             $editData['meta']['currentLangId']=array('DEF');
01898          }
01899          $editData['meta']['currentLangId'] = array_unique($editData['meta']['currentLangId']);
01900 
01901          if (!$langDisabled && count($languages) > 1) {
01902             $item.=$this->getSingleField_typeFlex_langMenu($languages, $PA['itemFormElName'].'[meta][currentLangId]', $editData['meta']['currentLangId']).'<br />';
01903          }
01904 
01905          if ($langChildren || $langDisabled) {
01906             $rotateLang = array('DEF');
01907          } else {
01908             $rotateLang = $editData['meta']['currentLangId'];
01909          }
01910 
01911             // Tabs sheets
01912          if (is_array($dataStructArray['sheets'])) {
01913             $tabsToTraverse = array_keys($dataStructArray['sheets']);
01914          } else {
01915             $tabsToTraverse = array($sheet);
01916          }
01917 
01918          foreach($rotateLang as $lKey) {
01919             if (!$langChildren && !$langDisabled)  {
01920                $item.= '<b>'.$lKey.':</b>';
01921             }
01922 
01923             $tabParts = array();
01924             foreach($tabsToTraverse as $sheet)  {
01925                $sheetCfg = $dataStructArray['sheets'][$sheet];
01926                list ($dataStruct, $sheet) = t3lib_div::resolveSheetDefInDS($dataStructArray,$sheet);
01927 
01928                   // Render sheet:
01929                if (is_array($dataStruct['ROOT']) && is_array($dataStruct['ROOT']['el']))     {
01930                   $cmdData = t3lib_div::_GP('flexFormsCmdData');
01931                   $lang = 'l'.$lKey;   // Default language, other options are "lUK" or whatever country code (independant of system!!!)
01932                   $PA['_valLang'] = $langChildren && !$langDisabled ? $editData['meta']['currentLangId'] : 'DEF'; // Default language, other options are "lUK" or whatever country code (independant of system!!!)
01933 
01934                      // Render flexform:
01935                   $tRows = $this->getSingleField_typeFlex_draw(
01936                            $dataStruct['ROOT']['el'],
01937                            $editData['data'][$sheet][$lang],
01938                            $cmdData['data'][$sheet][$lang],
01939                            $table,
01940                            $field,
01941                            $row,
01942                            $PA,
01943                            '[data]['.$sheet.']['.$lang.']'
01944                         );
01945                   $sheetContent= '<table border="0" cellpadding="1" cellspacing="1" class="typo3-TCEforms-flexForm">'.implode('',$tRows).'</table>';
01946 
01947          #        $item = '<div style=" position:absolute;">'.$item.'</div>';
01948                   //visibility:hidden;
01949                } else $sheetContent='Data Structure ERROR: No ROOT element found for sheet "'.$sheet.'".';
01950 
01951                   // Add to tab:
01952                $tabParts[] = array(
01953                   'label' => ($sheetCfg['ROOT']['TCEforms']['sheetTitle'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetTitle']) : $sheet),
01954                   'description' => ($sheetCfg['ROOT']['TCEforms']['sheetDescription'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetDescription']) : ''),
01955                   'linkTitle' => ($sheetCfg['ROOT']['TCEforms']['sheetShortDescr'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetShortDescr']) : ''),
01956                   'content' => $sheetContent
01957                );
01958             }
01959 
01960             if (is_array($dataStructArray['sheets'])) {
01961                $item.= $this->getDynTabMenu($tabParts,'TCEFORMS:flexform:'.$PA['itemFormElName']);
01962             } else {
01963                $item.= $sheetContent;
01964             }
01965          }
01966       } else $item='Data Structure ERROR: '.$dataStructArray;
01967 
01968       return $item;
01969    }
01970 
01980    function getSingleField_typeFlex_langMenu($languages,$elName,$selectedLanguage,$multi=1)  {
01981       $opt=array();
01982       foreach($languages as $lArr)  {
01983          $opt[]='<option value="'.htmlspecialchars($lArr['ISOcode']).'"'.(in_array($lArr['ISOcode'],$selectedLanguage)?' selected="selected"':'').'>'.htmlspecialchars($lArr['title']).'</option>';
01984       }
01985 
01986       $output = '<select name="'.$elName.'[]"'.($multi ? ' multiple="multiple" size="'.count($languages).'"' : '').'>'.implode('',$opt).'</select>';
01987 
01988       return $output;
01989    }
01990 
01999    function getSingleField_typeFlex_sheetMenu($sArr,$elName,$sheetKey)  {
02000 
02001       $tCells =array();
02002       $pct = round(100/count($sArr));
02003       foreach($sArr as $sKey => $sheetCfg)   {
02004          $onClick = 'if (confirm('.$GLOBALS['LANG']->JScharCode($this->getLL('m_onChangeAlert')).') && TBE_EDITOR_checkSubmit(-1)){'.$this->elName($elName).".value='".$sKey."'; TBE_EDITOR_submitForm()};";
02005 
02006          $tCells[]='<td width="'.$pct.'%" style="'.($sKey==$sheetKey ? 'background-color: #9999cc; font-weight: bold;' : 'background-color: #aaaaaa;').' cursor: hand;" onclick="'.htmlspecialchars($onClick).'" align="center">'.
02007                ($sheetCfg['ROOT']['TCEforms']['sheetTitle'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetTitle']) : $sKey).
02008                '</td>';
02009       }
02010 
02011       return '<table border="0" cellpadding="0" cellspacing="2" class="typo3-TCEforms-flexForm-sheetMenu"><tr>'.implode('',$tCells).'</tr></table>';
02012    }
02013 
02029    function getSingleField_typeFlex_draw($dataStruct,$editData,$cmdData,$table,$field,$row,&$PA,$formPrefix='',$level=0,$tRows=array())   {
02030 
02031          // Data Structure array must be ... and array of course...
02032       if (is_array($dataStruct)) {
02033          foreach($dataStruct as $key => $value) {
02034             if (is_array($value))   {  // The value of each entry must be an array.
02035 
02036                   // ********************
02037                   // Making the row:
02038                   // ********************
02039                $rowCells=array();
02040 
02041                   // Icon:
02042                $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>';;
02043 
02044                $rowCells['formEl']='';
02045                if ($value['type']=='array')  {
02046                   if ($value['section'])  {
02047                      if (is_array($value['el']))   {
02048                         $opt=array();
02049                         $opt[]='<option value=""></option>';
02050                         foreach($value['el'] as $kk => $vv) {
02051                            $opt[]='<option value="'.$kk.'">'.htmlspecialchars('NEW "'.$value['el'][$kk]['tx_templavoila']['title'].'"').'</option>';
02052                         }
02053                         $rowCells['formEl']='<select name="flexFormsCmdData'.$formPrefix.'['.$key.'][value]">'.implode('',$opt).'</select>';
02054                      }
02055 
02056                         // Put row together
02057                      $tRows[]='<tr class="bgColor2">
02058                         <td nowrap="nowrap" valign="top">'.$rowCells['title'].'</td>
02059                         <td>'.$rowCells['formEl'].'</td>
02060                      </tr>';
02061 
02062                      $cc=0;
02063                      if (is_array($editData[$key]['el']))   {
02064                         foreach($editData[$key]['el'] as $k3 => $v3) {
02065                            $cc=$k3;
02066                            $theType = key($v3);
02067                            $theDat = $v3[$theType];
02068                            $newSectionEl = $value['el'][$theType];
02069                            if (is_array($newSectionEl))  {
02070                               $tRows = $this->getSingleField_typeFlex_draw(
02071                                  array($theType => $newSectionEl),
02072                                  array($theType => $theDat),
02073                                  $cmdData[$key]['el'][$cc],
02074                                  $table,
02075                                  $field,
02076                                  $row,
02077                                  $PA,
02078                                  $formPrefix.'['.$key.'][el]['.$cc.']',
02079                                  $level+1,
02080                                  $tRows
02081                               );
02082                            }
02083                         }
02084                      }
02085 
02086 
02087 
02088                         // New form?
02089                      if ($cmdData[$key]['value'])  {
02090                         $newSectionEl = $value['el'][$cmdData[$key]['value']];
02091                         if (is_array($newSectionEl))  {
02092                            $tRows = $this->getSingleField_typeFlex_draw(
02093                               array($cmdData[$key]['value'] => $newSectionEl),
02094                               array(),
02095                               array(),
02096                               $table,
02097                               $field,
02098                               $row,
02099                               $PA,
02100                               $formPrefix.'['.$key.'][el]['.($cc+1).']',
02101                               $level+1,
02102                               $tRows
02103                            );
02104                         }
02105                      }
02106                   } else {
02107                         // Put row together
02108                      $tRows[]='<tr class="bgColor2">
02109                         <td nowrap="nowrap" valign="top">'.
02110                         '<input name="_DELETE_FLEX_FORM'.$PA['itemFormElName'].$formPrefix.'" type="checkbox" value="1" /><img src="'.$this->backPath.'gfx/garbage.gif" border="0" alt="" />'.
02111                         $rowCells['title'].'</td>
02112                         <td>'.$rowCells['formEl'].'</td>
02113                      </tr>';
02114 
02115                      $tRows = $this->getSingleField_typeFlex_draw(
02116                         $value['el'],
02117                         $editData[$key]['el'],
02118                         $cmdData[$key]['el'],
02119                         $table,
02120                         $field,
02121                         $row,
02122                         $PA,
02123                         $formPrefix.'['.$key.'][el]',
02124                         $level+1,
02125                         $tRows
02126                      );
02127                   }
02128 
02129                } elseif (is_array($value['TCEforms']['config'])) {   // Rendering a single form element:
02130 
02131                   if (is_array($PA['_valLang']))   {
02132                      $rotateLang = $PA['_valLang'];
02133                   } else {
02134                      $rotateLang = array($PA['_valLang']);
02135                   }
02136 
02137                   foreach($rotateLang as $vDEFkey) {
02138                      $vDEFkey = 'v'.$vDEFkey;
02139 
02140                      $fakePA=array();
02141                      $fakePA['fieldConf']=array(
02142                         'label' => $this->sL($value['TCEforms']['label']),
02143                         'config' => $value['TCEforms']['config'],
02144                         'defaultExtras' => $value['TCEforms']['defaultExtras'],
02145                         'displayCond' => $value['TCEforms']['displayCond'],   // Haven't tested this...
02146                      );
02147                      $fakePA['fieldChangeFunc']=$PA['fieldChangeFunc'];
02148                      $fakePA['onFocus']=$PA['onFocus'];
02149                      $fakePA['label']==$PA['label'];
02150 
02151                      $fakePA['itemFormElName']=$PA['itemFormElName'].$formPrefix.'['.$key.']['.$vDEFkey.']';
02152                      $fakePA['itemFormElName_file']=$PA['itemFormElName_file'].$formPrefix.'['.$key.']['.$vDEFkey.']';
02153                      $fakePA['itemFormElValue']=$editData[$key][$vDEFkey];
02154 
02155                      $rowCells['formEl']= $this->getSingleField_SW($table,$field,$row,$fakePA);
02156                      $rowCells['title']= htmlspecialchars($fakePA['fieldConf']['label']);
02157 
02158                         // Put row together
02159                      $tRows[]='<tr>
02160                         <td nowrap="nowrap" valign="top" class="bgColor5">'.$rowCells['title'].($vDEFkey=='vDEF' ? '' : ' ('.$vDEFkey.')').'</td>
02161                         <td class="bgColor4">'.$rowCells['formEl'].'</td>
02162                      </tr>';
02163                   }
02164                }
02165             }
02166          }
02167       }
02168 
02169       return $tRows;
02170    }
02171 
02181    function getSingleField_typeUnknown($table,$field,$row,&$PA)   {
02182       $item='Unknown type: '.$PA['fieldConf']['config']['form_type'].'<br />';
02183 
02184       return $item;
02185    }
02186 
02196    function getSingleField_typeUser($table,$field,$row,&$PA)   {
02197       $PA['table']=$table;
02198       $PA['field']=$field;
02199       $PA['row']=$row;
02200 
02201       $PA['pObj']=&$this;
02202 
02203       return t3lib_div::callUserFunction($PA['fieldConf']['config']['userFunc'],$PA,$this);
02204    }
02205 
02206 
02207 
02208 
02209 
02210 
02211 
02212 
02213 
02214 
02215 
02216 
02217    /************************************************************
02218     *
02219     * "Configuration" fetching/processing functions
02220     *
02221     ************************************************************/
02222 
02230    function getRTypeNum($table,$row)   {
02231       global $TCA;
02232          // If there is a "type" field configured...
02233       if ($TCA[$table]['ctrl']['type'])   {
02234          $typeFieldName = $TCA[$table]['ctrl']['type'];
02235          $typeNum=$row[$typeFieldName];   // Get value of the row from the record which contains the type value.
02236          if (!strcmp($typeNum,''))  $typeNum=0;       // If that value is an empty string, set it to "0" (zero)
02237       } else {
02238          $typeNum = 0;  // If no "type" field, then set to "0" (zero)
02239       }
02240 
02241       $typeNum = (string)$typeNum;     // Force to string. Necessary for eg '-1' to be recognized as a type value.
02242       if (!$TCA[$table]['types'][$typeNum])  {  // However, if the type "0" is not found in the "types" array, then default to "1" (for historical reasons)
02243          $typeNum = 1;
02244       }
02245 
02246       return $typeNum;
02247    }
02248 
02256    function rearrange($fields)   {
02257       $fO = array_flip(t3lib_div::trimExplode(',',$this->fieldOrder,1));
02258       reset($fields);
02259       $newFields=array();
02260       while(list($cc,$content)=each($fields))   {
02261          $cP = t3lib_div::trimExplode(';',$content);
02262          if (isset($fO[$cP[0]])) {
02263             $newFields[$fO[$cP[0]]] = $content;
02264             unset($fields[$cc]);
02265          }
02266       }
02267       ksort($newFields);
02268       $fields=array_merge($newFields,$fields);     // Candidate for t3lib_div::array_merge() if integer-keys will some day make trouble...
02269       return $fields;
02270    }
02271 
02282    function getExcludeElements($table,$row,$typeNum)  {
02283       global $TCA;
02284 
02285          // Init:
02286       $excludeElements=array();
02287 
02288          // If a subtype field is defined for the type
02289       if ($TCA[$table]['types'][$typeNum]['subtype_value_field']) {
02290          $sTfield = $TCA[$table]['types'][$typeNum]['subtype_value_field'];
02291          if (trim($TCA[$table]['types'][$typeNum]['subtypes_excludelist'][$row[$sTfield]]))  {
02292             $excludeElements=t3lib_div::trimExplode(',',$TCA[$table]['types'][$typeNum]['subtypes_excludelist'][$row[$sTfield]],1);
02293          }
02294       }
02295 
02296          // If a bitmask-value field has been configured, then find possible fields to exclude based on that:
02297       if ($TCA[$table]['types'][$typeNum]['bitmask_value_field']) {
02298          $sTfield = $TCA[$table]['types'][$typeNum]['bitmask_value_field'];
02299          $sTValue = t3lib_div::intInRange($row[$sTfield],0);
02300          if (is_array($TCA[$table]['types'][$typeNum]['bitmask_excludelist_bits'])) {
02301             reset($TCA[$table]['types'][$typeNum]['bitmask_excludelist_bits']);
02302             while(list($bitKey,$eList)=each($TCA[$table]['types'][$typeNum]['bitmask_excludelist_bits']))   {
02303                $bit=substr($bitKey,1);
02304                if (t3lib_div::testInt($bit)) {
02305                   $bit = t3lib_div::intInRange($bit,0,30);
02306                   if (
02307                         (substr($bitKey,0,1)=='-' && !($sTValue&pow(2,$bit))) ||
02308                         (substr($bitKey,0,1)=='+' && ($sTValue&pow(2,$bit)))
02309                      )  {
02310                      $excludeElements = array_merge($excludeElements,t3lib_div::trimExplode(',',$eList,1));
02311                   }
02312                }
02313             }
02314          }
02315       }
02316 
02317          // Return the array of elements:
02318       return $excludeElements;
02319    }
02320 
02330    function getFieldsToAdd($table,$row,$typeNum)   {
02331       global $TCA;
02332 
02333          // Init:
02334       $addElements=array();
02335 
02336          // If a subtype field is defined for the type
02337       if ($TCA[$table]['types'][$typeNum]['subtype_value_field']) {
02338          $sTfield = $TCA[$table]['types'][$typeNum]['subtype_value_field'];
02339          if (trim($TCA[$table]['types'][$typeNum]['subtypes_addlist'][$row[$sTfield]]))   {
02340             $addElements=t3lib_div::trimExplode(',',$TCA[$table]['types'][$typeNum]['subtypes_addlist'][$row[$sTfield]],1);
02341          }
02342       }
02343          // Return the return
02344       return array($addElements,$sTfield);
02345    }
02346 
02355    function mergeFieldsWithAddedFields($fields,$fieldsToAdd)   {
02356       if (count($fieldsToAdd[0]))   {
02357          reset($fields);
02358          $c=0;
02359          while(list(,$fieldInfo)=each($fields)) {
02360             $parts = explode(';',$fieldInfo);
02361             if (!strcmp(trim($parts[0]),$fieldsToAdd[1]))   {
02362                array_splice(
02363                   $fields,
02364                   $c+1,
02365                   0,
02366                   $fieldsToAdd[0]
02367                );
02368                break;
02369             }
02370             $c++;
02371          }
02372       }
02373       return $fields;
02374    }
02375 
02376 
02387    function setTSconfig($table,$row,$field='')  {
02388       $mainKey = $table.':'.$row['uid'];
02389       if (!isset($this->cachedTSconfig[$mainKey])) {
02390          $this->cachedTSconfig[$mainKey]=t3lib_BEfunc::getTCEFORM_TSconfig($table,$row);
02391       }
02392       if ($field) {
02393          return $this->cachedTSconfig[$mainKey][$field];
02394       } else {
02395          return $this->cachedTSconfig[$mainKey];
02396       }
02397    }
02398 
02409    function getSpecConfForField($table,$row,$field)   {
02410          // Finds the current "types" configuration for the table/row:
02411       $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table,$row);
02412 
02413          // If this is an array, then traverse it:
02414       if (is_array($types_fieldConfig))   {
02415          foreach($types_fieldConfig as $vconf)  {
02416                // If the input field name matches one found in the 'types' list, then return the 'special' configuration.
02417             if ($vconf['field']==$field)  return $vconf['spec'];
02418          }
02419       }
02420    }
02421 
02430    function getSpecConfFromString($extraString, $defaultExtras)    {
02431       return t3lib_BEfunc::getSpecConfParts($extraString, $defaultExtras);
02432    }
02433 
02434 
02435 
02436 
02437 
02438 
02439 
02440 
02441 
02442 
02443    /************************************************************
02444     *
02445     * Display of localized content etc.
02446     *
02447     ************************************************************/
02448 
02458    function registerDefaultLanguageData($table,$rec)  {
02459       global $TCA;
02460 
02461          // Add default language:
02462       if ($TCA[$table]['ctrl']['languageField']
02463             && $rec[$TCA[$table]['ctrl']['languageField']] > 0
02464             && $TCA[$table]['ctrl']['transOrigPointerField']
02465             && intval($rec[$TCA[$table]['ctrl']['transOrigPointerField']]) > 0)  {
02466 
02467          $lookUpTable = $TCA[$table]['ctrl']['transOrigPointerTable'] ? $TCA[$table]['ctrl']['transOrigPointerTable'] : $table;
02468 
02469             // Get data formatted:
02470          $this->defaultLanguageData[$table.':'.$rec['uid']] = t3lib_BEfunc::getRecord($lookUpTable, intval($rec[$TCA[$table]['ctrl']['transOrigPointerField']]));
02471 
02472             // Get data for diff:
02473          if ($TCA[$table]['ctrl']['transOrigDiffSourceField']) {
02474             $this->defaultLanguageData_diff[$table.':'.$rec['uid']] = unserialize($rec[$TCA[$table]['ctrl']['transOrigDiffSourceField']]);
02475          }
02476       }
02477    }
02478 
02490    function renderDefaultLanguageContent($table,$field,$row,$item)   {
02491       if (is_array($this->defaultLanguageData[$table.':'.$row['uid']])) {
02492          $dLVal = t3lib_BEfunc::getProcessedValue($table,$field,$this->defaultLanguageData[$table.':'.$row['uid']][$field],0,1);
02493 
02494          if (strcmp($dLVal,''))  {
02495             $item.='<div class="typo3-TCEforms-originalLanguageValue">'.nl2br(htmlspecialchars($dLVal)).'&nbsp;</div>';
02496          }
02497       }
02498 
02499       return $item;
02500    }
02501 
02513    function renderDefaultLanguageDiff($table,$field,$row,$item)   {
02514       if (is_array($this->defaultLanguageData_diff[$table.':'.$row['uid']]))  {
02515 
02516             // Initialize:
02517          $dLVal = array(
02518             'old' => $this->defaultLanguageData_diff[$table.':'.$row['uid']],
02519             'new' => $this->defaultLanguageData[$table.':'.$row['uid']],
02520          );
02521 
02522          if (isset($dLVal['old'][$field]))   {  // There must be diff-data:
02523             if (strcmp($dLVal['old'][$field],$dLVal['new'][$field])) {
02524 
02525                   // Create diff-result:
02526                $t3lib_diff_Obj = t3lib_div::makeInstance('t3lib_diff');
02527                $diffres = $t3lib_diff_Obj->makeDiffDisplay(
02528                   t3lib_BEfunc::getProcessedValue($table,$field,$dLVal['old'][$field],0,1),
02529                   t3lib_BEfunc::getProcessedValue($table,$field,$dLVal['new'][$field],0,1)
02530                );
02531 
02532                $item.='<div class="typo3-TCEforms-diffBox">'.
02533                   '<div class="typo3-TCEforms-diffBox-header">'.htmlspecialchars($this->getLL('l_changeInOrig')).':</div>'.
02534                   $diffres.
02535                '</div>';
02536             }
02537          }
02538       }
02539 
02540       return $item;
02541    }
02542 
02543 
02544 
02545 
02546 
02547 
02548 
02549 
02550 
02551    /************************************************************
02552     *
02553     * Form element helper functions
02554     *
02555     ************************************************************/
02556 
02569    function dbFileIcons($fName,$mode,$allowed,$itemArray,$selector='',$params=array(),$onFocus='') {
02570 
02571          // Sets a flag which means some JavaScript is included on the page to support this element.
02572       $this->printNeededJS['dbFileIcons']=1;
02573 
02574          // INIT
02575       $uidList=array();
02576       $opt=array();
02577       $itemArrayC=0;
02578 
02579          // Creating <option> elements:
02580       if (is_array($itemArray))  {
02581          $itemArrayC=count($itemArray);
02582          reset($itemArray);
02583          switch($mode)  {
02584             case 'db':
02585                while(list(,$pp)=each($itemArray))  {
02586                   $pRec = t3lib_BEfunc::getRecord($pp['table'],$pp['id']);
02587                   if (is_array($pRec)) {
02588                      $pTitle = t3lib_div::fixed_lgd_cs($this->noTitle($pRec[$GLOBALS['TCA'][$pp['table']]['ctrl']['label']]),$this->titleLen);
02589                      $pUid = $pp['table'].'_'.$pp['id'];
02590                      $uidList[]=$pUid;
02591                      $opt[]='<option value="'.htmlspecialchars($pUid).'">'.htmlspecialchars($pTitle).'</option>';
02592                   }
02593                }
02594             break;
02595             case 'file':
02596                while(list(,$pp)=each($itemArray))  {
02597                   $pParts = explode('|',$pp);
02598                   $uidList[]=$pUid=$pTitle = $pParts[0];
02599                   $opt[]='<option value="'.htmlspecialchars(rawurldecode($pParts[0])).'">'.htmlspecialchars(rawurldecode($pParts[0])).'</option>';
02600                }
02601             break;
02602             default:
02603                while(list(,$pp)=each($itemArray))  {
02604                   $pParts = explode('|',$pp);
02605                   $uidList[]=$pUid=$pParts[0];
02606                   $pTitle = $pParts[1];
02607                   $opt[]='<option value="'.htmlspecialchars(rawurldecode($pUid)).'">'.htmlspecialchars(rawurldecode($pTitle)).'</option>';
02608                }
02609             break;
02610          }
02611       }
02612 
02613          // Create selector box of the options
02614       if (!$selector)   {
02615          $sSize = $params['autoSizeMax'] ? t3lib_div::intInRange($itemArrayC+1,t3lib_div::intInRange($params['size'],1),$params['autoSizeMax']) : $params['size'];
02616          $selector = '<select size="'.$sSize.'"'.$this->insertDefStyle('group').' multiple="multiple" name="'.$fName.'_list" '.$onFocus.$params['style'].'>'.implode('',$opt).'</select>';
02617       }
02618 
02619 
02620       $icons = array(
02621          'L' => array(),
02622          'R' => array(),
02623       );
02624       if (!$params['noBrowser']) {
02625          $aOnClick='setFormValueOpenBrowser(\''.$mode.'\',\''.($fName.'|||'.$allowed.'|').'\'); return false;';
02626          $icons['R'][]='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
02627                '<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'))).' />'.
02628                '</a>';
02629       }
02630       if (!$params['dontShowMoveIcons'])  {
02631          $icons['L'][]='<a href="#" onclick="setFormValueManipulate(\''.$fName.'\',\'Up\'); return false;">'.
02632                '<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')).' />'.
02633                '</a>';
02634       }
02635 
02636       $clipElements = $this->getClipboardElements($allowed,$mode);
02637       if (count($clipElements))  {
02638          $aOnClick = '';
02639 #        $counter = 0;
02640          foreach($clipElements as $elValue)  {
02641             if ($mode=='file')   {
02642                $itemTitle = 'unescape(\''.rawurlencode(basename($elValue)).'\')';
02643             } else { // 'db' mode assumed
02644                list($itemTable,$itemUid) = explode('|', $elValue);
02645                $itemTitle = $GLOBALS['LANG']->JScharCode(t3lib_BEfunc::getRecordTitle($itemTable, t3lib_BEfunc::getRecord($itemTable,$itemUid)));
02646                $elValue = $itemTable.'_'.$itemUid;
02647             }
02648             $aOnClick.= 'setFormValueFromBrowseWin(\''.$fName.'\',unescape(\''.rawurlencode(str_replace('%20',' ',$elValue)).'\'),'.$itemTitle.');';
02649 
02650 #           $counter++;
02651 #           if ($params['maxitems'] && $counter >= $params['maxitems']) {  break;   }  // Makes sure that no more than the max items are inserted... for convenience.
02652          }
02653          $aOnClick.= 'return false;';
02654          $icons['R'][]='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
02655                '<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))).' />'.
02656                '</a>';
02657       }
02658 
02659       $icons['L'][]='<a href="#" onclick="setFormValueManipulate(\''.$fName.'\',\'Remove\'); return false;">'.
02660             '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/group_clear.gif','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib($this->getLL('l_remove_selected')).' />'.
02661             '</a>';
02662 
02663       $str='<table border="0" cellpadding="0" cellspacing="0" width="1">
02664          '.($params['headers']?'
02665             <tr>
02666                <td>'.$this->wrapLabels($params['headers']['selector']).'</td>
02667                <td></td>
02668                <td></td>
02669                <td></td>
02670                <td>'.$this->wrapLabels($params['headers']['items']).'</td>
02671             </tr>':'').
02672          '
02673          <tr>
02674             <td valign="top">'.
02675                $selector.'<br />'.
02676                $this->wrapLabels($params['info']).
02677             '</td>
02678             <td valign="top">'.
02679                implode('<br />',$icons['L']).'</td>
02680             <td valign="top">'.
02681                implode('<br />',$icons['R']).'</td>
02682             <td><img src="clear.gif" width="5" height="1" alt="" /></td>
02683             <td valign="top">'.
02684                $this->wrapLabels($params['thumbnails']).
02685             '</td>
02686          </tr>
02687       </table>';
02688 
02689          // Creating the hidden field which contains the actual value as a comma list.
02690       $str.='<input type="hidden" name="'.$fName.'" value="'.htmlspecialchars(implode(',',$uidList)).'" />';
02691 
02692       return $str;
02693    }
02694 
02702    function getClipboardElements($allowed,$mode)   {
02703 
02704       $output = array();
02705 
02706       if (is_object($this->clipObj))   {
02707          switch($mode)  {
02708             case 'file':
02709                $elFromTable = $this->clipObj->elFromTable('_FILE');
02710                $allowedExts = t3lib_div::trimExplode(',', $allowed, 1);
02711 
02712                if ($allowedExts) {  // If there are a set of allowed extensions, filter the content:
02713                   foreach($elFromTable as $elValue)   {
02714                      $pI = pathinfo($elValue);
02715                      $ext = strtolower($pI['extension']);
02716                      if (in_array($ext, $allowedExts))   {
02717                         $output[] = $elValue;
02718                      }
02719                   }
02720                } else { // If all is allowed, insert all: (This does NOT respect any disallowed extensions, but those will be filtered away by the backend TCEmain)
02721                   $output = $elFromTable;
02722                }
02723             break;
02724             case 'db':
02725                $allowedTables = t3lib_div::trimExplode(',', $allowed, 1);
02726                if (!strcmp(trim($allowedTables[0]),'*')) {  // All tables allowed for relation:
02727                   $output = $this->clipObj->elFromTable('');
02728                } else { // Only some tables, filter them:
02729                   foreach($allowedTables as $tablename)  {
02730                      $elFromTable = $this->clipObj->elFromTable($tablename);
02731                      $output = array_merge($output,$elFromTable);
02732                   }
02733                }
02734                $output = array_keys($output);
02735             break;
02736          }
02737       }
02738 
02739       return $output;
02740    }
02741 
02751    function getClickMenu($str,$table,$uid='')   {
02752       if ($this->enableClickMenu)   {
02753          $onClick = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($str,$table,$uid,1,'','+copy,info,edit,view', TRUE);
02754          return '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.$str.'</a>';
02755       }
02756    }
02757 
02772    function renderWizards($itemKinds,$wizConf,$table,$row,$field,&$PA,$itemName,$specConf,$RTE=0)  {
02773 
02774          // Init:
02775       $fieldChangeFunc = $PA['fieldChangeFunc'];
02776       $item = $itemKinds[0];
02777       $outArr = array();
02778       $colorBoxLinks = array();
02779       $fName = '['.$table.']['.$row['uid'].']['.$field.']';
02780       $md5ID = 'ID'.t3lib_div::shortmd5($itemName);
02781       $listFlag = '_list';
02782 
02783          // 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":
02784       if ($PA['fieldConf']['config']['type']=='select')  {
02785          if ($PA['fieldConf']['config']['maxitems']<=1)  {  // Single select situation:
02786             $listFlag = '';
02787          } elseif ($PA['fieldConf']['config']['renderMode']=='singlebox')  {
02788             $itemName.='[]';
02789             $listFlag = '';
02790          }
02791       }
02792 
02793          // traverse wizards:
02794       if (is_array($wizConf) && !$this->disableWizards)  {
02795          foreach($wizConf as $wid => $wConf) {
02796             if (substr($wid,0,1)!='_'
02797                   && (!$wConf['enableByTypeConfig'] || @in_array($wid,$specConf['wizards']['parameters']))
02798                   && ($RTE || !$wConf['RTEonly'])
02799                )  {
02800 
02801                   // Title / icon:
02802                $iTitle = htmlspecialchars($this->sL($wConf['title']));
02803                if ($wConf['icon'])  {
02804                   $iDat = $this->getIcon($wConf['icon']);
02805                   $icon = '<img src="'.$iDat[0].'" '.$iDat[1][3].' border="0"'.t3lib_BEfunc::titleAltAttrib($iTitle).' />';
02806                } else {
02807                   $icon = $iTitle;
02808                }
02809 
02810                   //
02811                switch((string)$wConf['type'])   {
02812                   case 'userFunc':
02813                   case 'script':
02814                   case 'popup':
02815                   case 'colorbox':
02816                      if (!$wConf['notNewRecords'] || t3lib_div::testInt($row['uid']))  {
02817 
02818                            // Setting &P array contents:
02819                         $params = array();
02820                         $params['params'] = $wConf['params'];
02821                         $params['exampleImg'] = $wConf['exampleImg'];
02822                         $params['table'] = $table;
02823                         $params['uid'] = $row['uid'];
02824                         $params['pid'] = $row['pid'];
02825                         $params['field'] = $field;
02826                         $params['md5ID'] = $md5ID;
02827                         $params['returnUrl'] = $this->thisReturnUrl();
02828 
02829                            // Resolving script filename and setting URL.
02830                         if (!strcmp(substr($wConf['script'],0,4), 'EXT:')) {
02831                            $wScript = t3lib_div::getFileAbsFileName($wConf['script']);
02832                            if ($wScript)  {
02833                               $wScript = '../'.substr($wScript,strlen(PATH_site));
02834                            } else break;
02835                         } else {
02836                            $wScript = $wConf['script'];
02837                         }
02838                         $url = $this->backPath.$wScript.(strstr($wScript,'?') ? '' : '?');
02839 
02840                            // If there is no script and the type is "colorbox", break right away:
02841                         if ((string)$wConf['type']=='colorbox' && !$wConf['script'])   { break; }
02842 
02843                            // If "script" type, create the links around the icon:
02844                         if ((string)$wConf['type']=='script')  {
02845                            $aUrl = $url.t3lib_div::implodeArrayForUrl('',array('P'=>$params));
02846                            $outArr[]='<a href="'.htmlspecialchars($aUrl).'" onclick="'.$this->blur().'return !TBE_EDITOR_isFormChanged();">'.
02847                               $icon.
02848                               '</a>';
02849                         } else {
02850 
02851                               // ... else types "popup", "colorbox" and "userFunc" will need additional parameters:
02852                            $params['formName'] = $this->formName;
02853                            $params['itemName'] = $itemName;
02854                            $params['fieldChangeFunc'] = $fieldChangeFunc;
02855 
02856                            switch((string)$wConf['type'])   {
02857                               case 'popup':
02858                               case 'colorbox':
02859                                     // Current form value is passed as P[currentValue]!
02860                                  $addJS = $wConf['popup_onlyOpenIfSelected']?'if (!TBE_EDITOR_curSelected(\''.$itemName.$listFlag.'\')){alert('.$GLOBALS['LANG']->JScharCode($this->getLL('m_noSelItemForEdit')).'); return false;}':'';
02861                                  $curSelectedValues='+\'&P[currentSelectedValues]=\'+TBE_EDITOR_curSelected(\''.$itemName.$listFlag.'\')';
02862                                  $aOnClick=  $this->blur().
02863                                           $addJS.
02864                                           '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'].'\');'.
02865                                           'vHWin.focus();return false;';
02866                                     // Setting "colorBoxLinks" - user LATER to wrap around the color box as well:
02867                                  $colorBoxLinks = Array('<a href="#" onclick="'.htmlspecialchars($aOnClick).'">','</a>');
02868                                  if ((string)$wConf['type']=='popup')   {
02869                                     $outArr[] = $colorBoxLinks[0].$icon.$colorBoxLinks[1];
02870                                  }
02871                               break;
02872                               case 'userFunc':
02873                                  $params['item'] = &$item;  // Reference set!
02874                                  $params['icon'] = $icon;
02875                                  $params['iTitle'] = $iTitle;
02876                                  $params['wConf'] = $wConf;
02877                                  $params['row'] = $row;
02878                                  $outArr[] = t3lib_div::callUserFunction($wConf['userFunc'],$params,$this);
02879                               break;
02880                            }
02881                         }
02882 
02883                            // Hide the real form element?
02884                         if (is_array($wConf['hideParent']) || $wConf['hideParent']) {
02885                            $item = $itemKinds[1];  // Setting the item to a hidden-field.
02886                            if (is_array($wConf['hideParent'])) {
02887                               $item.= $this->getSingleField_typeNone_render($wConf['hideParent'], $PA['itemFormElValue']);
02888                            }
02889                         }
02890                      }
02891                   break;
02892                   case 'select':
02893                      $fieldValue = array('config' => $wConf);
02894                      $TSconfig = $this->setTSconfig($table, $row);
02895                      $TSconfig[$field] = $TSconfig[$field]['wizards.'][$wid.'.'];
02896                      $selItems = $this->addSelectOptionsToItemArray($this->initItemArray($fieldValue), $fieldValue, $TSconfig, $field);
02897 
02898                      $opt = array();
02899                      $opt[] = '<option>'.$iTitle.'</option>';
02900                      foreach($selItems as $p)   {
02901                         $opt[] = '<option value="'.htmlspecialchars($p[1]).'">'.htmlspecialchars($p[0]).'</option>';
02902                      }
02903                      if ($wConf['mode']=='append') {
02904                         $assignValue = $this->elName($itemName).'.value=\'\'+this.options[this.selectedIndex].value+'.$this->elName($itemName).'.value';
02905                      } elseif ($wConf['mode']=='prepend')   {
02906                         $assignValue = $this->elName($itemName).'.value+=\'\'+this.options[this.selectedIndex].value';
02907                      } else {
02908                         $assignValue = $this->elName($itemName).'.value=this.options[this.selectedIndex].value';
02909                      }
02910                      $sOnChange = $assignValue.';this.selectedIndex=0;'.implode('',$fieldChangeFunc);
02911                      $outArr[] = '<select name="_WIZARD'.$fName.'" onchange="'.htmlspecialchars($sOnChange).'">'.implode('',$opt).'</select>';
02912                   break;
02913                }
02914 
02915                   // Color wizard colorbox:
02916                if ((string)$wConf['type']=='colorbox')   {
02917                   $dim = t3lib_div::intExplode('x',$wConf['dim']);
02918                   $dX = t3lib_div::intInRange($dim[0],1,200,20);
02919                   $dY = t3lib_div::intInRange($dim[1],1,200,20);
02920                   $color = $row[$field] ? ' bgcolor="'.htmlspecialchars($row[$field]).'"' : '';
02921                   $outArr[] = '<table border="0" cellpadding="0" cellspacing="0" id="'.$md5ID.'"'.$color.' style="'.htmlspecialchars($wConf['tableStyle']).'">
02922                            <tr>
02923                               <td>'.
02924                                  $colorBoxLinks[0].
02925                                  '<img src="clear.gif" width="'.$dX.'" height="'.$dY.'"'.t3lib_BEfunc::titleAltAttrib(trim($iTitle.' '.$row[$field])).' border="0" />'.
02926                                  $colorBoxLinks[1].
02927                                  '</td>
02928                            </tr>
02929                         </table>';
02930                }
02931             }
02932          }
02933 
02934             // For each rendered wizard, put them together around the item.
02935          if (count($outArr))  {
02936             if ($wizConf['_HIDDENFIELD']) $item = $itemKinds[1];
02937 
02938             $outStr = '';
02939             $vAlign = $wizConf['_VALIGN'] ? ' valign="'.$wizConf['_VALIGN'].'"' : '';
02940             if (count($outArr)>1 || $wizConf['_PADDING'])   {
02941                $dist = intval($wizConf['_DISTANCE']);
02942                if ($wizConf['_VERTICAL']) {
02943                   $dist = $dist ? '<tr><td><img src="clear.gif" width="1" height="'.$dist.'" alt="" /></td></tr>' : '';
02944                   $outStr = '<tr><td>'.implode('</td></tr>'.$dist.'<tr><td>',$outArr).'</td></tr>';
02945                } else {
02946                   $dist = $dist ? '<td><img src="clear.gif" height="1" width="'.$dist.'" alt="" /></td>' : '';
02947                   $outStr = '<tr><td'.$vAlign.'>'.implode('</td>'.$dist.'<td'.$vAlign.'>',$outArr).'</td></tr>';
02948                }
02949                $outStr = '<table border="0" cellpadding="'.intval($wizConf['_PADDING']).'" cellspacing="0">'.$outStr.'</table>';
02950             } else {
02951                $outStr = implode('',$outArr);
02952             }
02953 
02954             if (!strcmp($wizConf['_POSITION'],'left'))   {
02955                $outStr = '<tr><td'.$vAlign.'>'.$outStr.'</td><td'.$vAlign.'>'.$item.'</td></tr>';
02956             } elseif (!strcmp($wizConf['_POSITION'],'top')) {
02957                $outStr = '<tr><td>'.$outStr.'</td></tr><tr><td>'.$item.'</td></tr>';
02958             } elseif (!strcmp($wizConf['_POSITION'],'bottom')) {
02959                $outStr = '<tr><td>'.$item.'</td></tr><tr><td>'.$outStr.'</td></tr>';
02960             } else {
02961                $outStr = '<tr><td'.$vAlign.'>'.$item.'</td><td'.$vAlign.'>'.$outStr.'</td></tr>';
02962             }
02963 
02964             $item = '<table border="0" cellpadding="0" cellspacing="0">'.$outStr.'</table>';
02965          }
02966       }
02967       return $item;
02968    }
02969 
02976    function getIcon($icon) {
02977       if (substr($icon,0,4)=='EXT:')   {
02978          $file = t3lib_div::getFileAbsFileName($icon);
02979          if ($file)  {
02980             $file = substr($file,strlen(PATH_site));
02981             $selIconFile = $this->backPath.'../'.$file;
02982             $selIconInfo = @getimagesize(PATH_site.$file);
02983          }
02984       } elseif (substr($icon,0,3)=='../') {
02985          $selIconFile = $this->backPath.t3lib_div::resolveBackPath($icon);
02986          $selIconInfo = @getimagesize(PATH_site.t3lib_div::resolveBackPath(substr($icon,3)));
02987       } elseif (substr($icon,0,4)=='ext/' || substr($icon,0,7)=='sysext/') {
02988          $selIconFile = $this->backPath.$icon;
02989          $selIconInfo = @getimagesize(PATH_typo3.$icon);
02990       } else {
02991          $selIconFile = $this->backPath.'t3lib/gfx/'.$icon;
02992          $selIconInfo = @getimagesize(PATH_t3lib.'gfx/'.$icon);
02993       }
02994       return array($selIconFile,$selIconInfo);
02995    }
02996 
03003    function optionTagStyle($iconString)   {
03004       if ($iconString)  {
03005          list($selIconFile,$selIconInfo) = $this->getIcon($iconString);
03006          $padTop = t3lib_div::intInRange(($selIconInfo[1]-12)/2,0);
03007          $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;';
03008          return $styleAttr;
03009       }
03010    }
03011 
03019    function extractValuesOnlyFromValueLabelList($itemFormElValue) {
03020          // Get values of selected items:
03021       $itemArray = t3lib_div::trimExplode(',',$itemFormElValue,1);
03022       foreach($itemArray as $tk => $tv) {
03023          $tvP = explode('|',$tv,2);
03024          $tvP[0] = rawurldecode($tvP[0]);
03025 
03026          $itemArray[$tk] = $tvP[0];
03027       }
03028       return $itemArray;
03029    }
03030 
03041    function wrapOpenPalette($header,$table,$row,$palette,$retFunc=0) {
03042       $fieldL=array();
03043       if (!is_array($this->palFieldArr[$palette])) {$this->palFieldArr[$palette]=array();}
03044       $palFieldN = is_array($this->palFieldArr[$palette]) ? count($this->palFieldArr[$palette]) : 0;
03045       $palJSFunc = 'TBE_EDITOR_palUrl(\''.($table.':'.$row['uid'].':'.$palette).'\',\''.implode(',',$this->palFieldArr[$palette]).'\','.$palFieldN.',\''.$table.'\',\''.$row['uid'].'\',1);';
03046 
03047       $aOnClick = $this->blur().substr($palJSFunc,0,-3).'0);return false;';
03048 
03049       $iconCode = '<a href="#" onclick="'.htmlspecialchars($aOnClick).'" title="'.htmlspecialchars($table).'">'.
03050                $header.
03051                '</a>';
03052       return $retFunc ? array($iconCode,$palJSFunc) : $iconCode;
03053    }
03054 
03065    function checkBoxParams($itemName,$thisValue,$c,$iCount,$addFunc='') {
03066       $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)).');'.
03067                $addFunc;
03068       $str = ' onclick="'.htmlspecialchars($onClick).'"'.
03069             (($thisValue&pow(2,$c))?' checked="checked"':'');
03070       return $str;
03071    }
03072 
03079    function elName($itemName) {
03080       return 'document.'.$this->formName."['".$itemName."']";
03081    }
03082 
03090    function noTitle($str,$wrapParts=array()) {
03091       return strcmp($str,'') ? $str : $wrapParts[0].'['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title').']'.$wrapParts[1];
03092    }
03093 
03099    function blur()   {
03100       return $GLOBALS['CLIENT']['FORMSTYLE'] ? 'this.blur();':'';
03101    }
03102 
03108    function thisReturnUrl()   {
03109       return $this->returnUrl ? $this->returnUrl : t3lib_div::linkThisScript();
03110    }
03111 
03121    function getSingleHiddenField($table,$field,$row)  {
03122       global $TCA;
03123       $out='';
03124       t3lib_div::loadTCA($table);
03125       if ($TCA[$table]['columns'][$field])   {
03126 
03127          $uid=$row['uid'];
03128          $itemName=$this->prependFormFieldNames.'['.$table.']['.$uid.']['.$field.']';
03129          $itemValue=$row[$field];
03130          $item.='<input type="hidden" name="'.$itemName.'" value="'.htmlspecialchars($itemValue).'" />';
03131          $out = $item;
03132       }
03133       return $out;
03134    }
03135 
03143    function formWidth($size=48,$textarea=0) {
03144          // Input or text-field attribute (size or cols)
03145       if ($this->docLarge) $size = round($size*$this->form_largeComp);
03146       $wAttrib = $textarea?'cols':'size';
03147       if (!$GLOBALS['CLIENT']['FORMSTYLE'])  {  // If not setting the width by style-attribute
03148          $retVal = ' '.$wAttrib.'="'.$size.'"';
03149       } else { // Setting width by style-attribute. 'cols' MUST be avoided with NN6+
03150          $pixels = ceil($size*$this->form_rowsToStylewidth);
03151          $theStyle = 'width:'.$pixels.'px;'.$this->defStyle.$this->formElStyle($textarea?'text':'input');
03152          $retVal = ' style="'.htmlspecialchars($theStyle).'"';
03153 
03154          $class = $this->formElClass($textarea?'text':'input');
03155          if ($class) {
03156             $retVal.= ' class="'.htmlspecialchars($class).'"';
03157          }
03158       }
03159       return $retVal;
03160    }
03161 
03170    function formWidthText($size=48,$wrap='') {
03171       $wTags = $this->formWidth($size,1);
03172          // 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...
03173       if (strtolower(trim($wrap))!='off' && $GLOBALS['CLIENT']['BROWSER']=='net' && $GLOBALS['CLIENT']['VERSION']>=5)   {
03174          $wTags.=' cols="'.$size.'"';
03175       }
03176       return $wTags;
03177    }
03178 
03186    function formElStyle($type)   {
03187       return $this->formElStyleClassValue($type);
03188    }
03189 
03197    function formElClass($type)   {
03198       return $this->formElStyleClassValue($type, TRUE);
03199    }
03200 
03208    function formElStyleClassValue($type, $class=FALSE)   {
03209          // Get value according to field:
03210       if (isset($this->fieldStyle[$type]))   {
03211          $style = trim($this->fieldStyle[$type]);
03212       } else {
03213          $style = trim($this->fieldStyle['all']);
03214       }
03215 
03216          // Check class prefixed:
03217       if (substr($style,0,6)=='CLASS:')   {
03218          return $class ? trim(substr($style,6)) : '';
03219       } else {
03220          return !$class ? $style : '';
03221       }
03222    }
03223 
03230    function insertDefStyle($type)   {
03231       $out = '';
03232 
03233       $style = trim($this->defStyle.$this->formElStyle($type));
03234       $out.= $style?' style="'.htmlspecialchars($style).'"':'';
03235 
03236       $class = $this->formElClass($type);
03237       $out.= $class?' class="'.htmlspecialchars($class).'"':'';
03238 
03239       return $out;
03240    }
03241 
03249    function getDynTabMenu($parts, $idString) {
03250       if (is_object($GLOBALS['TBE_TEMPLATE']))  {
03251          return $GLOBALS['TBE_TEMPLATE']->getDynTabMenu($parts, $idString);
03252       } else {
03253          $output = '';
03254          foreach($parts as $singlePad) {
03255             $output.='
03256             <h3>'.htmlspecialchars($singlePad['label']).'</h3>
03257             '.($singlePad['description'] ? '<p class="c-descr">'.nl2br(htmlspecialchars($singlePad['description'])).'</p>' : '').'
03258             '.$singlePad['content'];
03259          }
03260 
03261          return '<div class="typo3-dyntabmenu-divs">'.$output.'</div>';
03262       }
03263    }
03264 
03265 
03266 
03267 
03268 
03269 
03270 
03271 
03272 
03273 
03274 
03275    /************************************************************
03276     *
03277     * Item-array manipulation functions (check/select/radio)
03278     *
03279     ************************************************************/
03280 
03288    function initItemArray($fieldValue) {
03289       $items = array();
03290       if (is_array($fieldValue['config']['items']))   {
03291          reset ($fieldValue['config']['items']);
03292          while (list($itemName,$itemValue) = each($fieldValue['config']['items']))  {
03293             $items[] = array($this->sL($itemValue[0]), $itemValue[1], $itemValue[2]);
03294          }
03295       }
03296       return $items;
03297    }
03298 
03306    function addItems($items,$iArray)   {
03307       global $TCA;
03308       if (is_array($iArray))  {
03309          reset($iArray);
03310          while(list($value,$label)=each($iArray))  {
03311             $items[]=array($this->sl($label),$value);
03312          }
03313       }
03314       return $items;
03315    }
03316 
03328    function procItems($items,$iArray,$config,$table,$row,$field)  {
03329       global $TCA;
03330 
03331       $params=array();
03332       $params['items'] = &$items;
03333       $params['config'] = $config;
03334       $params['TSconfig'] = $iArray;
03335       $params['table'] = $table;
03336       $params['row'] = $row;
03337       $params['field'] = $field;
03338 
03339       t3lib_div::callUserFunction($config['itemsProcFunc'],$params,$this);
03340       return $items;
03341    }
03342 
03352    function addSelectOptionsToItemArray($items,$fieldValue,$TSconfig,$field)  {
03353       global $TCA;
03354 
03355          // Values from foreign tables:
03356       if ($fieldValue['config']['foreign_table'])  {
03357          $items = $this->foreignTable($items,$fieldValue,$TSconfig,$field);
03358          if ($fieldValue['config']['neg_foreign_table']) {
03359             $items = $this->foreignTable($items,$fieldValue,$TSconfig,$field,1);
03360          }
03361       }
03362 
03363          // Values from a file folder:
03364       if ($fieldValue['config']['fileFolder'])  {
03365          $fileFolder = t3lib_div::getFileAbsFileName($fieldValue['config']['fileFolder']);
03366          if (@is_dir($fileFolder))  {
03367 
03368                // Configurations:
03369             $extList = $fieldValue['config']['fileFolder_extList'];
03370             $recursivityLevels = isset($fieldValue['config']['fileFolder_recursions']) ? t3lib_div::intInRange($fieldValue['config']['fileFolder_recursions'],0,99) : 99;
03371 
03372                // Get files:
03373             $fileFolder = ereg_replace('\/$','',$fileFolder).'/';
03374             $fileArr = t3lib_div::getAllFilesAndFoldersInPath(array(),$fileFolder,$extList,0,$recursivityLevels);
03375             $fileArr = t3lib_div::removePrefixPathFromList($fileArr, $fileFolder);
03376 
03377             foreach($fileArr as $fileRef) {
03378                $fI = pathinfo($fileRef);
03379                $icon = t3lib_div::inList('gif,png,jpeg,jpg', strtolower($fI['extension'])) ? '../'.substr($fileFolder,strlen(PATH_site)).$fileRef : '';
03380                $items[] = array(
03381                   $fileRef,
03382                   $fileRef,
03383                   $icon
03384                );
03385             }
03386          }
03387       }
03388 
03389          // If 'special' is configured:
03390       if ($fieldValue['config']['special'])  {
03391          switch ($fieldValue['config']['special']) {
03392             case 'tables':
03393                $temp_tc = array_keys($TCA);
03394                $descr = '';
03395 
03396                foreach($temp_tc as $theTableNames) {
03397                   if (!$TCA[$theTableNames]['ctrl']['adminOnly']) {
03398 
03399                         // Icon:
03400                      $icon = '../typo3/'.t3lib_iconWorks::skinImg($this->backPath,t3lib_iconWorks::getIcon($theTableNames, array()),'',1);
03401 
03402                         // Add description texts:
03403                      if ($this->edit_showFieldHelp)   {
03404                         $GLOBALS['LANG']->loadSingleTableDescription($theTableNames);
03405                         $fDat = $GLOBALS['TCA_DESCR'][$theTableNames]['columns'][''];
03406                         $descr = $fDat['description'];
03407                      }
03408 
03409                         // Item configuration:
03410                      $items[] = array(
03411                         $this->sL($TCA[$theTableNames]['ctrl']['title']),
03412                         $theTableNames,
03413                         $icon,
03414                         $descr
03415                      );
03416                   }
03417                }
03418             break;
03419             case 'pagetypes':
03420                $theTypes = $TCA['pages']['columns']['doktype']['config']['items'];
03421 
03422                foreach($theTypes as $theTypeArrays)   {
03423                      // Icon:
03424                   $icon = $theTypeArrays[1]!='--div--' ? '../typo3/'.t3lib_iconWorks::skinImg($this->backPath,t3lib_iconWorks::getIcon('pages', array('doktype' => $theTypeArrays[1])),'',1) : '';
03425 
03426                      // Item configuration:
03427                   $items[] = array(
03428                      $this->sL($theTypeArrays[0]),
03429                      $theTypeArrays[1],
03430                      $icon
03431                   );
03432                }
03433             break;
03434             case 'exclude':
03435                $theTypes = t3lib_BEfunc::getExcludeFields();
03436                $descr = '';
03437 
03438                foreach($theTypes as $theTypeArrays)   {
03439                   list($theTable, $theField) = explode(':', $theTypeArrays[1]);
03440 
03441                      // Add description texts:
03442                   if ($this->edit_showFieldHelp)   {
03443                      $GLOBALS['LANG']->loadSingleTableDescription($theTable);
03444                      $fDat = $GLOBALS['TCA_DESCR'][$theTable]['columns'][$theField];
03445                      $descr = $fDat['description'];
03446                   }
03447 
03448                      // Item configuration:
03449                   $items[] = array(
03450                      ereg_replace(':$','',$theTypeArrays[0]),
03451                      $theTypeArrays[1],
03452                      '',
03453                      $descr
03454                   );
03455                }
03456             break;
03457             case 'explicitValues':
03458                $theTypes = t3lib_BEfunc::getExplicitAuthFieldValues();
03459 
03460                      // Icons:
03461                $icons = array(
03462                   'ALLOW' => '../typo3/'.t3lib_iconWorks::skinImg($this->backPath,'gfx/icon_ok2.gif','',1),
03463                   'DENY' => '../typo3/'.t3lib_iconWorks::skinImg($this->backPath,'gfx/icon_fatalerror.gif','',1),
03464                );
03465 
03466                   // Traverse types:
03467                foreach($theTypes as $tableFieldKey => $theTypeArrays)   {
03468 
03469                   if (is_array($theTypeArrays['items'])) {
03470                         // Add header:
03471                      $items[] = array(
03472                         $theTypeArrays['tableFieldLabel'],
03473                         '--div--',
03474                      );
03475 
03476                         // Traverse options for this field:
03477                      foreach($theTypeArrays['items'] as $itemValue => $itemContent) {
03478                            // Add item to be selected:
03479                         $items[] = array(
03480                            '['.$itemContent[2].'] '.$itemContent[1],
03481                            $tableFieldKey.':'.ereg_replace('[:|,]','',$itemValue).':'.$itemContent[0],
03482                            $icons[$itemContent[0]]
03483                         );
03484                      }
03485                   }
03486                }
03487             break;
03488             case 'languages':
03489                $items = array_merge($items,t3lib_BEfunc::getSystemLanguages());
03490             break;
03491             case 'custom':
03492                   // Initialize:
03493                $customOptions = $GLOBALS['TYPO3_CONF_VARS']['BE']['customPermOptions'];
03494                if (is_array($customOptions)) {
03495                   foreach($customOptions as $coKey => $coValue) {
03496                      if (is_array($coValue['items'])) {
03497                            // Add header:
03498                         $items[] = array(
03499                            $GLOBALS['LANG']->sl($coValue['header']),
03500                            '--div--',
03501                         );
03502 
03503                            // Traverse items:
03504                         foreach($coValue['items'] as $itemKey => $itemCfg) {
03505                               // Icon:
03506                            if ($itemCfg[1])  {
03507                               list($icon) = $this->getIcon($itemCfg[1]);
03508                               if ($icon)  $icon = '../typo3/'.$icon;
03509                            } else $icon = '';
03510 
03511                               // Add item to be selected:
03512                            $items[] = array(
03513                               $GLOBALS['LANG']->sl($itemCfg[0]),
03514                               $coKey.':'.ereg_replace('[:|,]','',$itemKey),
03515                               $icon,
03516                               $GLOBALS['LANG']->sl($itemCfg[2]),
03517                            );
03518                         }
03519                      }
03520                   }
03521                }
03522             break;
03523             case 'modListGroup':
03524             case 'modListUser':
03525                if (!is_object($loadModules)) {
03526                   $loadModules = t3lib_div::makeInstance('t3lib_loadModules');
03527                   $loadModules->load($GLOBALS['TBE_MODULES']);
03528                }
03529 
03530                $modList = $fieldValue['config']['special']=='modListUser' ? $loadModules->modListUser : $loadModules->modListGroup;
03531                if (is_array($modList)) {
03532                   $descr = '';
03533 
03534                   foreach($modList as $theMod)  {
03535 
03536                         // Icon:
03537                      $icon = $GLOBALS['LANG']->moduleLabels['tabs_images'][$theMod.'_tab'];
03538                      if ($icon)  {
03539                         $icon = '../'.substr($icon,strlen(PATH_site));
03540                      }
03541 
03542                         // Description texts:
03543                      if ($this->edit_showFieldHelp)   {
03544                         $descr = $GLOBALS['LANG']->moduleLabels['labels'][$theMod.'_tablabel'].
03545                                  chr(10).
03546                                  $GLOBALS['LANG']->moduleLabels['labels'][$theMod.'_tabdescr'];
03547                      }
03548 
03549                         // Item configuration:
03550                      $items[] = array(
03551                         $this->addSelectOptionsToItemArray_makeModuleData($theMod),
03552                         $theMod,
03553                         $icon,
03554                         $descr
03555                      );
03556                   }
03557                }
03558             break;
03559          }
03560       }
03561 
03562          // Return the items:
03563       return $items;
03564    }
03565 
03574    function addSelectOptionsToItemArray_makeModuleData($value) {
03575       $label = '';
03576          // Add label for main module:
03577       $pp = explode('_',$value);
03578       if (count($pp)>1) $label.=$GLOBALS['LANG']->moduleLabels['tabs'][$pp[0].'_tab'].'>';
03579          // Add modules own label now:
03580       $label.= $GLOBALS['LANG']->moduleLabels['tabs'][$value.'_tab'];
03581 
03582       return $label;
03583    }
03584 
03596    function foreignTable($items,$fieldValue,$TSconfig,$field,$pFFlag=0) {
03597       global $TCA;
03598 
03599          // Init:
03600       $pF=$pFFlag?'neg_':'';
03601       $f_table = $fieldValue['config'][$pF.'foreign_table'];
03602       $uidPre = $pFFlag?'-':'';
03603 
03604          // Get query:
03605       $res = t3lib_BEfunc::exec_foreign_table_where_query($fieldValue,$field,$TSconfig,$pF);
03606 
03607          // Perform lookup
03608       if ($GLOBALS['TYPO3_DB']->sql_error()) {
03609          echo($GLOBALS['TYPO3_DB']->sql_error()."\n\nThis may indicate a table defined in tables.php is not existing in the database!");
03610          return array();
03611       }
03612 
03613          // Get label prefix.
03614       $lPrefix = $this->sL($fieldValue['config'][$pF.'foreign_table_prefix']);
03615 
03616          // Get icon field + path if any:
03617       $iField = $TCA[$f_table]['ctrl']['selicon_field'];
03618       $iPath = trim($TCA[$f_table]['ctrl']['selicon_field_path']);
03619 
03620          // Traverse the selected rows to add them:
03621       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))  {
03622             // Prepare the icon if available:
03623          if ($iField && $iPath && $row[$iField])   {
03624             $iParts = t3lib_div::trimExplode(',',$row[$iField],1);
03625             $icon = '../'.$iPath.'/'.trim($iParts[0]);
03626          } elseif (t3lib_div::inList('singlebox,checkbox',$fieldValue['config']['renderMode'])) {
03627             $icon = '../typo3/'.t3lib_iconWorks::skinImg($this->backPath,t3lib_iconWorks::getIcon($f_table, $row),'',1);
03628          } else $icon = '';
03629 
03630             // Add the item:
03631          $items[] = array(
03632             t3lib_div::fixed_lgd_cs($lPrefix.strip_tags(t3lib_BEfunc::getRecordTitle($f_table,$row)),$this->titleLen),
03633             $uidPre.$row['uid'],
03634             $icon
03635          );
03636       }
03637       return $items;
03638    }
03639 
03640 
03641 
03642 
03643 
03644 
03645 
03646 
03647 
03648 
03649 
03650 
03651 
03652 
03653 
03654 
03655 
03656 
03657 
03658 
03659 
03660 
03661 
03662 
03663 
03664    /********************************************
03665     *
03666     * Template functions
03667     *
03668     ********************************************/
03669 
03676    function setNewBEDesign()  {
03677 
03678          // Wrapping all table rows for a particular record being edited:
03679       $this->totalWrap='
03680       <table border="0" cellspacing="0" cellpadding="0" width="'.($this->docLarge ? 440+150 : 440).'" class="typo3-TCEforms">'.
03681          '<tr class="bgColor2">
03682             <td>&nbsp;</td>
03683             <td>###RECORD_ICON### <span class="typo3-TCEforms-recHeader">###TABLE_TITLE###</span> ###ID_NEW_INDICATOR### - ###RECORD_LABEL###</td>
03684          </tr>'.
03685          '|'.
03686          '<tr>
03687             <td>&nbsp;</td>
03688             <td><img src="clear.gif" width="'.($this->docLarge ? 440+150 : 440).'" height="1" alt="" /></td>
03689          </tr>
03690       </table>';
03691 
03692          // Wrapping a single field:
03693       $this->fieldTemplate='
03694          <tr ###BGCOLOR_HEAD######CLASSATTR_2###>
03695             <td>###FIELD_HELP_ICON###</td>
03696             <td width="99%"><span style="color:###FONTCOLOR_HEAD###;"###CLASSATTR_4###><b>###FIELD_NAME###</b></span>###FIELD_HELP_TEXT###</td>
03697          </tr>
03698          <tr ###BGCOLOR######CLASSATTR_1###>
03699             <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>
03700             <td valign="top">###FIELD_ITEM######FIELD_PAL_LINK_ICON###</td>
03701          </tr>';
03702 
03703       $this->palFieldTemplate='
03704          <tr ###BGCOLOR######CLASSATTR_1###>
03705             <td>&nbsp;</td>
03706             <td nowrap="nowrap" valign="top">###FIELD_PALETTE###</td>
03707          </tr>';
03708       $this->palFieldTemplateHeader='
03709          <tr ###BGCOLOR_HEAD######CLASSATTR_2###>
03710             <td>&nbsp;</td>
03711             <td nowrap="nowrap" valign="top"><strong>###FIELD_HEADER###</strong></td>
03712          </tr>';
03713 
03714       $this->sectionWrap='
03715          <tr>
03716             <td colspan="2"><img src="clear.gif" width="1" height="###SPACE_BEFORE###" alt="" /></td>
03717          </tr>
03718          <tr>
03719             <td colspan="2"><table ###TABLE_ATTRIBS###>###CONTENT###</table></td>
03720          </tr>
03721          ';
03722    }
03723 
03731    function intoTemplate($inArr,$altTemplate='')   {
03732             // Put into template_
03733       $fieldTemplateParts = explode('###FIELD_',$this->rplColorScheme($altTemplate?$altTemplate:$this->fieldTemplate));
03734       reset($fieldTemplateParts);
03735       $out=current($fieldTemplateParts);
03736       while(list(,$part)=each($fieldTemplateParts))   {
03737          list($key,$val)=explode('###',$part,2);
03738          $out.=$inArr[$key];
03739          $out.=$val;
03740       }
03741       return $out;
03742    }
03743 
03755    function addUserTemplateMarkers($marker,$table,$field,$row,&$PA)  {
03756       return $marker;
03757    }
03758 
03766    function wrapLabels($str)  {
03767       return $str;
03768    }
03769 
03779    function wrapTotal($c,$rec,$table)  {
03780       $parts = $this->replaceTableWrap(explode('|',$this->totalWrap,2),$rec,$table);
03781       return $parts[0].$c.$parts[1].implode('',$this->hiddenFieldAccum);
03782    }
03783 
03792    function replaceTableWrap($arr,$rec,$table)  {
03793       global $TCA;
03794       reset($arr);
03795       while(list($k,$v)=each($arr)) {
03796 
03797             // Make "new"-label
03798          if (strstr($rec['uid'],'NEW'))   {
03799             $newLabel = ' <span class="typo3-TCEforms-newToken">'.
03800                      $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.new',1).
03801                      '</span>';
03802 
03803             $truePid = t3lib_BEfunc::getTSconfig_pidValue($table,$rec['uid'],$rec['pid']);
03804             $prec = t3lib_BEfunc::getRecord('pages',$truePid,'title');
03805             $rLabel = '<em>[PID: '.$truePid.'] '.htmlspecialchars(trim(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle('pages',$prec),40))).'</em>';
03806          } else {
03807             $newLabel = ' <span class="typo3-TCEforms-recUid">['.$rec['uid'].']</span>';
03808             $rLabel  = htmlspecialchars(trim(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table,$rec),40)));
03809          }
03810 
03811             // Make substitutions:
03812          $arr[$k] = str_replace('###ID_NEW_INDICATOR###', $newLabel, $arr[$k]);
03813          $arr[$k] = str_replace('###RECORD_LABEL###',$rLabel,$arr[$k]);
03814          $arr[$k] = str_replace('###TABLE_TITLE###',htmlspecialchars($this->sL($TCA[$table]['ctrl']['title'])),$arr[$k]);
03815 
03816          $titleA=t3lib_BEfunc::titleAltAttrib($this->getRecordPath($table,$rec));
03817          $arr[$k]=str_replace('###RECORD_ICON###',t3lib_iconWorks::getIconImage($table,$rec,$this->backPath,'class="absmiddle"'.$titleA),$arr[$k]);
03818       }
03819       return $arr;
03820    }
03821 
03829    function wrapBorder(&$out_array,&$out_pointer)  {
03830       if ($this->sectionWrap && $out_array[$out_pointer])   {
03831          $tableAttribs='';
03832          $tableAttribs.= $this->borderStyle[0] ? ' style="'.htmlspecialchars($this->borderStyle[0]).'"':'';
03833          $tableAttribs.= $this->borderStyle[2] ? ' background="'.htmlspecialchars($this->backPath.$this->borderStyle[2]).'"':'';
03834          $tableAttribs.= $this->borderStyle[3] ? ' class="'.htmlspecialchars($this->borderStyle[3]).'"':'';
03835          if ($tableAttribs)   {
03836             $tableAttribs='border="0" cellspacing="0" cellpadding="0" width="100%"'.$tableAttribs;
03837             $out_array[$out_pointer] = str_replace('###CONTENT###',$out_array[$out_pointer],
03838                str_replace('###TABLE_ATTRIBS###',$tableAttribs,
03839                   str_replace('###SPACE_BEFORE###',intval($this->borderStyle[1]),$this->sectionWrap)));
03840          }
03841          $out_pointer++;
03842       }
03843    }
03844 
03851    function rplColorScheme($inTemplate)   {
03852          // Colors:
03853       $inTemplate = str_replace('###BGCOLOR###',$this->colorScheme[0]?' bgcolor="'.$this->colorScheme[0].'"':'',$inTemplate);
03854       $inTemplate = str_replace('###BGCOLOR_HEAD###',$this->colorScheme[1]?' bgcolor="'.$this->colorScheme[1].'"':'',$inTemplate);
03855       $inTemplate = str_replace('###FONTCOLOR_HEAD###',$this->colorScheme[3],$inTemplate);
03856 
03857          // Classes:
03858       $inTemplate = str_replace('###CLASSATTR_1###',$this->classScheme[0]?' class="'.$this->classScheme[0].'"':'',$inTemplate);
03859       $inTemplate = str_replace('###CLASSATTR_2###',$this->classScheme[1]?' class="'.$this->classScheme[1].'"':'',$inTemplate);
03860       $inTemplate = str_replace('###CLASSATTR_4###',$this->classScheme[3]?' class="'.$this->classScheme[3].'"':'',$inTemplate);
03861 
03862       return $inTemplate;
03863    }
03864 
03871    function getDivider()   {
03872       //return "<hr />";
03873    }
03874 
03881    function printPalette($palArr)   {
03882 
03883          // Init color/class attributes:
03884       $ccAttr2 = $this->colorScheme[2] ? ' bgcolor="'.$this->colorScheme[2].'"' : '';
03885       $ccAttr2.= $this->classScheme[2] ? ' class="'.$this->classScheme[2].'"' : '';
03886       $ccAttr4 = $this->colorScheme[4] ? ' style="color:'.$this->colorScheme[4].'"' : '';
03887       $ccAttr4.= $this->classScheme[4] ? ' class="'.$this->classScheme[4].'"' : '';
03888 
03889          // Traverse palette fields and render them into table rows:
03890       foreach($palArr as $content)  {
03891          $hRow[]='<td'.$ccAttr2.'>&nbsp;</td>
03892                <td nowrap="nowrap"'.$ccAttr2.'>'.
03893                   '<span'.$ccAttr4.'>'.
03894                      $content['NAME'].
03895                   '</span>'.
03896                '</td>';
03897          $iRow[]='<td valign="top">'.
03898                   '<img name="req_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="10" height="10" vspace="4" alt="" />'.
03899                   '<img name="cm_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="7" height="10" vspace="4" alt="" />'.
03900                '</td>
03901                <td nowrap="nowrap" valign="top">'.
03902                   $content['ITEM'].
03903                   $content['HELP_ICON'].
03904                '</td>';
03905       }
03906 
03907          // Final wrapping into the table:
03908       $out='<table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-palette">
03909          <tr>
03910             <td><img src="clear.gif" width="'.intval($this->paletteMargin).'" height="1" alt="" /></td>'.
03911                implode('
03912             ',$hRow).'
03913          </tr>
03914          <tr>
03915             <td></td>'.
03916                implode('
03917             ',$iRow).'
03918          </tr>
03919       </table>';
03920 
03921       return $out;
03922    }
03923 
03932    function helpTextIcon($table,$field,$force=0)   {
03933       if ($this->globalShowHelp && $GLOBALS['TCA_DESCR'][$table]['columns'][$field] && (($this->edit_showFieldHelp=='icon'&&!$this->doLoadTableDescr($table)) || $force))  {
03934          $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;';
03935          return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
03936                '<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="" />'.
03937                '</a>';
03938       } else {
03939             // Detects fields with no CSH and outputs dummy line to insert into CSH locallang file:
03940          #debug(array("'".$field.".description' => '[FILL IN] ".$table."->".$field."',"),$table);
03941          return '&nbsp;';
03942       }
03943    }
03944 
03952    function helpText($table,$field) {
03953       if ($this->globalShowHelp && $GLOBALS['TCA_DESCR'][$table]['columns'][$field] && ($this->edit_showFieldHelp=='text' || $this->doLoadTableDescr($table))) {
03954          $fDat = $GLOBALS['TCA_DESCR'][$table]['columns'][$field];
03955          return '<table border="0" cellpadding="2" cellspacing="0" width="90%"><tr><td valign="top" width="14">'.
03956                $this->helpTextIcon(
03957                   $table,
03958                   $field,
03959                   $fDat['details']||$fDat['syntax']||$fDat['image_descr']||$fDat['image']||$fDat['seeAlso']
03960                ).
03961                '</td><td valign="top"><span class="typo3-TCEforms-helpText">'.
03962                $GLOBALS['LANG']->hscAndCharConv($fDat['description'],1).
03963                '</span></td></tr></table>';
03964       }
03965    }
03966 
03973    function setColorScheme($scheme) {
03974       $this->colorScheme = $this->defColorScheme;
03975       $this->classScheme = $this->defClassScheme;
03976 
03977       $parts = t3lib_div::trimExplode(',',$scheme);
03978       foreach($parts as $key => $col)  {
03979             // Split for color|class:
03980          list($color,$class) = t3lib_div::trimExplode('|',$col);
03981 
03982             // Handle color values:
03983          if ($color) $this->colorScheme[$key] = $color;
03984          if ($color=='-')  $this->colorScheme[$key] = '';
03985 
03986             // Handle class values:
03987          if ($class) $this->classScheme[$key] = $class;
03988          if ($class=='-')  $this->classScheme[$key] = '';
03989       }
03990    }
03991 
03997    function resetSchemes() {
03998       $this->setColorScheme($GLOBALS['TBE_STYLES']['colorschemes'][0]);
03999       $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][0];
04000       $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][0];
04001    }
04002 
04008    function storeSchemes() {
04009       $this->savedSchemes['classScheme'] = $this->classScheme;
04010       $this->savedSchemes['colorScheme'] = $this->colorScheme;
04011       $this->savedSchemes['fieldStyle'] = $this->fieldStyle;
04012       $this->savedSchemes['borderStyle'] = $this->borderStyle;
04013    }
04014 
04020    function restoreSchemes()  {
04021       $this->classScheme = $this->savedSchemes['classScheme'];
04022       $this->colorScheme = $this->savedSchemes['colorScheme'];
04023       $this->fieldStyle = $this->savedSchemes['fieldStyle'];
04024       $this->borderStyle = $this->savedSchemes['borderStyle'];
04025    }
04026 
04027 
04028 
04029 
04030 
04031 
04032 
04033 
04034 
04035 
04036 
04037 
04038 
04039    /********************************************
04040     *
04041     * JavaScript related functions
04042     *
04043     ********************************************/
04044 
04050    function JStop()  {
04051 
04052       $out = '';
04053 
04054          // Additional top HTML:
04055       if (count($this->additionalCode_pre))  {
04056          $out.= implode('
04057 
04058             <!-- NEXT: -->
04059          ',$this->additionalCode_pre);
04060       }
04061 
04062          // Additional top JavaScript
04063       if (count($this->additionalJS_pre)) {
04064          $out.='
04065 
04066 
04067       <!--
04068          JavaScript in top of page (before form):
04069       -->
04070 
04071       <script type="text/javascript">
04072          /*<![CDATA[*/
04073 
04074          '.implode('
04075 
04076             // NEXT:
04077          ',$this->additionalJS_pre).'
04078 
04079          /*]]>*/
04080       </script>
04081          ';
04082       }
04083 
04084          // Return result:
04085       return $out;
04086    }
04087 
04101    function JSbottom($formname='forms[0]')   {
04102 
04103             // required
04104          $reqLines=array();
04105          $reqLinesCheck=array();
04106          $reqLinesSet=array();
04107          reset($this->requiredFields);
04108          while(list($itemImgName,$itemName)=each($this->requiredFields))   {
04109             $reqLines[]="              TBE_REQUIRED['".$itemName."']=1;";
04110             $reqLinesCheck[]="               if (!document.".$formname."['".$itemName."'].value)   {OK=0;}";
04111             $reqLinesSet[]="              if (!document.".$formname."['".$itemName."'].value)   {TBE_EDITOR_setImage('req_".$itemImgName."','TBE_EDITOR_req');}";
04112          }
04113 
04114          $reqRange=array();
04115          $reqRangeCheck=array();
04116          $reqRangeSet=array();
04117          reset($this->requiredElements);
04118          while(list($itemName,$range)=each($this->requiredElements)) {
04119             $reqRange[]="              TBE_RANGE['".$itemName."']=1;";
04120             $reqRange[]="              TBE_RANGE_lower['".$itemName."']=".$range[0].";";
04121             $reqRange[]="              TBE_RANGE_upper['".$itemName."']=".$range[1].";";
04122             $reqRangeCheck[]="               if (!TBE_EDITOR_checkRange(document.".$formname."['".$itemName."_list'],".$range[0].",".$range[1].")) {OK=0;}";
04123             $reqRangeSet[]="              if (!TBE_EDITOR_checkRange(document.".$formname."['".$itemName."_list'],".$range[0].",".$range[1].")) {TBE_EDITOR_setImage('req_".$range['imgName']."','TBE_EDITOR_req');}";
04124          }
04125 
04126          $this->TBE_EDITOR_fieldChanged_func='TBE_EDITOR_fieldChanged_fName(fName,formObj[fName+"_list"]);';
04127 
04128          if ($this->loadMD5_JS)  {
04129          $out.='
04130          <script type="text/javascript" src="'.$this->backPath.'md5.js"></script>';
04131          }
04132          $out.='
04133          <script type="text/javascript" src="'.$this->backPath.'t3lib/jsfunc.evalfield.js"></script>
04134          <script type="text/javascript">
04135             /*<![CDATA[*/
04136 
04137             var TBE_EDITOR_req=new Image();  TBE_EDITOR_req.src = "'.t3lib_iconWorks::skinImg($this->backPath,'gfx/required_h.gif','',1).'";
04138             var TBE_EDITOR_cm=new Image();      TBE_EDITOR_cm.src = "'.t3lib_iconWorks::skinImg($this->backPath,'gfx/content_client.gif','',1).'";
04139             var TBE_EDITOR_sel=new Image();  TBE_EDITOR_sel.src = "'.t3lib_iconWorks::skinImg($this->backPath,'gfx/content_selected.gif','',1).'";
04140             var TBE_EDITOR_clear=new Image();   TBE_EDITOR_clear.src = "'.$this->backPath.'clear.gif";
04141             var TBE_REQUIRED=new Array();
04142 '.implode(chr(10),$reqLines).'
04143 
04144             var TBE_RANGE=new Array();
04145             var TBE_RANGE_lower=new Array();
04146             var TBE_RANGE_upper=new Array();
04147 '.implode(chr(10),$reqRange).'
04148 
04149             // $this->additionalJS_post:
04150 '.implode(chr(10),$this->additionalJS_post).'
04151 
04152             var TBE_EDITOR_loadTime = 0;
04153             var TBE_EDITOR_isChanged = 0;
04154 
04155             function TBE_EDITOR_loginRefreshed()   {  //
04156                var date = new Date();
04157                TBE_EDITOR_loadTime = Math.floor(date.getTime()/1000);
04158                if (top.busy && top.busy.loginRefreshed)  {top.busy.loginRefreshed();}
04159             }
04160             function TBE_EDITOR_checkLoginTimeout()   {  //
04161                var date = new Date();
04162                var theTime = Math.floor(date.getTime()/1000);
04163                if (theTime > TBE_EDITOR_loadTime+'.intval($GLOBALS['BE_USER']->auth_timeout_field).'-10) {
04164                   return true;
04165                }
04166             }
04167             function TBE_EDITOR_setHiddenContent(RTEcontent,theField)   {  //
04168                document.'.$formname.'[theField].value = RTEcontent;
04169                alert(document.'.$formname.'[theField].value);
04170             }
04171             function TBE_EDITOR_fieldChanged_fName(fName,el)   {  //
04172                var idx='.(2+substr_count($this->prependFormFieldNames,'[')).';
04173                var table = TBE_EDITOR_split(fName, "[", idx);
04174                var uid = TBE_EDITOR_split(fName, "[", idx+1);
04175                var field = TBE_EDITOR_split(fName, "[", idx+2);
04176 
04177                table = table.substr(0,table.length-1);
04178                uid = uid.substr(0,uid.length-1);
04179                field = field.substr(0,field.length-1);
04180                TBE_EDITOR_fieldChanged(table,uid,field,el);
04181             }
04182             function TBE_EDITOR_fieldChanged(table,uid,field,el)  {  //
04183                var theField = "'.$this->prependFormFieldNames.'["+table+"]["+uid+"]["+field+"]";
04184                TBE_EDITOR_isChanged = 1;
04185 
04186                   // Set change image:
04187                var imgObjName = "cm_"+table+"_"+uid+"_"+field;
04188                TBE_EDITOR_setImage(imgObjName,"TBE_EDITOR_cm");
04189 
04190                   // Set change image
04191                if (document.'.$formname.'[theField] && document.'.$formname.'[theField].type=="select-one" && document.'.$formname.'[theField+"_selIconVal"])  {
04192                   var imgObjName = "selIcon_"+table+"_"+uid+"_"+field+"_";
04193                   TBE_EDITOR_setImage(imgObjName+document.'.$formname.'[theField+"_selIconVal"].value,"TBE_EDITOR_clear");
04194                   document.'.$formname.'[theField+"_selIconVal"].value = document.'.$formname.'[theField].selectedIndex;
04195                   TBE_EDITOR_setImage(imgObjName+document.'.$formname.'[theField+"_selIconVal"].value,"TBE_EDITOR_sel");
04196                }
04197 
04198                   // Set required flag:
04199                var imgReqObjName = "req_"+table+"_"+uid+"_"+field;
04200                if (TBE_REQUIRED[theField] && document.'.$formname.'[theField])   {
04201                   if (document.'.$formname.'[theField].value)  {
04202                      TBE_EDITOR_setImage(imgReqObjName,"TBE_EDITOR_clear");
04203                   } else {
04204                      TBE_EDITOR_setImage(imgReqObjName,"TBE_EDITOR_req");
04205                   }
04206                }
04207                if (TBE_RANGE[theField] && document.'.$formname.'[theField])   {
04208                   if (TBE_EDITOR_checkRange(document.'.$formname.'[theField+"_list"],TBE_RANGE_lower[theField],TBE_RANGE_upper[theField]))   {
04209                      TBE_EDITOR_setImage(imgReqObjName,"TBE_EDITOR_clear");
04210                   } else {
04211                      TBE_EDITOR_setImage(imgReqObjName,"TBE_EDITOR_req");
04212                   }
04213                }
04214                '.(!$this->isPalettedoc?'':'
04215                TBE_EDITOR_setOriginalFormFieldValue(theField);
04216                ').'
04217             }
04218             '.($this->isPalettedoc?'
04219             function TBE_EDITOR_setOriginalFormFieldValue(theField)  {  //
04220                if ('.$this->isPalettedoc.' && '.$this->isPalettedoc.'.document.'.$formname.' && '.$this->isPalettedoc.'.document.'.$formname.'[theField]) {
04221                   '.$this->isPalettedoc.'.document.'.$formname.'[theField].value = document.'.$formname.'[theField].value;
04222                }
04223             }
04224             ':'').'
04225             function TBE_EDITOR_isFormChanged(noAlert)   {  //
04226                if (TBE_EDITOR_isChanged && !noAlert && confirm('.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.fieldsChanged')).'))  {
04227                   return 0;
04228                }
04229                return TBE_EDITOR_isChanged;
04230             }
04231             function TBE_EDITOR_checkAndDoSubmit(sendAlert) {  //
04232                if (TBE_EDITOR_checkSubmit(sendAlert)) {
04233                   TBE_EDITOR_submitForm();
04234                }
04235             }
04236 
04243             function TBE_EDITOR_checkSubmit(sendAlert)   {  //
04244                if (TBE_EDITOR_checkLoginTimeout() && confirm('.$GLOBALS['LANG']->JScharCode($this->getLL('m_refresh_login')).')) {
04245                   vHWin=window.open(\''.$this->backPath.'login_frameset.php?\',\'relogin\',\'height=300,width=400,status=0,menubar=0\');
04246                   vHWin.focus();
04247                   return false;
04248                }
04249                var OK=1;
04250 
04251                // $this->additionalJS_post:
04252 '.implode(chr(10),$this->additionalJS_submit).'
04253 
04254                if(!OK)  {
04255                   if (!confirm(unescape("SYSTEM ERROR: One or more Rich Text Editors on the page could not be contacted. This IS an error, although it should not be regular.\nYou can save the form now by pressing OK, but you will loose the Rich Text Editor content if you do.\n\nPlease report the error to your administrator if it persists."))) {
04256                      return false;
04257                   } else {
04258                      OK = 1;
04259                   }
04260                }
04261 
04262 '.implode(chr(10),$reqLinesCheck).'
04263 '.implode(chr(10),$reqRangeCheck).'
04264 
04265                if (OK || sendAlert==-1)   {
04266                   return true;
04267                } else {
04268                   if(sendAlert)  alert('.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.fieldsMissing')).');
04269                   return false;
04270                }
04271             }
04272             function TBE_EDITOR_checkRange(el,lower,upper)  {  //
04273                if (el && el.length>=lower && el.length<=upper) {
04274                   return true;
04275                } else {
04276                   return false;
04277                }
04278             }
04279             function TBE_EDITOR_initRequired()  {  //
04280 '.implode(chr(10),$reqLinesSet).'
04281 '.implode(chr(10),$reqRangeSet).'
04282             }
04283             function TBE_EDITOR_setImage(name,imgName)   {  //
04284                if (document[name]) {document[name].src = eval(imgName+".src");}
04285             }
04286             function TBE_EDITOR_submitForm() {  //
04287                '.($this->doSaveFieldName?'document.'.$this->formName."['".$this->doSaveFieldName."'].value=1;":'').'
04288                document.'.$this->formName.'.submit();
04289             }
04290             function typoSetup   () {  //
04291                this.passwordDummy = "********";
04292                this.decimalSign = ".";
04293             }
04294             var TS = new typoSetup();
04295             var evalFunc = new evalFunc();
04296 
04297             function typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue)   {  //
04298                if (document.'.$formname.'[theField])  {
04299                   var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
04300                   var theValue = document.'.$formname.'[theField].value;
04301                   if (checkbox && theValue==checkboxValue)  {
04302                      document.'.$formname.'[theField+"_hr"].value="";
04303                      if (document.'.$formname.'[theField+"_cb"])  document.'.$formname.'[theField+"_cb"].checked = "";
04304                   } else {
04305                      document.'.$formname.'[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
04306                      if (document.'.$formname.'[theField+"_cb"])  document.'.$formname.'[theField+"_cb"].checked = "on";
04307                   }
04308                }
04309             }
04310             function typo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off, checkSetValue) {  //
04311                if (document.'.$formname.'[theField])  {
04312                   var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
04313                   if (checkbox_off) {
04314                      if (document.'.$formname.'[theField+"_cb"].checked)   {
04315                         document.'.$formname.'[theField].value=checkSetValue;
04316                      } else {
04317                         document.'.$formname.'[theField].value=checkboxValue;
04318                      }
04319                   }else{
04320                      document.'.$formname.'[theField].value = evalFunc.evalObjValue(theFObj, document.'.$formname.'[theField+"_hr"].value);
04321                   }
04322                   typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue);
04323                }
04324             }
04325             function TBE_EDITOR_split(theStr1, delim, index) {    //
04326                var theStr = ""+theStr1;
04327                var lengthOfDelim = delim.length;
04328                sPos = -lengthOfDelim;
04329                if (index<1) {index=1;}
04330                for (var a=1; a<index; a++)   {
04331                   sPos = theStr.indexOf(delim, sPos+lengthOfDelim);
04332                   if (sPos==-1)  {return null;}
04333                }
04334                ePos = theStr.indexOf(delim, sPos+lengthOfDelim);
04335                if(ePos == -1) {ePos = theStr.length;}
04336                return (theStr.substring(sPos+lengthOfDelim,ePos));
04337             }
04338             function TBE_EDITOR_palUrl(inData,fieldList,fieldNum,table,uid,isOnFocus) {      //
04339                var url = "'.$this->backPath.'alt_palette.php?inData="+inData+"&formName='.rawurlencode($this->formName).'"+"&prependFormFieldNames='.rawurlencode($this->prependFormFieldNames).'";
04340                var field = "";
04341                var theField="";
04342                for (var a=0; a<fieldNum;a++) {
04343                   field = TBE_EDITOR_split(fieldList, ",", a+1);
04344                   theField = "'.$this->prependFormFieldNames.'["+table+"]["+uid+"]["+field+"]";
04345                   if (document.'.$formname.'[theField])     url+="&rec["+field+"]="+TBE_EDITOR_rawurlencode(document.'.$formname.'[theField].value);
04346                }
04347                if (top.topmenuFrame)   {
04348                   top.topmenuFrame.document.location = url+"&backRef="+(top.content.list_frame ? (top.content.list_frame.view_frame ? "top.content.list_frame.view_frame" : "top.content.list_frame") : "top.content");
04349                } else if (!isOnFocus) {
04350                   var vHWin=window.open(url,"palette","height=300,width=200,status=0,menubar=0,scrollbars=1");
04351                   vHWin.focus();
04352                }
04353             }
04354             function TBE_EDITOR_curSelected(theField) {  //
04355                var fObjSel = document.'.$formname.'[theField];
04356                var retVal="";
04357                if (fObjSel)   {
04358                   if (fObjSel.type=="select-multiple" || fObjSel.type=="select-one")   {
04359                      var l=fObjSel.length;
04360                      for (a=0;a<l;a++) {
04361                         if (fObjSel.options[a].selected==1) {
04362                            retVal+=fObjSel.options[a].value+",";
04363                         }
04364                      }
04365                   }
04366                }
04367                return retVal;
04368             }
04369             function TBE_EDITOR_rawurlencode(str,maxlen) {  //
04370                var output = str;
04371                if (maxlen) output = output.substr(0,200);
04372                output = escape(output);
04373                output = TBE_EDITOR_str_replace("*","%2A", output);
04374                output = TBE_EDITOR_str_replace("+","%2B", output);
04375                output = TBE_EDITOR_str_replace("/","%2F", output);
04376                output = TBE_EDITOR_str_replace("@","%40", output);
04377                return output;
04378             }
04379             function TBE_EDITOR_str_replace(match,replace,string) {  //
04380                var input = ""+string;
04381                var matchStr = ""+match;
04382                if (!matchStr) {return string;}
04383                var output = "";
04384                var pointer=0;
04385                var pos = input.indexOf(matchStr);
04386                while (pos!=-1)   {
04387                   output+=""+input.substr(pointer, pos-pointer)+replace;
04388                   pointer=pos+matchStr.length;
04389                   pos = input.indexOf(match,pos+1);
04390                }
04391                output+=""+input.substr(pointer);
04392                return output;
04393             }
04394             /*]]>*/
04395          </script>
04396          <script type="text/javascript">
04397             /*<![CDATA[*/
04398 
04399             '.$this->extJSCODE.'
04400 
04401             TBE_EDITOR_initRequired();
04402             TBE_EDITOR_loginRefreshed();
04403             /*]]>*/
04404          </script>';
04405          return $out;
04406    }
04407 
04414    function dbFileCon($formObj='document.forms[0]')   {
04415       $str='
04416 
04417          // ***************
04418          // Used to connect the db/file browser with this document and the formfields on it!
04419          // ***************
04420 
04421          var browserWin="";
04422 
04423          function setFormValueOpenBrowser(mode,params) { //
04424             var url = "'.$this->backPath.'browser.php?mode="+mode+"&bparams="+params;
04425 
04426             browserWin = window.open(url,"Typo3WinBrowser","height=350,width="+(mode=="db"?650:600)+",status=0,menubar=0,resizable=1,scrollbars=1");
04427             browserWin.focus();
04428          }
04429          function setFormValueFromBrowseWin(fName,value,label) {  //
04430             var formObj = setFormValue_getFObj(fName)
04431             if (formObj && value!="--div--") {
04432                fObj = formObj[fName+"_list"];
04433                   // Inserting element
04434                var l=fObj.length;
04435                var setOK=1;
04436                if (!formObj[fName+"_mul"] || formObj[fName+"_mul"].value==0)  {
04437                   for (a=0;a<l;a++) {
04438                      if (fObj.options[a].value==value)   {
04439                         setOK=0;
04440                      }
04441                   }
04442                }
04443                if (setOK)  {
04444                   fObj.length++;
04445                   fObj.options[l].value=value;
04446                   fObj.options[l].text=unescape(label);
04447 
04448                      // Traversing list and set the hidden-field
04449                   setHiddenFromList(fObj,formObj[fName]);
04450                   '.$this->TBE_EDITOR_fieldChanged_func.'
04451                }
04452             }
04453          }
04454          function setHiddenFromList(fObjSel,fObjHid)  {  //
04455             l=fObjSel.length;
04456             fObjHid.value="";
04457             for (a=0;a<l;a++) {
04458                fObjHid.value+=fObjSel.options[a].value+",";
04459             }
04460          }
04461          function setFormValueManipulate(fName,type)  {  //
04462             var formObj = setFormValue_getFObj(fName)
04463             if (formObj)   {
04464                var localArray_V = new Array();
04465                var localArray_L = new Array();
04466                var fObjSel = formObj[fName+"_list"];
04467                var l=fObjSel.length;
04468                var c=0;
04469                var cS=0;
04470                if (type=="Remove" || type=="Up")   {
04471                   if (type=="Up")   {
04472                      for (a=0;a<l;a++) {
04473                         if (fObjSel.options[a].selected==1) {
04474                            localArray_V[c]=fObjSel.options[a].value;
04475                            localArray_L[c]=fObjSel.options[a].text;
04476                            c++;
04477                            cS++;
04478                         }
04479                      }
04480                   }
04481                   for (a=0;a<l;a++) {
04482                      if (fObjSel.options[a].selected!=1) {
04483                         localArray_V[c]=fObjSel.options[a].value;
04484                         localArray_L[c]=fObjSel.options[a].text;
04485                         c++;
04486                      }
04487                   }
04488                }
04489                fObjSel.length = c;
04490                for (a=0;a<c;a++) {
04491                   fObjSel.options[a].value = localArray_V[a];
04492                   fObjSel.options[a].text = localArray_L[a];
04493                   fObjSel.options[a].selected=(a<cS)?1:0;
04494                }
04495                setHiddenFromList(fObjSel,formObj[fName]);
04496 
04497                '.$this->TBE_EDITOR_fieldChanged_func.'
04498             }
04499          }
04500          function setFormValue_getFObj(fName)   {  //
04501             var formObj = '.$formObj.';
04502             if (formObj)   {
04503                if (formObj[fName] && formObj[fName+"_list"] && formObj[fName+"_list"].type=="select-multiple") {
04504                   return formObj;
04505                } else {
04506                   alert("Formfields missing:\n fName: "+formObj[fName]+"\n fName_list:"+formObj[fName+"_list"]+"\n type:"+formObj[fName+"_list"].type+"\n fName:"+fName);
04507                }
04508             }
04509             return "";
04510          }
04511 
04512          // END: dbFileCon parts.
04513       ';
04514       return $str;
04515    }
04516 
04522    function printNeededJSFunctions()   {
04523          // JS evaluation:
04524       $out = $this->JSbottom($this->formName);
04525          //
04526       if ($this->printNeededJS['dbFileIcons'])  {
04527          $out.= '
04528 
04529 
04530 
04531          <!--
04532             JavaScript after the form has been drawn:
04533          -->
04534 
04535          <script type="text/javascript">
04536             /*<![CDATA[*/
04537          '.$this->dbFileCon('document.'.$this->formName).'
04538             /*]]>*/
04539          </script>';
04540       }
04541       return $out;
04542    }
04543 
04549    function printNeededJSFunctions_top()  {
04550          // JS evaluation:
04551       $out = $this->JStop($this->formName);
04552       return $out;
04553    }
04554 
04555 
04556 
04557 
04558 
04559 
04560 
04561 
04562 
04563 
04564 
04565 
04566 
04567 
04568 
04569 
04570 
04571 
04572 
04573 
04574 
04575 
04576 
04577 
04578 
04579 
04580 
04581 
04582 
04583    /********************************************
04584     *
04585     * Various helper functions
04586     *
04587     ********************************************/
04588 
04589 
04597    function getDefaultRecord($table,$pid=0)  {
04598       global $TCA;
04599       if ($TCA[$table]) {
04600          t3lib_div::loadTCA($table);
04601          $row = array();
04602 
04603          if ($pid<0 && $TCA[$table]['ctrl']['useColumnsForDefaultValues']) {
04604                // Fetches the previous record:
04605             $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'uid='.abs($pid).t3lib_BEfunc::deleteClause($table));
04606             if ($drow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
04607                   // Gets the list of fields to copy from the previous record.
04608                $fArr = explode(',',$TCA[$table]['ctrl']['useColumnsForDefaultValues']);
04609                foreach($fArr as $theF) {
04610                   if ($TCA[$table]['columns'][$theF]) {
04611                      $row[$theF] = $drow[$theF];
04612                   }
04613                }
04614             }
04615             $GLOBALS['TYPO3_DB']->sql_free_result($res);
04616          }
04617 
04618          foreach($TCA[$table]['columns'] as $field => $info)   {
04619             if (isset($info['config']['default'])) {
04620                $row[$field] = $info['config']['default'];
04621             }
04622          }
04623 
04624          return $row;
04625       }
04626    }
04627 
04636    function getRecordPath($table,$rec) {
04637       t3lib_BEfunc::fixVersioningPid($table,$rec);
04638       list($tscPID,$thePidValue)=$this->getTSCpid($table,$rec['uid'],$rec['pid']);
04639       if ($thePidValue>=0) {
04640          return t3lib_BEfunc::getRecordPath($tscPID,$this->readPerms(),15);
04641       }
04642    }
04643 
04650    function readPerms() {
04651       if (!$this->perms_clause_set) {
04652          $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
04653          $this->perms_clause_set=1;
04654       }
04655       return $this->perms_clause;
04656    }
04657 
04664    function sL($str) {
04665       return $GLOBALS['LANG']->sL($str);
04666    }
04667 
04677    function getLL($str) {
04678       switch(substr($str,0,2))   {
04679          case 'l_':
04680             return $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.'.substr($str,2));
04681          break;
04682          case 'm_':
04683             return $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.'.substr($str,2));
04684          break;
04685       }
04686    }
04687 
04695    function isPalettesCollapsed($table,$palette)   {
04696       global $TCA;
04697 
04698       if ($TCA[$table]['ctrl']['canNotCollapse']) return 0;
04699       if (is_array($TCA[$table]['palettes'][$palette]) && $TCA[$table]['palettes'][$palette]['canNotCollapse'])   return 0;
04700       return $this->palettesCollapsed;
04701    }
04702 
04710    function isDisplayCondition($displayCond,$row)  {
04711       $output = FALSE;
04712 
04713       $parts = explode(':',$displayCond);
04714       switch((string)$parts[0])  {  // Type of condition:
04715          case 'FIELD':
04716             switch((string)$parts[2])  {
04717                case 'REQ':
04718                   if (strtolower($parts[3])=='true')  {
04719                      $output = $row[$parts[1]] ? TRUE : FALSE;
04720                   } elseif (strtolower($parts[3])=='false') {
04721                      $output = !$row[$parts[1]] ? TRUE : FALSE;
04722                   }
04723                break;
04724                case '>':
04725                   $output = $row[$parts[1]] > $parts[3];
04726                break;
04727                case '<':
04728                   $output = $row[$parts[1]] < $parts[3];
04729                break;
04730                case '>=':
04731                   $output = $row[$parts[1]] >= $parts[3];
04732                break;
04733                case '<=':
04734                   $output = $row[$parts[1]] <= $parts[3];
04735                break;
04736                case '-':
04737                case '!-':
04738                   $cmpParts = explode('-',$parts[3]);
04739                   $output = $row[$parts[1]] >= $cmpParts[0] && $row[$parts[1]] <= $cmpParts[1];
04740                   if ($parts[2]{0}=='!')  $output = !$output;
04741                break;
04742                case 'IN':
04743                case '!IN':
04744                   $output = t3lib_div::inList($parts[3],$row[$parts[1]]);
04745                   if ($parts[2]{0}=='!')  $output = !$output;
04746                break;
04747                case '=':
04748                case '!=':
04749                   $output = t3lib_div::inList($parts[3],$row[$parts[1]]);
04750                   if ($parts[2]{0}=='!')  $output = !$output;
04751                break;
04752             }
04753          break;
04754          case 'EXT':
04755             switch((string)$parts[2])  {
04756                case 'LOADED':
04757                   if (strtolower($parts[3])=='true')  {
04758                      $output = t3lib_extMgm::isLoaded($parts[1]) ? TRUE : FALSE;
04759                   } elseif (strtolower($parts[3])=='false') {
04760                      $output = !t3lib_extMgm::isLoaded($parts[1]) ? TRUE : FALSE;
04761                   }
04762                break;
04763             }
04764          break;
04765          case 'REC':
04766             switch((string)$parts[1])  {
04767                case 'NEW':
04768                   if (strtolower($parts[2])=='true')  {
04769                      $output = !(intval($row['uid']) > 0) ? TRUE : FALSE;
04770                   } elseif (strtolower($parts[2])=='false') {
04771                      $output = (intval($row['uid']) > 0) ? TRUE : FALSE;
04772                   }
04773                break;
04774             }
04775          break;
04776       }
04777 
04778       return $output;
04779    }
04780 
04791    function getTSCpid($table,$uid,$pid)   {
04792       $key = $table.':'.$uid.':'.$pid;
04793       if (!isset($this->cache_getTSCpid[$key])) {
04794          $this->cache_getTSCpid[$key] = t3lib_BEfunc::getTSCpid($table,$uid,$pid);
04795       }
04796       return $this->cache_getTSCpid[$key];
04797    }
04798 
04805    function doLoadTableDescr($table)   {
04806       global $TCA;
04807       return $TCA[$table]['interface']['always_description'];
04808    }
04809 
04817    function getAvailableLanguages($onlyIsoCoded=1,$setDefault=1)  {
04818       $isL = t3lib_extMgm::isLoaded('static_info_tables');
04819 
04820          // Find all language records in the system:
04821       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('static_lang_isocode,title,uid', 'sys_language', 'pid=0 AND NOT hidden'.t3lib_BEfunc::deleteClause('sys_language'), '', 'title');
04822 
04823          // Traverse them:
04824       $output=array();
04825       if ($setDefault)  {
04826          $output[0]=array(
04827             'uid' => 0,
04828             'title' => 'Default language',
04829             'ISOcode' => 'DEF'
04830          );
04831       }
04832       while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))   {
04833          $output[$row['uid']]=$row;
04834 
04835          if ($isL && $row['static_lang_isocode'])  {
04836             $rr = t3lib_BEfunc::getRecord('static_languages',$row['static_lang_isocode'],'lg_iso_2');
04837             if ($rr['lg_iso_2']) $output[$row['uid']]['ISOcode']=$rr['lg_iso_2'];
04838          }
04839 
04840          if ($onlyIsoCoded && !$output[$row['uid']]['ISOcode'])   unset($output[$row['uid']]);
04841       }
04842       return $output;
04843    }
04844 }
04845 
04846 
04847 
04848 
04849 
04850 
04851 
04852 
04853 
04859 class t3lib_TCEforms_FE extends t3lib_TCEforms {
04860 
04867    function wrapLabels($str)  {
04868       return '<font face="verdana" size="1" color="black">'.$str.'</font>';
04869    }
04870 
04877    function printPalette($palArr)   {
04878       $out='';
04879       reset($palArr);
04880       $bgColor=' bgcolor="#D6DAD0"';
04881       while(list(,$content)=each($palArr))   {
04882          $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>';
04883          $iRow[]='<td valign="top">'.
04884                   '<img name="req_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="10" height="10" alt="" />'.
04885                   '<img name="cm_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="7" height="10" alt="" />'.
04886                   '</td><td nowrap="nowrap" valign="top">'.$content['ITEM'].$content['HELP_ICON'].'</td>';
04887       }
04888       $out='<table border="0" cellpadding="0" cellspacing="0">
04889          <tr><td><img src="clear.gif" width="'.intval($this->paletteMargin).'" height="1" alt="" /></td>'.implode('',$hRow).'</tr>
04890          <tr><td></td>'.implode('',$iRow).'</tr>
04891       </table>';
04892 
04893       return $out;
04894    }
04895 
04902    function setFancyDesign()  {
04903       $this->fieldTemplate='
04904    <tr>
04905       <td nowrap="nowrap" bgcolor="#F6F2E6">###FIELD_HELP_ICON###<font face="verdana" size="1" color="black"><b>###FIELD_NAME###</b></font>###FIELD_HELP_TEXT###</td>
04906    </tr>
04907    <tr>
04908       <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>
04909    </tr> ';
04910 
04911       $this->totalWrap='<table border="0" cellpadding="1" cellspacing="0" bgcolor="black"><tr><td><table border="0" cellpadding="2" cellspacing="0">|</table></td></tr></table>';
04912 
04913       $this->palFieldTemplate='
04914    <tr>
04915       <td nowrap="nowrap" bgcolor="#ABBBB4"><font face="verdana" size="1" color="black">###FIELD_PALETTE###</font></td>
04916    </tr> ';
04917       $this->palFieldTemplateHeader='
04918    <tr>
04919       <td nowrap="nowrap" bgcolor="#F6F2E6"><font face="verdana" size="1" color="black"><b>###FIELD_HEADER###</b></font></td>
04920    </tr> ';
04921    }
04922 }
04923 
04924 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tceforms.php'])   {
04925    include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tceforms.php']);
04926 }
04927 ?>

Generated on Sun Oct 3 01:05:50 2004 for TYPO3core 3.7.0 dev by  doxygen 1.3.8-20040913