"TYPO3 4.0.1: typo3_src-4.0.1/t3lib/class.t3lib_tceforms.php Source File", "datetime" => "Sat Dec 2 19:22:19 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>

class.t3lib_tceforms.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2006 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 ***************************************************************/
00183 require_once(PATH_t3lib.'class.t3lib_diff.php');
00184 
00185 
00186 
00195 class t3lib_TCEforms    {
00196 
00197                 // variables not commented yet.... (do so...)
00198         var $palFieldArr = array();
00199         var $disableWizards = 0;
00200         var $isPalettedoc = 0;
00201         var $paletteMargin = 1;
00202         var $defStyle = ''; // 'font-family:Verdana;font-size:10px;';
00203         var $cachedTSconfig = array();
00204         var $cachedTSconfig_fieldLevel = array();
00205         var $transformedRow = array();
00206         var $extJSCODE = '';
00207         var $printNeededJS = array();
00208         var $hiddenFieldAccum=array();
00209         var $TBE_EDITOR_fieldChanged_func='';
00210         var $loadMD5_JS=1;
00211         var $prevBorderStyle='[nothing here...]';       // Something unique...
00212         var $allowUpload=0;                             // If set direct upload fields will be shown
00213         var $titleLen=15;                                       // $BE_USER->uc['titleLen'] but what is default??
00214         var $defaultLanguageData = array();     // Array where records in the default language is stored. (processed by transferdata)
00215         var $defaultLanguageData_diff = array();        // Array where records in the default language is stored (raw without any processing. used for making diff)
00216 
00217 
00218                 // EXTERNAL, static
00219         var $backPath='';                                       // Set this to the 'backPath' pointing back to the typo3 admin directory from the script where this form is displayed.
00220         var $returnUrl='';                                      // Alternative return URL path (default is t3lib_div::linkThisScript())
00221         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.
00222         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.
00223         var $disableRTE=0;                                      // If set, the RTE is disabled (from form display, eg. by checkbox in the bottom of the page!)
00224         var $globalShowHelp=1;                          // If false, then all CSH will be disabled, regardless of settings in $this->edit_showFieldHelp
00225         var $localizationMode='';               // If true, the forms are rendering only localization relevant fields of the records.
00226         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.
00227         var $doPrintPalette=1;                          // If set to false, palettes will NEVER be rendered.
00228         var $clipObj=FALSE;                                     // Set to initialized clipboard object; Then the element browser will offer a link to paste in records from clipboard.
00229         var $enableClickMenu=FALSE;                     // Enable click menu on reference icons.
00230         var $enableTabMenu = FALSE;                     // Enable Tab Menus. If set to true, the JavaScript content from template::getDynTabMenuJScode() must be included in the document.
00231         var $renderReadonly = FALSE;            // When enabled all fields are rendered non-editable.
00232 
00233         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)
00234         var $form_largeComp = 1.33;                     // Form field width compensation: Compensation for large documents, doc-tab (editing)
00235         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.
00236         var $maxTextareaWidth=48;                       // The maximum abstract value for textareas
00237         var $maxInputWidth=48;                          // The maximum abstract value for input fields
00238         var $defaultMultipleSelectorStyle='width:250px;';       // Default style for the selector boxes used for multiple items in "select" and "group" types.
00239 
00240 
00241                 // INTERNAL, static
00242         var $prependFormFieldNames = 'data';            // The string to prepend formfield names with.
00243         var $prependFormFieldNames_file = 'data_files';         // The string to prepend FILE form field names with.
00244         var $formName = 'editform';                                     // The name attribute of the form.
00245 
00246 
00247 
00248                 // INTERNAL, dynamic
00249         var $perms_clause='';                                           // Set by readPerms()  (caching)
00250         var $perms_clause_set=0;                                        // Set by readPerms()  (caching-flag)
00251         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).
00252         var $docLarge=0;                                                        // If set, the forms will be rendered a little wider, more precisely with a factor of $this->form_largeComp.
00253         var $clientInfo=array();                                        // Loaded with info about the browser when class is instantiated.
00254         var $RTEenabled=0;                                                      // True, if RTE is possible for the current user (based on result from BE_USER->isRTE())
00255         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)
00256         var $RTEcounter = 0;                                            // Counter that is incremented before an RTE is created. Can be used for unique ids etc.
00257 
00258         var $colorScheme;                                                       // Contains current color scheme
00259         var $classScheme;                                                       // Contains current class scheme
00260         var $defColorScheme;                                            // Contains the default color scheme
00261         var $defClassScheme;                                            // Contains the default class scheme
00262         var $fieldStyle;                                                        // Contains field style values
00263         var $borderStyle;                                                       // Contains border style values.
00264 
00265         var $commentMessages=array();                           // An accumulation of messages from the class.
00266 
00267                 // INTERNAL, templates
00268         var $totalWrap='<hr />|<hr />';                         // Total wrapping for the table rows.
00269         var $fieldTemplate='<b>###FIELD_NAME###</b><br />###FIELD_ITEM###<hr />';       // Field template
00270         var $sectionWrap='';                                            // Wrapping template code for a section
00271         var $palFieldTemplateHeader='';                         // Template for palette headers
00272         var $palFieldTemplate='';                                       // Template for palettes
00273 
00274                 // INTERNAL, working memory
00275         var $excludeElements='';                                        // Set to the fields NOT to display, if any.
00276         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)
00277         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!
00278         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.
00279         var $requiredElements=array();                          // Used to register the min and max number of elements for selectorboxes where that apply (in the "group" type for instance)
00280         var $renderDepth=0;                                                     // Keeps track of the rendering depth of nested records.
00281         var $savedSchemes=array();                                      // Color scheme buffer.
00282 
00283                 // Internal, registers for user defined functions etc.
00284         var $additionalCode_pre = array();                      // Additional HTML code, printed before the form.
00285         var $additionalJS_pre = array();                        // Additional JavaScript, printed before the form
00286         var $additionalJS_post = array();                       // Additional JavaScript printed after the form
00287         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.
00288 
00289 
00290 
00291 
00292 
00293 
00294 
00300         function t3lib_TCEforms()       {
00301                 global $CLIENT;
00302 
00303                 $this->clientInfo = t3lib_div::clientInfo();
00304 
00305                 $this->RTEenabled = $GLOBALS['BE_USER']->isRTE();
00306                 if (!$this->RTEenabled) {
00307                         $this->RTEenabled_notReasons = implode(chr(10),$GLOBALS['BE_USER']->RTE_errors);
00308                         $this->commentMessages[] = 'RTE NOT ENABLED IN SYSTEM due to:'.chr(10).$this->RTEenabled_notReasons;
00309                 }
00310 
00311                         // Default color+class scheme
00312                 $this->defColorScheme = array(
00313                         $GLOBALS['SOBE']->doc->bgColor, // Background for the field AND palette
00314                         t3lib_div::modifyHTMLColorAll($GLOBALS['SOBE']->doc->bgColor,-20),      // Background for the field header
00315                         t3lib_div::modifyHTMLColorAll($GLOBALS['SOBE']->doc->bgColor,-10),      // Background for the palette field header
00316                         'black',        // Field header font color
00317                         '#666666'       // Palette field header font color
00318                 );
00319                 $this->defColorScheme = array();
00320 
00321                         // Override / Setting defaults from TBE_STYLES array
00322                 $this->resetSchemes();
00323 
00324                         // Setting the current colorScheme to default.
00325                 $this->defColorScheme = $this->colorScheme;
00326                 $this->defClassScheme = $this->classScheme;
00327         }
00328 
00334         function initDefaultBEmode()    {
00335                 global $BE_USER;
00336                 $this->prependFormFieldNames = 'data';
00337                 $this->formName = 'editform';
00338                 $this->setNewBEDesign();
00339                 $this->docLarge = $BE_USER->uc['edit_wideDocument'] ? 1 : 0;
00340                 $this->edit_showFieldHelp = $BE_USER->uc['edit_showFieldHelp'];
00341 
00342                 $this->edit_docModuleUpload = $BE_USER->uc['edit_docModuleUpload'];
00343                 $this->titleLen = $BE_USER->uc['titleLen'];
00344         }
00345 
00346 
00347 
00348 
00349 
00350 
00351 
00352 
00353 
00354 
00355 
00356 
00357 
00358 
00359 
00360 
00361 
00362         /*******************************************************
00363          *
00364          * Rendering the forms, fields etc
00365          *
00366          *******************************************************/
00367 
00379         function getSoloField($table,$row,$theFieldToReturn)    {
00380                 global $TCA;
00381 
00382                 if ($TCA[$table])       {
00383                         t3lib_div::loadTCA($table);
00384                         $typeNum = $this->getRTypeNum($table,$row);
00385                         if ($TCA[$table]['types'][$typeNum])    {
00386                                 $itemList = $TCA[$table]['types'][$typeNum]['showitem'];
00387                                 if ($itemList)  {
00388                                         $fields = t3lib_div::trimExplode(',',$itemList,1);
00389                                         $excludeElements = $this->excludeElements = $this->getExcludeElements($table,$row,$typeNum);
00390 
00391                                         reset($fields);
00392                                         while(list(,$fieldInfo)=each($fields))  {
00393                                                 $parts = explode(';',$fieldInfo);
00394 
00395                                                 $theField = trim($parts[0]);
00396                                                 if (!in_array($theField,$excludeElements) && !strcmp($theField,$theFieldToReturn))      {
00397                                                         if ($TCA[$table]['columns'][$theField]) {
00398                                                                 $sField = $this->getSingleField($table,$theField,$row,$parts[1],1,$parts[3],$parts[2]);
00399                                                                 return $sField['ITEM'];
00400                                                         }
00401                                                 }
00402                                         }
00403                                 }
00404                         }
00405                 }
00406         }
00407 
00418         function getMainFields($table,$row,$depth=0)    {
00419                 global $TCA, $TYPO3_CONF_VARS;
00420 
00421                 $this->renderDepth=$depth;
00422 
00423                         // Init vars:
00424                 $out_array = array(array());
00425                 $out_array_meta = array(array(
00426                         'title' => $this->getLL('l_generalTab')
00427                 ));
00428 
00429                 $out_pointer=0;
00430                 $out_sheet=0;
00431                 $this->palettesRendered=array();
00432                 $this->palettesRendered[$this->renderDepth][$table]=array();
00433 
00434                         // First prepare user defined objects (if any) for hooks which extend this function:
00435                 $hookObjectsArr = array();
00436                 if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass']))  {
00437                         foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'] as $classRef)   {
00438                                 $hookObjectsArr[] = &t3lib_div::getUserObj($classRef);
00439                         }
00440                 }
00441 
00442                         // Hook: getMainFields_preProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
00443                 foreach ($hookObjectsArr as $hookObj)   {
00444                         if (method_exists($hookObj,'getMainFields_preProcess')) {
00445                                 $hookObj->getMainFields_preProcess($table,$row,$this);
00446                         }
00447                 }
00448 
00449                 if ($TCA[$table])       {
00450 
00451                                 // Load the full TCA for the table.
00452                         t3lib_div::loadTCA($table);
00453 
00454                                 // Load the description content for the table.
00455                         if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table))       {
00456                                 $GLOBALS['LANG']->loadSingleTableDescription($table);
00457                         }
00458                                 // Get the current "type" value for the record.
00459                         $typeNum = $this->getRTypeNum($table,$row);
00460 
00461                                 // Find the list of fields to display:
00462                         if ($TCA[$table]['types'][$typeNum])    {
00463                                 $itemList = $TCA[$table]['types'][$typeNum]['showitem'];
00464                                 if ($itemList)  {       // If such a list existed...
00465 
00466                                                 // Explode the field list and possibly rearrange the order of the fields, if configured for
00467                                         $fields = t3lib_div::trimExplode(',',$itemList,1);
00468                                         if ($this->fieldOrder)  {
00469                                                 $fields = $this->rearrange($fields);
00470                                         }
00471 
00472                                                 // Get excluded fields, added fiels and put it together:
00473                                         $excludeElements = $this->excludeElements = $this->getExcludeElements($table,$row,$typeNum);
00474                                         $fields = $this->mergeFieldsWithAddedFields($fields,$this->getFieldsToAdd($table,$row,$typeNum));
00475 
00476                                                 // Traverse the fields to render:
00477                                         $cc=0;
00478                                         foreach($fields as $fieldInfo)  {
00479                                                         // Exploding subparts of the field configuration:
00480                                                 $parts = explode(';',$fieldInfo);
00481 
00482                                                         // Getting the style information out:
00483                                                 $color_style_parts = t3lib_div::trimExplode('-',$parts[4]);
00484                                                 if (strcmp($color_style_parts[0],''))   {
00485                                                         $this->setColorScheme($GLOBALS['TBE_STYLES']['colorschemes'][intval($color_style_parts[0])]);
00486                                                 }
00487                                                 if (strcmp($color_style_parts[1],''))   {
00488                                                         $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][intval($color_style_parts[1])];
00489                                                         if (!isset($this->fieldStyle))  $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][0];
00490                                                 }
00491                                                 if (strcmp($color_style_parts[2],''))   {
00492                                                         $this->wrapBorder($out_array[$out_sheet],$out_pointer);
00493                                                         $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][intval($color_style_parts[2])];
00494                                                         if (!isset($this->borderStyle)) $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][0];
00495                                                 }
00496 
00497                                                         // Render the field:
00498                                                 $theField = $parts[0];
00499                                                 if (!in_array($theField,$excludeElements))      {
00500                                                         if ($TCA[$table]['columns'][$theField]) {
00501                                                                 $sFieldPal='';
00502 
00503                                                                 if ($parts[2] && !isset($this->palettesRendered[$this->renderDepth][$table][$parts[2]]))        {
00504                                                                         $sFieldPal=$this->getPaletteFields($table,$row,$parts[2]);
00505                                                                         $this->palettesRendered[$this->renderDepth][$table][$parts[2]] = 1;
00506                                                                 }
00507                                                                 $sField = $this->getSingleField($table,$theField,$row,$parts[1],0,$parts[3],$parts[2]);
00508                                                                 if ($sField)    $sField.=$sFieldPal;
00509 
00510                                                                 $out_array[$out_sheet][$out_pointer].= $sField;
00511                                                         } elseif ($theField=='--div--') {
00512                                                                 if ($cc>0)      {
00513                                                                         $out_array[$out_sheet][$out_pointer].=$this->getDivider();
00514 
00515                                                                         if ($this->enableTabMenu && $TCA[$table]['ctrl']['dividers2tabs'])      {
00516                                                                                 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
00517                                                                                 $out_sheet++;
00518                                                                                 $out_array[$out_sheet] = array();
00519                                                                                 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
00520                                                                         }
00521                                                                 } else {        // Setting alternative title for "General" tab if "--div--" is the very first element.
00522                                                                         $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
00523                                                                 }
00524                                                         } elseif($theField=='--palette--')      {
00525                                                                 if ($parts[2] && !isset($this->palettesRendered[$this->renderDepth][$table][$parts[2]]))        {
00526                                                                                 // render a 'header' if not collapsed
00527                                                                         if ($TCA[$table]['palettes'][$parts[2]]['canNotCollapse'] AND $parts[1]) {
00528                                                                                 $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$parts[2],$this->sL($parts[1]));
00529                                                                         } else {
00530                                                                                 $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$parts[2],'','',$this->sL($parts[1]));
00531                                                                         }
00532                                                                         $this->palettesRendered[$this->renderDepth][$table][$parts[2]] = 1;
00533                                                                 }
00534                                                         }
00535                                                 }
00536 
00537                                                 $cc++;
00538                                         }
00539                                 }
00540                         }
00541                 }
00542 
00543                         // Hook: getMainFields_postProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
00544                 foreach ($hookObjectsArr as $hookObj)   {
00545                         if (method_exists($hookObj,'getMainFields_postProcess'))        {
00546                                 $hookObj->getMainFields_postProcess($table,$row,$this);
00547                         }
00548                 }
00549 
00550                         // Wrapping a border around it all:
00551                 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
00552 
00553                         // Resetting styles:
00554                 $this->resetSchemes();
00555 
00556                         // Rendering Main palettes, if any
00557                 $mParr = t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['mainpalette']);
00558                 $i = 0;
00559                 if (count($mParr))      {
00560                         foreach ($mParr as $mP) {
00561                                 if (!isset($this->palettesRendered[$this->renderDepth][$table][$mP]))   {
00562                                         $temp_palettesCollapsed=$this->palettesCollapsed;
00563                                         $this->palettesCollapsed=0;
00564                                         $label = ($i==0?$this->getLL('l_generalOptions'):$this->getLL('l_generalOptions_more'));
00565                                         $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$mP,$label);
00566                                         $this->palettesCollapsed=$temp_palettesCollapsed;
00567                                         $this->palettesRendered[$this->renderDepth][$table][$mP] = 1;
00568                                 }
00569                                 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
00570                                 $i++;
00571                                 if ($this->renderDepth) {
00572                                         $this->renderDepth--;
00573                                 }
00574                         }
00575                 }
00576 
00577 
00578                         // Return the imploded $out_array:
00579                 if ($out_sheet>0)       {       // There were --div-- dividers around...
00580 
00581                                 // Create parts array for the tab menu:
00582                         $parts = array();
00583                         foreach($out_array as $idx => $sheetContent)    {
00584                                 $parts[] = array(
00585                                         'label' => $out_array_meta[$idx]['title'],
00586                                         'content' => '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.
00587                                                         implode('',$sheetContent).
00588                                                 '</table>'
00589                                 );
00590                         }
00591 
00592                         return '
00593                                 <tr>
00594                                         <td colspan="2">
00595                                         '.$this->getDynTabMenu($parts, 'TCEforms:'.$table.':'.$row['uid']).'
00596                                         </td>
00597                                 </tr>';
00598                 } else {        // Only one, so just implode:
00599                         return implode('',$out_array[$out_sheet]);
00600                 }
00601         }
00602 
00613         function getListedFields($table,$row,$list)     {
00614                 global $TCA;
00615 
00616                 t3lib_div::loadTCA($table);
00617                 if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table))       {
00618                         $GLOBALS['LANG']->loadSingleTableDescription($table);
00619                 }
00620 
00621                 $out='';
00622                 $types_fieldConfig=t3lib_BEfunc::getTCAtypes($table,$row,1);
00623 
00624                 $editFieldList=array_unique(t3lib_div::trimExplode(',',$list,1));
00625                 foreach($editFieldList as $theFieldC)   {
00626                         list($theField,$palFields) = split('\[|\]',$theFieldC);
00627                         $theField = trim($theField);
00628                         $palFields = trim($palFields);
00629                         if ($TCA[$table]['columns'][$theField]) {
00630                                 $parts = t3lib_div::trimExplode(';',$types_fieldConfig[$theField]['origString']);
00631                                 $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.
00632                                 $out.= $sField;
00633                         } elseif($theField=='--div--')  {
00634                                 $out.=$this->getDivider();
00635                         }
00636                         if ($palFields) {
00637                                 $out.=$this->getPaletteFields($table,$row,'','',implode(',',t3lib_div::trimExplode('|',$palFields,1)));
00638                         }
00639                 }
00640                 return $out;
00641         }
00642 
00654         function getPaletteFields($table,$row,$palette,$header='',$itemList='',$collapsedHeader='')     {
00655                 global $TCA;
00656                 if (!$this->doPrintPalette)     return '';
00657 
00658                 $out='';
00659                 $palParts=array();
00660                 t3lib_div::loadTCA($table);
00661 
00662                         // Getting excludeElements, if any.
00663                 if (!is_array($this->excludeElements))  {
00664                         $this->excludeElements = $this->getExcludeElements($table,$row,$this->getRTypeNum($table,$row));
00665                 }
00666 
00667                         // Render the palette TCEform elements.
00668                 if ($TCA[$table] && (is_array($TCA[$table]['palettes'][$palette]) || $itemList))        {
00669                         $itemList = $itemList?$itemList:$TCA[$table]['palettes'][$palette]['showitem'];
00670                         if ($itemList)  {
00671                                 $fields = t3lib_div::trimExplode(',',$itemList,1);
00672                                 reset($fields);
00673                                 while(list(,$fieldInfo)=each($fields))  {
00674                                         $parts = t3lib_div::trimExplode(';',$fieldInfo);
00675                                         $theField = $parts[0];
00676 
00677                                         if (!in_array($theField,$this->excludeElements) && $TCA[$table]['columns'][$theField])  {
00678                                                 $this->palFieldArr[$palette][] = $theField;
00679                                                 if ($this->isPalettesCollapsed($table,$palette))        {
00680                                                         $this->hiddenFieldListArr[] = $theField;
00681                                                 }
00682 
00683                                                 $part=$this->getSingleField($table,$theField,$row,$parts[1],1,'',$parts[2]);
00684                                                 if (is_array($part))    {
00685                                                         $palParts[]=$part;
00686                                                 }
00687                                         }
00688                                 }
00689                         }
00690                 }
00691                         // Put palette together if there are fields in it:
00692                 if (count($palParts))   {
00693                         if ($header)    {
00694                                 $out.=  $this->intoTemplate(array(
00695                                                                 'HEADER' => htmlspecialchars($header)
00696                                                         ),
00697                                                         $this->palFieldTemplateHeader
00698                                                 );
00699                         }
00700                         $out.=  $this->intoTemplate(array(
00701                                                         'PALETTE' => $this->printPalette($palParts)
00702                                                 ),
00703                                                 $this->palFieldTemplate
00704                                         );
00705                 }
00706                         // 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.
00707                 if ($this->isPalettesCollapsed($table,$palette) && $collapsedHeader)    {
00708                         $pC=    $this->intoTemplate(array(
00709                                                         '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),
00710                                                 ),
00711                                                 $this->palFieldTemplate
00712                                         );
00713                         $out.=$pC;
00714                 }
00715                 return $out;
00716         }
00717 
00730         function getSingleField($table,$field,$row,$altName='',$palette=0,$extra='',$pal=0)     {
00731                 global $TCA,$BE_USER;
00732 
00733                 $out = '';
00734                 $PA = array();
00735                 $PA['altName'] = $altName;
00736                 $PA['palette'] = $palette;
00737                 $PA['extra'] = $extra;
00738                 $PA['pal'] = $pal;
00739 
00740                         // Make sure to load full $TCA array for the table:
00741                 t3lib_div::loadTCA($table);
00742 
00743                         // Get the TCA configuration for the current field:
00744                 $PA['fieldConf'] = $TCA[$table]['columns'][$field];
00745                 $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ? $PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type'];       // Using "form_type" locally in this script
00746 
00747                         // Now, check if this field is configured and editable (according to excludefields + other configuration)
00748                 if (    is_array($PA['fieldConf']) &&
00749                                 (!$PA['fieldConf']['exclude'] || $BE_USER->check('non_exclude_fields',$table.':'.$field)) &&
00750                                 $PA['fieldConf']['config']['form_type']!='passthrough' &&
00751                                 ($this->RTEenabled || !$PA['fieldConf']['config']['showIfRTE']) &&
00752                                 (!$PA['fieldConf']['displayCond'] || $this->isDisplayCondition($PA['fieldConf']['displayCond'],$row)) &&
00753                                 (!$TCA[$table]['ctrl']['languageField'] || $PA['fieldConf']['l10n_display'] || strcmp($PA['fieldConf']['l10n_mode'],'exclude') || $row[$TCA[$table]['ctrl']['languageField']]<=0) &&
00754                                 (!$TCA[$table]['ctrl']['languageField'] || !$this->localizationMode || $this->localizationMode===$PA['fieldConf']['l10n_cat'])
00755                         )       {
00756 
00757 
00758 
00759                                 // Fetching the TSconfig for the current table/field. This includes the $row which means that
00760                         $PA['fieldTSConfig'] = $this->setTSconfig($table,$row,$field);
00761 
00762                                 // If the field is NOT disabled from TSconfig (which it could have been) then render it
00763                         if (!$PA['fieldTSConfig']['disabled'])  {
00764 
00765                                         // Init variables:
00766                                 $PA['itemFormElName']=$this->prependFormFieldNames.'['.$table.']['.$row['uid'].']['.$field.']';         // Form field name
00767                                 $PA['itemFormElName_file']=$this->prependFormFieldNames_file.'['.$table.']['.$row['uid'].']['.$field.']';       // Form field name, in case of file uploads
00768                                 $PA['itemFormElValue']=$row[$field];            // The value to show in the form field.
00769 
00770                                         // set field to read-only if configured for translated records to show default language content as readonly
00771                                 if ($PA['fieldConf']['l10n_display'] AND t3lib_div::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly') AND $row[$TCA[$table]['ctrl']['languageField']]) {
00772                                         $PA['fieldConf']['config']['readOnly'] =  true;
00773                                         $PA['itemFormElValue'] = $this->defaultLanguageData[$table.':'.$row['uid']][$field];
00774                                 }
00775 
00776                                         // 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"
00777                                 if (
00778                                         ($TCA[$table]['ctrl']['type'] && !strcmp($field,$TCA[$table]['ctrl']['type'])) ||
00779                                         ($TCA[$table]['ctrl']['requestUpdate'] && t3lib_div::inList($TCA[$table]['ctrl']['requestUpdate'],$field))) {
00780                                         if($GLOBALS['BE_USER']->jsConfirmation(1))      {
00781                                                 $alertMsgOnChange = 'if (confirm('.$GLOBALS['LANG']->JScharCode($this->getLL('m_onChangeAlert')).') && TBE_EDITOR_checkSubmit(-1)){ TBE_EDITOR_submitForm() };';
00782                                         } else {
00783                                                 $alertMsgOnChange = 'if (TBE_EDITOR_checkSubmit(-1)){ TBE_EDITOR_submitForm() };';
00784                                         }
00785                                 } else {
00786                                         $alertMsgOnChange = '';
00787                                 }
00788 
00789                                         // Render as a hidden field?
00790                                 if (in_array($field,$this->hiddenFieldListArr)) {
00791                                         $this->hiddenFieldAccum[]='<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
00792                                 } else {        // Render as a normal field:
00793 
00794                                                 // 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.
00795                                         if (!$PA['palette'])    {
00796                                                 if ($PA['pal'] && $this->isPalettesCollapsed($table,$PA['pal']))        {
00797                                                         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);
00798                                                 } else {
00799                                                         $thePalIcon = '';
00800                                                         $palJSfunc = '';
00801                                                 }
00802                                         }
00803                                                 // onFocus attribute to add to the field:
00804                                         $PA['onFocus'] = ($palJSfunc && !$BE_USER->uc['dontShowPalettesOnFocusInAB']) ? ' onfocus="'.htmlspecialchars($palJSfunc).'"' : '';
00805 
00806                                                 // Find item
00807                                         $item='';
00808                                         $PA['label'] = $PA['altName'] ? $PA['altName'] : $PA['fieldConf']['label'];
00809                                         $PA['label'] = $this->sL($PA['label']);
00810                                                 // JavaScript code for event handlers:
00811                                         $PA['fieldChangeFunc']=array();
00812                                         $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = "TBE_EDITOR_fieldChanged('".$table."','".$row['uid']."','".$field."','".$PA['itemFormElName']."');";
00813                                         $PA['fieldChangeFunc']['alert']=$alertMsgOnChange;
00814 
00815                                                 // Based on the type of the item, call a render function:
00816                                         $item = $this->getSingleField_SW($table,$field,$row,$PA);
00817 
00818 
00819                                                 // Add language + diff
00820                                         if ($PA['fieldConf']['l10n_display'] && (t3lib_div::inList($PA['fieldConf']['l10n_display'], 'hideDiff') || t3lib_div::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly'))) {
00821                                                 $renderLanguageDiff = false;
00822                                         } else {
00823                                                 $renderLanguageDiff = true;
00824                                         }
00825 
00826                                         if ($renderLanguageDiff) {
00827                                                 $item = $this->renderDefaultLanguageContent($table,$field,$row,$item);
00828                                                 $item = $this->renderDefaultLanguageDiff($table,$field,$row,$item);
00829                                         }
00830                                                 // 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
00831                                         $PA['label'] = t3lib_div::deHSCentities(htmlspecialchars($PA['label']));
00832                                         if (t3lib_div::testInt($row['uid']) && $PA['fieldTSConfig']['linkTitleToSelf']) {
00833                                                 $lTTS_url = $this->backPath.'alt_doc.php?edit['.$table.']['.$row['uid'].']=edit&columnsOnly='.$field.
00834                                                                         ($PA['fieldTSConfig']['linkTitleToSelf.']['returnUrl']?'&returnUrl='.rawurlencode($this->thisReturnUrl()):'');
00835                                                 $PA['label'] = '<a href="'.htmlspecialchars($lTTS_url).'">'.$PA['label'].'</a>';
00836                                         }
00837 
00838                                                 // Create output value:
00839                                         if ($PA['fieldConf']['config']['form_type']=='user' && $PA['fieldConf']['config']['noTableWrapping'])   {
00840                                                 $out = $item;
00841                                         } elseif ($PA['palette'])       {
00842                                                         // Array:
00843                                                 $out=array(
00844                                                         'NAME'=>$PA['label'],
00845                                                         'ID'=>$row['uid'],
00846                                                         'FIELD'=>$field,
00847                                                         'TABLE'=>$table,
00848                                                         'ITEM'=>$item,
00849                                                         'HELP_ICON' => $this->helpTextIcon($table,$field,1)
00850                                                 );
00851                                                 $out = $this->addUserTemplateMarkers($out,$table,$field,$row,$PA);
00852                                         } else {
00853                                                         // String:
00854                                                 $out=array(
00855                                                         'NAME'=>$PA['label'],
00856                                                         'ITEM'=>$item,
00857                                                         'TABLE'=>$table,
00858                                                         'ID'=>$row['uid'],
00859                                                         'HELP_ICON'=>$this->helpTextIcon($table,$field),
00860                                                         'HELP_TEXT'=>$this->helpText($table,$field),
00861                                                         'PAL_LINK_ICON'=>$thePalIcon,
00862                                                         'FIELD'=>$field
00863                                                 );
00864                                                 $out = $this->addUserTemplateMarkers($out,$table,$field,$row,$PA);
00865                                                         // String:
00866                                                 $out=$this->intoTemplate($out);
00867                                         }
00868                                 }
00869                         } else $this->commentMessages[]=$this->prependFormFieldNames.'['.$table.']['.$row['uid'].']['.$field.']: Disabled by TSconfig';
00870                 }
00871                         // Return value (string or array)
00872                 return $out;
00873         }
00874 
00886         function getSingleField_SW($table,$field,$row,&$PA)     {
00887                 $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ? $PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type'];       // Using "form_type" locally in this script
00888 
00889                 switch($PA['fieldConf']['config']['form_type']) {
00890                         case 'input':
00891                                 $item = $this->getSingleField_typeInput($table,$field,$row,$PA);
00892                         break;
00893                         case 'text':
00894                                 $item = $this->getSingleField_typeText($table,$field,$row,$PA);
00895                         break;
00896                         case 'check':
00897                                 $item = $this->getSingleField_typeCheck($table,$field,$row,$PA);
00898                         break;
00899                         case 'radio':
00900                                 $item = $this->getSingleField_typeRadio($table,$field,$row,$PA);
00901                         break;
00902                         case 'select':
00903                                 $item = $this->getSingleField_typeSelect($table,$field,$row,$PA);
00904                         break;
00905                         case 'group':
00906                                 $item = $this->getSingleField_typeGroup($table,$field,$row,$PA);
00907                         break;
00908                         case 'none':
00909                                 $item = $this->getSingleField_typeNone($table,$field,$row,$PA);
00910                         break;
00911                         case 'user':
00912                                 $item = $this->getSingleField_typeUser($table,$field,$row,$PA);
00913                         break;
00914                         case 'flex':
00915                                 $item = $this->getSingleField_typeFlex($table,$field,$row,$PA);
00916                         break;
00917                         default:
00918                                 $item = $this->getSingleField_typeUnknown($table,$field,$row,$PA);
00919                         break;
00920                 }
00921 
00922                 return $item;
00923         }
00924 
00925 
00926 
00927 
00928 
00929 
00930 
00931 
00932 
00933 
00934 
00935 
00936 
00937 
00938 
00939 
00940 
00941 
00942 
00943         /**********************************************************
00944          *
00945          * Rendering of each TCEform field type
00946          *
00947          ************************************************************/
00948 
00959         function getSingleField_typeInput($table,$field,$row,&$PA)      {
00960                 // typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue)
00961                 // typo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off)
00962 
00963                 $config = $PA['fieldConf']['config'];
00964 
00965 #               $specConf = $this->getSpecConfForField($table,$row,$field);
00966                 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
00967                 $size = t3lib_div::intInRange($config['size']?$config['size']:30,5,$this->maxInputWidth);
00968                 $evalList = t3lib_div::trimExplode(',',$config['eval'],1);
00969 
00970 
00971                 if($this->renderReadonly || $config['readOnly'])  {
00972                         $itemFormElValue = $PA['itemFormElValue'];
00973                         if (in_array('date',$evalList)) {
00974                                 $config['format'] = 'date';
00975                         } elseif (in_array('date',$evalList))   {
00976                                 $config['format'] = 'date';
00977                         } elseif (in_array('datetime',$evalList))       {
00978                                 $config['format'] = 'datetime';
00979                         } elseif (in_array('time',$evalList))   {
00980                                 $config['format'] = 'time';
00981                         }
00982                         if (in_array('password',$evalList))     {
00983                                 $itemFormElValue = $itemFormElValue ? '*********' : '';
00984                         }
00985                         return $this->getSingleField_typeNone_render($config, $itemFormElValue);
00986                 }
00987 
00988                 if (in_array('required',$evalList))     {
00989                         $this->requiredFields[$table.'_'.$row['uid'].'_'.$field]=$PA['itemFormElName'];
00990                 }
00991 
00992                 $paramsList = "'".$PA['itemFormElName']."','".implode(',',$evalList)."','".trim($config['is_in'])."',".(isset($config['checkbox'])?1:0).",'".$config['checkbox']."'";
00993                 if (isset($config['checkbox'])) {
00994                                 // Setting default "click-checkbox" values for eval types "date" and "datetime":
00995                         $thisMidnight = mktime(0,0,0);
00996                         $checkSetValue = in_array('date',$evalList) ? $thisMidnight : '';
00997                         $checkSetValue = in_array('datetime',$evalList) ? time() : $checkSetValue;
00998 
00999                         $cOnClick = 'typo3FormFieldGet('.$paramsList.',1,\''.$checkSetValue.'\');'.implode('',$PA['fieldChangeFunc']);
01000                         $item.='<input type="checkbox"'.$this->insertDefStyle('check').' name="'.$PA['itemFormElName'].'_cb" onclick="'.htmlspecialchars($cOnClick).'" />';
01001                 }
01002 
01003                 $PA['fieldChangeFunc'] = array_merge(array('typo3FormFieldGet'=>'typo3FormFieldGet('.$paramsList.');'), $PA['fieldChangeFunc']);
01004                 $mLgd = ($config['max']?$config['max']:256);
01005                 $iOnChange = implode('',$PA['fieldChangeFunc']);
01006                 $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.
01007                 $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.
01008                 $this->extJSCODE.='typo3FormFieldSet('.$paramsList.');';
01009 
01010                         // going through all custom evaluations configured for this field
01011                 foreach ($evalList as $evalData) {
01012                         if (substr($evalData, 0, 3) == 'tx_')   {
01013                                 $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$evalData].':&'.$evalData);
01014                                 if(is_object($evalObj) && method_exists($evalObj, 'returnFieldJS'))     {
01015                                         $this->extJSCODE .= "\n\nfunction ".$evalData."(value) {\n".$evalObj->returnFieldJS()."\n}\n";
01016                                 }
01017                         }
01018                 }
01019 
01020                         // Creating an alternative item without the JavaScript handlers.
01021                 $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'_hr" value="" />';
01022                 $altItem.= '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
01023 
01024                         // Wrap a wizard around the item?
01025                 $item= $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'].'_hr',$specConf);
01026 
01027                 return $item;
01028         }
01029 
01040         function getSingleField_typeText($table,$field,$row,&$PA)       {
01041 
01042                         // Init config:
01043                 $config = $PA['fieldConf']['config'];
01044 
01045                 if($this->renderReadonly || $config['readOnly'])  {
01046                         return $this->getSingleField_typeNone_render($config, $PA['itemFormElValue']);
01047                 }
01048 
01049                         // Setting columns number:
01050                 $cols = t3lib_div::intInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
01051 
01052                         // Setting number of rows:
01053                 $origRows = $rows = t3lib_div::intInRange($config['rows'] ? $config['rows'] : 5, 1, 20);
01054                 if (strlen($PA['itemFormElValue']) > $this->charsPerRow*2)      {
01055                         $cols = $this->maxTextareaWidth;
01056                         $rows = t3lib_div::intInRange(round(strlen($PA['itemFormElValue'])/$this->charsPerRow), count(explode(chr(10),$PA['itemFormElValue'])), 20);
01057                         if ($rows<$origRows)    $rows = $origRows;
01058                 }
01059 
01060                         // Init RTE vars:
01061                 $RTEwasLoaded = 0;                              // Set true, if the RTE is loaded; If not a normal textarea is shown.
01062                 $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...
01063 
01064                         // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. Traditionally, this is where RTE configuration has been found.
01065                 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
01066 
01067                         // Setting up the altItem form field, which is a hidden field containing the value
01068                 $altItem = '<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
01069 
01070                         // If RTE is generally enabled (TYPO3_CONF_VARS and user settings)
01071                 if ($this->RTEenabled) {
01072                         $p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
01073                         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.
01074                                 t3lib_BEfunc::fixVersioningPid($table,$row);
01075                                 list($tscPID,$thePidValue) = $this->getTSCpid($table,$row['uid'],$row['pid']);
01076 
01077                                         // If the pid-value is not negative (that is, a pid could NOT be fetched)
01078                                 if ($thePidValue >= 0)  {
01079                                         $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($tscPID));
01080                                         $RTEtypeVal = t3lib_BEfunc::getTCAtypeValue($table,$row);
01081                                         $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$table,$field,$RTEtypeVal);
01082 
01083                                         if (!$thisConfig['disabled'])   {
01084                                                 if (!$this->disableRTE) {
01085                                                         $this->RTEcounter++;
01086 
01087                                                                 // Find alternative relative path for RTE images/links:
01088                                                         $eFile = t3lib_parsehtml_proc::evalWriteFile($specConf['static_write'], $row);
01089                                                         $RTErelPath = is_array($eFile) ? dirname($eFile['relEditFile']) : '';
01090 
01091                                                                 // Get RTE object, draw form and set flag:
01092                                                         $RTEobj = &t3lib_BEfunc::RTEgetObj();
01093                                                         $item = $RTEobj->drawRTE($this,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue);
01094 
01095                                                                 // Wizard:
01096                                                         $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf,1);
01097 
01098                                                         $RTEwasLoaded = 1;
01099                                                 } else {
01100                                                         $RTEwouldHaveBeenLoaded = 1;
01101                                                         $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!)';
01102                                                 }
01103                                         } else $this->commentMessages[] = $PA['itemFormElName'].': RTE is disabled by the Page TSconfig, "RTE"-key (eg. by RTE.default.disabled=0 or such)';
01104                                 } else $this->commentMessages[] = $PA['itemFormElName'].': PID value could NOT be fetched. Rare error, normally with new records.';
01105                         } else {
01106                                 if (!isset($specConf['richtext']))      $this->commentMessages[] = $PA['itemFormElName'].': RTE was not configured for this field in TCA-types';
01107                                 if (!(!$p['flag'] || !$row[$p['flag']]))         $this->commentMessages[] = $PA['itemFormElName'].': Field-flag ('.$PA['flag'].') has been set to disable RTE!';
01108                         }
01109                 }
01110 
01111                         // Display ordinary field if RTE was not loaded.
01112                 if (!$RTEwasLoaded) {
01113                         if ($specConf['rte_only'])      {       // Show message, if no RTE (field can only be edited with RTE!)
01114                                 $item = '<p><em>'.htmlspecialchars($this->getLL('l_noRTEfound')).'</em></p>';
01115                         } else {
01116                                 if ($specConf['nowrap'])        {
01117                                         $wrap = 'off';
01118                                 } else {
01119                                         $wrap = ($config['wrap'] ? $config['wrap'] : 'virtual');
01120                                 }
01121 
01122                                 $classes = array();
01123                                 if ($specConf['fixed-font'])    { $classes[] = 'fixed-font'; }
01124                                 if ($specConf['enable-tab'])    { $classes[] = 'enable-tab'; }
01125 
01126                                 if (count($classes))    {
01127                                         $class = ' class="'.implode(' ',$classes).'"';
01128                                 } else $class='';
01129 
01130                                 $iOnChange = implode('',$PA['fieldChangeFunc']);
01131                                 $item.= '
01132                                                         <textarea name="'.$PA['itemFormElName'].'"'.$this->formWidthText($cols,$wrap).$class.' rows="'.$rows.'" wrap="'.$wrap.'" onchange="'.htmlspecialchars($iOnChange).'"'.$PA['onFocus'].'>'.
01133                                                         t3lib_div::formatForTextarea($PA['itemFormElValue']).
01134                                                         '</textarea>';
01135                                 $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf,$RTEwouldHaveBeenLoaded);
01136                         }
01137                 }
01138 
01139                         // Return field HTML:
01140                 return $item;
01141         }
01142 
01153         function getSingleField_typeCheck($table,$field,$row,&$PA)      {
01154                 $config = $PA['fieldConf']['config'];
01155 
01156                 $disabled = '';
01157                 if($this->renderReadonly || $config['readOnly'])  {
01158                         $disabled = ' disabled="disabled"';
01159                 }
01160 
01161                         // Traversing the array of items:
01162                 $selItems = $this->initItemArray($PA['fieldConf']);
01163                 if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
01164 
01165                 if (!count($selItems))  {
01166                         $selItems[]=array('','');
01167                 }
01168                 $thisValue = intval($PA['itemFormElValue']);
01169 
01170                 $cols = intval($config['cols']);
01171                 if ($cols > 1)  {
01172                         $item.= '<table border="0" cellspacing="0" cellpadding="0" class="typo3-TCEforms-checkboxArray">';
01173                         for ($c=0;$c<count($selItems);$c++) {
01174                                 $p = $selItems[$c];
01175                                 if(!($c%$cols)) { $item.='<tr>'; }
01176                                 $cBP = $this->checkBoxParams($PA['itemFormElName'],$thisValue,$c,count($selItems),implode('',$PA['fieldChangeFunc']));
01177                                 $cBName = $PA['itemFormElName'].'_'.$c;
01178                                 $item.= '<td nowrap="nowrap">'.
01179                                                 '<input type="checkbox"'.$this->insertDefStyle('check').' value="1" name="'.$cBName.'"'.$cBP.$disabled.' />'.
01180                                                 $this->wrapLabels(htmlspecialchars($p[0]).'&nbsp;').
01181                                                 '</td>';
01182                                 if(($c%$cols)+1==$cols) {$item.='</tr>';}
01183                         }
01184                         if ($c%$cols)   {
01185                                 $rest=$cols-($c%$cols);
01186                                 for ($c=0;$c<$rest;$c++) {
01187                                         $item.= '<td></td>';
01188                                 }
01189                                 if ($c>0)       { $item.= '</tr>'; }
01190                         }
01191                         $item.= '</table>';
01192                 } else {
01193                         for ($c=0;$c<count($selItems);$c++) {
01194                                 $p = $selItems[$c];
01195                                 $cBP = $this->checkBoxParams($PA['itemFormElName'],$thisValue,$c,count($selItems),implode('',$PA['fieldChangeFunc']));
01196                                 $cBName = $PA['itemFormElName'].'_'.$c;
01197                                 $item.= ($c>0?'<br />':'').
01198                                                 '<input type="checkbox"'.$this->insertDefStyle('check').' value="1" name="'.$cBName.'"'.$cBP.$PA['onFocus'].$disabled.' />'.
01199                                                 htmlspecialchars($p[0]);
01200                         }
01201                 }
01202                 if (!$disabled) {
01203                         $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($thisValue).'" />';
01204                 }
01205 
01206                 return $item;
01207         }
01208 
01219         function getSingleField_typeRadio($table,$field,$row,&$PA)      {
01220                 $config = $PA['fieldConf']['config'];
01221 
01222                 $disabled = '';
01223                 if($this->renderReadonly || $config['readOnly'])  {
01224                         $disabled = ' disabled="disabled"';
01225                 }
01226 
01227                         // Get items for the array:
01228                 $selItems = $this->initItemArray($PA['fieldConf']);
01229                 if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
01230 
01231                         // Traverse the items, making the form elements:
01232                 for ($c=0;$c<count($selItems);$c++) {
01233                         $p = $selItems[$c];
01234                         $rOnClick = implode('',$PA['fieldChangeFunc']);
01235                         $rChecked = (!strcmp($p[1],$PA['itemFormElValue'])?' checked="checked"':'');
01236                         $item.= '<input type="radio"'.$this->insertDefStyle('radio').' name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($p[1]).'" onclick="'.htmlspecialchars($rOnClick).'"'.$rChecked.$PA['onFocus'].$disabled.' />'.
01237                                         htmlspecialchars($p[0]).
01238                                         '<br />';
01239                 }
01240 
01241                 return $item;
01242         }
01243 
01254         function getSingleField_typeSelect($table,$field,$row,&$PA)     {
01255                 global $TCA;
01256 
01257                         // Field configuration from TCA:
01258                 $config = $PA['fieldConf']['config'];
01259 
01260                 $disabled = '';
01261                 if($this->renderReadonly || $config['readOnly'])  {
01262                         $disabled = ' disabled="disabled"';
01263                 }
01264 
01265                         // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. See http://typo3.org/documentation/document-library/doc_core_api/Wizards_Configuratio/.
01266                 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
01267 
01268                         // Getting the selector box items from the system
01269                 $selItems = $this->addSelectOptionsToItemArray($this->initItemArray($PA['fieldConf']),$PA['fieldConf'],$this->setTSconfig($table,$row),$field);
01270                 $selItems = $this->addItems($selItems,$PA['fieldTSConfig']['addItems.']);
01271                 if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
01272 
01273                         // Possibly remove some items:
01274                 $removeItems = t3lib_div::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
01275                 foreach($selItems as $tk => $p) {
01276 
01277                                 // Checking languages and authMode:
01278                         $languageDeny = $TCA[$table]['ctrl']['languageField'] && !strcmp($TCA[$table]['ctrl']['languageField'], $field) && !$GLOBALS['BE_USER']->checkLanguageAccess($p[1]);
01279                         $authModeDeny = $config['form_type']=='select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table,$field,$p[1],$config['authMode']);
01280                         if (in_array($p[1],$removeItems) || $languageDeny || $authModeDeny)     {
01281                                 unset($selItems[$tk]);
01282                         } elseif (isset($PA['fieldTSConfig']['altLabels.'][$p[1]])) {
01283                                 $selItems[$tk][0]=$this->sL($PA['fieldTSConfig']['altLabels.'][$p[1]]);
01284                         }
01285 
01286                                 // Removing doktypes with no access:
01287                         if ($table.'.'.$field == 'pages.doktype')       {
01288                                 if (!($GLOBALS['BE_USER']->isAdmin() || t3lib_div::inList($GLOBALS['BE_USER']->groupData['pagetypes_select'],$p[1])))   {
01289                                         unset($selItems[$tk]);
01290                                 }
01291                         }
01292                 }
01293 
01294                         // Creating the label for the "No Matching Value" entry.
01295                 $nMV_label = isset($PA['fieldTSConfig']['noMatchingValue_label']) ? $this->sL($PA['fieldTSConfig']['noMatchingValue_label']) : '[ '.$this->getLL('l_noMatchingValue').' ]';
01296 
01297                         // Prepare some values:
01298                 $maxitems = intval($config['maxitems']);
01299 
01300                         // If a SINGLE selector box...
01301                 if ($maxitems<=1)       {
01302                         $item = $this->getSingleField_typeSelect_single($table,$field,$row,$PA,$config,$selItems,$nMV_label);
01303                 } elseif (!strcmp($config['renderMode'],'checkbox'))    {       // Checkbox renderMode
01304                         $item = $this->getSingleField_typeSelect_checkbox($table,$field,$row,$PA,$config,$selItems,$nMV_label);
01305                 } elseif (!strcmp($config['renderMode'],'singlebox'))   {       // Single selector box renderMode
01306                         $item = $this->getSingleField_typeSelect_singlebox($table,$field,$row,$PA,$config,$selItems,$nMV_label);
01307                 } else {        // Traditional multiple selector box:
01308                         $item = $this->getSingleField_typeSelect_multiple($table,$field,$row,$PA,$config,$selItems,$nMV_label);
01309                 }
01310 
01311                         // Wizards:
01312                 if (!$disabled) {
01313                         $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
01314                         $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf);
01315                 }
01316 
01317                 return $item;
01318         }
01319 
01334         function getSingleField_typeSelect_single($table,$field,$row,&$PA,$config,$selItems,$nMV_label) {
01335 
01336                         // Initialization:
01337                 $c = 0;
01338                 $sI = 0;
01339                 $noMatchingValue = 1;
01340                 $opt = array();
01341                 $selicons = array();
01342                 $onlySelectedIconShown = 0;
01343                 $size = intval($config['size']);
01344 
01345                 $disabled = '';
01346                 if($this->renderReadonly || $config['readOnly'])  {
01347                         $disabled = ' disabled="disabled"';
01348                         $onlySelectedIconShown = 1;
01349                 }
01350 
01351                         // Icon configuration:
01352                 if ($config['suppress_icons']=='IF_VALUE_FALSE')        {
01353                         $suppressIcons = !$PA['itemFormElValue'] ? 1 : 0;
01354                 } elseif ($config['suppress_icons']=='ONLY_SELECTED')   {
01355                         $suppressIcons=0;
01356                         $onlySelectedIconShown=1;
01357                 } elseif ($config['suppress_icons'])    {
01358                         $suppressIcons = 1;
01359                 } else $suppressIcons = 0;
01360 
01361                         // Traverse the Array of selector box items:
01362                 foreach($selItems as $p)        {
01363                         $sM = (!strcmp($PA['itemFormElValue'],$p[1])?' selected="selected"':'');
01364                         if ($sM)        {
01365                                 $sI = $c;
01366                                 $noMatchingValue = 0;
01367                         }
01368 
01369                                 // Getting style attribute value (for icons):
01370                         if ($config['iconsInOptionTags'])       {
01371                                 $styleAttrValue = $this->optionTagStyle($p[2]);
01372                         }
01373 
01374                                 // Compiling the <option> tag:
01375                         $opt[]= '<option value="'.htmlspecialchars($p[1]).'"'.
01376                                                 $sM.
01377                                                 ($styleAttrValue ? ' style="'.htmlspecialchars($styleAttrValue).'"' : '').
01378                                                 (!strcmp($p[1],'--div--') ? ' class="c-divider"' : '').
01379                                                 '>'.t3lib_div::deHSCentities(htmlspecialchars($p[0])).'</option>';
01380 
01381                                 // If there is an icon for the selector box (rendered in table under)...:
01382                         if ($p[2] && !$suppressIcons && (!$onlySelectedIconShown || $sM))       {
01383                                 list($selIconFile,$selIconInfo)=$this->getIcon($p[2]);
01384                                 $iOnClick = $this->elName($PA['itemFormElName']).'.selectedIndex='.$c.'; '.implode('',$PA['fieldChangeFunc']).$this->blur().'return false;';
01385                                 $selicons[]=array(
01386                                         (!$onlySelectedIconShown ? '<a href="#" onclick="'.htmlspecialchars($iOnClick).'">' : '').
01387                                         '<img src="'.$selIconFile.'" '.$selIconInfo[3].' vspace="2" border="0" title="'.htmlspecialchars($p[0]).'" alt="'.htmlspecialchars($p[0]).'" />'.
01388                                         (!$onlySelectedIconShown ? '</a>' : ''),
01389                                         $c,$sM);
01390                         }
01391                         $c++;
01392                 }
01393 
01394                         // No-matching-value:
01395                 if ($PA['itemFormElValue'] && $noMatchingValue && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement'])  {
01396                         $nMV_label = @sprintf($nMV_label, $PA['itemFormElValue']);
01397                         $opt[]= '<option value="'.htmlspecialchars($PA['itemFormElValue']).'" selected="selected">'.htmlspecialchars($nMV_label).'</option>';
01398                 }
01399 
01400                         // Create item form fields:
01401                 $sOnChange = 'if (this.options[this.selectedIndex].value==\'--div--\') {this.selectedIndex='.$sI.';} '.implode('',$PA['fieldChangeFunc']);
01402                 if(!$disabled) {
01403                         $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...
01404                 }
01405                 $item.= '<select name="'.$PA['itemFormElName'].'"'.
01406                                         $this->insertDefStyle('select').
01407                                         ($size?' size="'.$size.'"':'').
01408                                         ' onchange="'.htmlspecialchars($sOnChange).'"'.
01409                                         $PA['onFocus'].$disabled.'>';
01410                 $item.= implode('',$opt);
01411                 $item.= '</select>';
01412 
01413                         // Create icon table:
01414                 if (count($selicons))   {
01415                         $item.='<table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-selectIcons">';
01416                         $selicon_cols = intval($config['selicon_cols']);
01417                         if (!$selicon_cols)     $selicon_cols=count($selicons);
01418                         $sR = ceil(count($selicons)/$selicon_cols);
01419                         $selicons = array_pad($selicons,$sR*$selicon_cols,'');
01420                         for($sa=0;$sa<$sR;$sa++)        {
01421                                 $item.='<tr>';
01422                                 for($sb=0;$sb<$selicon_cols;$sb++)      {
01423                                         $sk=($sa*$selicon_cols+$sb);
01424                                         $imgN = 'selIcon_'.$table.'_'.$row['uid'].'_'.$field.'_'.$selicons[$sk][1];
01425                                         $imgS = ($selicons[$sk][2]?$this->backPath.'gfx/content_selected.gif':'clear.gif');
01426                                         $item.='<td><img name="'.htmlspecialchars($imgN).'" src="'.$imgS.'" width="7" height="10" alt="" /></td>';
01427                                         $item.='<td>'.$selicons[$sk][0].'</td>';
01428                                 }
01429                                 $item.='</tr>';
01430                         }
01431                         $item.='</table>';
01432                 }
01433 
01434                 return $item;
01435         }
01436 
01451         function getSingleField_typeSelect_checkbox($table,$field,$row,&$PA,$config,$selItems,$nMV_label)       {
01452 
01453                         // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
01454                 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
01455 
01456                 $disabled = '';
01457                 if($this->renderReadonly || $config['readOnly'])  {
01458                         $disabled = ' disabled="disabled"';
01459                 }
01460 
01461                         // Traverse the Array of selector box items:
01462                 $tRows = array();
01463                 $c=0;
01464                 if (!$disabled) {
01465                         $sOnChange = implode('',$PA['fieldChangeFunc']);
01466                         $setAll = array();      // Used to accumulate the JS needed to restore the original selection.
01467                         foreach($selItems as $p)        {
01468                                         // Non-selectable element:
01469                                 if (!strcmp($p[1],'--div--'))   {
01470                                         if (count($setAll))     {
01471                                                         $tRows[] = '
01472                                                                 <tr>
01473                                                                         <td colspan="2">'.
01474                                                                         '<a href="#" onclick="'.htmlspecialchars(implode('',$setAll).' return false;').'">'.
01475                                                                         htmlspecialchars($this->getLL('l_setAllCheckboxes')).
01476                                                                         '</a></td>
01477                                                                 </tr>';
01478                                                         $setAll = array();
01479                                         }
01480 
01481                                         $tRows[] = '
01482                                                 <tr class="c-header">
01483                                                         <td colspan="2">'.htmlspecialchars($p[0]).'</td>
01484                                                 </tr>';
01485                                 } else {
01486                                                 // Selected or not by default:
01487                                         $sM = '';
01488                                         if (isset($itemArray[$p[1]]))   {
01489                                                 $sM = ' checked="checked"';
01490                                                 unset($itemArray[$p[1]]);
01491                                         }
01492 
01493                                                 // Icon:
01494                                         $selIconFile = '';
01495                                         if ($p[2])      {
01496                                                 list($selIconFile,$selIconInfo) = $this->getIcon($p[2]);
01497                                         }
01498 
01499                                                 // Compile row:
01500                                         $onClickCell = $this->elName($PA['itemFormElName'].'['.$c.']').'.checked=!'.$this->elName($PA['itemFormElName'].'['.$c.']').'.checked;';
01501                                         $onClick = 'this.attributes.getNamedItem("class").nodeValue = '.$this->elName($PA['itemFormElName'].'['.$c.']').'.checked ? "c-selectedItem" : "";';
01502                                         $setAll[] = $this->elName($PA['itemFormElName'].'['.$c.']').'.checked=1;';
01503                                         $tRows[] = '
01504                                                 <tr class="'.($sM ? 'c-selectedItem' : '').'" onclick="'.htmlspecialchars($onClick).'" style="cursor: pointer;">
01505                                                         <td><input type="checkbox"'.$this->insertDefStyle('check').' name="'.htmlspecialchars($PA['itemFormElName'].'['.$c.']').'" value="'.htmlspecialchars($p[1]).'"'.$sM.' onclick="'.htmlspecialchars($sOnChange).'"'.$PA['onFocus'].' /></td>
01506                                                         <td class="c-labelCell" onclick="'.htmlspecialchars($onClickCell).'">'.
01507                                                                 ($selIconFile ? '<img src="'.$selIconFile.'" '.$selIconInfo[3].' vspace="2" border="0" class="absmiddle" style="margin-right: 4px;" alt="" />' : '').
01508                                                                 t3lib_div::deHSCentities(htmlspecialchars($p[0])).
01509                                                                 (strcmp($p[3],'') ? '<br/><p class="c-descr">'.nl2br(trim(htmlspecialchars($p[3]))).'</p>' : '').
01510                                                                 '</td>
01511                                                 </tr>';
01512                                         $c++;
01513                                 }
01514                         }
01515 
01516                                 // Remaining checkboxes will get their set-all link:
01517                         if (count($setAll))     {
01518                                         $tRows[] = '
01519                                                 <tr>
01520                                                         <td colspan="2">'.
01521                                                         '<a href="#" onclick="'.htmlspecialchars(implode('',$setAll).' return false;').'">'.
01522                                                         htmlspecialchars($this->getLL('l_setAllCheckboxes')).
01523                                                         '</a></td>
01524                                                 </tr>';
01525                         }
01526                 }
01527 
01528                         // Remaining values (invalid):
01529                 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement'])   {
01530                         foreach($itemArray as $theNoMatchValue => $temp)        {
01531                                         // Compile <checkboxes> tag:
01532                                 array_unshift($tRows,'
01533                                                 <tr class="c-invalidItem">
01534                                                         <td><input type="checkbox"'.$this->insertDefStyle('check').' name="'.htmlspecialchars($PA['itemFormElName'].'['.$c.']').'" value="'.htmlspecialchars($theNoMatchValue).'" checked="checked" onclick="'.htmlspecialchars($sOnChange).'"'.$PA['onFocus'].$disabled.' /></td>
01535                                                         <td class="c-labelCell">'.
01536                                                                 t3lib_div::deHSCentities(htmlspecialchars(@sprintf($nMV_label, $theNoMatchValue))).
01537                                                                 '</td>
01538                                                 </tr>');
01539                                 $c++;
01540                         }
01541                 }
01542 
01543                         // Add an empty hidden field which will send a blank value if all items are unselected.
01544                 $item.='<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="" />';
01545 
01546                         // Implode rows in table:
01547                 $item.= '
01548                         <table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-select-checkbox">'.
01549                                 implode('',$tRows).'
01550                         </table>
01551                         ';
01552 
01553                 return $item;
01554         }
01555 
01570         function getSingleField_typeSelect_singlebox($table,$field,$row,&$PA,$config,$selItems,$nMV_label)      {
01571 
01572                         // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
01573                 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
01574 
01575                 $disabled = '';
01576                 if($this->renderReadonly || $config['readOnly'])  {
01577                         $disabled = ' disabled="disabled"';
01578                 }
01579 
01580                         // Traverse the Array of selector box items:
01581                 $opt = array();
01582                 $restoreCmd = array();  // Used to accumulate the JS needed to restore the original selection.
01583                 $c = 0;
01584                 foreach($selItems as $p)        {
01585                                 // Selected or not by default:
01586                         $sM = '';
01587                         if (isset($itemArray[$p[1]]))   {
01588                                 $sM = ' selected="selected"';
01589                                 $restoreCmd[] = $this->elName($PA['itemFormElName'].'[]').'.options['.$c.'].selected=1;';
01590                                 unset($itemArray[$p[1]]);
01591                         }
01592 
01593                                 // Non-selectable element:
01594                         $nonSel = '';
01595                         if (!strcmp($p[1],'--div--'))   {
01596                                 $nonSel = ' onclick="this.selected=0;" class="c-divider"';
01597                         }
01598 
01599                                 // Icon style for option tag:
01600                         if ($config['iconsInOptionTags']) {
01601                                 $styleAttrValue = $this->optionTagStyle($p[2]);
01602                         }
01603 
01604                                 // Compile <option> tag:
01605                         $opt[] = '<option value="'.htmlspecialchars($p[1]).'"'.
01606                                                 $sM.
01607                                                 $nonSel.
01608                                                 ($styleAttrValue ? ' style="'.htmlspecialchars($styleAttrValue).'"' : '').
01609                                                 '>'.t3lib_div::deHSCentities(htmlspecialchars($p[0])).'</option>';
01610                         $c++;
01611                 }
01612 
01613                         // Remaining values:
01614                 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement'])   {
01615                         foreach($itemArray as $theNoMatchValue => $temp)        {
01616                                         // Compile <option> tag:
01617                                 array_unshift($opt,'<option value="'.htmlspecialchars($theNoMatchValue).'" selected="selected">'.t3lib_div::deHSCentities(htmlspecialchars(@sprintf($nMV_label, $theNoMatchValue))).'</option>');
01618                         }
01619                 }
01620 
01621                         // Compile selector box:
01622                 $sOnChange = implode('',$PA['fieldChangeFunc']);
01623                 $selector_itemListStyle = isset($config['itemListStyle']) ? ' style="'.htmlspecialchars($config['itemListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"';
01624                 $size = intval($config['size']);
01625                 $size = $config['autoSizeMax'] ? t3lib_div::intInRange(count($selItems)+1,t3lib_div::intInRange($size,1),$config['autoSizeMax']) : $size;
01626                 $selectBox = '<select name="'.$PA['itemFormElName'].'[]"'.
01627                                                 $this->insertDefStyle('select').
01628                                                 ($size ? ' size="'.$size.'"' : '').
01629                                                 ' multiple="multiple" onchange="'.htmlspecialchars($sOnChange).'"'.
01630                                                 $PA['onFocus'].
01631                                                 $selector_itemListStyle.
01632                                                 $disabled.'>
01633                                                 '.
01634                                         implode('
01635                                                 ',$opt).'
01636                                         </select>';
01637 
01638                         // Add an empty hidden field which will send a blank value if all items are unselected.
01639                 if (!$disabled) {
01640                         $item.='<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="" />';
01641                 }
01642 
01643                         // Put it all into a table:
01644                 $item.= '
01645                         <table border="0" cellspacing="0" cellpadding="0" width="1" class="typo3-TCEforms-select-singlebox">
01646                                 <tr>
01647                                         <td>
01648                                         '.$selectBox.'
01649                                         <br/>
01650                                         <em>'.
01651                                                 htmlspecialchars($this->getLL('l_holdDownCTRL')).
01652                                                 '</em>
01653                                         </td>
01654                                         <td valign="top">
01655                                         <a href="#" onclick="'.htmlspecialchars($this->elName($PA['itemFormElName'].'[]').'.selectedIndex=-1;'.implode('',$restoreCmd).' return false;').'">'.
01656                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/history.gif','width="13" height="12"').' title="'.htmlspecialchars($this->getLL('l_revertSelection')).'" alt="" />'.
01657                                                 '</a>
01658                                         </td>
01659                                 </tr>
01660                         </table>
01661                                 ';
01662 
01663                 return $item;
01664         }
01665 
01680         function getSingleField_typeSelect_multiple($table,$field,$row,&$PA,$config,$selItems,$nMV_label)       {
01681 
01682                 $disabled = '';
01683                 if($this->renderReadonly || $config['readOnly'])  {
01684                         $disabled = ' disabled="disabled"';
01685                 }
01686 
01687                         // Setting this hidden field (as a flag that JavaScript can read out)
01688                 if (!$disabled) {
01689                         $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'_mul" value="'.($config['multiple']?1:0).'" />';
01690                 }
01691 
01692                         // Set max and min items:
01693                 $maxitems = t3lib_div::intInRange($config['maxitems'],0);
01694                 if (!$maxitems) $maxitems=100000;
01695                 $minitems = t3lib_div::intInRange($config['minitems'],0);
01696 
01697                         // Register the required number of elements:
01698                 $this->requiredElements[$PA['itemFormElName']] = array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field);
01699 
01700                         // Get "removeItems":
01701                 $removeItems = t3lib_div::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
01702 
01703                         // Perform modification of the selected items array:
01704                 $itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
01705                 foreach($itemArray as $tk => $tv) {
01706                         $tvP = explode('|',$tv,2);
01707                         $evalValue = rawurldecode($tvP[0]);
01708                         $isRemoved = in_array($evalValue,$removeItems)  || ($config['form_type']=='select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table,$field,$evalValue,$config['authMode']));
01709                         if ($isRemoved && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement'])  {
01710                                 $tvP[1] = rawurlencode(@sprintf($nMV_label, $evalValue));
01711                         } elseif (isset($PA['fieldTSConfig']['altLabels.'][$evalValue])) {
01712                                 $tvP[1] = rawurlencode($this->sL($PA['fieldTSConfig']['altLabels.'][$evalValue]));
01713                         }
01714                         $itemArray[$tk] = implode('|',$tvP);
01715                 }
01716                 $itemsToSelect = '';
01717 
01718                 if(!$disabled) {
01719                                 // Create option tags:
01720                         $opt = array();
01721                         $styleAttrValue = '';
01722                         foreach($selItems as $p)        {
01723                                 if ($config['iconsInOptionTags'])       {
01724                                         $styleAttrValue = $this->optionTagStyle($p[2]);
01725                                 }
01726                                 $opt[]= '<option value="'.htmlspecialchars($p[1]).'"'.
01727                                                                 ($styleAttrValue ? ' style="'.htmlspecialchars($styleAttrValue).'"' : '').
01728                                                                 '>'.htmlspecialchars($p[0]).'</option>';
01729                         }
01730 
01731                                 // Put together the selector box:
01732                         $selector_itemListStyle = isset($config['itemListStyle']) ? ' style="'.htmlspecialchars($config['itemListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"';
01733                         $size = intval($config['size']);
01734                         $size = $config['autoSizeMax'] ? t3lib_div::intInRange(count($itemArray)+1,t3lib_div::intInRange($size,1),$config['autoSizeMax']) : $size;
01735                         if ($config['exclusiveKeys'])   {
01736                                 $sOnChange = 'setFormValueFromBrowseWin(\''.$PA['itemFormElName'].'\',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text,\''.$config['exclusiveKeys'].'\'); ';
01737                         } else {
01738                                 $sOnChange = 'setFormValueFromBrowseWin(\''.$PA['itemFormElName'].'\',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text); ';
01739                         }
01740                         $sOnChange .= implode('',$PA['fieldChangeFunc']);
01741                         $itemsToSelect = '
01742                                 <select name="'.$PA['itemFormElName'].'_sel"'.
01743                                                         $this->insertDefStyle('select').
01744                                                         ($size ? ' size="'.$size.'"' : '').
01745                                                         ' onchange="'.htmlspecialchars($sOnChange).'"'.
01746                                                         $PA['onFocus'].
01747                                                         $selector_itemListStyle.'>
01748                                         '.implode('
01749                                         ',$opt).'
01750                                 </select>';
01751                 }
01752 
01753                         // Pass to "dbFileIcons" function:
01754                 $params = array(
01755                         'size' => $size,
01756                         'autoSizeMax' => t3lib_div::intInRange($config['autoSizeMax'],0),
01757                         'style' => isset($config['selectedListStyle']) ? ' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"',
01758                         'dontShowMoveIcons' => ($maxitems<=1),
01759                         'maxitems' => $maxitems,
01760                         'info' => '',
01761                         'headers' => array(
01762                                 'selector' => $this->getLL('l_selected').':<br />',
01763                                 'items' => $this->getLL('l_items').':<br />'
01764                         ),
01765                         'noBrowser' => 1,
01766                         'thumbnails' => $itemsToSelect,
01767                         'readOnly' => $disabled
01768                 );
01769                 $item.= $this->dbFileIcons($PA['itemFormElName'],'','',$itemArray,'',$params,$PA['onFocus']);
01770 
01771                 return $item;
01772         }
01773 
01784         function getSingleField_typeGroup($table,$field,$row,&$PA)      {
01785                         // Init:
01786                 $config = $PA['fieldConf']['config'];
01787                 $internal_type = $config['internal_type'];
01788                 $show_thumbs = $config['show_thumbs'];
01789                 $size = intval($config['size']);
01790                 $maxitems = t3lib_div::intInRange($config['maxitems'],0);
01791                 if (!$maxitems) $maxitems=100000;
01792                 $minitems = t3lib_div::intInRange($config['minitems'],0);
01793                 $allowed = $config['allowed'];
01794                 $disallowed = $config['disallowed'];
01795 
01796                 $disabled = '';
01797                 if($this->renderReadonly || $config['readOnly'])  {
01798                         $disabled = ' disabled="disabled"';
01799                 }
01800 
01801                 $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'_mul" value="'.($config['multiple']?1:0).'"'.$disabled.' />';
01802                 $this->requiredElements[$PA['itemFormElName']] = array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field);
01803                 $info='';
01804 
01805                         // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. See http://typo3.org/documentation/document-library/doc_core_api/Wizards_Configuratio/.
01806                 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
01807 
01808                         // Acting according to either "file" or "db" type:
01809                 switch((string)$config['internal_type'])        {
01810                         case 'file':    // If the element is of the internal type "file":
01811 
01812                                         // Creating string showing allowed types:
01813                                 $tempFT = t3lib_div::trimExplode(',',$allowed,1);
01814                                 if (!count($tempFT))    {$info.='*';}
01815                                 foreach($tempFT as $ext)        {
01816                                         if ($ext)       {
01817                                                 $info.=strtoupper($ext).' ';
01818                                         }
01819                                 }
01820                                         // Creating string, showing disallowed types:
01821                                 $tempFT_dis = t3lib_div::trimExplode(',',$disallowed,1);
01822                                 if (count($tempFT_dis)) {$info.='<br />';}
01823                                 foreach($tempFT_dis as $ext)    {
01824                                         if ($ext)       {
01825                                                 $info.='-'.strtoupper($ext).' ';
01826                                         }
01827                                 }
01828 
01829                                         // Making the array of file items:
01830                                 $itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
01831 
01832                                         // Showing thumbnails:
01833                                 $thumbsnail = '';
01834                                 if ($show_thumbs)       {
01835                                         $imgs = array();
01836                                         foreach($itemArray as $imgRead) {
01837                                                 $imgP = explode('|',$imgRead);
01838 
01839                                                 $rowCopy = array();
01840                                                 $rowCopy[$field] = $imgP[0];
01841 
01842                                                         // Icon + clickmenu:
01843                                                 $absFilePath = t3lib_div::getFileAbsFileName($config['uploadfolder'].'/'.$imgP[0]);
01844 
01845                                                 $fI = pathinfo($imgP[0]);
01846                                                 $fileIcon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
01847                                                 $fileIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/fileicons/'.$fileIcon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].($absFilePath && @is_file($absFilePath) ? ' ('.t3lib_div::formatSize(filesize($absFilePath)).'bytes)' : ' - FILE NOT FOUND!')).'" alt="" />';
01848 
01849                                                 $imgs[] = '<span class="nobr">'.t3lib_BEfunc::thumbCode($rowCopy,$table,$field,$this->backPath,'thumbs.php',$config['uploadfolder'],0,' align="middle"').
01850                                                                         ($absFilePath ? $this->getClickMenu($fileIcon, $absFilePath) : $fileIcon).
01851                                                                         $imgP[0].
01852                                                                         '</span>';
01853                                         }
01854                                         $thumbsnail = implode('<br />',$imgs);
01855                                 }
01856 
01857                                         // Creating the element:
01858                                 $params = array(
01859                                         'size' => $size,
01860                                         'dontShowMoveIcons' => ($maxitems<=1),
01861                                         'autoSizeMax' => t3lib_div::intInRange($config['autoSizeMax'],0),
01862                                         'maxitems' => $maxitems,
01863                                         'style' => isset($config['selectedListStyle']) ? ' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"',
01864                                         'info' => $info,
01865                                         'thumbnails' => $thumbsnail,
01866                                         'readOnly' => $disabled
01867                                 );
01868                                 $item.= $this->dbFileIcons($PA['itemFormElName'],'file',implode(',',$tempFT),$itemArray,'',$params,$PA['onFocus']);
01869 
01870                                 if(!$disabled) {
01871                                                 // Adding the upload field:
01872                                         if ($this->edit_docModuleUpload)        $item.='<input type="file" name="'.$PA['itemFormElName_file'].'"'.$this->formWidth().' size="60" />';
01873                                 }
01874                         break;
01875                         case 'db':      // If the element is of the internal type "db":
01876 
01877                                         // Creating string showing allowed types:
01878                                 $tempFT = t3lib_div::trimExplode(',',$allowed,1);
01879                                 if (!strcmp(trim($tempFT[0]),'*'))      {
01880                                         $info.='<span class="nobr">&nbsp;&nbsp;&nbsp;&nbsp;'.
01881                                                         htmlspecialchars($this->getLL('l_allTables')).
01882                                                         '</span><br />';
01883                                 } else {
01884                                         while(list(,$theT)=each($tempFT))       {
01885                                                 if ($theT)      {
01886                                                         $info.='<span class="nobr">&nbsp;&nbsp;&nbsp;&nbsp;'.
01887                                                                         t3lib_iconWorks::getIconImage($theT,array(),$this->backPath,'align="top"').
01888                                                                         htmlspecialchars($this->sL($GLOBALS['TCA'][$theT]['ctrl']['title'])).
01889                                                                         '</span><br />';
01890                                                 }
01891                                         }
01892                                 }
01893 
01894                                 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
01895                                 $itemArray = array();
01896                                 $imgs = array();
01897 
01898                                         // Thumbnails:
01899                                 $temp_itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
01900                                 foreach($temp_itemArray as $dbRead)     {
01901                                         $recordParts = explode('|',$dbRead);
01902                                         list($this_table,$this_uid) = t3lib_BEfunc::splitTable_Uid($recordParts[0]);
01903                                         $itemArray[] = array('table'=>$this_table, 'id'=>$this_uid);
01904                                         if (!$disabled && $show_thumbs) {
01905                                                 $rr = t3lib_BEfunc::getRecordWSOL($this_table,$this_uid);
01906                                                 $imgs[] = '<span class="nobr">'.
01907                                                                 $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).
01908                                                                 '&nbsp;'.
01909                                                                 htmlspecialchars(t3lib_div::fixed_lgd_cs($this->noTitle($rr[$GLOBALS['TCA'][$this_table]['ctrl']['label']],array('<em>','</em>')),$this->titleLen)).' <span class="typo3-dimmed"><em>['.$rr['uid'].']</em></span>'.
01910                                                                 '</span>';
01911                                         }
01912                                 }
01913                                 $thumbsnail='';
01914                                 if (!$disabled && $show_thumbs) {
01915                                         $thumbsnail = implode('<br />',$imgs);
01916                                 }
01917 
01918                                         // Creating the element:
01919                                 $params = array(
01920                                         'size' => $size,
01921                                         'dontShowMoveIcons' => ($maxitems<=1),
01922                                         'autoSizeMax' => t3lib_div::intInRange($config['autoSizeMax'],0),
01923                                         'maxitems' => $maxitems,
01924                                         'style' => isset($config['selectedListStyle']) ? ' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"',
01925                                         'info' => $info,
01926                                         'thumbnails' => $thumbsnail,
01927                                         'readOnly' => $disabled
01928                                 );
01929                                 $item.= $this->dbFileIcons($PA['itemFormElName'],'db',implode(',',$tempFT),$itemArray,'',$params,$PA['onFocus']);
01930 
01931                         break;
01932                 }
01933 
01934                         // Wizards:
01935                 $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
01936                 if (!$disabled) {
01937                         $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf);
01938                 }
01939 
01940                 return $item;
01941         }
01942 
01953         function getSingleField_typeNone($table,$field,$row,&$PA)       {
01954                         // Init:
01955                 $config = $PA['fieldConf']['config'];
01956                 $itemValue = $PA['itemFormElValue'];
01957 
01958                 return $this->getSingleField_typeNone_render($config,$itemValue);
01959         }
01960 
01969         function getSingleField_typeNone_render($config,$itemValue)     {
01970 
01971                                 // is colorScheme[0] the right value?
01972                 $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;';
01973 
01974                 if ($config['format'])  {
01975                         $itemValue = $this->formatValue($config, $itemValue);
01976                 }
01977 
01978                 $rows = intval($config['rows']);
01979                 if ($rows > 1) {
01980                         if(!$config['pass_content']) {
01981                                 $itemValue = nl2br(htmlspecialchars($itemValue));
01982                         }
01983                                 // like textarea
01984                         $cols = t3lib_div::intInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
01985                         if (!$config['fixedRows']) {
01986                                 $origRows = $rows = t3lib_div::intInRange($rows, 1, 20);
01987                                 if (strlen($itemValue)>$this->charsPerRow*2)    {
01988                                         $cols = $this->maxTextareaWidth;
01989                                         $rows = t3lib_div::intInRange(round(strlen($itemValue)/$this->charsPerRow),count(explode(chr(10),$itemValue)),20);
01990                                         if ($rows<$origRows)    $rows=$origRows;
01991                                 }
01992                         }
01993 
01994                         if ($this->docLarge)    $cols = round($cols*$this->form_largeComp);
01995                         $width = ceil($cols*$this->form_rowsToStylewidth);
01996                                 // hardcoded: 12 is the height of the font
01997                         $height=$rows*12;
01998 
01999                         $item='
02000                                 <div style="'.htmlspecialchars($divStyle.' overflow:auto; height:'.$height.'px; width:'.$width.'px;').'" class="'.htmlspecialchars($this->formElClass('none')).'">'.
02001                                 $itemValue.
02002                                 '</div>';
02003                 } else {
02004                         if(!$config['pass_content']) {
02005                                 $itemValue = htmlspecialchars($itemValue);
02006                         }
02007 
02008                         $cols = $config['cols']?$config['cols']:($config['size']?$config['size']:$this->maxInputWidth);
02009                         if ($this->docLarge)    $cols = round($cols*$this->form_largeComp);
02010                         $width = ceil($cols*$this->form_rowsToStylewidth);
02011 
02012                                 // overflow:auto crashes mozilla here. Title tag is usefull when text is longer than the div box (overflow:hidden).
02013                         $item = '
02014                                 <div style="'.htmlspecialchars($divStyle.' overflow:hidden; width:'.$width.'px;').'" class="'.htmlspecialchars($this->formElClass('none')).'" title="'.$itemValue.'">'.
02015                                 '<span class="nobr">'.(strcmp($itemValue,'')?$itemValue:'&nbsp;').'</span>'.
02016                                 '</div>';
02017                 }
02018 
02019                 return $item;
02020         }
02021 
02031         function getSingleField_typeFlex($table,$field,$row,&$PA)       {
02032 
02033                         // Data Structure:
02034                 $dataStructArray = t3lib_BEfunc::getFlexFormDS($PA['fieldConf']['config'],$row,$table);
02035 
02036                         // Get data structure:
02037                 if (is_array($dataStructArray)) {
02038 
02039                                 // Get data:
02040                         $xmlData = $PA['itemFormElValue'];
02041                         $xmlHeaderAttributes = t3lib_div::xmlGetHeaderAttribs($xmlData);
02042                         $storeInCharset = strtolower($xmlHeaderAttributes['encoding']);
02043                         if ($storeInCharset)    {
02044                                 $currentCharset=$GLOBALS['LANG']->charSet;
02045                                 $xmlData = $GLOBALS['LANG']->csConvObj->conv($xmlData,$storeInCharset,$currentCharset,1);
02046                         }
02047                         $editData=t3lib_div::xml2array($xmlData);
02048                         if (!is_array($editData))       {       // Must be XML parsing error...
02049                                 $editData=array();
02050                         } elseif (isset($editData['meta']) && !is_array($editData['meta']))     {
02051                             $editData['meta'] = array();
02052                         }
02053 
02054                                 // Find the data structure if sheets are found:
02055                         $sheet = $editData['meta']['currentSheetId'] ? $editData['meta']['currentSheetId'] : 'sDEF';    // Sheet to display
02056 
02057                                 // Create sheet menu:
02058 //                      if (is_array($dataStructArray['sheets']))       {
02059 //                              #$item.=$this->getSingleField_typeFlex_sheetMenu($dataStructArray['sheets'], $PA['itemFormElName'].'[meta][currentSheetId]', $sheet).'<br />';
02060 //                      }
02061 
02062                                 // Create language menu:
02063                         $langChildren = $dataStructArray['meta']['langChildren'] ? 1 : 0;
02064                         $langDisabled = $dataStructArray['meta']['langDisable'] ? 1 : 0;
02065 
02066                         $editData['meta']['currentLangId']=array();
02067                         $languages = $this->getAvailableLanguages();
02068 
02069                         foreach($languages as $lInfo)   {
02070                                 if ($GLOBALS['BE_USER']->checkLanguageAccess($lInfo['uid']))    {
02071                                         $editData['meta']['currentLangId'][] =  $lInfo['ISOcode'];
02072                                 }
02073                         }
02074                         if (!is_array($editData['meta']['currentLangId']) || !count($editData['meta']['currentLangId']))        {
02075                                 $editData['meta']['currentLangId']=array('DEF');
02076                         }
02077 
02078                         $editData['meta']['currentLangId'] = array_unique($editData['meta']['currentLangId']);
02079 
02080 
02081 //                      if (!$langDisabled && count($languages) > 1)    {
02082 //                              $item.=$this->getSingleField_typeFlex_langMenu($languages, $PA['itemFormElName'].'[meta][currentLangId]', $editData['meta']['currentLangId']).'<br />';
02083 //                      }
02084 
02085                         $PA['_noEditDEF'] = FALSE;
02086                         if ($langChildren || $langDisabled)     {
02087                                 $rotateLang = array('DEF');
02088                         } else {
02089                                 if (!in_array('DEF',$editData['meta']['currentLangId']))        {
02090                                         array_unshift($editData['meta']['currentLangId'],'DEF');
02091                                         $PA['_noEditDEF'] = TRUE;
02092                                 }
02093                                 $rotateLang = $editData['meta']['currentLangId'];
02094                         }
02095 
02096                                 // Tabs sheets
02097                         if (is_array($dataStructArray['sheets']))       {
02098                                 $tabsToTraverse = array_keys($dataStructArray['sheets']);
02099                         } else {
02100                                 $tabsToTraverse = array($sheet);
02101                         }
02102 
02103                         foreach($rotateLang as $lKey)   {
02104                                 if (!$langChildren && !$langDisabled)   {
02105                                         $item.= '<b>'.$lKey.':</b>';
02106                                 }
02107 
02108                                 $tabParts = array();
02109                                 foreach($tabsToTraverse as $sheet)      {
02110                                         $sheetCfg = $dataStructArray['sheets'][$sheet];
02111                                         list ($dataStruct, $sheet) = t3lib_div::resolveSheetDefInDS($dataStructArray,$sheet);
02112 
02113                                                 // Render sheet:
02114                                         if (is_array($dataStruct['ROOT']) && is_array($dataStruct['ROOT']['el']))               {
02115                                                 $cmdData = t3lib_div::_GP('flexFormsCmdData');
02116                                                 $lang = 'l'.$lKey;      // Default language, other options are "lUK" or whatever country code (independant of system!!!)
02117                                                 $PA['_valLang'] = $langChildren && !$langDisabled ? $editData['meta']['currentLangId'] : 'DEF'; // Default language, other options are "lUK" or whatever country code (independant of system!!!)
02118                                                 $PA['_lang'] = $lang;
02119 
02120                                                         // Render flexform:
02121                                                 $tRows = $this->getSingleField_typeFlex_draw(
02122                                                                         $dataStruct['ROOT']['el'],
02123                                                                         $editData['data'][$sheet][$lang],
02124                                                                         $cmdData['data'][$sheet][$lang],
02125                                                                         $table,
02126                                                                         $field,
02127                                                                         $row,
02128                                                                         $PA,
02129                                                                         '[data]['.$sheet.']['.$lang.']'
02130                                                                 );
02131                                                 $sheetContent= '<table border="0" cellpadding="1" cellspacing="1" class="typo3-TCEforms-flexForm">'.implode('',$tRows).'</table>';
02132 
02133                         #                       $item = '<div style=" position:absolute;">'.$item.'</div>';
02134                                                 //visibility:hidden;
02135                                         } else $sheetContent='Data Structure ERROR: No ROOT element found for sheet "'.$sheet.'".';
02136 
02137                                                 // Add to tab:
02138                                         $tabParts[] = array(
02139                                                 'label' => ($sheetCfg['ROOT']['TCEforms']['sheetTitle'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetTitle']) : $sheet),
02140                                                 'description' => ($sheetCfg['ROOT']['TCEforms']['sheetDescription'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetDescription']) : ''),
02141                                                 'linkTitle' => ($sheetCfg['ROOT']['TCEforms']['sheetShortDescr'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetShortDescr']) : ''),
02142                                                 'content' => $sheetContent
02143                                         );
02144                                 }
02145 
02146                                 if (is_array($dataStructArray['sheets']))       {
02147                                         $item.= $this->getDynTabMenu($tabParts,'TCEFORMS:flexform:'.$PA['itemFormElName'].$PA['_lang']);
02148                                 } else {
02149                                         $item.= $sheetContent;
02150                                 }
02151                         }
02152                 } else $item='Data Structure ERROR: '.$dataStructArray;
02153 
02154                 return $item;
02155         }
02156 
02166         function getSingleField_typeFlex_langMenu($languages,$elName,$selectedLanguage,$multi=1)        {
02167                 $opt=array();
02168                 foreach($languages as $lArr)    {
02169                         $opt[]='<option value="'.htmlspecialchars($lArr['ISOcode']).'"'.(in_array($lArr['ISOcode'],$selectedLanguage)?' selected="selected"':'').'>'.htmlspecialchars($lArr['title']).'</option>';
02170                 }
02171 
02172                 $output = '<select name="'.$elName.'[]"'.($multi ? ' multiple="multiple" size="'.count($languages).'"' : '').'>'.implode('',$opt).'</select>';
02173 
02174                 return $output;
02175         }
02176 
02185         function getSingleField_typeFlex_sheetMenu($sArr,$elName,$sheetKey)     {
02186 
02187                 $tCells =array();
02188                 $pct = round(100/count($sArr));
02189                 foreach($sArr as $sKey => $sheetCfg)    {
02190                         if ($GLOBALS['BE_USER']->jsConfirmation(1))     {
02191                                 $onClick = 'if (confirm('.$GLOBALS['LANG']->JScharCode($this->getLL('m_onChangeAlert')).') && TBE_EDITOR_checkSubmit(-1)){'.$this->elName($elName).".value='".$sKey."'; TBE_EDITOR_submitForm()};";
02192                         } else {
02193                                 $onClick = 'if(TBE_EDITOR_checkSubmit(-1)){ '.$this->elName($elName).".value='".$sKey."'; TBE_EDITOR_submitForm();}";
02194                         }
02195 
02196 
02197                         $tCells[]='<td width="'.$pct.'%" style="'.($sKey==$sheetKey ? 'background-color: #9999cc; font-weight: bold;' : 'background-color: #aaaaaa;').' cursor: hand;" onclick="'.htmlspecialchars($onClick).'" align="center">'.
02198                                         ($sheetCfg['ROOT']['TCEforms']['sheetTitle'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetTitle']) : $sKey).
02199                                         '</td>';
02200                 }
02201 
02202                 return '<table border="0" cellpadding="0" cellspacing="2" class="typo3-TCEforms-flexForm-sheetMenu"><tr>'.implode('',$tCells).'</tr></table>';
02203         }
02204 
02220         function getSingleField_typeFlex_draw($dataStruct,$editData,$cmdData,$table,$field,$row,&$PA,$formPrefix='',$level=0,$tRows=array())    {
02221 
02222                         // Data Structure array must be ... and array of course...
02223                 if (is_array($dataStruct))      {
02224                         foreach($dataStruct as $key => $value)  {
02225                                 if (is_array($value))   {       // The value of each entry must be an array.
02226 
02227                                                 // ********************
02228                                                 // Making the row:
02229                                                 // ********************
02230                                         $rowCells=array();
02231 
02232                                                 // Icon:
02233                                         $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>';;
02234 
02235                                         $rowCells['formEl']='';
02236                                         if ($value['type']=='array')    {
02237                                                 if ($value['section'])  {
02238                                                                 // Render "NEW [container]" selectorbox:
02239                                                         if (is_array($value['el']))     {
02240                                                                 $opt=array();
02241                                                                 $opt[]='<option value=""></option>';
02242                                                                 foreach($value['el'] as $kk => $vv)     {
02243                                                                         $opt[]='<option value="'.$kk.'">'.htmlspecialchars($this->getLL('l_new') . ' "'.$this->sL($value['el'][$kk]['tx_templavoila']['title']).'"').'</option>';
02244                                                                 }
02245                                                                 $rowCells['formEl']='<select name="flexFormsCmdData'.$formPrefix.'['.$key.'][value]">'.implode('',$opt).'</select>';
02246                                                         }
02247 
02248                                                                 // Put row together
02249                                                         $tRows[]='<tr class="bgColor2">
02250                                                                 <td nowrap="nowrap" valign="top">'.$rowCells['title'].'</td>
02251                                                                 <td>'.$rowCells['formEl'].'</td>
02252                                                         </tr>';
02253 
02254                                                         $cc=0;
02255                                                         if (is_array($editData[$key]['el']))    {
02256                                                                 foreach($editData[$key]['el'] as $k3 => $v3)    {
02257                                                                         $cc=$k3;
02258                                                                         $theType = key($v3);
02259                                                                         $theDat = $v3[$theType];
02260                                                                         $newSectionEl = $value['el'][$theType];
02261                                                                         if (is_array($newSectionEl))    {
02262                                                                                 $tRows = $this->getSingleField_typeFlex_draw(
02263                                                                                         array($theType => $newSectionEl),
02264                                                                                         array($theType => $theDat),
02265                                                                                         $cmdData[$key]['el'][$cc],
02266                                                                                         $table,
02267                                                                                         $field,
02268                                                                                         $row,
02269                                                                                         $PA,
02270                                                                                         $formPrefix.'['.$key.'][el]['.$cc.']',
02271                                                                                         $level+1,
02272                                                                                         $tRows
02273                                                                                 );
02274                                                                         }
02275                                                                 }
02276                                                         }
02277 
02278 
02279 
02280                                                                 // New form?
02281                                                         if ($cmdData[$key]['value'])    {
02282                                                                 $newSectionEl = $value['el'][$cmdData[$key]['value']];
02283                                                                 if (is_array($newSectionEl))    {
02284                                                                         $tRows = $this->getSingleField_typeFlex_draw(
02285                                                                                 array($cmdData[$key]['value'] => $newSectionEl),
02286                                                                                 array(),
02287                                                                                 array(),
02288                                                                                 $table,
02289                                                                                 $field,
02290                                                                                 $row,
02291                                                                                 $PA,
02292                                                                                 $formPrefix.'['.$key.'][el]['.($cc+1).']',
02293                                                                                 $level+1,
02294                                                                                 $tRows
02295                                                                         );
02296                                                                 }
02297                                                         }
02298                                                 } else {
02299                                                         $idTagPrefix = uniqid('id',true); // ID attributes are used for the move and delete checkboxes for referencing to them in the label tag (<label for="the form field id">) that's rendered around the icons
02300 
02301                                                                 // Put row together
02302                                                         $tRows[]='<tr class="bgColor2">
02303                                                                 <td nowrap="nowrap" valign="top">'.
02304                                                                 '<input name="_DELETE_FLEX_FORM'.$PA['itemFormElName'].$formPrefix.'" id="'.$idTagPrefix.'-del" type="checkbox"'.$this->insertDefStyle('check').' value="1" /><label for="'.$idTagPrefix.'-del"><img src="'.$this->backPath.'gfx/garbage.gif" border="0" alt="" /></label>'.
02305                                                                 '<input name="_MOVEUP_FLEX_FORM'.$PA['itemFormElName'].$formPrefix.'" id="'.$idTagPrefix.'-mvup" type="checkbox"'.$this->insertDefStyle('check').' value="1" /><label for="'.$idTagPrefix.'-mvup"><img src="'.$this->backPath.'gfx/button_up.gif" border="0" alt="" /></label>'.
02306                                                                 '<input name="_MOVEDOWN_FLEX_FORM'.$PA['itemFormElName'].$formPrefix.'" id="'.$idTagPrefix.'-mvdown" type="checkbox"'.$this->insertDefStyle('check').' value="1" /><label for="'.$idTagPrefix.'-mvdown"><img src="'.$this->backPath.'gfx/button_down.gif" border="0" alt="" /></label>'.
02307                                                                 $rowCells['title'].'</td>
02308                                                                 <td>'.$rowCells['formEl'].'</td>
02309                                                         </tr>';
02310 
02311                                                         $tRows = $this->getSingleField_typeFlex_draw(
02312                                                                 $value['el'],
02313                                                                 $editData[$key]['el'],
02314                                                                 $cmdData[$key]['el'],
02315                                                                 $table,
02316                                                                 $field,
02317                                                                 $row,
02318                                                                 $PA,
02319                                                                 $formPrefix.'['.$key.'][el]',
02320                                                                 $level+1,
02321                                                                 $tRows
02322                                                         );
02323                                                 }
02324 
02325                                         } elseif (is_array($value['TCEforms']['config'])) {     // Rendering a single form element:
02326 
02327                                                 if (is_array($PA['_valLang']))  {
02328                                                         $rotateLang = $PA['_valLang'];
02329                                                 } else {
02330                                                         $rotateLang = array($PA['_valLang']);
02331                                                 }
02332 
02333                                                 foreach($rotateLang as $vDEFkey)        {
02334                                                         $vDEFkey = 'v'.$vDEFkey;
02335 
02336                                                         if (!$value['TCEforms']['displayCond'] || $this->isDisplayCondition($value['TCEforms']['displayCond'],$editData,$vDEFkey)) {
02337                                                                 $fakePA=array();
02338                                                                 $fakePA['fieldConf']=array(
02339                                                                         'label' => $this->sL(trim($value['TCEforms']['label'])),
02340                                                                         'config' => $value['TCEforms']['config'],
02341                                                                         'defaultExtras' => $value['TCEforms']['defaultExtras'],
02342                                     'onChange' => $value['TCEforms']['onChange']
02343                                                                 );
02344                                                                 if ($PA['_noEditDEF'] && $PA['_lang']==='lDEF') {
02345                                                                         $fakePA['fieldConf']['config'] = array(
02346                                                                                 'type' => 'none',
02347                                                                                 'rows' => 2
02348                                                                         );
02349                                                                 }
02350 
02351                                                                 if (
02352                                     $fakePA['fieldConf']['onChange'] == 'reload' ||
02353                                                                         ($GLOBALS['TCA'][$table]['ctrl']['type'] && !strcmp($key,$GLOBALS['TCA'][$table]['ctrl']['type'])) ||
02354                                                                         ($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'] && t3lib_div::inList($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'],$key))) {
02355                                                                         if ($GLOBALS['BE_USER']->jsConfirmation(1))     {
02356                                                                                 $alertMsgOnChange = 'if (confirm('.$GLOBALS['LANG']->JScharCode($this->getLL('m_onChangeAlert')).') && TBE_EDITOR_checkSubmit(-1)){ TBE_EDITOR_submitForm() };';
02357                                                                         } else {
02358                                                                                 $alertMsgOnChange = 'if(TBE_EDITOR_checkSubmit(-1)){ TBE_EDITOR_submitForm();}';
02359                                                                         }
02360                                                                 } else {
02361                                                                         $alertMsgOnChange = '';
02362                                                                 }
02363 
02364                                                                 $fakePA['fieldChangeFunc']=$PA['fieldChangeFunc'];
02365                                                                 if (strlen($alertMsgOnChange)) {
02366                                                                         $fakePA['fieldChangeFunc']['alert']=$alertMsgOnChange;
02367                                                                 }
02368                                                                 $fakePA['onFocus']=$PA['onFocus'];
02369                                                                 $fakePA['label']=$PA['label'];
02370 
02371                                                                 $fakePA['itemFormElName']=$PA['itemFormElName'].$formPrefix.'['.$key.']['.$vDEFkey.']';
02372                                                                 $fakePA['itemFormElName_file']=$PA['itemFormElName_file'].$formPrefix.'['.$key.']['.$vDEFkey.']';
02373 
02374                                                                 if(isset($editData[$key][$vDEFkey])) {
02375                                                                         $fakePA['itemFormElValue']=$editData[$key][$vDEFkey];
02376                                                                 } else {
02377                                                                         $fakePA['itemFormElValue']=$fakePA['fieldConf']['config']['default'];
02378                                                                 }
02379 
02380                                                                 $rowCells['formEl']= $this->getSingleField_SW($table,$field,$row,$fakePA);
02381                                                                 $rowCells['title']= htmlspecialchars($fakePA['fieldConf']['label']);
02382 
02383                                                                 if (!in_array('DEF',$rotateLang))       {
02384                                                                         $defInfo = '<div class="typo3-TCEforms-originalLanguageValue">'.nl2br(htmlspecialchars($editData[$key]['vDEF'])).'&nbsp;</div>';
02385                                                                 } else {
02386                                                                         $defInfo = '';
02387                                                                 }
02388 
02389                                                                         // Put row together
02390                                                                 $tRows[]='<tr>
02391                                                                         <td nowrap="nowrap" valign="top" class="bgColor5">'.$rowCells['title'].($vDEFkey=='vDEF' ? '' : ' ('.$vDEFkey.')').'</td>
02392                                                                         <td class="bgColor4">'.$rowCells['formEl'].$defInfo.'</td>
02393                                                                 </tr>';
02394                                                         }
02395                                                 }
02396                                         }
02397                                 }
02398                         }
02399                 }
02400 
02401                 return $tRows;
02402         }
02403 
02413         function getSingleField_typeUnknown($table,$field,$row,&$PA)    {
02414                 $item='Unknown type: '.$PA['fieldConf']['config']['form_type'].'<br />';
02415 
02416                 return $item;
02417         }
02418 
02428         function getSingleField_typeUser($table,$field,$row,&$PA)       {
02429                 $PA['table']=$table;
02430                 $PA['field']=$field;
02431                 $PA['row']=$row;
02432 
02433                 $PA['pObj']=&$this;
02434 
02435                 return t3lib_div::callUserFunction($PA['fieldConf']['config']['userFunc'],$PA,$this);
02436         }
02437 
02438 
02439 
02440 
02441 
02442 
02443         /************************************************************
02444          *
02445          * Field content processing
02446          *
02447          ************************************************************/
02448 
02457         function formatValue ($config, $itemValue)      {
02458                 $format = trim($config['format']);
02459                 switch($format) {
02460                         case 'date':
02461                                 $option = trim($config['format.']['option']);
02462                                 if ($option)    {
02463                                         if ($config['format.']['strftime'])     {
02464                                                 $value = strftime($option,$itemValue);
02465                                         } else {
02466                                                 $value = date($option,$itemValue);
02467                                         }
02468                                 } else {
02469                                         $value = date('d-m-Y',$itemValue);
02470                                 }
02471                                 if ($config['format.']['appendAge'])    {
02472                                         $value .= ' ('.t3lib_BEfunc::calcAge((time()-$itemValue), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')).')';
02473                                 }
02474                                 $itemValue = $value;
02475                                 break;
02476                         case 'datetime':        // compatibility with "eval" (type "input")
02477                                 $itemValue = date('H:i d-m-Y',$itemValue);
02478                                 break;
02479                         case 'time':    // compatibility with "eval" (type "input")
02480                                 $itemValue = date('H:i',$itemValue);
02481                                 break;
02482                         case 'timesec': // compatibility with "eval" (type "input")
02483                                 $itemValue = date('H:i:s',$itemValue);
02484                                 break;
02485                         case 'year':    // compatibility with "eval" (type "input")
02486                                 $itemValue = date('Y',$itemValue);
02487                                 break;
02488                         case 'int':
02489                                 $baseArr = array('dec'=>'d','hex'=>'x','HEX'=>'X','oct'=>'o','bin'=>'b');
02490                                 $base = trim($config['format.']['base']);
02491                                 $format = $baseArr[$base] ? $baseArr[$base] : 'd';
02492                                 $itemValue = sprintf('%'.$format,$itemValue);
02493                                 break;
02494                         case 'float':
02495                                 $precision = t3lib_div::intInRange($config['format.']['precision'],1,10,2);
02496                                 $itemValue = sprintf('%.'.$precision.'f',$itemValue);
02497                                 break;
02498                         case 'number':
02499                                 $format = trim($config['format.']['option']);
02500                                 $itemValue = sprintf('%'.$format,$itemValue);
02501                                 break;
02502                         case 'md5':
02503                                 $itemValue = md5($itemValue);
02504                                 break;
02505                         case 'filesize':
02506                                 $value = t3lib_div::formatSize(intval($itemValue));
02507                                 if ($config['format.']['appendByteSize'])       {
02508                                         $value .= ' ('.$itemValue.')';
02509                                 }
02510                                 $itemValue = $value;
02511                                 break;
02512                         case 'user':
02513                                 $func = trim($config['format.']['userFunc']);
02514                                 if ($func)      {
02515                                         $params = array(
02516                                                 'value' => $itemValue,
02517                                                 'args' => $config['format.']['userFunc'],
02518                                                 'config' => $config,
02519                                                 'pObj' => &$this
02520                                         );
02521                                         $itemValue = t3lib_div::callUserFunction($func,$params,$this);
02522                                 }
02523                                 break;
02524                         default:
02525                         break;
02526                 }
02527 
02528                 return $itemValue;
02529         }
02530 
02531 
02532 
02533 
02534 
02535 
02536         /************************************************************
02537          *
02538          * "Configuration" fetching/processing functions
02539          *
02540          ************************************************************/
02541 
02549         function getRTypeNum($table,$row)       {
02550                 global $TCA;
02551                         // If there is a "type" field configured...
02552                 if ($TCA[$table]['ctrl']['type'])       {
02553                         $typeFieldName = $TCA[$table]['ctrl']['type'];
02554                         $typeNum=$row[$typeFieldName];  // Get value of the row from the record which contains the type value.
02555                         if (!strcmp($typeNum,''))       $typeNum=0;                     // If that value is an empty string, set it to "0" (zero)
02556                 } else {
02557                         $typeNum = 0;   // If no "type" field, then set to "0" (zero)
02558                 }
02559 
02560                 $typeNum = (string)$typeNum;            // Force to string. Necessary for eg '-1' to be recognized as a type value.
02561                 if (!$TCA[$table]['types'][$typeNum])   {       // However, if the type "0" is not found in the "types" array, then default to "1" (for historical reasons)
02562                         $typeNum = 1;
02563                 }
02564 
02565                 return $typeNum;
02566         }
02567 
02575         function rearrange($fields)     {
02576                 $fO = array_flip(t3lib_div::trimExplode(',',$this->fieldOrder,1));
02577                 reset($fields);
02578                 $newFields=array();
02579                 while(list($cc,$content)=each($fields)) {
02580                         $cP = t3lib_div::trimExplode(';',$content);
02581                         if (isset($fO[$cP[0]])) {
02582                                 $newFields[$fO[$cP[0]]] = $content;
02583                                 unset($fields[$cc]);
02584                         }
02585                 }
02586                 ksort($newFields);
02587                 $fields=array_merge($newFields,$fields);                // Candidate for t3lib_div::array_merge() if integer-keys will some day make trouble...
02588                 return $fields;
02589         }
02590 
02601         function getExcludeElements($table,$row,$typeNum)       {
02602                 global $TCA;
02603 
02604                         // Init:
02605                 $excludeElements=array();
02606 
02607                         // If a subtype field is defined for the type
02608                 if ($TCA[$table]['types'][$typeNum]['subtype_value_field'])     {
02609                         $sTfield = $TCA[$table]['types'][$typeNum]['subtype_value_field'];
02610                         if (trim($TCA[$table]['types'][$typeNum]['subtypes_excludelist'][$row[$sTfield]]))      {
02611                                 $excludeElements=t3lib_div::trimExplode(',',$TCA[$table]['types'][$typeNum]['subtypes_excludelist'][$row[$sTfield]],1);
02612                         }
02613                 }
02614 
02615                         // If a bitmask-value field has been configured, then find possible fields to exclude based on that:
02616                 if ($TCA[$table]['types'][$typeNum]['bitmask_value_field'])     {
02617                         $sTfield = $TCA[$table]['types'][$typeNum]['bitmask_value_field'];
02618                         $sTValue = t3lib_div::intInRange($row[$sTfield],0);
02619                         if (is_array($TCA[$table]['types'][$typeNum]['bitmask_excludelist_bits']))      {
02620                                 reset($TCA[$table]['types'][$typeNum]['bitmask_excludelist_bits']);
02621                                 while(list($bitKey,$eList)=each($TCA[$table]['types'][$typeNum]['bitmask_excludelist_bits']))   {
02622                                         $bit=substr($bitKey,1);
02623                                         if (t3lib_div::testInt($bit))   {
02624                                                 $bit = t3lib_div::intInRange($bit,0,30);
02625                                                 if (
02626                                                                 (substr($bitKey,0,1)=='-' && !($sTValue&pow(2,$bit))) ||
02627                                                                 (substr($bitKey,0,1)=='+' && ($sTValue&pow(2,$bit)))
02628                                                         )       {
02629                                                         $excludeElements = array_merge($excludeElements,t3lib_div::trimExplode(',',$eList,1));
02630                                                 }
02631                                         }
02632                                 }
02633                         }
02634                 }
02635 
02636                         // Return the array of elements:
02637                 return $excludeElements;
02638         }
02639 
02649         function getFieldsToAdd($table,$row,$typeNum)   {
02650                 global $TCA;
02651 
02652                         // Init:
02653                 $addElements=array();
02654 
02655                         // If a subtype field is defined for the type
02656                 if ($TCA[$table]['types'][$typeNum]['subtype_value_field'])     {
02657                         $sTfield = $TCA[$table]['types'][$typeNum]['subtype_value_field'];
02658                         if (trim($TCA[$table]['types'][$typeNum]['subtypes_addlist'][$row[$sTfield]]))  {
02659                                 $addElements=t3lib_div::trimExplode(',',$TCA[$table]['types'][$typeNum]['subtypes_addlist'][$row[$sTfield]],1);
02660                         }
02661                 }
02662                         // Return the return
02663                 return array($addElements,$sTfield);
02664         }
02665 
02674         function mergeFieldsWithAddedFields($fields,$fieldsToAdd)       {
02675                 if (count($fieldsToAdd[0]))     {
02676                         reset($fields);
02677                         $c=0;
02678                         while(list(,$fieldInfo)=each($fields))  {
02679                                 $parts = explode(';',$fieldInfo);
02680                                 if (!strcmp(trim($parts[0]),$fieldsToAdd[1]))   {
02681                                         array_splice(
02682                                                 $fields,
02683                                                 $c+1,
02684                                                 0,
02685                                                 $fieldsToAdd[0]
02686                                         );
02687                                         break;
02688                                 }
02689                                 $c++;
02690                         }
02691                 }
02692                 return $fields;
02693         }
02694 
02695 
02706         function setTSconfig($table,$row,$field='')     {
02707                 $mainKey = $table.':'.$row['uid'];
02708                 if (!isset($this->cachedTSconfig[$mainKey]))    {
02709                         $this->cachedTSconfig[$mainKey]=t3lib_BEfunc::getTCEFORM_TSconfig($table,$row);
02710                 }
02711                 if ($field)     {
02712                         return $this->cachedTSconfig[$mainKey][$field];
02713                 } else {
02714                         return $this->cachedTSconfig[$mainKey];
02715                 }
02716         }
02717 
02728         function getSpecConfForField($table,$row,$field)        {
02729                         // Finds the current "types" configuration for the table/row:
02730                 $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table,$row);
02731 
02732                         // If this is an array, then traverse it:
02733                 if (is_array($types_fieldConfig))       {
02734                         foreach($types_fieldConfig as $vconf)   {
02735                                         // If the input field name matches one found in the 'types' list, then return the 'special' configuration.
02736                                 if ($vconf['field']==$field)    return $vconf['spec'];
02737                         }
02738                 }
02739         }
02740 
02749         function getSpecConfFromString($extraString, $defaultExtras)    {
02750                 return t3lib_BEfunc::getSpecConfParts($extraString, $defaultExtras);
02751         }
02752 
02753 
02754 
02755 
02756 
02757 
02758 
02759 
02760 
02761 
02762         /************************************************************
02763          *
02764          * Display of localized content etc.
02765          *
02766          ************************************************************/
02767 
02777         function registerDefaultLanguageData($table,$rec)       {
02778                 global $TCA;
02779 
02780                         // Add default language:
02781                 if ($TCA[$table]['ctrl']['languageField']
02782                                 && $rec[$TCA[$table]['ctrl']['languageField']] > 0
02783                                 && $TCA[$table]['ctrl']['transOrigPointerField']
02784                                 && intval($rec[$TCA[$table]['ctrl']['transOrigPointerField']]) > 0)     {
02785 
02786                         $lookUpTable = $TCA[$table]['ctrl']['transOrigPointerTable'] ? $TCA[$table]['ctrl']['transOrigPointerTable'] : $table;
02787 
02788                                 // Get data formatted:
02789                         $this->defaultLanguageData[$table.':'.$rec['uid']] = t3lib_BEfunc::getRecordWSOL($lookUpTable, intval($rec[$TCA[$table]['ctrl']['transOrigPointerField']]));
02790 
02791                                 // Get data for diff:
02792                         if ($TCA[$table]['ctrl']['transOrigDiffSourceField'])   {
02793                                 $this->defaultLanguageData_diff[$table.':'.$rec['uid']] = unserialize($rec[$TCA[$table]['ctrl']['transOrigDiffSourceField']]);
02794                         }
02795                 }
02796         }
02797 
02809         function getLanguageOverlayRawValue($table, $row, $field, $fieldConf)   {
02810                 global $TCA;
02811 
02812                 $value = $row[$field];
02813 
02814                 if (is_array($this->defaultLanguageData[$table.':'.$row['uid']]))       {
02815 
02816                         if ($fieldConf['l10n_mode']=='exclude'
02817                                         || ($fieldConf['l10n_mode']=='mergeIfNotBlank' && strcmp(trim($this->defaultLanguageData[$table.':'.$row['uid']][$field]),''))) {
02818                                 $value = $this->defaultLanguageData[$table.':'.$row['uid']][$field];
02819                         }
02820 
02821                 }
02822 
02823                 return $value;
02824         }
02825 
02837         function renderDefaultLanguageContent($table,$field,$row,$item) {
02838                 if (is_array($this->defaultLanguageData[$table.':'.$row['uid']]))       {
02839                         $dLVal = t3lib_BEfunc::getProcessedValue($table,$field,$this->defaultLanguageData[$table.':'.$row['uid']][$field],0,1);
02840 
02841                         if (strcmp($dLVal,''))  {
02842                                 $item.='<div class="typo3-TCEforms-originalLanguageValue">'.nl2br(htmlspecialchars($dLVal)).'&nbsp;</div>';
02843                         }
02844                 }
02845 
02846                 return $item;
02847         }
02848 
02860         function renderDefaultLanguageDiff($table,$field,$row,$item)    {
02861                 if (is_array($this->defaultLanguageData_diff[$table.':'.$row['uid']]))  {
02862 
02863                                 // Initialize:
02864                         $dLVal = array(
02865                                 'old' => $this->defaultLanguageData_diff[$table.':'.$row['uid']],
02866                                 'new' => $this->defaultLanguageData[$table.':'.$row['uid']],
02867                         );
02868 
02869                         if (isset($dLVal['old'][$field]))       {       // There must be diff-data:
02870                                 if (strcmp($dLVal['old'][$field],$dLVal['new'][$field]))        {
02871 
02872                                                 // Create diff-result:
02873                                         $t3lib_diff_Obj = t3lib_div::makeInstance('t3lib_diff');
02874                                         $diffres = $t3lib_diff_Obj->makeDiffDisplay(
02875                                                 t3lib_BEfunc::getProcessedValue($table,$field,$dLVal['old'][$field],0,1),
02876                                                 t3lib_BEfunc::getProcessedValue($table,$field,$dLVal['new'][$field],0,1)
02877                                         );
02878 
02879                                         $item.='<div class="typo3-TCEforms-diffBox">'.
02880                                                 '<div class="typo3-TCEforms-diffBox-header">'.htmlspecialchars($this->getLL('l_changeInOrig')).':</div>'.
02881                                                 $diffres.
02882                                         '</div>';
02883                                 }
02884                         }
02885                 }
02886 
02887                 return $item;
02888         }
02889 
02890 
02891 
02892 
02893 
02894 
02895 
02896 
02897 
02898         /************************************************************
02899          *
02900          * Form element helper functions
02901          *
02902          ************************************************************/
02903 
02916         function dbFileIcons($fName,$mode,$allowed,$itemArray,$selector='',$params=array(),$onFocus='') {
02917 
02918 
02919                 $disabled = '';
02920                 if($this->renderReadonly || $params['readOnly'])  {
02921                         $disabled = ' disabled="disabled"';
02922                 }
02923 
02924                         // Sets a flag which means some JavaScript is included on the page to support this element.
02925                 $this->printNeededJS['dbFileIcons']=1;
02926 
02927                         // INIT
02928                 $uidList=array();
02929                 $opt=array();
02930                 $itemArrayC=0;
02931 
02932                         // Creating <option> elements:
02933                 if (is_array($itemArray))       {
02934                         $itemArrayC=count($itemArray);
02935                         reset($itemArray);
02936                         switch($mode)   {
02937                                 case 'db':
02938                                         while(list(,$pp)=each($itemArray))      {
02939                                                 $pRec = t3lib_BEfunc::getRecordWSOL($pp['table'],$pp['id']);
02940                                                 if (is_array($pRec))    {
02941                                                         $pTitle = t3lib_div::fixed_lgd_cs($this->noTitle($pRec[$GLOBALS['TCA'][$pp['table']]['ctrl']['label']]),$this->titleLen);
02942                                                         $pUid = $pp['table'].'_'.$pp['id'];
02943                                                         $uidList[]=$pUid;
02944                                                         $opt[]='<option value="'.htmlspecialchars($pUid).'">'.htmlspecialchars($pTitle).'</option>';
02945                                                 }
02946                                         }
02947                                 break;
02948                                 case 'file':
02949                                         while(list(,$pp)=each($itemArray))      {
02950                                                 $pParts = explode('|',$pp);
02951                                                 $uidList[]=$pUid=$pTitle = $pParts[0];
02952                                                 $opt[]='<option value="'.htmlspecialchars(rawurldecode($pParts[0])).'">'.htmlspecialchars(rawurldecode($pParts[0])).'</option>';
02953                                         }
02954                                 break;
02955                                 default:
02956                                         while(list(,$pp)=each($itemArray))      {
02957                                                 $pParts = explode('|',$pp, 2);
02958                                                 $uidList[]=$pUid=$pParts[0];
02959                                                 $pTitle = $pParts[1];
02960                                                 $opt[]='<option value="'.htmlspecialchars(rawurldecode($pUid)).'">'.htmlspecialchars(rawurldecode($pTitle)).'</option>';
02961                                         }
02962                                 break;
02963                         }
02964                 }
02965 
02966                         // Create selector box of the options
02967                 $sSize = $params['autoSizeMax'] ? t3lib_div::intInRange($itemArrayC+1,t3lib_div::intInRange($params['size'],1),$params['autoSizeMax']) : $params['size'];
02968                 if (!$selector) {
02969                         $selector = '<select size="'.$sSize.'"'.$this->insertDefStyle('group').' multiple="multiple" name="'.$fName.'_list" '.$onFocus.$params['style'].$disabled.'>'.implode('',$opt).'</select>';
02970                 }
02971 
02972 
02973                 $icons = array(
02974                         'L' => array(),
02975                         'R' => array(),
02976                 );
02977                 if (!$params['readOnly']) {
02978                         if (!$params['noBrowser'])      {
02979                                 $aOnClick='setFormValueOpenBrowser(\''.$mode.'\',\''.($fName.'|||'.$allowed.'|').'\'); return false;';
02980                                 $icons['R'][]='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
02981                                                 '<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'))).' />'.
02982                                                 '</a>';
02983                         }
02984                         if (!$params['dontShowMoveIcons'])      {
02985                                 if ($sSize>=5)  {
02986                                         $icons['L'][]='<a href="#" onclick="setFormValueManipulate(\''.$fName.'\',\'Top\'); return false;">'.
02987                                                         '<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')).' />'.
02988                                                         '</a>';
02989                                 }
02990                                 $icons['L'][]='<a href="#" onclick="setFormValueManipulate(\''.$fName.'\',\'Up\'); return false;">'.
02991                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/up.gif','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib($this->getLL('l_move_up')).' />'.
02992                                                 '</a>';
02993                                 $icons['L'][]='<a href="#" onclick="setFormValueManipulate(\''.$fName.'\',\'Down\'); return false;">'.
02994                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/down.gif','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib($this->getLL('l_move_down')).' />'.
02995                                                 '</a>';
02996                                 if ($sSize>=5)  {
02997                                         $icons['L'][]='<a href="#" onclick="setFormValueManipulate(\''.$fName.'\',\'Bottom\'); return false;">'.
02998                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/group_tobottom.gif','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib($this->getLL('l_move_to_bottom')).' />'.
02999                                                         '</a>';
03000                                 }
03001                         }
03002 
03003                         $clipElements = $this->getClipboardElements($allowed,$mode);
03004                         if (count($clipElements))       {
03005                                 $aOnClick = '';
03006         #                       $counter = 0;
03007                                 foreach($clipElements as $elValue)      {
03008                                         if ($mode=='file')      {
03009                                                 $itemTitle = 'unescape(\''.rawurlencode(basename($elValue)).'\')';
03010                                         } else {        // 'db' mode assumed
03011                                                 list($itemTable,$itemUid) = explode('|', $elValue);
03012                                                 $itemTitle = $GLOBALS['LANG']->JScharCode(t3lib_BEfunc::getRecordTitle($itemTable, t3lib_BEfunc::getRecordWSOL($itemTable,$itemUid)));
03013                                                 $elValue = $itemTable.'_'.$itemUid;
03014                                         }
03015                                         $aOnClick.= 'setFormValueFromBrowseWin(\''.$fName.'\',unescape(\''.rawurlencode(str_replace('%20',' ',$elValue)).'\'),'.$itemTitle.');';
03016 
03017         #                               $counter++;
03018         #                               if ($params['maxitems'] && $counter >= $params['maxitems'])     {       break;  }       // Makes sure that no more than the max items are inserted... for convenience.
03019                                 }
03020                                 $aOnClick.= 'return false;';
03021                                 $icons['R'][]='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
03022                                                 '<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))).' />'.
03023                                                 '</a>';
03024                         }
03025                         $icons['L'][]='<a href="#" onclick="setFormValueManipulate(\''.$fName.'\',\'Remove\'); return false;">'.
03026                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/group_clear.gif','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib($this->getLL('l_remove_selected')).' />'.
03027                                         '</a>';
03028                 }
03029 
03030                 $str='<table border="0" cellpadding="0" cellspacing="0" width="1">
03031                         '.($params['headers']?'
03032                                 <tr>
03033                                         <td>'.$this->wrapLabels($params['headers']['selector']).'</td>
03034                                         <td></td>
03035                                         <td></td>
03036                                         <td></td>
03037                                         <td>'.($params['thumbnails'] ? $this->wrapLabels($params['headers']['items']) : '').'</td>
03038                                 </tr>':'').
03039                         '
03040                         <tr>
03041                                 <td valign="top">'.
03042                                         $selector.'<br />'.
03043                                         $this->wrapLabels($params['info']).
03044                                 '</td>
03045                                 <td valign="top">'.
03046                                         implode('<br />',$icons['L']).'</td>
03047                                 <td valign="top">'.
03048                                         implode('<br />',$icons['R']).'</td>
03049                                 <td><img src="clear.gif" width="5" height="1" alt="" /></td>
03050                                 <td valign="top">'.
03051                                         $this->wrapLabels($params['thumbnails']).
03052                                 '</td>
03053                         </tr>
03054                 </table>';
03055 
03056                         // Creating the hidden field which contains the actual value as a comma list.
03057                 $str.='<input type="hidden" name="'.$fName.'" value="'.htmlspecialchars(implode(',',$uidList)).'" />';
03058 
03059                 return $str;
03060         }
03061 
03069         function getClipboardElements($allowed,$mode)   {
03070 
03071                 $output = array();
03072 
03073                 if (is_object($this->clipObj))  {
03074                         switch($mode)   {
03075                                 case 'file':
03076                                         $elFromTable = $this->clipObj->elFromTable('_FILE');
03077                                         $allowedExts = t3lib_div::trimExplode(',', $allowed, 1);
03078 
03079                                         if ($allowedExts)       {       // If there are a set of allowed extensions, filter the content:
03080                                                 foreach($elFromTable as $elValue)       {
03081                                                         $pI = pathinfo($elValue);
03082                                                         $ext = strtolower($pI['extension']);
03083                                                         if (in_array($ext, $allowedExts))       {
03084                                                                 $output[] = $elValue;
03085                                                         }
03086                                                 }
03087                                         } else {        // If all is allowed, insert all: (This does NOT respect any disallowed extensions, but those will be filtered away by the backend TCEmain)
03088                                                 $output = $elFromTable;
03089                                         }
03090                                 break;
03091                                 case 'db':
03092                                         $allowedTables = t3lib_div::trimExplode(',', $allowed, 1);
03093                                         if (!strcmp(trim($allowedTables[0]),'*'))       {       // All tables allowed for relation:
03094                                                 $output = $this->clipObj->elFromTable('');
03095                                         } else {        // Only some tables, filter them:
03096                                                 foreach($allowedTables as $tablename)   {
03097                                                         $elFromTable = $this->clipObj->elFromTable($tablename);
03098                                                         $output = array_merge($output,$elFromTable);
03099                                                 }
03100                                         }
03101                                         $output = array_keys($output);
03102                                 break;
03103                         }
03104                 }
03105 
03106                 return $output;
03107         }
03108 
03118         function getClickMenu($str,$table,$uid='')      {
03119                 if ($this->enableClickMenu)     {
03120                         $onClick = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($str,$table,$uid,1,'','+copy,info,edit,view', TRUE);
03121                         return '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.$str.'</a>';
03122                 }
03123         }
03124 
03139         function renderWizards($itemKinds,$wizConf,$table,$row,$field,&$PA,$itemName,$specConf,$RTE=0)  {
03140 
03141                         // Init:
03142                 $fieldChangeFunc = $PA['fieldChangeFunc'];
03143                 $item = $itemKinds[0];
03144                 $outArr = array();
03145                 $colorBoxLinks = array();
03146                 $fName = '['.$table.']['.$row['uid'].']['.$field.']';
03147                 $md5ID = 'ID'.t3lib_div::shortmd5($itemName);
03148                 $listFlag = '_list';
03149 
03150                         // 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":
03151                 if ($PA['fieldConf']['config']['form_type']=='select')  {
03152                         if ($PA['fieldConf']['config']['maxitems']<=1)  {       // Single select situation:
03153                                 $listFlag = '';
03154                         } elseif ($PA['fieldConf']['config']['renderMode']=='singlebox')        {
03155                                 $itemName.='[]';
03156                                 $listFlag = '';
03157                         }
03158                 }
03159 
03160                         // traverse wizards:
03161                 if (is_array($wizConf) && !$this->disableWizards)       {
03162                         foreach($wizConf as $wid => $wConf)     {
03163                                 if (substr($wid,0,1)!='_'
03164                                                 && (!$wConf['enableByTypeConfig'] || @in_array($wid,$specConf['wizards']['parameters']))
03165                                                 && ($RTE || !$wConf['RTEonly'])
03166                                         )       {
03167 
03168                                                 // Title / icon:
03169                                         $iTitle = htmlspecialchars($this->sL($wConf['title']));
03170                                         if ($wConf['icon'])     {
03171                                                 $iDat = $this->getIcon($wConf['icon']);
03172                                                 $icon = '<img src="'.$iDat[0].'" '.$iDat[1][3].' border="0"'.t3lib_BEfunc::titleAltAttrib($iTitle).' />';
03173                                         } else {
03174                                                 $icon = $iTitle;
03175                                         }
03176 
03177                                                 //
03178                                         switch((string)$wConf['type'])  {
03179                                                 case 'userFunc':
03180                                                 case 'script':
03181                                                 case 'popup':
03182                                                 case 'colorbox':
03183                                                         if (!$wConf['notNewRecords'] || t3lib_div::testInt($row['uid']))        {
03184 
03185                                                                         // Setting &P array contents:
03186                                                                 $params = array();
03187                                                                 $params['params'] = $wConf['params'];
03188                                                                 $params['exampleImg'] = $wConf['exampleImg'];
03189                                                                 $params['table'] = $table;
03190                                                                 $params['uid'] = $row['uid'];
03191                                                                 $params['pid'] = $row['pid'];
03192                                                                 $params['field'] = $field;
03193                                                                 $params['md5ID'] = $md5ID;
03194                                                                 $params['returnUrl'] = $this->thisReturnUrl();
03195 
03196                                                                         // Resolving script filename and setting URL.
03197                                                                 if (!strcmp(substr($wConf['script'],0,4), 'EXT:')) {
03198                                                                         $wScript = t3lib_div::getFileAbsFileName($wConf['script']);
03199                                                                         if ($wScript)   {
03200                                                                                 $wScript = '../'.substr($wScript,strlen(PATH_site));
03201                                                                         } else break;
03202                                                                 } else {
03203                                                                         $wScript = $wConf['script'];
03204                                                                 }
03205                                                                 $url = $this->backPath.$wScript.(strstr($wScript,'?') ? '' : '?');
03206 
03207                                                                         // If there is no script and the type is "colorbox", break right away:
03208                                                                 if ((string)$wConf['type']=='colorbox' && !$wConf['script'])    { break; }
03209 
03210                                                                         // If "script" type, create the links around the icon:
03211                                                                 if ((string)$wConf['type']=='script')   {
03212                                                                         $aUrl = $url.t3lib_div::implodeArrayForUrl('',array('P'=>$params));
03213                                                                         $outArr[]='<a href="'.htmlspecialchars($aUrl).'" onclick="'.$this->blur().'return !TBE_EDITOR_isFormChanged();">'.
03214                                                                                 $icon.
03215                                                                                 '</a>';
03216                                                                 } else {
03217 
03218                                                                                 // ... else types "popup", "colorbox" and "userFunc" will need additional parameters:
03219                                                                         $params['formName'] = $this->formName;
03220                                                                         $params['itemName'] = $itemName;
03221                                                                         $params['fieldChangeFunc'] = $fieldChangeFunc;
03222 
03223                                                                         switch((string)$wConf['type'])  {
03224                                                                                 case 'popup':
03225                                                                                 case 'colorbox':
03226                                                                                                 // Current form value is passed as P[currentValue]!
03227                                                                                         $addJS = $wConf['popup_onlyOpenIfSelected']?'if (!TBE_EDITOR_curSelected(\''.$itemName.$listFlag.'\')){alert('.$GLOBALS['LANG']->JScharCode($this->getLL('m_noSelItemForEdit')).'); return false;}':'';
03228                                                                                         $curSelectedValues='+\'&P[currentSelectedValues]=\'+TBE_EDITOR_curSelected(\''.$itemName.$listFlag.'\')';
03229                                                                                         $aOnClick=      $this->blur().
03230                                                                                                                 $addJS.
03231                                                                                                                 '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'].'\');'.
03232                                                                                                                 'vHWin.focus();return false;';
03233                                                                                                 // Setting "colorBoxLinks" - user LATER to wrap around the color box as well:
03234                                                                                         $colorBoxLinks = Array('<a href="#" onclick="'.htmlspecialchars($aOnClick).'">','</a>');
03235                                                                                         if ((string)$wConf['type']=='popup')    {
03236                                                                                                 $outArr[] = $colorBoxLinks[0].$icon.$colorBoxLinks[1];
03237                                                                                         }
03238                                                                                 break;
03239                                                                                 case 'userFunc':
03240                                                                                         $params['item'] = &$item;       // Reference set!
03241                                                                                         $params['icon'] = $icon;
03242                                                                                         $params['iTitle'] = $iTitle;
03243                                                                                         $params['wConf'] = $wConf;
03244                                                                                         $params['row'] = $row;
03245                                                                                         $outArr[] = t3lib_div::callUserFunction($wConf['userFunc'],$params,$this);
03246                                                                                 break;
03247                                                                         }
03248                                                                 }
03249 
03250                                                                         // Hide the real form element?
03251                                                                 if (is_array($wConf['hideParent']) || $wConf['hideParent'])     {
03252                                                                         $item = $itemKinds[1];  // Setting the item to a hidden-field.
03253                                                                         if (is_array($wConf['hideParent']))     {
03254                                                                                 $item.= $this->getSingleField_typeNone_render($wConf['hideParent'], $PA['itemFormElValue']);
03255                                                                         }
03256                                                                 }
03257                                                         }
03258                                                 break;
03259                                                 case 'select':
03260                                                         $fieldValue = array('config' => $wConf);
03261                                                         $TSconfig = $this->setTSconfig($table, $row);
03262                                                         $TSconfig[$field] = $TSconfig[$field]['wizards.'][$wid.'.'];
03263                                                         $selItems = $this->addSelectOptionsToItemArray($this->initItemArray($fieldValue), $fieldValue, $TSconfig, $field);
03264 
03265                                                         $opt = array();
03266                                                         $opt[] = '<option>'.$iTitle.'</option>';
03267                                                         foreach($selItems as $p)        {
03268                                                                 $opt[] = '<option value="'.htmlspecialchars($p[1]).'">'.htmlspecialchars($p[0]).'</option>';
03269                                                         }
03270                                                         if ($wConf['mode']=='append')   {
03271                                                                 $assignValue = $this->elName($itemName).'.value=\'\'+this.options[this.selectedIndex].value+'.$this->elName($itemName).'.value';
03272                                                         } elseif ($wConf['mode']=='prepend')    {
03273                                                                 $assignValue = $this->elName($itemName).'.value+=\'\'+this.options[this.selectedIndex].value';
03274                                                         } else {
03275                                                                 $assignValue = $this->elName($itemName).'.value=this.options[this.selectedIndex].value';
03276                                                         }
03277                                                         $sOnChange = $assignValue.';this.selectedIndex=0;'.implode('',$fieldChangeFunc);
03278                                                         $outArr[] = '<select name="_WIZARD'.$fName.'" onchange="'.htmlspecialchars($sOnChange).'">'.implode('',$opt).'</select>';
03279                                                 break;
03280                                         }
03281 
03282                                                 // Color wizard colorbox:
03283                                         if ((string)$wConf['type']=='colorbox') {
03284                                                 $dim = t3lib_div::intExplode('x',$wConf['dim']);
03285                                                 $dX = t3lib_div::intInRange($dim[0],1,200,20);
03286                                                 $dY = t3lib_div::intInRange($dim[1],1,200,20);
03287                                                 $color = $row[$field] ? ' bgcolor="'.htmlspecialchars($row[$field]).'"' : '';
03288                                                 $outArr[] = '<table border="0" cellpadding="0" cellspacing="0" id="'.$md5ID.'"'.$color.' style="'.htmlspecialchars($wConf['tableStyle']).'">
03289                                                                         <tr>
03290                                                                                 <td>'.
03291                                                                                         $colorBoxLinks[0].
03292                                                                                         '<img src="clear.gif" width="'.$dX.'" height="'.$dY.'"'.t3lib_BEfunc::titleAltAttrib(trim($iTitle.' '.$row[$field])).' border="0" />'.
03293                                                                                         $colorBoxLinks[1].
03294                                                                                         '</td>
03295                                                                         </tr>
03296                                                                 </table>';
03297                                         }
03298                                 }
03299                         }
03300 
03301                                 // For each rendered wizard, put them together around the item.
03302                         if (count($outArr))     {
03303                                 if ($wizConf['_HIDDENFIELD'])   $item = $itemKinds[1];
03304 
03305                                 $outStr = '';
03306                                 $vAlign = $wizConf['_VALIGN'] ? ' valign="'.$wizConf['_VALIGN'].'"' : '';
03307                                 if (count($outArr)>1 || $wizConf['_PADDING'])   {
03308                                         $dist = intval($wizConf['_DISTANCE']);
03309                                         if ($wizConf['_VERTICAL'])      {
03310                                                 $dist = $dist ? '<tr><td><img src="clear.gif" width="1" height="'.$dist.'" alt="" /></td></tr>' : '';
03311                                                 $outStr = '<tr><td>'.implode('</td></tr>'.$dist.'<tr><td>',$outArr).'</td></tr>';
03312                                         } else {
03313                                                 $dist = $dist ? '<td><img src="clear.gif" height="1" width="'.$dist.'" alt="" /></td>' : '';
03314                                                 $outStr = '<tr><td'.$vAlign.'>'.implode('</td>'.$dist.'<td'.$vAlign.'>',$outArr).'</td></tr>';
03315                                         }
03316                                         $outStr = '<table border="0" cellpadding="'.intval($wizConf['_PADDING']).'" cellspacing="0">'.$outStr.'</table>';
03317                                 } else {
03318                                         $outStr = implode('',$outArr);
03319                                 }
03320 
03321                                 if (!strcmp($wizConf['_POSITION'],'left'))      {
03322                                         $outStr = '<tr><td'.$vAlign.'>'.$outStr.'</td><td'.$vAlign.'>'.$item.'</td></tr>';
03323                                 } elseif (!strcmp($wizConf['_POSITION'],'top')) {
03324                                         $outStr = '<tr><td>'.$outStr.'</td></tr><tr><td>'.$item.'</td></tr>';
03325                                 } elseif (!strcmp($wizConf['_POSITION'],'bottom'))      {
03326                                         $outStr = '<tr><td>'.$item.'</td></tr><tr><td>'.$outStr.'</td></tr>';
03327                                 } else {
03328                                         $outStr = '<tr><td'.$vAlign.'>'.$item.'</td><td'.$vAlign.'>'.$outStr.'</td></tr>';
03329                                 }
03330 
03331                                 $item = '<table border="0" cellpadding="0" cellspacing="0">'.$outStr.'</table>';
03332                         }
03333                 }
03334                 return $item;
03335         }
03336 
03343         function getIcon($icon) {
03344                 if (substr($icon,0,4)=='EXT:')  {
03345                         $file = t3lib_div::getFileAbsFileName($icon);
03346                         if ($file)      {
03347                                 $file = substr($file,strlen(PATH_site));
03348                                 $selIconFile = $this->backPath.'../'.$file;
03349                                 $selIconInfo = @getimagesize(PATH_site.$file);
03350                         }
03351                 } elseif (substr($icon,0,3)=='../')     {
03352                         $selIconFile = $this->backPath.t3lib_div::resolveBackPath($icon);
03353                         $selIconInfo = @getimagesize(PATH_site.t3lib_div::resolveBackPath(substr($icon,3)));
03354                 } elseif (substr($icon,0,4)=='ext/' || substr($icon,0,7)=='sysext/') {
03355                         $selIconFile = $this->backPath.$icon;
03356                         $selIconInfo = @getimagesize(PATH_typo3.$icon);
03357                 } else {
03358                         $selIconFile = t3lib_iconWorks::skinImg($this->backPath,'gfx/'.$icon,'',1);
03359                         $selIconInfo = @getimagesize(PATH_typo3.$selIconFile);
03360                 }
03361                 return array($selIconFile,$selIconInfo);
03362         }
03363 
03370         function optionTagStyle($iconString)    {
03371                 if ($iconString)        {
03372                         list($selIconFile,$selIconInfo) = $this->getIcon($iconString);
03373                         $padTop = t3lib_div::intInRange(($selIconInfo[1]-12)/2,0);
03374                         $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;';
03375                         return $styleAttr;
03376                 }
03377         }
03378 
03386         function extractValuesOnlyFromValueLabelList($itemFormElValue)  {
03387                         // Get values of selected items:
03388                 $itemArray = t3lib_div::trimExplode(',',$itemFormElValue,1);
03389                 foreach($itemArray as $tk => $tv) {
03390                         $tvP = explode('|',$tv,2);
03391                         $tvP[0] = rawurldecode($tvP[0]);
03392 
03393                         $itemArray[$tk] = $tvP[0];
03394                 }
03395                 return $itemArray;
03396         }
03397 
03408         function wrapOpenPalette($header,$table,$row,$palette,$retFunc=0)       {
03409                 $fieldL=array();
03410                 if (!is_array($this->palFieldArr[$palette]))    {$this->palFieldArr[$palette]=array();}
03411                 $palFieldN = is_array($this->palFieldArr[$palette]) ? count($this->palFieldArr[$palette]) : 0;
03412                 $palJSFunc = 'TBE_EDITOR_palUrl(\''.($table.':'.$row['uid'].':'.$palette).'\',\''.implode(',',$this->palFieldArr[$palette]).'\','.$palFieldN.',\''.$table.'\',\''.$row['uid'].'\',1);';
03413 
03414                 $aOnClick = $this->blur().substr($palJSFunc,0,-3).'0);return false;';
03415 
03416                 $iconCode = '<a href="#" onclick="'.htmlspecialchars($aOnClick).'" title="'.htmlspecialchars($table).'">'.
03417                                         $header.
03418                                         '</a>';
03419                 return $retFunc ? array($iconCode,$palJSFunc) : $iconCode;
03420         }
03421 
03432         function checkBoxParams($itemName,$thisValue,$c,$iCount,$addFunc='')    {
03433                 $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)).');'.
03434                                         $addFunc;
03435                 $str = ' onclick="'.htmlspecialchars($onClick).'"'.
03436                                 (($thisValue&pow(2,$c))?' checked="checked"':'');
03437                 return $str;
03438         }
03439 
03446         function elName($itemName)      {
03447                 return 'document.'.$this->formName."['".$itemName."']";
03448         }
03449 
03457         function noTitle($str,$wrapParts=array())       {
03458                 return strcmp($str,'') ? $str : $wrapParts[0].'['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title').']'.$wrapParts[1];
03459         }
03460 
03466         function blur() {
03467                 return $GLOBALS['CLIENT']['FORMSTYLE'] ? 'this.blur();':'';
03468         }
03469 
03475         function thisReturnUrl()        {
03476                 return $this->returnUrl ? $this->returnUrl : t3lib_div::linkThisScript();
03477         }
03478 
03488         function getSingleHiddenField($table,$field,$row)       {
03489                 global $TCA;
03490                 $out='';
03491                 t3lib_div::loadTCA($table);
03492                 if ($TCA[$table]['columns'][$field])    {
03493 
03494                         $uid=$row['uid'];
03495                         $itemName=$this->prependFormFieldNames.'['.$table.']['.$uid.']['.$field.']';
03496                         $itemValue=$row[$field];
03497                         $item.='<input type="hidden" name="'.$itemName.'" value="'.htmlspecialchars($itemValue).'" />';
03498                         $out = $item;
03499                 }
03500                 return $out;
03501         }
03502 
03510         function formWidth($size=48,$textarea=0) {
03511                         // Input or text-field attribute (size or cols)
03512                 if ($this->docLarge)    $size = round($size*$this->form_largeComp);
03513                 $wAttrib = $textarea?'cols':'size';
03514                 if (!$GLOBALS['CLIENT']['FORMSTYLE'])   {       // If not setting the width by style-attribute
03515                         $retVal = ' '.$wAttrib.'="'.$size.'"';
03516                 } else {        // Setting width by style-attribute. 'cols' MUST be avoided with NN6+
03517                         $pixels = ceil($size*$this->form_rowsToStylewidth);
03518                         $theStyle = 'width:'.$pixels.'px;'.$this->defStyle.$this->formElStyle($textarea?'text':'input');
03519                         $retVal = ' style="'.htmlspecialchars($theStyle).'"';
03520 
03521                         $class = $this->formElClass($textarea?'text':'input');
03522                         if ($class)     {
03523                                 $retVal.= ' class="'.htmlspecialchars($class).'"';
03524                         }
03525                 }
03526                 return $retVal;
03527         }
03528 
03537         function formWidthText($size=48,$wrap='') {
03538                 $wTags = $this->formWidth($size,1);
03539                         // 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...
03540                 if (strtolower(trim($wrap))!='off' && $GLOBALS['CLIENT']['BROWSER']=='net' && $GLOBALS['CLIENT']['VERSION']>=5) {
03541                         $wTags.=' cols="'.$size.'"';
03542                 }
03543                 return $wTags;
03544         }
03545 
03553         function formElStyle($type)     {
03554                 return $this->formElStyleClassValue($type);
03555         }
03556 
03564         function formElClass($type)     {
03565                 return $this->formElStyleClassValue($type, TRUE);
03566         }
03567 
03575         function formElStyleClassValue($type, $class=FALSE)     {
03576                         // Get value according to field:
03577                 if (isset($this->fieldStyle[$type]))    {
03578                         $style = trim($this->fieldStyle[$type]);
03579                 } else {
03580                         $style = trim($this->fieldStyle['all']);
03581                 }
03582 
03583                         // Check class prefixed:
03584                 if (substr($style,0,6)=='CLASS:')       {
03585                         return $class ? trim(substr($style,6)) : '';
03586                 } else {
03587                         return !$class ? $style : '';
03588                 }
03589         }
03590 
03597         function insertDefStyle($type)  {
03598                 $out = '';
03599 
03600                 $style = trim($this->defStyle.$this->formElStyle($type));
03601                 $out.= $style?' style="'.htmlspecialchars($style).'"':'';
03602 
03603                 $class = $this->formElClass($type);
03604                 $out.= $class?' class="'.htmlspecialchars($class).'"':'';
03605 
03606                 return $out;
03607         }
03608 
03616         function getDynTabMenu($parts, $idString) {
03617                 if (is_object($GLOBALS['TBE_TEMPLATE']))        {
03618                         return $GLOBALS['TBE_TEMPLATE']->getDynTabMenu($parts, $idString);
03619                 } else {
03620                         $output = '';
03621                         foreach($parts as $singlePad)   {
03622                                 $output.='
03623                                 <h3>'.htmlspecialchars($singlePad['label']).'</h3>
03624                                 '.($singlePad['description'] ? '<p class="c-descr">'.nl2br(htmlspecialchars($singlePad['description'])).'</p>' : '').'
03625                                 '.$singlePad['content'];
03626                         }
03627 
03628                         return '<div class="typo3-dyntabmenu-divs">'.$output.'</div>';
03629                 }
03630         }
03631 
03632 
03633 
03634 
03635 
03636 
03637 
03638 
03639 
03640 
03641 
03642         /************************************************************
03643          *
03644          * Item-array manipulation functions (check/select/radio)
03645          *
03646          ************************************************************/
03647 
03655         function initItemArray($fieldValue)     {
03656                 $items = array();
03657                 if (is_array($fieldValue['config']['items']))   {
03658                         reset ($fieldValue['config']['items']);
03659                         while (list($itemName,$itemValue) = each($fieldValue['config']['items']))       {
03660                                 $items[] = array($this->sL($itemValue[0]), $itemValue[1], $itemValue[2]);
03661                         }
03662                 }
03663                 return $items;
03664         }
03665 
03673         function addItems($items,$iArray)       {
03674                 global $TCA;
03675                 if (is_array($iArray))  {
03676                         reset($iArray);
03677                         while(list($value,$label)=each($iArray))        {
03678                                 $items[]=array($this->sl($label),$value);
03679                         }
03680                 }
03681                 return $items;
03682         }
03683 
03695         function procItems($items,$iArray,$config,$table,$row,$field)   {
03696                 global $TCA;
03697 
03698                 $params=array();
03699                 $params['items'] = &$items;
03700                 $params['config'] = $config;
03701                 $params['TSconfig'] = $iArray;
03702                 $params['table'] = $table;
03703                 $params['row'] = $row;
03704                 $params['field'] = $field;
03705 
03706                 t3lib_div::callUserFunction($config['itemsProcFunc'],$params,$this);
03707                 return $items;
03708         }
03709 
03719         function addSelectOptionsToItemArray($items,$fieldValue,$TSconfig,$field)       {
03720                 global $TCA;
03721 
03722                         // Values from foreign tables:
03723                 if ($fieldValue['config']['foreign_table'])     {
03724                         $items = $this->foreignTable($items,$fieldValue,$TSconfig,$field);
03725                         if ($fieldValue['config']['neg_foreign_table']) {
03726                                 $items = $this->foreignTable($items,$fieldValue,$TSconfig,$field,1);
03727                         }
03728                 }
03729 
03730                         // Values from a file folder:
03731                 if ($fieldValue['config']['fileFolder'])        {
03732                         $fileFolder = t3lib_div::getFileAbsFileName($fieldValue['config']['fileFolder']);
03733                         if (@is_dir($fileFolder))       {
03734 
03735                                         // Configurations:
03736                                 $extList = $fieldValue['config']['fileFolder_extList'];
03737                                 $recursivityLevels = isset($fieldValue['config']['fileFolder_recursions']) ? t3lib_div::intInRange($fieldValue['config']['fileFolder_recursions'],0,99) : 99;
03738 
03739                                         // Get files:
03740                                 $fileFolder = ereg_replace('\/$','',$fileFolder).'/';
03741                                 $fileArr = t3lib_div::getAllFilesAndFoldersInPath(array(),$fileFolder,$extList,0,$recursivityLevels);
03742                                 $fileArr = t3lib_div::removePrefixPathFromList($fileArr, $fileFolder);
03743 
03744                                 foreach($fileArr as $fileRef)   {
03745                                         $fI = pathinfo($fileRef);
03746                                         $icon = t3lib_div::inList('gif,png,jpeg,jpg', strtolower($fI['extension'])) ? '../'.substr($fileFolder,strlen(PATH_site)).$fileRef : '';
03747                                         $items[] = array(
03748                                                 $fileRef,
03749                                                 $fileRef,
03750                                                 $icon
03751                                         );
03752                                 }
03753                         }
03754                 }
03755 
03756                         // If 'special' is configured:
03757                 if ($fieldValue['config']['special'])   {
03758                         switch ($fieldValue['config']['special'])       {
03759                                 case 'tables':
03760                                         $temp_tc = array_keys($TCA);
03761                                         $descr = '';
03762 
03763                                         foreach($temp_tc as $theTableNames)     {
03764                                                 if (!$TCA[$theTableNames]['ctrl']['adminOnly']) {
03765 
03766                                                                 // Icon:
03767                                                         $icon = '../'.TYPO3_mainDir.t3lib_iconWorks::skinImg($this->backPath,t3lib_iconWorks::getIcon($theTableNames, array()),'',1);
03768 
03769                                                                 // Add description texts:
03770                                                         if ($this->edit_showFieldHelp)  {
03771                                                                 $GLOBALS['LANG']->loadSingleTableDescription($theTableNames);
03772                                                                 $fDat = $GLOBALS['TCA_DESCR'][$theTableNames]['columns'][''];
03773                                                                 $descr = $fDat['description'];
03774                                                         }
03775 
03776                                                                 // Item configuration:
03777                                                         $items[] = array(
03778                                                                 $this->sL($TCA[$theTableNames]['ctrl']['title']),
03779                                                                 $theTableNames,
03780                                                                 $icon,
03781                                                                 $descr
03782                                                         );
03783                                                 }
03784                                         }
03785                                 break;
03786                                 case 'pagetypes':
03787                                         $theTypes = $TCA['pages']['columns']['doktype']['config']['items'];
03788 
03789                                         foreach($theTypes as $theTypeArrays)    {
03790                                                         // Icon:
03791                                                 $icon = $theTypeArrays[1]!='--div--' ? '../'.TYPO3_mainDir.t3lib_iconWorks::skinImg($this->backPath,t3lib_iconWorks::getIcon('pages', array('doktype' => $theTypeArrays[1])),'',1) : '';
03792 
03793                                                         // Item configuration:
03794                                                 $items[] = array(
03795                                                         $this->sL($theTypeArrays[0]),
03796                                                         $theTypeArrays[1],
03797                                                         $icon
03798                                                 );
03799                                         }
03800                                 break;
03801                                 case 'exclude':
03802                                         $theTypes = t3lib_BEfunc::getExcludeFields();
03803                                         $descr = '';
03804 
03805                                         foreach($theTypes as $theTypeArrays)    {
03806                                                 list($theTable, $theField) = explode(':', $theTypeArrays[1]);
03807 
03808                                                         // Add description texts:
03809                                                 if ($this->edit_showFieldHelp)  {
03810                                                         $GLOBALS['LANG']->loadSingleTableDescription($theTable);
03811                                                         $fDat = $GLOBALS['TCA_DESCR'][$theTable]['columns'][$theField];
03812                                                         $descr = $fDat['description'];
03813                                                 }
03814 
03815                                                         // Item configuration:
03816                                                 $items[] = array(
03817                                                         ereg_replace(':$','',$theTypeArrays[0]),
03818                                                         $theTypeArrays[1],
03819                                                         '',
03820                                                         $descr
03821                                                 );
03822                                         }
03823                                 break;
03824                                 case 'explicitValues':
03825                                         $theTypes = t3lib_BEfunc::getExplicitAuthFieldValues();
03826 
03827                                                         // Icons:
03828                                         $icons = array(
03829                                                 'ALLOW' => '../'.TYPO3_mainDir.t3lib_iconWorks::skinImg($this->backPath,'gfx/icon_ok2.gif','',1),
03830                                                 'DENY' => '../'.TYPO3_mainDir.t3lib_iconWorks::skinImg($this->backPath,'gfx/icon_fatalerror.gif','',1),
03831                                         );
03832 
03833                                                 // Traverse types:
03834                                         foreach($theTypes as $tableFieldKey => $theTypeArrays)  {
03835 
03836                                                 if (is_array($theTypeArrays['items']))  {
03837                                                                 // Add header:
03838                                                         $items[] = array(
03839                                                                 $theTypeArrays['tableFieldLabel'],
03840                                                                 '--div--',
03841                                                         );
03842 
03843                                                                 // Traverse options for this field:
03844                                                         foreach($theTypeArrays['items'] as $itemValue => $itemContent)  {
03845                                                                         // Add item to be selected:
03846                                                                 $items[] = array(
03847                                                                         '['.$itemContent[2].'] '.$itemContent[1],
03848                                                                         $tableFieldKey.':'.ereg_replace('[:|,]','',$itemValue).':'.$itemContent[0],
03849                                                                         $icons[$itemContent[0]]
03850                                                                 );
03851                                                         }
03852                                                 }
03853                                         }
03854                                 break;
03855                                 case 'languages':
03856                                         $items = array_merge($items,t3lib_BEfunc::getSystemLanguages());
03857                                 break;
03858                                 case 'custom':
03859                                                 // Initialize:
03860                                         $customOptions = $GLOBALS['TYPO3_CONF_VARS']['BE']['customPermOptions'];
03861                                         if (is_array($customOptions))   {
03862                                                 foreach($customOptions as $coKey => $coValue) {
03863                                                         if (is_array($coValue['items']))        {
03864                                                                         // Add header:
03865                                                                 $items[] = array(
03866                                                                         $GLOBALS['LANG']->sl($coValue['header']),
03867                                                                         '--div--',
03868                                                                 );
03869 
03870                                                                         // Traverse items:
03871                                                                 foreach($coValue['items'] as $itemKey => $itemCfg)      {
03872                                                                                 // Icon:
03873                                                                         if ($itemCfg[1])        {
03874                                                                                 list($icon) = $this->getIcon($itemCfg[1]);
03875                                                                                 if ($icon)      $icon = '../'.TYPO3_mainDir.$icon;
03876                                                                         } else $icon = '';
03877 
03878                                                                                 // Add item to be selected:
03879                                                                         $items[] = array(
03880                                                                                 $GLOBALS['LANG']->sl($itemCfg[0]),
03881                                                                                 $coKey.':'.ereg_replace('[:|,]','',$itemKey),
03882                                                                                 $icon,
03883                                                                                 $GLOBALS['LANG']->sl($itemCfg[2]),
03884                                                                         );
03885                                                                 }
03886                                                         }
03887                                                 }
03888                                         }
03889                                 break;
03890                                 case 'modListGroup':
03891                                 case 'modListUser':
03892                                         $loadModules = t3lib_div::makeInstance('t3lib_loadModules');
03893                                         $loadModules->load($GLOBALS['TBE_MODULES']);
03894 
03895                                         $modList = $fieldValue['config']['special']=='modListUser' ? $loadModules->modListUser : $loadModules->modListGroup;
03896                                         if (is_array($modList)) {
03897                                                 $descr = '';
03898 
03899                                                 foreach($modList as $theMod)    {
03900 
03901                                                                 // Icon:
03902                                                         $icon = $GLOBALS['LANG']->moduleLabels['tabs_images'][$theMod.'_tab'];
03903                                                         if ($icon)      {
03904                                                                 $icon = '../'.substr($icon,strlen(PATH_site));
03905                                                         }
03906 
03907                                                                 // Description texts:
03908                                                         if ($this->edit_showFieldHelp)  {
03909                                                                 $descr = $GLOBALS['LANG']->moduleLabels['labels'][$theMod.'_tablabel'].
03910                                                                                         chr(10).
03911                                                                                         $GLOBALS['LANG']->moduleLabels['labels'][$theMod.'_tabdescr'];
03912                                                         }
03913 
03914                                                                 // Item configuration:
03915                                                         $items[] = array(
03916                                                                 $this->addSelectOptionsToItemArray_makeModuleData($theMod),
03917                                                                 $theMod,
03918                                                                 $icon,
03919                                                                 $descr
03920                                                         );
03921                                                 }
03922                                         }
03923                                 break;
03924                         }
03925                 }
03926 
03927                         // Return the items:
03928                 return $items;
03929         }
03930 
03939         function addSelectOptionsToItemArray_makeModuleData($value)     {
03940                 $label = '';
03941                         // Add label for main module:
03942                 $pp = explode('_',$value);
03943                 if (count($pp)>1)       $label.=$GLOBALS['LANG']->moduleLabels['tabs'][$pp[0].'_tab'].'>';
03944                         // Add modules own label now:
03945                 $label.= $GLOBALS['LANG']->moduleLabels['tabs'][$value.'_tab'];
03946 
03947                 return $label;
03948         }
03949 
03961         function foreignTable($items,$fieldValue,$TSconfig,$field,$pFFlag=0)    {
03962                 global $TCA;
03963 
03964                         // Init:
03965                 $pF=$pFFlag?'neg_':'';
03966                 $f_table = $fieldValue['config'][$pF.'foreign_table'];
03967                 $uidPre = $pFFlag?'-':'';
03968 
03969                         // Get query:
03970                 $res = t3lib_BEfunc::exec_foreign_table_where_query($fieldValue,$field,$TSconfig,$pF);
03971 
03972                         // Perform lookup
03973                 if ($GLOBALS['TYPO3_DB']->sql_error())  {
03974                         echo($GLOBALS['TYPO3_DB']->sql_error()."\n\nThis may indicate a table defined in tables.php is not existing in the database!");
03975                         return array();
03976                 }
03977 
03978                         // Get label prefix.
03979                 $lPrefix = $this->sL($fieldValue['config'][$pF.'foreign_table_prefix']);
03980 
03981                         // Get icon field + path if any:
03982                 $iField = $TCA[$f_table]['ctrl']['selicon_field'];
03983                 $iPath = trim($TCA[$f_table]['ctrl']['selicon_field_path']);
03984 
03985                         // Traverse the selected rows to add them:
03986                 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))      {
03987                         t3lib_BEfunc::workspaceOL($f_table, $row);
03988                                 // Prepare the icon if available:
03989                         if ($iField && $iPath && $row[$iField]) {
03990                                 $iParts = t3lib_div::trimExplode(',',$row[$iField],1);
03991                                 $icon = '../'.$iPath.'/'.trim($iParts[0]);
03992                         } elseif (t3lib_div::inList('singlebox,checkbox',$fieldValue['config']['renderMode'])) {
03993                                 $icon = '../'.TYPO3_mainDir.t3lib_iconWorks::skinImg($this->backPath,t3lib_iconWorks::getIcon($f_table, $row),'',1);
03994                         } else $icon = '';
03995 
03996                                 // Add the item:
03997                         $items[] = array(
03998                                 t3lib_div::fixed_lgd_cs($lPrefix.strip_tags(t3lib_BEfunc::getRecordTitle($f_table,$row)),$this->titleLen),
03999                                 $uidPre.$row['uid'],
04000                                 $icon
04001                         );
04002                 }
04003                 return $items;
04004         }
04005 
04006 
04007 
04008 
04009 
04010 
04011 
04012 
04013 
04014 
04015 
04016 
04017 
04018 
04019 
04020 
04021 
04022 
04023 
04024 
04025 
04026 
04027 
04028 
04029 
04030         /********************************************
04031          *
04032          * Template functions
04033          *
04034          ********************************************/
04035 
04042         function setNewBEDesign()       {
04043 
04044                         // Wrapping all table rows for a particular record being edited:
04045                 $this->totalWrap='
04046                 <table border="0" cellspacing="0" cellpadding="0" width="'.($this->docLarge ? 440+150 : 440).'" class="typo3-TCEforms">'.
04047                         '<tr class="bgColor2">
04048                                 <td>&nbsp;</td>
04049                                 <td>###RECORD_ICON### <span class="typo3-TCEforms-recHeader">###TABLE_TITLE###</span> ###ID_NEW_INDICATOR### - ###RECORD_LABEL###</td>
04050                         </tr>'.
04051                         '|'.
04052                         '<tr>
04053                                 <td>&nbsp;</td>
04054                                 <td><img src="clear.gif" width="'.($this->docLarge ? 440+150 : 440).'" height="1" alt="" /></td>
04055                         </tr>
04056                 </table>';
04057 
04058                         // Wrapping a single field:
04059                 $this->fieldTemplate='
04060                         <tr ###BGCOLOR_HEAD######CLASSATTR_2###>
04061                                 <td>###FIELD_HELP_ICON###</td>
04062                                 <td width="99%"><span style="color:###FONTCOLOR_HEAD###;"###CLASSATTR_4###><b>###FIELD_NAME###</b></span>###FIELD_HELP_TEXT###</td>
04063                         </tr>
04064                         <tr ###BGCOLOR######CLASSATTR_1###>
04065                                 <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>
04066                                 <td valign="top">###FIELD_ITEM######FIELD_PAL_LINK_ICON###</td>
04067                         </tr>';
04068 
04069                 $this->palFieldTemplate='
04070                         <tr ###BGCOLOR######CLASSATTR_1###>
04071                                 <td>&nbsp;</td>
04072                                 <td nowrap="nowrap" valign="top">###FIELD_PALETTE###</td>
04073                         </tr>';
04074                 $this->palFieldTemplateHeader='
04075                         <tr ###BGCOLOR_HEAD######CLASSATTR_2###>
04076                                 <td>&nbsp;</td>
04077                                 <td nowrap="nowrap" valign="top"><strong>###FIELD_HEADER###</strong></td>
04078                         </tr>';
04079 
04080                 $this->sectionWrap='
04081                         <tr>
04082                                 <td colspan="2"><img src="clear.gif" width="1" height="###SPACE_BEFORE###" alt="" /></td>
04083                         </tr>
04084                         <tr>
04085                                 <td colspan="2"><table ###TABLE_ATTRIBS###>###CONTENT###</table></td>
04086                         </tr>
04087                         ';
04088         }
04089 
04097         function intoTemplate($inArr,$altTemplate='')   {
04098                                 // Put into template_
04099                 $fieldTemplateParts = explode('###FIELD_',$this->rplColorScheme($altTemplate?$altTemplate:$this->fieldTemplate));
04100                 reset($fieldTemplateParts);
04101                 $out=current($fieldTemplateParts);
04102                 while(list(,$part)=each($fieldTemplateParts))   {
04103                         list($key,$val)=explode('###',$part,2);
04104                         $out.=$inArr[$key];
04105                         $out.=$val;
04106                 }
04107                 return $out;
04108         }
04109 
04121         function addUserTemplateMarkers($marker,$table,$field,$row,&$PA)        {
04122                 return $marker;
04123         }
04124 
04132         function wrapLabels($str)       {
04133                 return $str;
04134         }
04135 
04145         function wrapTotal($c,$rec,$table)      {
04146                 $parts = $this->replaceTableWrap(explode('|',$this->totalWrap,2),$rec,$table);
04147                 return $parts[0].$c.$parts[1].implode('',$this->hiddenFieldAccum);
04148         }
04149 
04158         function replaceTableWrap($arr,$rec,$table)     {
04159                 global $TCA;
04160                 reset($arr);
04161                 while(list($k,$v)=each($arr))   {
04162 
04163                                 // Make "new"-label
04164                         if (strstr($rec['uid'],'NEW'))  {
04165                                 $newLabel = ' <span class="typo3-TCEforms-newToken">'.
04166                                                         $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.new',1).
04167                                                         '</span>';
04168 
04169                                 #t3lib_BEfunc::fixVersioningPid($table,$rec);   // Kasper: Should not be used here because NEW records are not offline workspace versions...
04170                                 $truePid = t3lib_BEfunc::getTSconfig_pidValue($table,$rec['uid'],$rec['pid']);
04171                                 $prec = t3lib_BEfunc::getRecordWSOL('pages',$truePid,'title');
04172                                 $rLabel = '<em>[PID: '.$truePid.'] '.htmlspecialchars(trim(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle('pages',$prec),40))).'</em>';
04173                         } else {
04174                                 $newLabel = ' <span class="typo3-TCEforms-recUid">['.$rec['uid'].']</span>';
04175                                 $rLabel  = htmlspecialchars(trim(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table,$rec),40)));
04176                         }
04177 
04178                                 // Make substitutions:
04179                         $arr[$k] = str_replace('###ID_NEW_INDICATOR###', $newLabel, $arr[$k]);
04180                         $arr[$k] = str_replace('###RECORD_LABEL###',$rLabel,$arr[$k]);
04181                         $arr[$k] = str_replace('###TABLE_TITLE###',htmlspecialchars($this->sL($TCA[$table]['ctrl']['title'])),$arr[$k]);
04182 
04183                         $titleA=t3lib_BEfunc::titleAltAttrib($this->getRecordPath($table,$rec));
04184                         $arr[$k]=str_replace('###RECORD_ICON###',t3lib_iconWorks::getIconImage($table,$rec,$this->backPath,'class="absmiddle"'.$titleA),$arr[$k]);
04185                 }
04186                 return $arr;
04187         }
04188 
04196         function wrapBorder(&$out_array,&$out_pointer)  {
04197                 if ($this->sectionWrap && $out_array[$out_pointer])     {
04198                         $tableAttribs='';
04199                         $tableAttribs.= $this->borderStyle[0] ? ' style="'.htmlspecialchars($this->borderStyle[0]).'"':'';
04200                         $tableAttribs.= $this->borderStyle[2] ? ' background="'.htmlspecialchars($this->backPath.$this->borderStyle[2]).'"':'';
04201                         $tableAttribs.= $this->borderStyle[3] ? ' class="'.htmlspecialchars($this->borderStyle[3]).'"':'';
04202                         if ($tableAttribs)      {
04203                                 $tableAttribs='border="0" cellspacing="0" cellpadding="0" width="100%"'.$tableAttribs;
04204                                 $out_array[$out_pointer] = str_replace('###CONTENT###',$out_array[$out_pointer],
04205                                         str_replace('###TABLE_ATTRIBS###',$tableAttribs,
04206                                                 str_replace('###SPACE_BEFORE###',intval($this->borderStyle[1]),$this->sectionWrap)));
04207                         }
04208                         $out_pointer++;
04209                 }
04210         }
04211 
04218         function rplColorScheme($inTemplate)    {
04219                         // Colors:
04220                 $inTemplate = str_replace('###BGCOLOR###',$this->colorScheme[0]?' bgcolor="'.$this->colorScheme[0].'"':'',$inTemplate);
04221                 $inTemplate = str_replace('###BGCOLOR_HEAD###',$this->colorScheme[1]?' bgcolor="'.$this->colorScheme[1].'"':'',$inTemplate);
04222                 $inTemplate = str_replace('###FONTCOLOR_HEAD###',$this->colorScheme[3],$inTemplate);
04223 
04224                         // Classes:
04225                 $inTemplate = str_replace('###CLASSATTR_1###',$this->classScheme[0]?' class="'.$this->classScheme[0].'"':'',$inTemplate);
04226                 $inTemplate = str_replace('###CLASSATTR_2###',$this->classScheme[1]?' class="'.$this->classScheme[1].'"':'',$inTemplate);
04227                 $inTemplate = str_replace('###CLASSATTR_4###',$this->classScheme[3]?' class="'.$this->classScheme[3].'"':'',$inTemplate);
04228 
04229                 return $inTemplate;
04230         }
04231 
04238         function getDivider()   {
04239                 //return "<hr />";
04240         }
04241 
04248         function printPalette($palArr)  {
04249 
04250                         // Init color/class attributes:
04251                 $ccAttr2 = $this->colorScheme[2] ? ' bgcolor="'.$this->colorScheme[2].'"' : '';
04252                 $ccAttr2.= $this->classScheme[2] ? ' class="'.$this->classScheme[2].'"' : '';
04253                 $ccAttr4 = $this->colorScheme[4] ? ' style="color:'.$this->colorScheme[4].'"' : '';
04254                 $ccAttr4.= $this->classScheme[4] ? ' class="'.$this->classScheme[4].'"' : '';
04255 
04256                         // Traverse palette fields and render them into table rows:
04257                 foreach($palArr as $content)    {
04258                         $hRow[]='<td'.$ccAttr2.'>&nbsp;</td>
04259                                         <td nowrap="nowrap"'.$ccAttr2.'>'.
04260                                                 '<span'.$ccAttr4.'>'.
04261                                                         $content['NAME'].
04262                                                 '</span>'.
04263                                         '</td>';
04264                         $iRow[]='<td valign="top">'.
04265                                                 '<img name="req_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="10" height="10" vspace="4" alt="" />'.
04266                                                 '<img name="cm_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="7" height="10" vspace="4" alt="" />'.
04267                                         '</td>
04268                                         <td nowrap="nowrap" valign="top">'.
04269                                                 $content['ITEM'].
04270                                                 $content['HELP_ICON'].
04271                                         '</td>';
04272                 }
04273 
04274                         // Final wrapping into the table:
04275                 $out='<table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-palette">
04276                         <tr>
04277                                 <td><img src="clear.gif" width="'.intval($this->paletteMargin).'" height="1" alt="" /></td>'.
04278                                         implode('
04279                                 ',$hRow).'
04280                         </tr>
04281                         <tr>
04282                                 <td></td>'.
04283                                         implode('
04284                                 ',$iRow).'
04285                         </tr>
04286                 </table>';
04287 
04288                 return $out;
04289         }
04290 
04299         function helpTextIcon($table,$field,$force=0)   {
04300                 if ($this->globalShowHelp && $GLOBALS['TCA_DESCR'][$table]['columns'][$field] && (($this->edit_showFieldHelp=='icon'&&!$this->doLoadTableDescr($table)) || $force))     {
04301                         $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;';
04302                         return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
04303                                         '<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="" />'.
04304                                         '</a>';
04305                 } else {
04306                                 // Detects fields with no CSH and outputs dummy line to insert into CSH locallang file:
04307                         #debug(array("'".$field.".description' => '[FILL IN] ".$table."->".$field."',"),$table);
04308                         return '<span class="nbsp">&nbsp;</span>';
04309                 }
04310         }
04311 
04319         function helpText($table,$field)        {
04320                 if ($this->globalShowHelp && $GLOBALS['TCA_DESCR'][$table]['columns'][$field] && ($this->edit_showFieldHelp=='text' || $this->doLoadTableDescr($table)))        {
04321                         $fDat = $GLOBALS['TCA_DESCR'][$table]['columns'][$field];
04322                         return '<table border="0" cellpadding="2" cellspacing="0" width="90%"><tr><td valign="top" width="14">'.
04323                                         $this->helpTextIcon(
04324                                                 $table,
04325                                                 $field,
04326                                                 $fDat['details']||$fDat['syntax']||$fDat['image_descr']||$fDat['image']||$fDat['seeAlso']
04327                                         ).
04328                                         '</td><td valign="top"><span class="typo3-TCEforms-helpText">'.
04329                                         $GLOBALS['LANG']->hscAndCharConv(strip_tags($fDat['description']),1).
04330                                         '</span></td></tr></table>';
04331                 }
04332         }
04333 
04340         function setColorScheme($scheme)        {
04341                 $this->colorScheme = $this->defColorScheme;
04342                 $this->classScheme = $this->defClassScheme;
04343 
04344                 $parts = t3lib_div::trimExplode(',',$scheme);
04345                 foreach($parts as $key => $col) {
04346                                 // Split for color|class:
04347                         list($color,$class) = t3lib_div::trimExplode('|',$col);
04348 
04349                                 // Handle color values:
04350                         if ($color)     $this->colorScheme[$key] = $color;
04351                         if ($color=='-')        $this->colorScheme[$key] = '';
04352 
04353                                 // Handle class values:
04354                         if ($class)     $this->classScheme[$key] = $class;
04355                         if ($class=='-')        $this->classScheme[$key] = '';
04356                 }
04357         }
04358 
04364         function resetSchemes() {
04365                 $this->setColorScheme($GLOBALS['TBE_STYLES']['colorschemes'][0]);
04366                 $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][0];
04367                 $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][0];
04368         }
04369 
04375         function storeSchemes() {
04376                 $this->savedSchemes['classScheme'] = $this->classScheme;
04377                 $this->savedSchemes['colorScheme'] = $this->colorScheme;
04378                 $this->savedSchemes['fieldStyle'] = $this->fieldStyle;
04379                 $this->savedSchemes['borderStyle'] = $this->borderStyle;
04380         }
04381 
04387         function restoreSchemes()       {
04388                 $this->classScheme = $this->savedSchemes['classScheme'];
04389                 $this->colorScheme = $this->savedSchemes['colorScheme'];
04390                 $this->fieldStyle = $this->savedSchemes['fieldStyle'];
04391                 $this->borderStyle = $this->savedSchemes['borderStyle'];
04392         }
04393 
04394 
04395 
04396 
04397 
04398 
04399 
04400 
04401 
04402 
04403 
04404 
04405 
04406         /********************************************
04407          *
04408          * JavaScript related functions
04409          *
04410          ********************************************/
04411 
04417         function JStop()        {
04418 
04419                 $out = '';
04420 
04421                         // Additional top HTML:
04422                 if (count($this->additionalCode_pre))   {
04423                         $out.= implode('
04424 
04425                                 <!-- NEXT: -->
04426                         ',$this->additionalCode_pre);
04427                 }
04428 
04429                         // Additional top JavaScript
04430                 if (count($this->additionalJS_pre))     {
04431                         $out.='
04432 
04433 
04434                 <!--
04435                         JavaScript in top of page (before form):
04436                 -->
04437 
04438                 <script type="text/javascript">
04439                         /*<![CDATA[*/
04440 
04441                         '.implode('
04442 
04443                                 // NEXT:
04444                         ',$this->additionalJS_pre).'
04445 
04446                         /*]]>*/
04447                 </script>
04448                         ';
04449                 }
04450 
04451                         // Return result:
04452                 return $out;
04453         }
04454 
04468         function JSbottom($formname='forms[0]') {
04469 
04470                                 // required
04471                         $reqLines=array();
04472                         $reqLinesCheck=array();
04473                         $reqLinesSet=array();
04474                         reset($this->requiredFields);
04475                         while(list($itemImgName,$itemName)=each($this->requiredFields)) {
04476                                 $reqLines[]="                                   TBE_REQUIRED['".$itemName."']=1;";
04477                                 $reqLinesCheck[]="                                      if (!document.".$formname."['".$itemName."'].value)     {OK=0;}";
04478                                 $reqLinesSet[]="                                        if (!document.".$formname."['".$itemName."'].value)     {TBE_EDITOR_setImage('req_".$itemImgName."','TBE_EDITOR_req');}";
04479                         }
04480 
04481                         $reqRange=array();
04482                         $reqRangeCheck=array();
04483                         $reqRangeSet=array();
04484                         reset($this->requiredElements);
04485                         while(list($itemName,$range)=each($this->requiredElements))     {
04486                                 $reqRange[]="                                   TBE_RANGE['".$itemName."']=1;";
04487                                 $reqRange[]="                                   TBE_RANGE_lower['".$itemName."']=".$range[0].";";
04488                                 $reqRange[]="                                   TBE_RANGE_upper['".$itemName."']=".$range[1].";";
04489                                 $reqRangeCheck[]="                                      if (!TBE_EDITOR_checkRange(document.".$formname."['".$itemName."_list'],".$range[0].",".$range[1]."))   {OK=0;}";
04490                                 $reqRangeSet[]="                                        if (!TBE_EDITOR_checkRange(document.".$formname."['".$itemName."_list'],".$range[0].",".$range[1]."))   {TBE_EDITOR_setImage('req_".$range['imgName']."','TBE_EDITOR_req');}";
04491                         }
04492 
04493                         $this->TBE_EDITOR_fieldChanged_func='TBE_EDITOR_fieldChanged_fName(fName,formObj[fName+"_list"]);';
04494 
04495                         if ($this->loadMD5_JS)  {
04496                         $out.='
04497                         <script type="text/javascript" src="'.$this->backPath.'md5.js"></script>';
04498                         }
04499                         $out.='
04500                         <script type="text/javascript" src="'.$this->backPath.'../t3lib/jsfunc.evalfield.js"></script>
04501                         <script type="text/javascript">
04502                                 /*<![CDATA[*/
04503 
04504                                 var TBE_EDITOR_req=new Image();         TBE_EDITOR_req.src = "'.t3lib_iconWorks::skinImg($this->backPath,'gfx/required_h.gif','',1).'";
04505                                 var TBE_EDITOR_cm=new Image();          TBE_EDITOR_cm.src = "'.t3lib_iconWorks::skinImg($this->backPath,'gfx/content_client.gif','',1).'";
04506                                 var TBE_EDITOR_sel=new Image();         TBE_EDITOR_sel.src = "'.t3lib_iconWorks::skinImg($this->backPath,'gfx/content_selected.gif','',1).'";
04507                                 var TBE_EDITOR_clear=new Image();       TBE_EDITOR_clear.src = "'.$this->backPath.'clear.gif";
04508                                 var TBE_REQUIRED=new Array();
04509 '.implode(chr(10),$reqLines).'
04510 
04511                                 var TBE_RANGE=new Array();
04512                                 var TBE_RANGE_lower=new Array();
04513                                 var TBE_RANGE_upper=new Array();
04514 '.implode(chr(10),$reqRange).'
04515 
04516                                 // $this->additionalJS_post:
04517 '.implode(chr(10),$this->additionalJS_post).'
04518 
04519                                 var TBE_EDITOR_loadTime = 0;
04520                                 var TBE_EDITOR_isChanged = 0;
04521 
04522                                 function TBE_EDITOR_loginRefreshed()    {       //
04523                                         var date = new Date();
04524                                         TBE_EDITOR_loadTime = Math.floor(date.getTime()/1000);
04525                                         if (top.busy && top.busy.loginRefreshed)        {top.busy.loginRefreshed();}
04526                                 }
04527                                 function TBE_EDITOR_checkLoginTimeout() {       //
04528                                         var date = new Date();
04529                                         var theTime = Math.floor(date.getTime()/1000);
04530                                         if (theTime > TBE_EDITOR_loadTime+'.intval($GLOBALS['BE_USER']->auth_timeout_field).'-10)       {
04531                                                 return true;
04532                                         }
04533                                 }
04534                                 function TBE_EDITOR_setHiddenContent(RTEcontent,theField)       {       //
04535                                         document.'.$formname.'[theField].value = RTEcontent;
04536                                         alert(document.'.$formname.'[theField].value);
04537                                 }
04538                                 function TBE_EDITOR_fieldChanged_fName(fName,el)        {       //
04539                                         var idx='.(2+substr_count($this->prependFormFieldNames,'[')).';
04540                                         var table = TBE_EDITOR_split(fName, "[", idx);
04541                                         var uid = TBE_EDITOR_split(fName, "[", idx+1);
04542                                         var field = TBE_EDITOR_split(fName, "[", idx+2);
04543 
04544                                         table = table.substr(0,table.length-1);
04545                                         uid = uid.substr(0,uid.length-1);
04546                                         field = field.substr(0,field.length-1);
04547                                         TBE_EDITOR_fieldChanged(table,uid,field,el);
04548                                 }
04549                                 function TBE_EDITOR_fieldChanged(table,uid,field,el)    {       //
04550                                         var theField = "'.$this->prependFormFieldNames.'["+table+"]["+uid+"]["+field+"]";
04551                                         TBE_EDITOR_isChanged = 1;
04552 
04553                                                 // Set change image:
04554                                         var imgObjName = "cm_"+table+"_"+uid+"_"+field;
04555                                         TBE_EDITOR_setImage(imgObjName,"TBE_EDITOR_cm");
04556 
04557                                                 // Set change image
04558                                         if (document.'.$formname.'[theField] && document.'.$formname.'[theField].type=="select-one" && document.'.$formname.'[theField+"_selIconVal"])  {
04559                                                 var imgObjName = "selIcon_"+table+"_"+uid+"_"+field+"_";
04560                                                 TBE_EDITOR_setImage(imgObjName+document.'.$formname.'[theField+"_selIconVal"].value,"TBE_EDITOR_clear");
04561                                                 document.'.$formname.'[theField+"_selIconVal"].value = document.'.$formname.'[theField].selectedIndex;
04562                                                 TBE_EDITOR_setImage(imgObjName+document.'.$formname.'[theField+"_selIconVal"].value,"TBE_EDITOR_sel");
04563                                         }
04564 
04565                                                 // Set required flag:
04566                                         var imgReqObjName = "req_"+table+"_"+uid+"_"+field;
04567                                         if (TBE_REQUIRED[theField] && document.'.$formname.'[theField]) {
04568                                                 if (document.'.$formname.'[theField].value)     {
04569                                                         TBE_EDITOR_setImage(imgReqObjName,"TBE_EDITOR_clear");
04570                                                 } else {
04571                                                         TBE_EDITOR_setImage(imgReqObjName,"TBE_EDITOR_req");
04572                                                 }
04573                                         }
04574                                         if (TBE_RANGE[theField] && document.'.$formname.'[theField])    {
04575                                                 if (TBE_EDITOR_checkRange(document.'.$formname.'[theField+"_list"],TBE_RANGE_lower[theField],TBE_RANGE_upper[theField]))        {
04576                                                         TBE_EDITOR_setImage(imgReqObjName,"TBE_EDITOR_clear");
04577                                                 } else {
04578                                                         TBE_EDITOR_setImage(imgReqObjName,"TBE_EDITOR_req");
04579                                                 }
04580                                         }
04581                                         '.(!$this->isPalettedoc?'':'
04582                                         TBE_EDITOR_setOriginalFormFieldValue(theField);
04583                                         ').'
04584                                 }
04585                                 '.($this->isPalettedoc?'
04586                                 function TBE_EDITOR_setOriginalFormFieldValue(theField) {       //
04587                                         if ('.$this->isPalettedoc.' && '.$this->isPalettedoc.'.document.'.$formname.' && '.$this->isPalettedoc.'.document.'.$formname.'[theField]) {
04588                                                 '.$this->isPalettedoc.'.document.'.$formname.'[theField].value = document.'.$formname.'[theField].value;
04589                                         }
04590                                 }
04591                                 ':'').'
04592                                 function TBE_EDITOR_isFormChanged(noAlert)      {       //
04593                                         if (TBE_EDITOR_isChanged && !noAlert && confirm('.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.fieldsChanged')).'))        {
04594                                                 return 0;
04595                                         }
04596                                         return TBE_EDITOR_isChanged;
04597                                 }
04598                                 function TBE_EDITOR_checkAndDoSubmit(sendAlert) {       //
04599                                         if (TBE_EDITOR_checkSubmit(sendAlert))  {
04600                                                 TBE_EDITOR_submitForm();
04601                                         }
04602                                 }
04603 
04610                                 function TBE_EDITOR_checkSubmit(sendAlert)      {       //
04611                                         if (TBE_EDITOR_checkLoginTimeout() && confirm('.$GLOBALS['LANG']->JScharCode($this->getLL('m_refresh_login')).'))       {
04612                                                 vHWin=window.open(\''.$this->backPath.'login_frameset.php?\',\'relogin\',\'height=300,width=400,status=0,menubar=0\');
04613                                                 vHWin.focus();
04614                                                 return false;
04615                                         }
04616                                         var OK=1;
04617 
04618                                         // $this->additionalJS_post:
04619 '.implode(chr(10),$this->additionalJS_submit).'
04620 
04621                                         if(!OK) {
04622                                                 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.")))  {
04623                                                         return false;
04624                                                 } else {
04625                                                         OK = 1;
04626                                                 }
04627                                         }
04628 
04629 '.implode(chr(10),$reqLinesCheck).'
04630 '.implode(chr(10),$reqRangeCheck).'
04631 
04632                                         if (OK || sendAlert==-1)        {
04633                                                 return true;
04634                                         } else {
04635                                                 if(sendAlert)   alert('.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.fieldsMissing')).');
04636                                                 return false;
04637                                         }
04638                                 }
04639                                 function TBE_EDITOR_checkRange(el,lower,upper)  {       //
04640                                         if (el && el.length>=lower && el.length<=upper) {
04641                                                 return true;
04642                                         } else {
04643                                                 return false;
04644                                         }
04645                                 }
04646                                 function TBE_EDITOR_initRequired()      {       //
04647 '.implode(chr(10),$reqLinesSet).'
04648 '.implode(chr(10),$reqRangeSet).'
04649                                 }
04650                                 function TBE_EDITOR_setImage(name,imgName)      {       //
04651                                         if (document[name]) {document[name].src = eval(imgName+".src");}
04652                                 }
04653                                 function TBE_EDITOR_submitForm()        {       //
04654                                         '.($this->doSaveFieldName?'document.'.$this->formName."['".$this->doSaveFieldName."'].value=1;":'').'
04655                                         document.'.$this->formName.'.submit();
04656                                 }
04657                                 function typoSetup      ()      {       //
04658                                         this.passwordDummy = "********";
04659                                         this.decimalSign = ".";
04660                                 }
04661                                 var TS = new typoSetup();
04662                                 var evalFunc = new evalFunc();
04663                                 evalFunc.USmode = '.($GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat']?'1':'0').';
04664 
04665                                 function typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue)  {       //
04666                                         if (document.'.$formname.'[theField])   {
04667                                                 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
04668                                                 var theValue = document.'.$formname.'[theField].value;
04669                                                 if (checkbox && theValue==checkboxValue)        {
04670                                                         document.'.$formname.'[theField+"_hr"].value="";
04671                                                         if (document.'.$formname.'[theField+"_cb"])     document.'.$formname.'[theField+"_cb"].checked = "";
04672                                                 } else {
04673                                                         document.'.$formname.'[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
04674                                                         if (document.'.$formname.'[theField+"_cb"])     document.'.$formname.'[theField+"_cb"].checked = "on";
04675                                                 }
04676                                         }
04677                                 }
04678                                 function typo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off, checkSetValue)     {       //
04679                                         if (document.'.$formname.'[theField])   {
04680                                                 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
04681                                                 if (checkbox_off)       {
04682                                                         if (document.'.$formname.'[theField+"_cb"].checked)     {
04683                                                                 document.'.$formname.'[theField].value=checkSetValue;
04684                                                         } else {
04685                                                                 document.'.$formname.'[theField].value=checkboxValue;
04686                                                         }
04687                                                 }else{
04688                                                         document.'.$formname.'[theField].value = evalFunc.evalObjValue(theFObj, document.'.$formname.'[theField+"_hr"].value);
04689                                                 }
04690                                                 typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue);
04691                                         }
04692                                 }
04693                                 function TBE_EDITOR_split(theStr1, delim, index) {              //
04694                                         var theStr = ""+theStr1;
04695                                         var lengthOfDelim = delim.length;
04696                                         sPos = -lengthOfDelim;
04697                                         if (index<1) {index=1;}
04698                                         for (var a=1; a<index; a++)     {
04699                                                 sPos = theStr.indexOf(delim, sPos+lengthOfDelim);
04700                                                 if (sPos==-1)   {return null;}
04701                                         }
04702                                         ePos = theStr.indexOf(delim, sPos+lengthOfDelim);
04703                                         if(ePos == -1)  {ePos = theStr.length;}
04704                                         return (theStr.substring(sPos+lengthOfDelim,ePos));
04705                                 }
04706                                 function TBE_EDITOR_palUrl(inData,fieldList,fieldNum,table,uid,isOnFocus) {             //
04707                                         var url = "'.$this->backPath.'alt_palette.php?inData="+inData+"&formName='.rawurlencode($this->formName).'"+"&prependFormFieldNames='.rawurlencode($this->prependFormFieldNames).'";
04708                                         var field = "";
04709                                         var theField="";
04710                                         for (var a=0; a<fieldNum;a++)   {
04711                                                 field = TBE_EDITOR_split(fieldList, ",", a+1);
04712                                                 theField = "'.$this->prependFormFieldNames.'["+table+"]["+uid+"]["+field+"]";
04713                                                 if (document.'.$formname.'[theField])           url+="&rec["+field+"]="+TBE_EDITOR_rawurlencode(document.'.$formname.'[theField].value);
04714                                         }
04715                                         if (top.topmenuFrame)   {
04716                                                 top.topmenuFrame.location.href = url+"&backRef="+(top.content.list_frame ? (top.content.list_frame.view_frame ? "top.content.list_frame.view_frame" : "top.content.list_frame") : "top.content");
04717                                         } else if (!isOnFocus) {
04718                                                 var vHWin=window.open(url,"palette","height=300,width=200,status=0,menubar=0,scrollbars=1");
04719                                                 vHWin.focus();
04720                                         }
04721                                 }
04722                                 function TBE_EDITOR_curSelected(theField)       {       //
04723                                         var fObjSel = document.'.$formname.'[theField];
04724                                         var retVal="";
04725                                         if (fObjSel)    {
04726                                                 if (fObjSel.type=="select-multiple" || fObjSel.type=="select-one")      {
04727                                                         var l=fObjSel.length;
04728                                                         for (a=0;a<l;a++)       {
04729                                                                 if (fObjSel.options[a].selected==1)     {
04730                                                                         retVal+=fObjSel.options[a].value+",";
04731                                                                 }
04732                                                         }
04733                                                 }
04734                                         }
04735                                         return retVal;
04736                                 }
04737                                 function TBE_EDITOR_rawurlencode(str,maxlen)    {       //
04738                                         var output = str;
04739                                         if (maxlen)     output = output.substr(0,200);
04740                                         output = escape(output);
04741                                         output = TBE_EDITOR_str_replace("*","%2A", output);
04742                                         output = TBE_EDITOR_str_replace("+","%2B", output);
04743                                         output = TBE_EDITOR_str_replace("/","%2F", output);
04744                                         output = TBE_EDITOR_str_replace("@","%40", output);
04745                                         return output;
04746                                 }
04747                                 function TBE_EDITOR_str_replace(match,replace,string)   {       //
04748                                         var input = ""+string;
04749                                         var matchStr = ""+match;
04750                                         if (!matchStr)  {return string;}
04751                                         var output = "";
04752                                         var pointer=0;
04753                                         var pos = input.indexOf(matchStr);
04754                                         while (pos!=-1) {
04755                                                 output+=""+input.substr(pointer, pos-pointer)+replace;
04756                                                 pointer=pos+matchStr.length;
04757                                                 pos = input.indexOf(match,pos+1);
04758                                         }
04759                                         output+=""+input.substr(pointer);
04760                                         return output;
04761                                 }
04762                                 /*]]>*/
04763                         </script>
04764                         <script type="text/javascript">
04765                                 /*<![CDATA[*/
04766 
04767                                 '.$this->extJSCODE.'
04768 
04769                                 TBE_EDITOR_initRequired();
04770                                 TBE_EDITOR_loginRefreshed();
04771                                 /*]]>*/
04772                         </script>';
04773                         return $out;
04774         }
04775 
04782         function dbFileCon($formObj='document.forms[0]')        {
04783                 $str='
04784 
04785                         // ***************
04786                         // Used to connect the db/file browser with this document and the formfields on it!
04787                         // ***************
04788 
04789                         var browserWin="";
04790 
04791                         function setFormValueOpenBrowser(mode,params) { //
04792                                 var url = "'.$this->backPath.'browser.php?mode="+mode+"&bparams="+params;
04793 
04794                                 browserWin = window.open(url,"Typo3WinBrowser","height=350,width="+(mode=="db"?650:600)+",status=0,menubar=0,resizable=1,scrollbars=1");
04795                                 browserWin.focus();
04796                         }
04797                         function setFormValueFromBrowseWin(fName,value,label,exclusiveValues)   {       //
04798                                 var formObj = setFormValue_getFObj(fName)
04799                                 if (formObj && value!="--div--")        {
04800                                         fObj = formObj[fName+"_list"];
04801                                         var len = fObj.length;
04802                                                 // Clear elements if exclusive values are found
04803                                         if (exclusiveValues)    {
04804                                                 var m = new RegExp("(^|,)"+value+"($|,)");
04805                                                 if (exclusiveValues.match(m))   {
04806                                                                 // the new value is exclusive
04807                                                         for (a=len-1;a>=0;a--)  fObj[a] = null;
04808                                                         len = 0;
04809                                                 } else if (len == 1)    {
04810                                                         m = new RegExp("(^|,)"+fObj.options[0].value+"($|,)");
04811                                                         if (exclusiveValues.match(m))   {
04812                                                                         // the old value is exclusive
04813                                                                 fObj[0] = null;
04814                                                                 len = 0;
04815                                                         }
04816                                                 }
04817                                         }
04818                                                 // Inserting element
04819                                         var setOK = 1;
04820                                         if (!formObj[fName+"_mul"] || formObj[fName+"_mul"].value==0)   {
04821                                                 for (a=0;a<len;a++)     {
04822                                                         if (fObj.options[a].value==value)       {
04823                                                                 setOK = 0;
04824                                                         }
04825                                                 }
04826                                         }
04827                                         if (setOK)      {
04828                                                 fObj.length++;
04829                                                 fObj.options[len].value = value;
04830                                                 fObj.options[len].text = unescape(label);
04831 
04832                                                         // Traversing list and set the hidden-field
04833                                                 setHiddenFromList(fObj,formObj[fName]);
04834                                                 '.$this->TBE_EDITOR_fieldChanged_func.'
04835                                         }
04836                                 }
04837                         }
04838                         function setHiddenFromList(fObjSel,fObjHid)     {       //
04839                                 l=fObjSel.length;
04840                                 fObjHid.value="";
04841                                 for (a=0;a<l;a++)       {
04842                                         fObjHid.value+=fObjSel.options[a].value+",";
04843                                 }
04844                         }
04845                         function setFormValueManipulate(fName,type)     {       //
04846                                 var formObj = setFormValue_getFObj(fName)
04847                                 if (formObj)    {
04848                                         var localArray_V = new Array();
04849                                         var localArray_L = new Array();
04850                                         var localArray_S = new Array();
04851                                         var fObjSel = formObj[fName+"_list"];
04852                                         var l=fObjSel.length;
04853                                         var c=0;
04854                                         if (type=="Remove" || type=="Top" || type=="Bottom")    {
04855                                                 if (type=="Top")        {
04856                                                         for (a=0;a<l;a++)       {
04857                                                                 if (fObjSel.options[a].selected==1)     {
04858                                                                         localArray_V[c]=fObjSel.options[a].value;
04859                                                                         localArray_L[c]=fObjSel.options[a].text;
04860                                                                         localArray_S[c]=1;
04861                                                                         c++;
04862                                                                 }
04863                                                         }
04864                                                 }
04865                                                 for (a=0;a<l;a++)       {
04866                                                         if (fObjSel.options[a].selected!=1)     {
04867                                                                 localArray_V[c]=fObjSel.options[a].value;
04868                                                                 localArray_L[c]=fObjSel.options[a].text;
04869                                                                 localArray_S[c]=0;
04870                                                                 c++;
04871                                                         }
04872                                                 }
04873                                                 if (type=="Bottom")     {
04874                                                         for (a=0;a<l;a++)       {
04875                                                                 if (fObjSel.options[a].selected==1)     {
04876                                                                         localArray_V[c]=fObjSel.options[a].value;
04877                                                                         localArray_L[c]=fObjSel.options[a].text;
04878                                                                         localArray_S[c]=1;
04879                                                                         c++;
04880                                                                 }
04881                                                         }
04882                                                 }
04883                                         }
04884                                         if (type=="Down")       {
04885                                                 var tC = 0;
04886                                                 var tA = new Array();
04887 
04888                                                 for (a=0;a<l;a++)       {
04889                                                         if (fObjSel.options[a].selected!=1)     {
04890                                                                         // Add non-selected element:
04891                                                                 localArray_V[c]=fObjSel.options[a].value;
04892                                                                 localArray_L[c]=fObjSel.options[a].text;
04893                                                                 localArray_S[c]=0;
04894                                                                 c++;
04895 
04896                                                                         // Transfer any accumulated and reset:
04897                                                                 if (tA.length > 0)      {
04898                                                                         for (aa=0;aa<tA.length;aa++)    {
04899                                                                                 localArray_V[c]=fObjSel.options[tA[aa]].value;
04900                                                                                 localArray_L[c]=fObjSel.options[tA[aa]].text;
04901                                                                                 localArray_S[c]=1;
04902                                                                                 c++;
04903                                                                         }
04904 
04905                                                                         var tC = 0;
04906                                                                         var tA = new Array();
04907                                                                 }
04908                                                         } else {
04909                                                                 tA[tC] = a;
04910                                                                 tC++;
04911                                                         }
04912                                                 }
04913                                                         // Transfer any remaining:
04914                                                 if (tA.length > 0)      {
04915                                                         for (aa=0;aa<tA.length;aa++)    {
04916                                                                 localArray_V[c]=fObjSel.options[tA[aa]].value;
04917                                                                 localArray_L[c]=fObjSel.options[tA[aa]].text;
04918                                                                 localArray_S[c]=1;
04919                                                                 c++;
04920                                                         }
04921                                                 }
04922                                         }
04923                                         if (type=="Up") {
04924                                                 var tC = 0;
04925                                                 var tA = new Array();
04926                                                 var c = l-1;
04927 
04928                                                 for (a=l-1;a>=0;a--)    {
04929                                                         if (fObjSel.options[a].selected!=1)     {
04930 
04931                                                                         // Add non-selected element:
04932                                                                 localArray_V[c]=fObjSel.options[a].value;
04933                                                                 localArray_L[c]=fObjSel.options[a].text;
04934                                                                 localArray_S[c]=0;
04935                                                                 c--;
04936 
04937                                                                         // Transfer any accumulated and reset:
04938                                                                 if (tA.length > 0)      {
04939                                                                         for (aa=0;aa<tA.length;aa++)    {
04940                                                                                 localArray_V[c]=fObjSel.options[tA[aa]].value;
04941                                                                                 localArray_L[c]=fObjSel.options[tA[aa]].text;
04942                                                                                 localArray_S[c]=1;
04943                                                                                 c--;
04944                                                                         }
04945 
04946                                                                         var tC = 0;
04947                                                                         var tA = new Array();
04948                                                                 }
04949                                                         } else {
04950                                                                 tA[tC] = a;
04951                                                                 tC++;
04952                                                         }
04953                                                 }
04954                                                         // Transfer any remaining:
04955                                                 if (tA.length > 0)      {
04956                                                         for (aa=0;aa<tA.length;aa++)    {
04957                                                                 localArray_V[c]=fObjSel.options[tA[aa]].value;
04958                                                                 localArray_L[c]=fObjSel.options[tA[aa]].text;
04959                                                                 localArray_S[c]=1;
04960                                                                 c--;
04961                                                         }
04962                                                 }
04963                                                 c=l;    // Restore length value in "c"
04964                                         }
04965 
04966                                                 // Transfer items in temporary storage to list object:
04967                                         fObjSel.length = c;
04968                                         for (a=0;a<c;a++)       {
04969                                                 fObjSel.options[a].value = localArray_V[a];
04970                                                 fObjSel.options[a].text = localArray_L[a];
04971                                                 fObjSel.options[a].selected = localArray_S[a];
04972                                         }
04973                                         setHiddenFromList(fObjSel,formObj[fName]);
04974 
04975                                         '.$this->TBE_EDITOR_fieldChanged_func.'
04976                                 }
04977                         }
04978                         function setFormValue_getFObj(fName)    {       //
04979                                 var formObj = '.$formObj.';
04980                                 if (formObj)    {
04981                                         if (formObj[fName] && formObj[fName+"_list"] && formObj[fName+"_list"].type=="select-multiple") {
04982                                                 return formObj;
04983                                         } else {
04984                                                 alert("Formfields missing:\n fName: "+formObj[fName]+"\n fName_list:"+formObj[fName+"_list"]+"\n type:"+formObj[fName+"_list"].type+"\n fName:"+fName);
04985                                         }
04986                                 }
04987                                 return "";
04988                         }
04989 
04990                         // END: dbFileCon parts.
04991                 ';
04992                 return $str;
04993         }
04994 
05000         function printNeededJSFunctions()       {
05001                         // JS evaluation:
05002                 $out = $this->JSbottom($this->formName);
05003                         //
05004                 if ($this->printNeededJS['dbFileIcons'])        {
05005                         $out.= '
05006 
05007 
05008 
05009                         <!--
05010                                 JavaScript after the form has been drawn:
05011                         -->
05012 
05013                         <script type="text/javascript">
05014                                 /*<![CDATA[*/
05015                         '.$this->dbFileCon('document.'.$this->formName).'
05016                                 /*]]>*/
05017                         </script>';
05018                 }
05019                 return $out;
05020         }
05021 
05027         function printNeededJSFunctions_top()   {
05028                         // JS evaluation:
05029                 $out = $this->JStop($this->formName);
05030                 return $out;
05031         }
05032 
05033 
05034 
05035 
05036 
05037 
05038 
05039 
05040 
05041 
05042 
05043 
05044 
05045 
05046 
05047 
05048 
05049 
05050 
05051 
05052 
05053 
05054 
05055 
05056 
05057 
05058 
05059 
05060 
05061         /********************************************
05062          *
05063          * Various helper functions
05064          *
05065          ********************************************/
05066 
05067 
05075         function getDefaultRecord($table,$pid=0)        {
05076                 global $TCA;
05077                 if ($TCA[$table])       {
05078                         t3lib_div::loadTCA($table);
05079                         $row = array();
05080 
05081                         if ($pid<0 && $TCA[$table]['ctrl']['useColumnsForDefaultValues'])       {
05082                                         // Fetches the previous record:
05083                                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'uid='.abs($pid).t3lib_BEfunc::deleteClause($table));
05084                                 if ($drow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))        {
05085                                                 // Gets the list of fields to copy from the previous record.
05086                                         $fArr = explode(',',$TCA[$table]['ctrl']['useColumnsForDefaultValues']);
05087                                         foreach($fArr as $theF) {
05088                                                 if ($TCA[$table]['columns'][$theF])     {
05089                                                         $row[$theF] = $drow[$theF];
05090                                                 }
05091                                         }
05092                                 }
05093                                 $GLOBALS['TYPO3_DB']->sql_free_result($res);
05094                         }
05095 
05096                         foreach($TCA[$table]['columns'] as $field => $info)     {
05097                                 if (isset($info['config']['default']))  {
05098                                         $row[$field] = $info['config']['default'];
05099                                 }
05100                         }
05101 
05102                         return $row;
05103                 }
05104         }
05105 
05114         function getRecordPath($table,$rec)     {
05115                 t3lib_BEfunc::fixVersioningPid($table,$rec);
05116                 list($tscPID,$thePidValue)=$this->getTSCpid($table,$rec['uid'],$rec['pid']);
05117                 if ($thePidValue>=0)    {
05118                         return t3lib_BEfunc::getRecordPath($tscPID,$this->readPerms(),15);
05119                 }
05120         }
05121 
05128         function readPerms()    {
05129                 if (!$this->perms_clause_set)   {
05130                         $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
05131                         $this->perms_clause_set=1;
05132                 }
05133                 return $this->perms_clause;
05134         }
05135 
05142         function sL($str)       {
05143                 return $GLOBALS['LANG']->sL($str);
05144         }
05145 
05155         function getLL($str)    {
05156                 $content = '';
05157 
05158                 switch(substr($str,0,2))        {
05159                         case 'l_':
05160                                 $content = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.'.substr($str,2));
05161                         break;
05162                         case 'm_':
05163                                 $content = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.'.substr($str,2));
05164                         break;
05165                 }
05166                 return $content;
05167         }
05168 
05176         function isPalettesCollapsed($table,$palette)   {
05177                 global $TCA;
05178 
05179                 if ($TCA[$table]['ctrl']['canNotCollapse']) return 0;
05180                 if (is_array($TCA[$table]['palettes'][$palette]) && $TCA[$table]['palettes'][$palette]['canNotCollapse'])       return 0;
05181                 return $this->palettesCollapsed;
05182         }
05183 
05192         function isDisplayCondition($displayCond,$row,$ffValueKey='')   {
05193                 $output = FALSE;
05194 
05195                 $parts = explode(':',$displayCond);
05196                 switch((string)$parts[0])       {       // Type of condition:
05197                         case 'FIELD':
05198                                 $theFieldValue = $ffValueKey ? $row[$parts[1]][$ffValueKey] : $row[$parts[1]];
05199 
05200                                 switch((string)$parts[2])       {
05201                                         case 'REQ':
05202                                                 if (strtolower($parts[3])=='true')      {
05203                                                         $output = $theFieldValue ? TRUE : FALSE;
05204                                                 } elseif (strtolower($parts[3])=='false') {
05205                                                         $output = !$theFieldValue ? TRUE : FALSE;
05206                                                 }
05207                                         break;
05208                                         case '>':
05209                                                 $output = $theFieldValue > $parts[3];
05210                                         break;
05211                                         case '<':
05212                                                 $output = $theFieldValue < $parts[3];
05213                                         break;
05214                                         case '>=':
05215                                                 $output = $theFieldValue >= $parts[3];
05216                                         break;
05217                                         case '<=':
05218                                                 $output = $theFieldValue <= $parts[3];
05219                                         break;
05220                                         case '-':
05221                                         case '!-':
05222                                                 $cmpParts = explode('-',$parts[3]);
05223                                                 $output = $theFieldValue >= $cmpParts[0] && $theFieldValue <= $cmpParts[1];
05224                                                 if ($parts[2]{0}=='!')  $output = !$output;
05225                                         break;
05226                                         case 'IN':
05227                                         case '!IN':
05228                                                 $output = t3lib_div::inList($parts[3],$theFieldValue);
05229                                                 if ($parts[2]{0}=='!')  $output = !$output;
05230                                         break;
05231                                         case '=':
05232                                         case '!=':
05233                                                 $output = t3lib_div::inList($parts[3],$theFieldValue);
05234                                                 if ($parts[2]{0}=='!')  $output = !$output;
05235                                         break;
05236                                 }
05237                         break;
05238                         case 'EXT':
05239                                 switch((string)$parts[2])       {
05240                                         case 'LOADED':
05241                                                 if (strtolower($parts[3])=='true')      {
05242                                                         $output = t3lib_extMgm::isLoaded($parts[1]) ? TRUE : FALSE;
05243                                                 } elseif (strtolower($parts[3])=='false') {
05244                                                         $output = !t3lib_extMgm::isLoaded($parts[1]) ? TRUE : FALSE;
05245                                                 }
05246                                         break;
05247                                 }
05248                         break;
05249                         case 'REC':
05250                                 switch((string)$parts[1])       {
05251                                         case 'NEW':
05252                                                 if (strtolower($parts[2])=='true')      {
05253                                                         $output = !(intval($row['uid']) > 0) ? TRUE : FALSE;
05254                                                 } elseif (strtolower($parts[2])=='false') {
05255                                                         $output = (intval($row['uid']) > 0) ? TRUE : FALSE;
05256                                                 }
05257                                         break;
05258                                 }
05259                         break;
05260                         case 'HIDE_L10N_SIBLINGS':
05261                                 if ($ffValueKey==='vDEF')       {
05262                                         $output = TRUE;
05263                                 } elseif ($parts[1]==='except_admin' && $GLOBALS['BE_USER']->isAdmin()) {
05264                                         $output = TRUE;
05265                                 }
05266                         break;
05267                         case 'HIDE_FOR_NON_ADMINS':
05268                                 $output = $GLOBALS['BE_USER']->isAdmin() ? TRUE : FALSE;
05269                         break;
05270                         case 'VERSION':
05271                                 switch((string)$parts[1])       {
05272                                         case 'IS':
05273                                                 if (strtolower($parts[2])=='true')      {
05274                                                         $output = intval($row['pid'])==-1 ? TRUE : FALSE;
05275                                                 } elseif (strtolower($parts[2])=='false') {
05276                                                         $output = !(intval($row['pid'])==-1) ? TRUE : FALSE;
05277                                                 }
05278                                         break;
05279                                 }
05280                         break;
05281                 }
05282 
05283                 return $output;
05284         }
05285 
05296         function getTSCpid($table,$uid,$pid)    {
05297                 $key = $table.':'.$uid.':'.$pid;
05298                 if (!isset($this->cache_getTSCpid[$key]))       {
05299                         $this->cache_getTSCpid[$key] = t3lib_BEfunc::getTSCpid($table,$uid,$pid);
05300                 }
05301                 return $this->cache_getTSCpid[$key];
05302         }
05303 
05310         function doLoadTableDescr($table)       {
05311                 global $TCA;
05312                 return $TCA[$table]['interface']['always_description'];
05313         }
05314 
05322         function getAvailableLanguages($onlyIsoCoded=1,$setDefault=1)   {
05323                 $isL = t3lib_extMgm::isLoaded('static_info_tables');
05324 
05325                         // Find all language records in the system:
05326                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('static_lang_isocode,title,uid', 'sys_language', 'pid=0 AND hidden=0'.t3lib_BEfunc::deleteClause('sys_language'), '', 'title');
05327 
05328                         // Traverse them:
05329                 $output=array();
05330                 if ($setDefault)        {
05331                         $output[0]=array(
05332                                 'uid' => 0,
05333                                 'title' => 'Default language',
05334                                 'ISOcode' => 'DEF'
05335                         );
05336                 }
05337                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
05338                         $output[$row['uid']]=$row;
05339 
05340                         if ($isL && $row['static_lang_isocode'])        {
05341                                 $rr = t3lib_BEfunc::getRecord('static_languages',$row['static_lang_isocode'],'lg_iso_2');
05342                                 if ($rr['lg_iso_2'])    $output[$row['uid']]['ISOcode']=$rr['lg_iso_2'];
05343                         }
05344 
05345                         if ($onlyIsoCoded && !$output[$row['uid']]['ISOcode'])  unset($output[$row['uid']]);
05346                 }
05347                 return $output;
05348         }
05349 }
05350 
05351 
05352 
05353 
05354 
05355 
05356 
05357 
05358 
05364 class t3lib_TCEforms_FE extends t3lib_TCEforms {
05365 
05372         function wrapLabels($str)       {
05373                 return '<font face="verdana" size="1" color="black">'.$str.'</font>';
05374         }
05375 
05382         function printPalette($palArr)  {
05383                 $out='';
05384                 reset($palArr);
05385                 $bgColor=' bgcolor="#D6DAD0"';
05386                 while(list(,$content)=each($palArr))    {
05387                         $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>';
05388                         $iRow[]='<td valign="top">'.
05389                                                 '<img name="req_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="10" height="10" alt="" />'.
05390                                                 '<img name="cm_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="7" height="10" alt="" />'.
05391                                                 '</td><td nowrap="nowrap" valign="top">'.$content['ITEM'].$content['HELP_ICON'].'</td>';
05392                 }
05393                 $out='<table border="0" cellpadding="0" cellspacing="0">
05394                         <tr><td><img src="clear.gif" width="'.intval($this->paletteMargin).'" height="1" alt="" /></td>'.implode('',$hRow).'</tr>
05395                         <tr><td></td>'.implode('',$iRow).'</tr>
05396                 </table>';
05397 
05398                 return $out;
05399         }
05400 
05407         function setFancyDesign()       {
05408                 $this->fieldTemplate='
05409         <tr>
05410                 <td nowrap="nowrap" bgcolor="#F6F2E6">###FIELD_HELP_ICON###<font face="verdana" size="1" color="black"><b>###FIELD_NAME###</b></font>###FIELD_HELP_TEXT###</td>
05411         </tr>
05412         <tr>
05413                 <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>
05414         </tr>   ';
05415 
05416                 $this->totalWrap='<table border="0" cellpadding="1" cellspacing="0" bgcolor="black"><tr><td><table border="0" cellpadding="2" cellspacing="0">|</table></td></tr></table>';
05417 
05418                 $this->palFieldTemplate='
05419         <tr>
05420                 <td nowrap="nowrap" bgcolor="#ABBBB4"><font face="verdana" size="1" color="black">###FIELD_PALETTE###</font></td>
05421         </tr>   ';
05422                 $this->palFieldTemplateHeader='
05423         <tr>
05424                 <td nowrap="nowrap" bgcolor="#F6F2E6"><font face="verdana" size="1" color="black"><b>###FIELD_HEADER###</b></font></td>
05425         </tr>   ';
05426         }
05427 }
05428 
05429 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tceforms.php'])  {
05430         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tceforms.php']);
05431 }
05432 ?>