Documentation TYPO3 par Ameos

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                         $sOnChange = 'setFormValueFromBrowseWin(\''.$PA['itemFormElName'].'\',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text); '.implode('',$PA['fieldChangeFunc']);
01736                         $itemsToSelect = '
01737                                 <select name="'.$PA['itemFormElName'].'_sel"'.
01738                                                         $this->insertDefStyle('select').
01739                                                         ($size ? ' size="'.$size.'"' : '').
01740                                                         ' onchange="'.htmlspecialchars($sOnChange).'"'.
01741                                                         $PA['onFocus'].
01742                                                         $selector_itemListStyle.'>
01743                                         '.implode('
01744                                         ',$opt).'
01745                                 </select>';
01746                 }
01747 
01748                         // Pass to "dbFileIcons" function:
01749                 $params = array(
01750                         'size' => $size,
01751                         'autoSizeMax' => t3lib_div::intInRange($config['autoSizeMax'],0),
01752                         'style' => isset($config['selectedListStyle']) ? ' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"',
01753                         'dontShowMoveIcons' => ($maxitems<=1),
01754                         'maxitems' => $maxitems,
01755                         'info' => '',
01756                         'headers' => array(
01757                                 'selector' => $this->getLL('l_selected').':<br />',
01758                                 'items' => $this->getLL('l_items').':<br />'
01759                         ),
01760                         'noBrowser' => 1,
01761                         'thumbnails' => $itemsToSelect,
01762                         'readOnly' => $disabled
01763                 );
01764                 $item.= $this->dbFileIcons($PA['itemFormElName'],'','',$itemArray,'',$params,$PA['onFocus']);
01765 
01766                 return $item;
01767         }
01768 
01779         function getSingleField_typeGroup($table,$field,$row,&$PA)      {
01780                         // Init:
01781                 $config = $PA['fieldConf']['config'];
01782                 $internal_type = $config['internal_type'];
01783                 $show_thumbs = $config['show_thumbs'];
01784                 $size = intval($config['size']);
01785                 $maxitems = t3lib_div::intInRange($config['maxitems'],0);
01786                 if (!$maxitems) $maxitems=100000;
01787                 $minitems = t3lib_div::intInRange($config['minitems'],0);
01788                 $allowed = $config['allowed'];
01789                 $disallowed = $config['disallowed'];
01790 
01791                 $disabled = '';
01792                 if($this->renderReadonly || $config['readOnly'])  {
01793                         $disabled = ' disabled="disabled"';
01794                 }
01795 
01796                 $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'_mul" value="'.($config['multiple']?1:0).'"'.$disabled.' />';
01797                 $this->requiredElements[$PA['itemFormElName']] = array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field);
01798                 $info='';
01799 
01800                         // "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/.
01801                 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
01802 
01803                         // Acting according to either "file" or "db" type:
01804                 switch((string)$config['internal_type'])        {
01805                         case 'file':    // If the element is of the internal type "file":
01806 
01807                                         // Creating string showing allowed types:
01808                                 $tempFT = t3lib_div::trimExplode(',',$allowed,1);
01809                                 if (!count($tempFT))    {$info.='*';}
01810                                 foreach($tempFT as $ext)        {
01811                                         if ($ext)       {
01812                                                 $info.=strtoupper($ext).' ';
01813                                         }
01814                                 }
01815                                         // Creating string, showing disallowed types:
01816                                 $tempFT_dis = t3lib_div::trimExplode(',',$disallowed,1);
01817                                 if (count($tempFT_dis)) {$info.='<br />';}
01818                                 foreach($tempFT_dis as $ext)    {
01819                                         if ($ext)       {
01820                                                 $info.='-'.strtoupper($ext).' ';
01821                                         }
01822                                 }
01823 
01824                                         // Making the array of file items:
01825                                 $itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
01826 
01827                                         // Showing thumbnails:
01828                                 $thumbsnail = '';
01829                                 if ($show_thumbs)       {
01830                                         $imgs = array();
01831                                         foreach($itemArray as $imgRead) {
01832                                                 $imgP = explode('|',$imgRead);
01833 
01834                                                 $rowCopy = array();
01835                                                 $rowCopy[$field] = $imgP[0];
01836 
01837                                                         // Icon + clickmenu:
01838                                                 $absFilePath = t3lib_div::getFileAbsFileName($config['uploadfolder'].'/'.$imgP[0]);
01839 
01840                                                 $fI = pathinfo($imgP[0]);
01841                                                 $fileIcon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
01842                                                 $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="" />';
01843 
01844                                                 $imgs[] = '<span class="nobr">'.t3lib_BEfunc::thumbCode($rowCopy,$table,$field,$this->backPath,'thumbs.php',$config['uploadfolder'],0,' align="middle"').
01845                                                                         ($absFilePath ? $this->getClickMenu($fileIcon, $absFilePath) : $fileIcon).
01846                                                                         $imgP[0].
01847                                                                         '</span>';
01848                                         }
01849                                         $thumbsnail = implode('<br />',$imgs);
01850                                 }
01851 
01852                                         // Creating the element:
01853                                 $params = array(
01854                                         'size' => $size,
01855                                         'dontShowMoveIcons' => ($maxitems<=1),
01856                                         'autoSizeMax' => t3lib_div::intInRange($config['autoSizeMax'],0),
01857                                         'maxitems' => $maxitems,
01858                                         'style' => isset($config['selectedListStyle']) ? ' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"',
01859                                         'info' => $info,
01860                                         'thumbnails' => $thumbsnail,
01861                                         'readOnly' => $disabled
01862                                 );
01863                                 $item.= $this->dbFileIcons($PA['itemFormElName'],'file',implode(',',$tempFT),$itemArray,'',$params,$PA['onFocus']);
01864 
01865                                 if(!$disabled) {
01866                                                 // Adding the upload field:
01867                                         if ($this->edit_docModuleUpload)        $item.='<input type="file" name="'.$PA['itemFormElName_file'].'"'.$this->formWidth().' size="60" />';
01868                                 }
01869                         break;
01870                         case 'db':      // If the element is of the internal type "db":
01871 
01872                                         // Creating string showing allowed types:
01873                                 $tempFT = t3lib_div::trimExplode(',',$allowed,1);
01874                                 if (!strcmp(trim($tempFT[0]),'*'))      {
01875                                         $info.='<span class="nobr">&nbsp;&nbsp;&nbsp;&nbsp;'.
01876                                                         htmlspecialchars($this->getLL('l_allTables')).
01877                                                         '</span><br />';
01878                                 } else {
01879                                         while(list(,$theT)=each($tempFT))       {
01880                                                 if ($theT)      {
01881                                                         $info.='<span class="nobr">&nbsp;&nbsp;&nbsp;&nbsp;'.
01882                                                                         t3lib_iconWorks::getIconImage($theT,array(),$this->backPath,'align="top"').
01883                                                                         htmlspecialchars($this->sL($GLOBALS['TCA'][$theT]['ctrl']['title'])).
01884                                                                         '</span><br />';
01885                                                 }
01886                                         }
01887                                 }
01888 
01889                                 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
01890                                 $itemArray = array();
01891                                 $imgs = array();
01892 
01893                                         // Thumbnails:
01894                                 $temp_itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
01895                                 foreach($temp_itemArray as $dbRead)     {
01896                                         $recordParts = explode('|',$dbRead);
01897                                         list($this_table,$this_uid) = t3lib_BEfunc::splitTable_Uid($recordParts[0]);
01898                                         $itemArray[] = array('table'=>$this_table, 'id'=>$this_uid);
01899                                         if (!$disabled && $show_thumbs) {
01900                                                 $rr = t3lib_BEfunc::getRecordWSOL($this_table,$this_uid);
01901                                                 $imgs[] = '<span class="nobr">'.
01902                                                                 $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).
01903                                                                 '&nbsp;'.
01904                                                                 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>'.
01905                                                                 '</span>';
01906                                         }
01907                                 }
01908                                 $thumbsnail='';
01909                                 if (!$disabled && $show_thumbs) {
01910                                         $thumbsnail = implode('<br />',$imgs);
01911                                 }
01912 
01913                                         // Creating the element:
01914                                 $params = array(
01915                                         'size' => $size,
01916                                         'dontShowMoveIcons' => ($maxitems<=1),
01917                                         'autoSizeMax' => t3lib_div::intInRange($config['autoSizeMax'],0),
01918                                         'maxitems' => $maxitems,
01919                                         'style' => isset($config['selectedListStyle']) ? ' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"',
01920                                         'info' => $info,
01921                                         'thumbnails' => $thumbsnail,
01922                                         'readOnly' => $disabled
01923                                 );
01924                                 $item.= $this->dbFileIcons($PA['itemFormElName'],'db',implode(',',$tempFT),$itemArray,'',$params,$PA['onFocus']);
01925 
01926                         break;
01927                 }
01928 
01929                         // Wizards:
01930                 $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
01931                 if (!$disabled) {
01932                         $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf);
01933                 }
01934 
01935                 return $item;
01936         }
01937 
01948         function getSingleField_typeNone($table,$field,$row,&$PA)       {
01949                         // Init:
01950                 $config = $PA['fieldConf']['config'];
01951                 $itemValue = $PA['itemFormElValue'];
01952 
01953                 return $this->getSingleField_typeNone_render($config,$itemValue);
01954         }
01955 
01964         function getSingleField_typeNone_render($config,$itemValue)     {
01965 
01966                                 // is colorScheme[0] the right value?
01967                 $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;';
01968 
01969                 if ($config['format'])  {
01970                         $itemValue = $this->formatValue($config, $itemValue);
01971                 }
01972 
01973                 $rows = intval($config['rows']);
01974                 if ($rows > 1) {
01975                         if(!$config['pass_content']) {
01976                                 $itemValue = nl2br(htmlspecialchars($itemValue));
01977                         }
01978                                 // like textarea
01979                         $cols = t3lib_div::intInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
01980                         if (!$config['fixedRows']) {
01981                                 $origRows = $rows = t3lib_div::intInRange($rows, 1, 20);
01982                                 if (strlen($itemValue)>$this->charsPerRow*2)    {
01983                                         $cols = $this->maxTextareaWidth;
01984                                         $rows = t3lib_div::intInRange(round(strlen($itemValue)/$this->charsPerRow),count(explode(chr(10),$itemValue)),20);
01985                                         if ($rows<$origRows)    $rows=$origRows;
01986                                 }
01987                         }
01988 
01989                         if ($this->docLarge)    $cols = round($cols*$this->form_largeComp);
01990                         $width = ceil($cols*$this->form_rowsToStylewidth);
01991                                 // hardcoded: 12 is the height of the font
01992                         $height=$rows*12;
01993 
01994                         $item='
01995                                 <div style="'.htmlspecialchars($divStyle.' overflow:auto; height:'.$height.'px; width:'.$width.'px;').'" class="'.htmlspecialchars($this->formElClass('none')).'">'.
01996                                 $itemValue.
01997                                 '</div>';
01998                 } else {
01999                         if(!$config['pass_content']) {
02000                                 $itemValue = htmlspecialchars($itemValue);
02001                         }
02002 
02003                         $cols = $config['cols']?$config['cols']:($config['size']?$config['size']:$this->maxInputWidth);
02004                         if ($this->docLarge)    $cols = round($cols*$this->form_largeComp);
02005                         $width = ceil($cols*$this->form_rowsToStylewidth);
02006 
02007                                 // overflow:auto crashes mozilla here. Title tag is usefull when text is longer than the div box (overflow:hidden).
02008                         $item = '
02009                                 <div style="'.htmlspecialchars($divStyle.' overflow:hidden; width:'.$width.'px;').'" class="'.htmlspecialchars($this->formElClass('none')).'" title="'.$itemValue.'">'.
02010                                 '<span class="nobr">'.(strcmp($itemValue,'')?$itemValue:'&nbsp;').'</span>'.
02011                                 '</div>';
02012                 }
02013 
02014                 return $item;
02015         }
02016 
02026         function getSingleField_typeFlex($table,$field,$row,&$PA)       {
02027 
02028                         // Data Structure:
02029                 $dataStructArray = t3lib_BEfunc::getFlexFormDS($PA['fieldConf']['config'],$row,$table);
02030 #debug($dataStructArray);
02031                         // Get data structure:
02032                 if (is_array($dataStructArray)) {
02033 #debug(array(str_replace(' ',chr(160),$PA['itemFormElValue'])));
02034 
02035                                 // Get data:
02036                         $xmlData = $PA['itemFormElValue'];
02037                         $xmlHeaderAttributes = t3lib_div::xmlGetHeaderAttribs($xmlData);
02038                         $storeInCharset = strtolower($xmlHeaderAttributes['encoding']);
02039                         if ($storeInCharset)    {
02040                                 $currentCharset=$GLOBALS['LANG']->charSet;
02041                                 $xmlData = $GLOBALS['LANG']->csConvObj->conv($xmlData,$storeInCharset,$currentCharset,1);
02042                         }
02043                         $editData=t3lib_div::xml2array($xmlData);
02044                         if (!is_array($editData))       {       // Must be XML parsing error...
02045 #debug(array($editData,$xmlData));
02046                                 $editData=array();
02047                         }
02048 
02049                                 // Find the data structure if sheets are found:
02050                         $sheet = $editData['meta']['currentSheetId'] ? $editData['meta']['currentSheetId'] : 'sDEF';    // Sheet to display
02051 #                       $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'[meta][currentSheetId]" value="'.$sheet.'">';
02052 
02053                                 // Create sheet menu:
02054                         if (is_array($dataStructArray['sheets']))       {
02055                                 #$item.=$this->getSingleField_typeFlex_sheetMenu($dataStructArray['sheets'], $PA['itemFormElName'].'[meta][currentSheetId]', $sheet).'<br />';
02056                         }
02057 #debug($editData);
02058 
02059                                 // Create language menu:
02060                         $langChildren = $dataStructArray['meta']['langChildren'] ? 1 : 0;
02061                         $langDisabled = $dataStructArray['meta']['langDisable'] ? 1 : 0;
02062 
02063                         $editData['meta']['currentLangId']=array();
02064                         $languages = $this->getAvailableLanguages();
02065 
02066                         foreach($languages as $lInfo)   {
02067                                 if ($GLOBALS['BE_USER']->checkLanguageAccess($lInfo['uid']))    {
02068                                         $editData['meta']['currentLangId'][] =  $lInfo['ISOcode'];
02069                                 }
02070                         }
02071                         if (!is_array($editData['meta']['currentLangId']) || !count($editData['meta']['currentLangId']))        {
02072                                 $editData['meta']['currentLangId']=array('DEF');
02073                         }
02074 
02075                         $editData['meta']['currentLangId'] = array_unique($editData['meta']['currentLangId']);
02076 
02077 
02078 //                      if (!$langDisabled && count($languages) > 1)    {
02079 //                              $item.=$this->getSingleField_typeFlex_langMenu($languages, $PA['itemFormElName'].'[meta][currentLangId]', $editData['meta']['currentLangId']).'<br />';
02080 //                      }
02081 
02082                         $PA['_noEditDEF'] = FALSE;
02083                         if ($langChildren || $langDisabled)     {
02084                                 $rotateLang = array('DEF');
02085                         } else {
02086                                 if (!in_array('DEF',$editData['meta']['currentLangId']))        {
02087                                         array_unshift($editData['meta']['currentLangId'],'DEF');
02088                                         $PA['_noEditDEF'] = TRUE;
02089                                 }
02090                                 $rotateLang = $editData['meta']['currentLangId'];
02091                         }
02092 
02093                                 // Tabs sheets
02094                         if (is_array($dataStructArray['sheets']))       {
02095                                 $tabsToTraverse = array_keys($dataStructArray['sheets']);
02096                         } else {
02097                                 $tabsToTraverse = array($sheet);
02098                         }
02099 
02100                         foreach($rotateLang as $lKey)   {
02101                                 if (!$langChildren && !$langDisabled)   {
02102                                         $item.= '<b>'.$lKey.':</b>';
02103                                 }
02104 
02105                                 $tabParts = array();
02106                                 foreach($tabsToTraverse as $sheet)      {
02107                                         $sheetCfg = $dataStructArray['sheets'][$sheet];
02108                                         list ($dataStruct, $sheet) = t3lib_div::resolveSheetDefInDS($dataStructArray,$sheet);
02109 
02110                                                 // Render sheet:
02111                                         if (is_array($dataStruct['ROOT']) && is_array($dataStruct['ROOT']['el']))               {
02112                                                 $cmdData = t3lib_div::_GP('flexFormsCmdData');
02113                                                 $lang = 'l'.$lKey;      // Default language, other options are "lUK" or whatever country code (independant of system!!!)
02114                                                 $PA['_valLang'] = $langChildren && !$langDisabled ? $editData['meta']['currentLangId'] : 'DEF'; // Default language, other options are "lUK" or whatever country code (independant of system!!!)
02115                                                 $PA['_lang'] = $lang;
02116 
02117                                                         // Render flexform:
02118                                                 $tRows = $this->getSingleField_typeFlex_draw(
02119                                                                         $dataStruct['ROOT']['el'],
02120                                                                         $editData['data'][$sheet][$lang],
02121                                                                         $cmdData['data'][$sheet][$lang],
02122                                                                         $table,
02123                                                                         $field,
02124                                                                         $row,
02125                                                                         $PA,
02126                                                                         '[data]['.$sheet.']['.$lang.']'
02127                                                                 );
02128                                                 $sheetContent= '<table border="0" cellpadding="1" cellspacing="1" class="typo3-TCEforms-flexForm">'.implode('',$tRows).'</table>';
02129 
02130                         #                       $item = '<div style=" position:absolute;">'.$item.'</div>';
02131                                                 //visibility:hidden;
02132                                         } else $sheetContent='Data Structure ERROR: No ROOT element found for sheet "'.$sheet.'".';
02133 
02134                                                 // Add to tab:
02135                                         $tabParts[] = array(
02136                                                 'label' => ($sheetCfg['ROOT']['TCEforms']['sheetTitle'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetTitle']) : $sheet),
02137                                                 'description' => ($sheetCfg['ROOT']['TCEforms']['sheetDescription'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetDescription']) : ''),
02138                                                 'linkTitle' => ($sheetCfg['ROOT']['TCEforms']['sheetShortDescr'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetShortDescr']) : ''),
02139                                                 'content' => $sheetContent
02140                                         );
02141                                 }
02142 
02143                                 if (is_array($dataStructArray['sheets']))       {
02144                                         $item.= $this->getDynTabMenu($tabParts,'TCEFORMS:flexform:'.$PA['itemFormElName']);
02145                                 } else {
02146                                         $item.= $sheetContent;
02147                                 }
02148                         }
02149                 } else $item='Data Structure ERROR: '.$dataStructArray;
02150 
02151                 return $item;
02152         }
02153 
02163         function getSingleField_typeFlex_langMenu($languages,$elName,$selectedLanguage,$multi=1)        {
02164                 $opt=array();
02165                 foreach($languages as $lArr)    {
02166                         $opt[]='<option value="'.htmlspecialchars($lArr['ISOcode']).'"'.(in_array($lArr['ISOcode'],$selectedLanguage)?' selected="selected"':'').'>'.htmlspecialchars($lArr['title']).'</option>';
02167                 }
02168 
02169                 $output = '<select name="'.$elName.'[]"'.($multi ? ' multiple="multiple" size="'.count($languages).'"' : '').'>'.implode('',$opt).'</select>';
02170 
02171                 return $output;
02172         }
02173 
02182         function getSingleField_typeFlex_sheetMenu($sArr,$elName,$sheetKey)     {
02183 
02184                 $tCells =array();
02185                 $pct = round(100/count($sArr));
02186                 foreach($sArr as $sKey => $sheetCfg)    {
02187                         if ($GLOBALS['BE_USER']->jsConfirmation(1))     {
02188                                 $onClick = 'if (confirm('.$GLOBALS['LANG']->JScharCode($this->getLL('m_onChangeAlert')).') && TBE_EDITOR_checkSubmit(-1)){'.$this->elName($elName).".value='".$sKey."'; TBE_EDITOR_submitForm()};";
02189                         } else {
02190                                 $onClick = 'if(TBE_EDITOR_checkSubmit(-1)){ '.$this->elName($elName).".value='".$sKey."'; TBE_EDITOR_submitForm();}";
02191                         }
02192 
02193 
02194                         $tCells[]='<td width="'.$pct.'%" style="'.($sKey==$sheetKey ? 'background-color: #9999cc; font-weight: bold;' : 'background-color: #aaaaaa;').' cursor: hand;" onclick="'.htmlspecialchars($onClick).'" align="center">'.
02195                                         ($sheetCfg['ROOT']['TCEforms']['sheetTitle'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetTitle']) : $sKey).
02196                                         '</td>';
02197                 }
02198 
02199                 return '<table border="0" cellpadding="0" cellspacing="2" class="typo3-TCEforms-flexForm-sheetMenu"><tr>'.implode('',$tCells).'</tr></table>';
02200         }
02201 
02217         function getSingleField_typeFlex_draw($dataStruct,$editData,$cmdData,$table,$field,$row,&$PA,$formPrefix='',$level=0,$tRows=array())    {
02218 
02219                         // Data Structure array must be ... and array of course...
02220                 if (is_array($dataStruct))      {
02221                         foreach($dataStruct as $key => $value)  {
02222                                 if (is_array($value))   {       // The value of each entry must be an array.
02223 
02224                                                 // ********************
02225                                                 // Making the row:
02226                                                 // ********************
02227                                         $rowCells=array();
02228 
02229                                                 // Icon:
02230                                         $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>';;
02231 
02232                                         $rowCells['formEl']='';
02233                                         if ($value['type']=='array')    {
02234                                                 if ($value['section'])  {
02235                                                                 // Render "NEW [container]" selectorbox:
02236                                                         if (is_array($value['el']))     {
02237                                                                 $opt=array();
02238                                                                 $opt[]='<option value=""></option>';
02239                                                                 foreach($value['el'] as $kk => $vv)     {
02240                                                                         $opt[]='<option value="'.$kk.'">'.htmlspecialchars('NEW "'.$value['el'][$kk]['tx_templavoila']['title'].'"').'</option>';
02241                                                                 }
02242                                                                 $rowCells['formEl']='<select name="flexFormsCmdData'.$formPrefix.'['.$key.'][value]">'.implode('',$opt).'</select>';
02243                                                         }
02244 
02245                                                                 // Put row together
02246                                                         $tRows[]='<tr class="bgColor2">
02247                                                                 <td nowrap="nowrap" valign="top">'.$rowCells['title'].'</td>
02248                                                                 <td>'.$rowCells['formEl'].'</td>
02249                                                         </tr>';
02250 
02251                                                         $cc=0;
02252                                                         if (is_array($editData[$key]['el']))    {
02253                                                                 foreach($editData[$key]['el'] as $k3 => $v3)    {
02254                                                                         $cc=$k3;
02255                                                                         $theType = key($v3);
02256                                                                         $theDat = $v3[$theType];
02257                                                                         $newSectionEl = $value['el'][$theType];
02258                                                                         if (is_array($newSectionEl))    {
02259                                                                                 $tRows = $this->getSingleField_typeFlex_draw(
02260                                                                                         array($theType => $newSectionEl),
02261                                                                                         array($theType => $theDat),
02262                                                                                         $cmdData[$key]['el'][$cc],
02263                                                                                         $table,
02264                                                                                         $field,
02265                                                                                         $row,
02266                                                                                         $PA,
02267                                                                                         $formPrefix.'['.$key.'][el]['.$cc.']',
02268                                                                                         $level+1,
02269                                                                                         $tRows
02270                                                                                 );
02271                                                                         }
02272                                                                 }
02273                                                         }
02274 
02275 
02276 
02277                                                                 // New form?
02278                                                         if ($cmdData[$key]['value'])    {
02279                                                                 $newSectionEl = $value['el'][$cmdData[$key]['value']];
02280                                                                 if (is_array($newSectionEl))    {
02281                                                                         $tRows = $this->getSingleField_typeFlex_draw(
02282                                                                                 array($cmdData[$key]['value'] => $newSectionEl),
02283                                                                                 array(),
02284                                                                                 array(),
02285                                                                                 $table,
02286                                                                                 $field,
02287                                                                                 $row,
02288                                                                                 $PA,
02289                                                                                 $formPrefix.'['.$key.'][el]['.($cc+1).']',
02290                                                                                 $level+1,
02291                                                                                 $tRows
02292                                                                         );
02293                                                                 }
02294                                                         }
02295                                                 } else {
02296                                                         $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
02297 
02298                                                                 // Put row together
02299                                                         $tRows[]='<tr class="bgColor2">
02300                                                                 <td nowrap="nowrap" valign="top">'.
02301                                                                 '<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>'.
02302                                                                 '<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>'.
02303                                                                 '<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>'.
02304                                                                 $rowCells['title'].'</td>
02305                                                                 <td>'.$rowCells['formEl'].'</td>
02306                                                         </tr>';
02307 
02308                                                         $tRows = $this->getSingleField_typeFlex_draw(
02309                                                                 $value['el'],
02310                                                                 $editData[$key]['el'],
02311                                                                 $cmdData[$key]['el'],
02312                                                                 $table,
02313                                                                 $field,
02314                                                                 $row,
02315                                                                 $PA,
02316                                                                 $formPrefix.'['.$key.'][el]',
02317                                                                 $level+1,
02318                                                                 $tRows
02319                                                         );
02320                                                 }
02321 
02322                                         } elseif (is_array($value['TCEforms']['config'])) {     // Rendering a single form element:
02323 
02324                                                 if (is_array($PA['_valLang']))  {
02325                                                         $rotateLang = $PA['_valLang'];
02326                                                 } else {
02327                                                         $rotateLang = array($PA['_valLang']);
02328                                                 }
02329 
02330                                                 foreach($rotateLang as $vDEFkey)        {
02331                                                         $vDEFkey = 'v'.$vDEFkey;
02332 
02333                                                         if (!$value['TCEforms']['displayCond'] || $this->isDisplayCondition($value['TCEforms']['displayCond'],$editData,$vDEFkey)) {
02334                                                                 $fakePA=array();
02335                                                                 $fakePA['fieldConf']=array(
02336                                                                         'label' => $this->sL(trim($value['TCEforms']['label'])),
02337                                                                         'config' => $value['TCEforms']['config'],
02338                                                                         'defaultExtras' => $value['TCEforms']['defaultExtras'],
02339                                     'onChange' => $value['TCEforms']['onChange']
02340                                                                 );
02341                                                                 if ($PA['_noEditDEF'] && $PA['_lang']==='lDEF') {
02342                                                                         $fakePA['fieldConf']['config'] = array(
02343                                                                                 'type' => 'none',
02344                                                                                 'rows' => 2
02345                                                                         );
02346                                                                 }
02347 
02348                                                                 if (
02349                                     $fakePA['fieldConf']['onChange'] == 'reload' ||
02350                                                                         ($GLOBALS['TCA'][$table]['ctrl']['type'] && !strcmp($key,$GLOBALS['TCA'][$table]['ctrl']['type'])) ||
02351                                                                         ($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'] && t3lib_div::inList($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'],$key))) {
02352                                                                         if ($GLOBALS['BE_USER']->jsConfirmation(1))     {
02353                                                                                 $alertMsgOnChange = 'if (confirm('.$GLOBALS['LANG']->JScharCode($this->getLL('m_onChangeAlert')).') && TBE_EDITOR_checkSubmit(-1)){ TBE_EDITOR_submitForm() };';
02354                                                                         } else {
02355                                                                                 $alertMsgOnChange = 'if(TBE_EDITOR_checkSubmit(-1)){ TBE_EDITOR_submitForm();}';
02356                                                                         }
02357                                                                 } else {
02358                                                                         $alertMsgOnChange = '';
02359                                                                 }
02360 
02361                                                                 $fakePA['fieldChangeFunc']=$PA['fieldChangeFunc'];
02362                                                                 if (strlen($alertMsgOnChange)) {
02363                                                                         $fakePA['fieldChangeFunc']['alert']=$alertMsgOnChange;
02364                                                                 }
02365                                                                 $fakePA['onFocus']=$PA['onFocus'];
02366                                                                 $fakePA['label']=$PA['label'];
02367 
02368                                                                 $fakePA['itemFormElName']=$PA['itemFormElName'].$formPrefix.'['.$key.']['.$vDEFkey.']';
02369                                                                 $fakePA['itemFormElName_file']=$PA['itemFormElName_file'].$formPrefix.'['.$key.']['.$vDEFkey.']';
02370 
02371                                                                 if(isset($editData[$key][$vDEFkey])) {
02372                                                                         $fakePA['itemFormElValue']=$editData[$key][$vDEFkey];
02373                                                                 } else {
02374                                                                         $fakePA['itemFormElValue']=$fakePA['fieldConf']['config']['default'];
02375                                                                 }
02376 
02377                                                                 $rowCells['formEl']= $this->getSingleField_SW($table,$field,$row,$fakePA);
02378                                                                 $rowCells['title']= htmlspecialchars($fakePA['fieldConf']['label']);
02379 
02380                                                                 if (!in_array('DEF',$rotateLang))       {
02381                                                                         $defInfo = '<div class="typo3-TCEforms-originalLanguageValue">'.nl2br(htmlspecialchars($editData[$key]['vDEF'])).'&nbsp;</div>';
02382                                                                 } else {
02383                                                                         $defInfo = '';
02384                                                                 }
02385 
02386                                                                         // Put row together
02387                                                                 $tRows[]='<tr>
02388                                                                         <td nowrap="nowrap" valign="top" class="bgColor5">'.$rowCells['title'].($vDEFkey=='vDEF' ? '' : ' ('.$vDEFkey.')').'</td>
02389                                                                         <td class="bgColor4">'.$rowCells['formEl'].$defInfo.'</td>
02390                                                                 </tr>';
02391                                                         }
02392                                                 }
02393                                         }
02394                                 }
02395                         }
02396                 }
02397 
02398                 return $tRows;
02399         }
02400 
02410         function getSingleField_typeUnknown($table,$field,$row,&$PA)    {
02411                 $item='Unknown type: '.$PA['fieldConf']['config']['form_type'].'<br />';
02412 
02413                 return $item;
02414         }
02415 
02425         function getSingleField_typeUser($table,$field,$row,&$PA)       {
02426                 $PA['table']=$table;
02427                 $PA['field']=$field;
02428                 $PA['row']=$row;
02429 
02430                 $PA['pObj']=&$this;
02431 
02432                 return t3lib_div::callUserFunction($PA['fieldConf']['config']['userFunc'],$PA,$this);
02433         }
02434 
02435 
02436 
02437 
02438 
02439 
02440         /************************************************************
02441          *
02442          * Field content processing
02443          *
02444          ************************************************************/
02445 
02454         function formatValue ($config, $itemValue)      {
02455                 $format = trim($config['format']);
02456                 switch($format) {
02457                         case 'date':
02458                                 $option = trim($config['format.']['option']);
02459                                 if ($option)    {
02460                                         if ($config['format.']['strftime'])     {
02461                                                 $value = strftime($option,$itemValue);
02462                                         } else {
02463                                                 $value = date($option,$itemValue);
02464                                         }
02465                                 } else {
02466                                         $value = date('d-m-Y',$itemValue);
02467                                 }
02468                                 if ($config['format.']['appendAge'])    {
02469                                         $value .= ' ('.t3lib_BEfunc::calcAge((time()-$itemValue), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')).')';
02470                                 }
02471                                 $itemValue = $value;
02472                                 break;
02473                         case 'datetime':        // compatibility with "eval" (type "input")
02474                                 $itemValue = date('H:i d-m-Y',$itemValue);
02475                                 break;
02476                         case 'time':    // compatibility with "eval" (type "input")
02477                                 $itemValue = date('H:i',$itemValue);
02478                                 break;
02479                         case 'timesec': // compatibility with "eval" (type "input")
02480                                 $itemValue = date('H:i:s',$itemValue);
02481                                 break;
02482                         case 'year':    // compatibility with "eval" (type "input")
02483                                 $itemValue = date('Y',$itemValue);
02484                                 break;
02485                         case 'int':
02486                                 $baseArr = array('dec'=>'d','hex'=>'x','HEX'=>'X','oct'=>'o','bin'=>'b');
02487                                 $base = trim($config['format.']['base']);
02488                                 $format = $baseArr[$base] ? $baseArr[$base] : 'd';
02489                                 $itemValue = sprintf('%'.$format,$itemValue);
02490                                 break;
02491                         case 'float':
02492                                 $precision = t3lib_div::intInRange($config['format.']['precision'],1,10,2);
02493                                 $itemValue = sprintf('%.'.$precision.'f',$itemValue);
02494                                 break;
02495                         case 'number':
02496                                 $format = trim($config['format.']['option']);
02497                                 $itemValue = sprintf('%'.$format,$itemValue);
02498                                 break;
02499                         case 'md5':
02500                                 $itemValue = md5($itemValue);
02501                                 break;
02502                         case 'filesize':
02503                                 $value = t3lib_div::formatSize(intval($itemValue));
02504                                 if ($config['format.']['appendByteSize'])       {
02505                                         $value .= ' ('.$itemValue.')';
02506                                 }
02507                                 $itemValue = $value;
02508                                 break;
02509                         case 'user':
02510                                 $func = trim($config['format.']['userFunc']);
02511                                 if ($func)      {
02512                                         $params = array(
02513                                                 'value' => $itemValue,
02514                                                 'args' => $config['format.']['userFunc'],
02515                                                 'config' => $config,
02516                                                 'pObj' => &$this
02517                                         );
02518                                         $itemValue = t3lib_div::callUserFunction($func,$params,$this);
02519                                 }
02520                                 break;
02521                         default:
02522                         break;
02523                 }
02524 
02525                 return $itemValue;
02526         }
02527 
02528 
02529 
02530 
02531 
02532 
02533         /************************************************************
02534          *
02535          * "Configuration" fetching/processing functions
02536          *
02537          ************************************************************/
02538 
02546         function getRTypeNum($table,$row)       {
02547                 global $TCA;
02548                         // If there is a "type" field configured...
02549                 if ($TCA[$table]['ctrl']['type'])       {
02550                         $typeFieldName = $TCA[$table]['ctrl']['type'];
02551                         $typeNum=$row[$typeFieldName];  // Get value of the row from the record which contains the type value.
02552                         if (!strcmp($typeNum,''))       $typeNum=0;                     // If that value is an empty string, set it to "0" (zero)
02553                 } else {
02554                         $typeNum = 0;   // If no "type" field, then set to "0" (zero)
02555                 }
02556 
02557                 $typeNum = (string)$typeNum;            // Force to string. Necessary for eg '-1' to be recognized as a type value.
02558                 if (!$TCA[$table]['types'][$typeNum])   {       // However, if the type "0" is not found in the "types" array, then default to "1" (for historical reasons)
02559                         $typeNum = 1;
02560                 }
02561 
02562                 return $typeNum;
02563         }
02564 
02572         function rearrange($fields)     {
02573                 $fO = array_flip(t3lib_div::trimExplode(',',$this->fieldOrder,1));
02574                 reset($fields);
02575                 $newFields=array();
02576                 while(list($cc,$content)=each($fields)) {
02577                         $cP = t3lib_div::trimExplode(';',$content);
02578                         if (isset($fO[$cP[0]])) {
02579                                 $newFields[$fO[$cP[0]]] = $content;
02580                                 unset($fields[$cc]);
02581                         }
02582                 }
02583                 ksort($newFields);
02584                 $fields=array_merge($newFields,$fields);                // Candidate for t3lib_div::array_merge() if integer-keys will some day make trouble...
02585                 return $fields;
02586         }
02587 
02598         function getExcludeElements($table,$row,$typeNum)       {
02599                 global $TCA;
02600 
02601                         // Init:
02602                 $excludeElements=array();
02603 
02604                         // If a subtype field is defined for the type
02605                 if ($TCA[$table]['types'][$typeNum]['subtype_value_field'])     {
02606                         $sTfield = $TCA[$table]['types'][$typeNum]['subtype_value_field'];
02607                         if (trim($TCA[$table]['types'][$typeNum]['subtypes_excludelist'][$row[$sTfield]]))      {
02608                                 $excludeElements=t3lib_div::trimExplode(',',$TCA[$table]['types'][$typeNum]['subtypes_excludelist'][$row[$sTfield]],1);
02609                         }
02610                 }
02611 
02612                         // If a bitmask-value field has been configured, then find possible fields to exclude based on that:
02613                 if ($TCA[$table]['types'][$typeNum]['bitmask_value_field'])     {
02614                         $sTfield = $TCA[$table]['types'][$typeNum]['bitmask_value_field'];
02615                         $sTValue = t3lib_div::intInRange($row[$sTfield],0);
02616                         if (is_array($TCA[$table]['types'][$typeNum]['bitmask_excludelist_bits']))      {
02617                                 reset($TCA[$table]['types'][$typeNum]['bitmask_excludelist_bits']);
02618                                 while(list($bitKey,$eList)=each($TCA[$table]['types'][$typeNum]['bitmask_excludelist_bits']))   {
02619                                         $bit=substr($bitKey,1);
02620                                         if (t3lib_div::testInt($bit))   {
02621                                                 $bit = t3lib_div::intInRange($bit,0,30);
02622                                                 if (
02623                                                                 (substr($bitKey,0,1)=='-' && !($sTValue&pow(2,$bit))) ||
02624                                                                 (substr($bitKey,0,1)=='+' && ($sTValue&pow(2,$bit)))
02625                                                         )       {
02626                                                         $excludeElements = array_merge($excludeElements,t3lib_div::trimExplode(',',$eList,1));
02627                                                 }
02628                                         }
02629                                 }
02630                         }
02631                 }
02632 
02633                         // Return the array of elements:
02634                 return $excludeElements;
02635         }
02636 
02646         function getFieldsToAdd($table,$row,$typeNum)   {
02647                 global $TCA;
02648 
02649                         // Init:
02650                 $addElements=array();
02651 
02652                         // If a subtype field is defined for the type
02653                 if ($TCA[$table]['types'][$typeNum]['subtype_value_field'])     {
02654                         $sTfield = $TCA[$table]['types'][$typeNum]['subtype_value_field'];
02655                         if (trim($TCA[$table]['types'][$typeNum]['subtypes_addlist'][$row[$sTfield]]))  {
02656                                 $addElements=t3lib_div::trimExplode(',',$TCA[$table]['types'][$typeNum]['subtypes_addlist'][$row[$sTfield]],1);
02657                         }
02658                 }
02659                         // Return the return
02660                 return array($addElements,$sTfield);
02661         }
02662 
02671         function mergeFieldsWithAddedFields($fields,$fieldsToAdd)       {
02672                 if (count($fieldsToAdd[0]))     {
02673                         reset($fields);
02674                         $c=0;
02675                         while(list(,$fieldInfo)=each($fields))  {
02676                                 $parts = explode(';',$fieldInfo);
02677                                 if (!strcmp(trim($parts[0]),$fieldsToAdd[1]))   {
02678                                         array_splice(
02679                                                 $fields,
02680                                                 $c+1,
02681                                                 0,
02682                                                 $fieldsToAdd[0]
02683                                         );
02684                                         break;
02685                                 }
02686                                 $c++;
02687                         }
02688                 }
02689                 return $fields;
02690         }
02691 
02692 
02703         function setTSconfig($table,$row,$field='')     {
02704                 $mainKey = $table.':'.$row['uid'];
02705                 if (!isset($this->cachedTSconfig[$mainKey]))    {
02706                         $this->cachedTSconfig[$mainKey]=t3lib_BEfunc::getTCEFORM_TSconfig($table,$row);
02707                 }
02708                 if ($field)     {
02709                         return $this->cachedTSconfig[$mainKey][$field];
02710                 } else {
02711                         return $this->cachedTSconfig[$mainKey];
02712                 }
02713         }
02714 
02725         function getSpecConfForField($table,$row,$field)        {
02726                         // Finds the current "types" configuration for the table/row:
02727                 $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table,$row);
02728 
02729                         // If this is an array, then traverse it:
02730                 if (is_array($types_fieldConfig))       {
02731                         foreach($types_fieldConfig as $vconf)   {
02732                                         // If the input field name matches one found in the 'types' list, then return the 'special' configuration.
02733                                 if ($vconf['field']==$field)    return $vconf['spec'];
02734                         }
02735                 }
02736         }
02737 
02746         function getSpecConfFromString($extraString, $defaultExtras)    {
02747                 return t3lib_BEfunc::getSpecConfParts($extraString, $defaultExtras);
02748         }
02749 
02750 
02751 
02752 
02753 
02754 
02755 
02756 
02757 
02758 
02759         /************************************************************
02760          *
02761          * Display of localized content etc.
02762          *
02763          ************************************************************/
02764 
02774         function registerDefaultLanguageData($table,$rec)       {
02775                 global $TCA;
02776 
02777                         // Add default language:
02778                 if ($TCA[$table]['ctrl']['languageField']
02779                                 && $rec[$TCA[$table]['ctrl']['languageField']] > 0
02780                                 && $TCA[$table]['ctrl']['transOrigPointerField']
02781                                 && intval($rec[$TCA[$table]['ctrl']['transOrigPointerField']]) > 0)     {
02782 
02783                         $lookUpTable = $TCA[$table]['ctrl']['transOrigPointerTable'] ? $TCA[$table]['ctrl']['transOrigPointerTable'] : $table;
02784 
02785                                 // Get data formatted:
02786                         $this->defaultLanguageData[$table.':'.$rec['uid']] = t3lib_BEfunc::getRecordWSOL($lookUpTable, intval($rec[$TCA[$table]['ctrl']['transOrigPointerField']]));
02787 
02788                                 // Get data for diff:
02789                         if ($TCA[$table]['ctrl']['transOrigDiffSourceField'])   {
02790                                 $this->defaultLanguageData_diff[$table.':'.$rec['uid']] = unserialize($rec[$TCA[$table]['ctrl']['transOrigDiffSourceField']]);
02791                         }
02792                 }
02793         }
02794 
02806         function getLanguageOverlayRawValue($table, $row, $field, $fieldConf)   {
02807                 global $TCA;
02808 
02809                 $value = $row[$field];
02810 
02811                 if (is_array($this->defaultLanguageData[$table.':'.$row['uid']]))       {
02812 
02813                         if ($fieldConf['l10n_mode']=='exclude'
02814                                         || ($fieldConf['l10n_mode']=='mergeIfNotBlank' && strcmp(trim($this->defaultLanguageData[$table.':'.$row['uid']][$field]),''))) {
02815                                 $value = $this->defaultLanguageData[$table.':'.$row['uid']][$field];
02816                         }
02817 
02818                 }
02819 
02820                 return $value;
02821         }
02822 
02834         function renderDefaultLanguageContent($table,$field,$row,$item) {
02835                 if (is_array($this->defaultLanguageData[$table.':'.$row['uid']]))       {
02836                         $dLVal = t3lib_BEfunc::getProcessedValue($table,$field,$this->defaultLanguageData[$table.':'.$row['uid']][$field],0,1);
02837 
02838                         if (strcmp($dLVal,''))  {
02839                                 $item.='<div class="typo3-TCEforms-originalLanguageValue">'.nl2br(htmlspecialchars($dLVal)).'&nbsp;</div>';
02840                         }
02841                 }
02842 
02843                 return $item;
02844         }
02845 
02857         function renderDefaultLanguageDiff($table,$field,$row,$item)    {
02858                 if (is_array($this->defaultLanguageData_diff[$table.':'.$row['uid']]))  {
02859 
02860                                 // Initialize:
02861                         $dLVal = array(
02862                                 'old' => $this->defaultLanguageData_diff[$table.':'.$row['uid']],
02863                                 'new' => $this->defaultLanguageData[$table.':'.$row['uid']],
02864                         );
02865 
02866                         if (isset($dLVal['old'][$field]))       {       // There must be diff-data:
02867                                 if (strcmp($dLVal['old'][$field],$dLVal['new'][$field]))        {
02868 
02869                                                 // Create diff-result:
02870                                         $t3lib_diff_Obj = t3lib_div::makeInstance('t3lib_diff');
02871                                         $diffres = $t3lib_diff_Obj->makeDiffDisplay(
02872                                                 t3lib_BEfunc::getProcessedValue($table,$field,$dLVal['old'][$field],0,1),
02873                                                 t3lib_BEfunc::getProcessedValue($table,$field,$dLVal['new'][$field],0,1)
02874                                         );
02875 
02876                                         $item.='<div class="typo3-TCEforms-diffBox">'.
02877                                                 '<div class="typo3-TCEforms-diffBox-header">'.htmlspecialchars($this->getLL('l_changeInOrig')).':</div>'.
02878                                                 $diffres.
02879                                         '</div>';
02880                                 }
02881                         }
02882                 }
02883 
02884                 return $item;
02885         }
02886 
02887 
02888 
02889 
02890 
02891 
02892 
02893 
02894 
02895         /************************************************************
02896          *
02897          * Form element helper functions
02898          *
02899          ************************************************************/
02900 
02913         function dbFileIcons($fName,$mode,$allowed,$itemArray,$selector='',$params=array(),$onFocus='') {
02914 
02915 
02916                 $disabled = '';
02917                 if($this->renderReadonly || $params['readOnly'])  {
02918                         $disabled = ' disabled="disabled"';
02919                 }
02920 
02921                         // Sets a flag which means some JavaScript is included on the page to support this element.
02922                 $this->printNeededJS['dbFileIcons']=1;
02923 
02924                         // INIT
02925                 $uidList=array();
02926                 $opt=array();
02927                 $itemArrayC=0;
02928 
02929                         // Creating <option> elements:
02930                 if (is_array($itemArray))       {
02931                         $itemArrayC=count($itemArray);
02932                         reset($itemArray);
02933                         switch($mode)   {
02934                                 case 'db':
02935                                         while(list(,$pp)=each($itemArray))      {
02936                                                 $pRec = t3lib_BEfunc::getRecordWSOL($pp['table'],$pp['id']);
02937                                                 if (is_array($pRec))    {
02938                                                         $pTitle = t3lib_div::fixed_lgd_cs($this->noTitle($pRec[$GLOBALS['TCA'][$pp['table']]['ctrl']['label']]),$this->titleLen);
02939                                                         $pUid = $pp['table'].'_'.$pp['id'];
02940                                                         $uidList[]=$pUid;
02941                                                         $opt[]='<option value="'.htmlspecialchars($pUid).'">'.htmlspecialchars($pTitle).'</option>';
02942                                                 }
02943                                         }
02944                                 break;
02945                                 case 'file':
02946                                         while(list(,$pp)=each($itemArray))      {
02947                                                 $pParts = explode('|',$pp);
02948                                                 $uidList[]=$pUid=$pTitle = $pParts[0];
02949                                                 $opt[]='<option value="'.htmlspecialchars(rawurldecode($pParts[0])).'">'.htmlspecialchars(rawurldecode($pParts[0])).'</option>';
02950                                         }
02951                                 break;
02952                                 default:
02953                                         while(list(,$pp)=each($itemArray))      {
02954                                                 $pParts = explode('|',$pp, 2);
02955                                                 $uidList[]=$pUid=$pParts[0];
02956                                                 $pTitle = $pParts[1];
02957                                                 $opt[]='<option value="'.htmlspecialchars(rawurldecode($pUid)).'">'.htmlspecialchars(rawurldecode($pTitle)).'</option>';
02958                                         }
02959                                 break;
02960                         }
02961                 }
02962 
02963                         // Create selector box of the options
02964                 $sSize = $params['autoSizeMax'] ? t3lib_div::intInRange($itemArrayC+1,t3lib_div::intInRange($params['size'],1),$params['autoSizeMax']) : $params['size'];
02965                 if (!$selector) {
02966                         $selector = '<select size="'.$sSize.'"'.$this->insertDefStyle('group').' multiple="multiple" name="'.$fName.'_list" '.$onFocus.$params['style'].$disabled.'>'.implode('',$opt).'</select>';
02967                 }
02968 
02969 
02970                 $icons = array(
02971                         'L' => array(),
02972                         'R' => array(),
02973                 );
02974                 if (!$params['readOnly']) {
02975                         if (!$params['noBrowser'])      {
02976                                 $aOnClick='setFormValueOpenBrowser(\''.$mode.'\',\''.($fName.'|||'.$allowed.'|').'\'); return false;';
02977                                 $icons['R'][]='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
02978                                                 '<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'))).' />'.
02979                                                 '</a>';
02980                         }
02981                         if (!$params['dontShowMoveIcons'])      {
02982                                 if ($sSize>=5)  {
02983                                         $icons['L'][]='<a href="#" onclick="setFormValueManipulate(\''.$fName.'\',\'Top\'); return false;">'.
02984                                                         '<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')).' />'.
02985                                                         '</a>';
02986                                 }
02987                                 $icons['L'][]='<a href="#" onclick="setFormValueManipulate(\''.$fName.'\',\'Up\'); return false;">'.
02988                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/up.gif','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib($this->getLL('l_move_up')).' />'.
02989                                                 '</a>';
02990                                 $icons['L'][]='<a href="#" onclick="setFormValueManipulate(\''.$fName.'\',\'Down\'); return false;">'.
02991                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/down.gif','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib($this->getLL('l_move_down')).' />'.
02992                                                 '</a>';
02993                                 if ($sSize>=5)  {
02994                                         $icons['L'][]='<a href="#" onclick="setFormValueManipulate(\''.$fName.'\',\'Bottom\'); return false;">'.
02995                                                         '<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')).' />'.
02996                                                         '</a>';
02997                                 }
02998                         }
02999 
03000                         $clipElements = $this->getClipboardElements($allowed,$mode);
03001                         if (count($clipElements))       {
03002                                 $aOnClick = '';
03003         #                       $counter = 0;
03004                                 foreach($clipElements as $elValue)      {
03005                                         if ($mode=='file')      {
03006                                                 $itemTitle = 'unescape(\''.rawurlencode(basename($elValue)).'\')';
03007                                         } else {        // 'db' mode assumed
03008                                                 list($itemTable,$itemUid) = explode('|', $elValue);
03009                                                 $itemTitle = $GLOBALS['LANG']->JScharCode(t3lib_BEfunc::getRecordTitle($itemTable, t3lib_BEfunc::getRecordWSOL($itemTable,$itemUid)));
03010                                                 $elValue = $itemTable.'_'.$itemUid;
03011                                         }
03012                                         $aOnClick.= 'setFormValueFromBrowseWin(\''.$fName.'\',unescape(\''.rawurlencode(str_replace('%20',' ',$elValue)).'\'),'.$itemTitle.');';
03013 
03014         #                               $counter++;
03015         #                               if ($params['maxitems'] && $counter >= $params['maxitems'])     {       break;  }       // Makes sure that no more than the max items are inserted... for convenience.
03016                                 }
03017                                 $aOnClick.= 'return false;';
03018                                 $icons['R'][]='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
03019                                                 '<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))).' />'.
03020                                                 '</a>';
03021                         }
03022                         $icons['L'][]='<a href="#" onclick="setFormValueManipulate(\''.$fName.'\',\'Remove\'); return false;">'.
03023                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/group_clear.gif','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib($this->getLL('l_remove_selected')).' />'.
03024                                         '</a>';
03025                 }
03026 
03027                 $str='<table border="0" cellpadding="0" cellspacing="0" width="1">
03028                         '.($params['headers']?'
03029                                 <tr>
03030                                         <td>'.$this->wrapLabels($params['headers']['selector']).'</td>
03031                                         <td></td>
03032                                         <td></td>
03033                                         <td></td>
03034                                         <td>'.($params['thumbnails'] ? $this->wrapLabels($params['headers']['items']) : '').'</td>
03035                                 </tr>':'').
03036                         '
03037                         <tr>
03038                                 <td valign="top">'.
03039                                         $selector.'<br />'.
03040                                         $this->wrapLabels($params['info']).
03041                                 '</td>
03042                                 <td valign="top">'.
03043                                         implode('<br />',$icons['L']).'</td>
03044                                 <td valign="top">'.
03045                                         implode('<br />',$icons['R']).'</td>
03046                                 <td><img src="clear.gif" width="5" height="1" alt="" /></td>
03047                                 <td valign="top">'.
03048                                         $this->wrapLabels($params['thumbnails']).
03049                                 '</td>
03050                         </tr>
03051                 </table>';
03052 
03053                         // Creating the hidden field which contains the actual value as a comma list.
03054                 $str.='<input type="hidden" name="'.$fName.'" value="'.htmlspecialchars(implode(',',$uidList)).'" />';
03055 
03056                 return $str;
03057         }
03058 
03066         function getClipboardElements($allowed,$mode)   {
03067 
03068                 $output = array();
03069 
03070                 if (is_object($this->clipObj))  {
03071                         switch($mode)   {
03072                                 case 'file':
03073                                         $elFromTable = $this->clipObj->elFromTable('_FILE');
03074                                         $allowedExts = t3lib_div::trimExplode(',', $allowed, 1);
03075 
03076                                         if ($allowedExts)       {       // If there are a set of allowed extensions, filter the content:
03077                                                 foreach($elFromTable as $elValue)       {
03078                                                         $pI = pathinfo($elValue);
03079                                                         $ext = strtolower($pI['extension']);
03080                                                         if (in_array($ext, $allowedExts))       {
03081                                                                 $output[] = $elValue;
03082                                                         }
03083                                                 }
03084                                         } else {        // If all is allowed, insert all: (This does NOT respect any disallowed extensions, but those will be filtered away by the backend TCEmain)
03085                                                 $output = $elFromTable;
03086                                         }
03087                                 break;
03088                                 case 'db':
03089                                         $allowedTables = t3lib_div::trimExplode(',', $allowed, 1);
03090                                         if (!strcmp(trim($allowedTables[0]),'*'))       {       // All tables allowed for relation:
03091                                                 $output = $this->clipObj->elFromTable('');
03092                                         } else {        // Only some tables, filter them:
03093                                                 foreach($allowedTables as $tablename)   {
03094                                                         $elFromTable = $this->clipObj->elFromTable($tablename);
03095                                                         $output = array_merge($output,$elFromTable);
03096                                                 }
03097                                         }
03098                                         $output = array_keys($output);
03099                                 break;
03100                         }
03101                 }
03102 
03103                 return $output;
03104         }
03105 
03115         function getClickMenu($str,$table,$uid='')      {
03116                 if ($this->enableClickMenu)     {
03117                         $onClick = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($str,$table,$uid,1,'','+copy,info,edit,view', TRUE);
03118                         return '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.$str.'</a>';
03119                 }
03120         }
03121 
03136         function renderWizards($itemKinds,$wizConf,$table,$row,$field,&$PA,$itemName,$specConf,$RTE=0)  {
03137 
03138                         // Init:
03139                 $fieldChangeFunc = $PA['fieldChangeFunc'];
03140                 $item = $itemKinds[0];
03141                 $outArr = array();
03142                 $colorBoxLinks = array();
03143                 $fName = '['.$table.']['.$row['uid'].']['.$field.']';
03144                 $md5ID = 'ID'.t3lib_div::shortmd5($itemName);
03145                 $listFlag = '_list';
03146 
03147                         // 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":
03148                 if ($PA['fieldConf']['config']['form_type']=='select')  {
03149                         if ($PA['fieldConf']['config']['maxitems']<=1)  {       // Single select situation:
03150                                 $listFlag = '';
03151                         } elseif ($PA['fieldConf']['config']['renderMode']=='singlebox')        {
03152                                 $itemName.='[]';
03153                                 $listFlag = '';
03154                         }
03155                 }
03156 
03157                         // traverse wizards:
03158                 if (is_array($wizConf) && !$this->disableWizards)       {
03159                         foreach($wizConf as $wid => $wConf)     {
03160                                 if (substr($wid,0,1)!='_'
03161                                                 && (!$wConf['enableByTypeConfig'] || @in_array($wid,$specConf['wizards']['parameters']))
03162                                                 && ($RTE || !$wConf['RTEonly'])
03163                                         )       {
03164 
03165                                                 // Title / icon:
03166                                         $iTitle = htmlspecialchars($this->sL($wConf['title']));
03167                                         if ($wConf['icon'])     {
03168                                                 $iDat = $this->getIcon($wConf['icon']);
03169                                                 $icon = '<img src="'.$iDat[0].'" '.$iDat[1][3].' border="0"'.t3lib_BEfunc::titleAltAttrib($iTitle).' />';
03170                                         } else {
03171                                                 $icon = $iTitle;
03172                                         }
03173 
03174                                                 //
03175                                         switch((string)$wConf['type'])  {
03176                                                 case 'userFunc':
03177                                                 case 'script':
03178                                                 case 'popup':
03179                                                 case 'colorbox':
03180                                                         if (!$wConf['notNewRecords'] || t3lib_div::testInt($row['uid']))        {
03181 
03182                                                                         // Setting &P array contents:
03183                                                                 $params = array();
03184                                                                 $params['params'] = $wConf['params'];
03185                                                                 $params['exampleImg'] = $wConf['exampleImg'];
03186                                                                 $params['table'] = $table;
03187                                                                 $params['uid'] = $row['uid'];
03188                                                                 $params['pid'] = $row['pid'];
03189                                                                 $params['field'] = $field;
03190                                                                 $params['md5ID'] = $md5ID;
03191                                                                 $params['returnUrl'] = $this->thisReturnUrl();
03192 
03193                                                                         // Resolving script filename and setting URL.
03194                                                                 if (!strcmp(substr($wConf['script'],0,4), 'EXT:')) {
03195                                                                         $wScript = t3lib_div::getFileAbsFileName($wConf['script']);
03196                                                                         if ($wScript)   {
03197                                                                                 $wScript = '../'.substr($wScript,strlen(PATH_site));
03198                                                                         } else break;
03199                                                                 } else {
03200                                                                         $wScript = $wConf['script'];
03201                                                                 }
03202                                                                 $url = $this->backPath.$wScript.(strstr($wScript,'?') ? '' : '?');
03203 
03204                                                                         // If there is no script and the type is "colorbox", break right away:
03205                                                                 if ((string)$wConf['type']=='colorbox' && !$wConf['script'])    { break; }
03206 
03207                                                                         // If "script" type, create the links around the icon:
03208                                                                 if ((string)$wConf['type']=='script')   {
03209                                                                         $aUrl = $url.t3lib_div::implodeArrayForUrl('',array('P'=>$params));
03210                                                                         $outArr[]='<a href="'.htmlspecialchars($aUrl).'" onclick="'.$this->blur().'return !TBE_EDITOR_isFormChanged();">'.
03211                                                                                 $icon.
03212                                                                                 '</a>';
03213                                                                 } else {
03214 
03215                                                                                 // ... else types "popup", "colorbox" and "userFunc" will need additional parameters:
03216                                                                         $params['formName'] = $this->formName;
03217                                                                         $params['itemName'] = $itemName;
03218                                                                         $params['fieldChangeFunc'] = $fieldChangeFunc;
03219 
03220                                                                         switch((string)$wConf['type'])  {
03221                                                                                 case 'popup':
03222                                                                                 case 'colorbox':
03223                                                                                                 // Current form value is passed as P[currentValue]!
03224                                                                                         $addJS = $wConf['popup_onlyOpenIfSelected']?'if (!TBE_EDITOR_curSelected(\''.$itemName.$listFlag.'\')){alert('.$GLOBALS['LANG']->JScharCode($this->getLL('m_noSelItemForEdit')).'); return false;}':'';
03225                                                                                         $curSelectedValues='+\'&P[currentSelectedValues]=\'+TBE_EDITOR_curSelected(\''.$itemName.$listFlag.'\')';
03226                                                                                         $aOnClick=      $this->blur().
03227                                                                                                                 $addJS.
03228                                                                                                                 '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'].'\');'.
03229                                                                                                                 'vHWin.focus();return false;';
03230                                                                                                 // Setting "colorBoxLinks" - user LATER to wrap around the color box as well:
03231                                                                                         $colorBoxLinks = Array('<a href="#" onclick="'.htmlspecialchars($aOnClick).'">','</a>');
03232                                                                                         if ((string)$wConf['type']=='popup')    {
03233                                                                                                 $outArr[] = $colorBoxLinks[0].$icon.$colorBoxLinks[1];
03234                                                                                         }
03235                                                                                 break;
03236                                                                                 case 'userFunc':
03237                                                                                         $params['item'] = &$item;       // Reference set!
03238                                                                                         $params['icon'] = $icon;
03239                                                                                         $params['iTitle'] = $iTitle;
03240                                                                                         $params['wConf'] = $wConf;
03241                                                                                         $params['row'] = $row;
03242                                                                                         $outArr[] = t3lib_div::callUserFunction($wConf['userFunc'],$params,$this);
03243                                                                                 break;
03244                                                                         }
03245                                                                 }
03246 
03247                                                                         // Hide the real form element?
03248                                                                 if (is_array($wConf['hideParent']) || $wConf['hideParent'])     {
03249                                                                         $item = $itemKinds[1];  // Setting the item to a hidden-field.
03250                                                                         if (is_array($wConf['hideParent']))     {
03251                                                                                 $item.= $this->getSingleField_typeNone_render($wConf['hideParent'], $PA['itemFormElValue']);
03252                                                                         }
03253                                                                 }
03254                                                         }
03255                                                 break;
03256                                                 case 'select':
03257                                                         $fieldValue = array('config' => $wConf);
03258                                                         $TSconfig = $this->setTSconfig($table, $row);
03259                                                         $TSconfig[$field] = $TSconfig[$field]['wizards.'][$wid.'.'];
03260                                                         $selItems = $this->addSelectOptionsToItemArray($this->initItemArray($fieldValue), $fieldValue, $TSconfig, $field);
03261 
03262                                                         $opt = array();
03263                                                         $opt[] = '<option>'.$iTitle.'</option>';
03264                                                         foreach($selItems as $p)        {
03265                                                                 $opt[] = '<option value="'.htmlspecialchars($p[1]).'">'.htmlspecialchars($p[0]).'</option>';
03266                                                         }
03267                                                         if ($wConf['mode']=='append')   {
03268                                                                 $assignValue = $this->elName($itemName).'.value=\'\'+this.options[this.selectedIndex].value+'.$this->elName($itemName).'.value';
03269                                                         } elseif ($wConf['mode']=='prepend')    {
03270                                                                 $assignValue = $this->elName($itemName).'.value+=\'\'+this.options[this.selectedIndex].value';
03271                                                         } else {
03272                                                                 $assignValue = $this->elName($itemName).'.value=this.options[this.selectedIndex].value';
03273                                                         }
03274                                                         $sOnChange = $assignValue.';this.selectedIndex=0;'.implode('',$fieldChangeFunc);
03275                                                         $outArr[] = '<select name="_WIZARD'.$fName.'" onchange="'.htmlspecialchars($sOnChange).'">'.implode('',$opt).'</select>';
03276                                                 break;
03277                                         }
03278 
03279                                                 // Color wizard colorbox:
03280                                         if ((string)$wConf['type']=='colorbox') {
03281                                                 $dim = t3lib_div::intExplode('x',$wConf['dim']);
03282                                                 $dX = t3lib_div::intInRange($dim[0],1,200,20);
03283                                                 $dY = t3lib_div::intInRange($dim[1],1,200,20);
03284                                                 $color = $row[$field] ? ' bgcolor="'.htmlspecialchars($row[$field]).'"' : '';
03285                                                 $outArr[] = '<table border="0" cellpadding="0" cellspacing="0" id="'.$md5ID.'"'.$color.' style="'.htmlspecialchars($wConf['tableStyle']).'">
03286                                                                         <tr>
03287                                                                                 <td>'.
03288                                                                                         $colorBoxLinks[0].
03289                                                                                         '<img src="clear.gif" width="'.$dX.'" height="'.$dY.'"'.t3lib_BEfunc::titleAltAttrib(trim($iTitle.' '.$row[$field])).' border="0" />'.
03290                                                                                         $colorBoxLinks[1].
03291                                                                                         '</td>
03292                                                                         </tr>
03293                                                                 </table>';
03294                                         }
03295                                 }
03296                         }
03297 
03298                                 // For each rendered wizard, put them together around the item.
03299                         if (count($outArr))     {
03300                                 if ($wizConf['_HIDDENFIELD'])   $item = $itemKinds[1];
03301 
03302                                 $outStr = '';
03303                                 $vAlign = $wizConf['_VALIGN'] ? ' valign="'.$wizConf['_VALIGN'].'"' : '';
03304                                 if (count($outArr)>1 || $wizConf['_PADDING'])   {
03305                                         $dist = intval($wizConf['_DISTANCE']);
03306                                         if ($wizConf['_VERTICAL'])      {
03307                                                 $dist = $dist ? '<tr><td><img src="clear.gif" width="1" height="'.$dist.'" alt="" /></td></tr>' : '';
03308                                                 $outStr = '<tr><td>'.implode('</td></tr>'.$dist.'<tr><td>',$outArr).'</td></tr>';
03309                                         } else {
03310                                                 $dist = $dist ? '<td><img src="clear.gif" height="1" width="'.$dist.'" alt="" /></td>' : '';
03311                                                 $outStr = '<tr><td'.$vAlign.'>'.implode('</td>'.$dist.'<td'.$vAlign.'>',$outArr).'</td></tr>';
03312                                         }
03313                                         $outStr = '<table border="0" cellpadding="'.intval($wizConf['_PADDING']).'" cellspacing="0">'.$outStr.'</table>';
03314                                 } else {
03315                                         $outStr = implode('',$outArr);
03316                                 }
03317 
03318                                 if (!strcmp($wizConf['_POSITION'],'left'))      {
03319                                         $outStr = '<tr><td'.$vAlign.'>'.$outStr.'</td><td'.$vAlign.'>'.$item.'</td></tr>';
03320                                 } elseif (!strcmp($wizConf['_POSITION'],'top')) {
03321                                         $outStr = '<tr><td>'.$outStr.'</td></tr><tr><td>'.$item.'</td></tr>';
03322                                 } elseif (!strcmp($wizConf['_POSITION'],'bottom'))      {
03323                                         $outStr = '<tr><td>'.$item.'</td></tr><tr><td>'.$outStr.'</td></tr>';
03324                                 } else {
03325                                         $outStr = '<tr><td'.$vAlign.'>'.$item.'</td><td'.$vAlign.'>'.$outStr.'</td></tr>';
03326                                 }
03327 
03328                                 $item = '<table border="0" cellpadding="0" cellspacing="0">'.$outStr.'</table>';
03329                         }
03330                 }
03331                 return $item;
03332         }
03333 
03340         function getIcon($icon) {
03341                 if (substr($icon,0,4)=='EXT:')  {
03342                         $file = t3lib_div::getFileAbsFileName($icon);
03343                         if ($file)      {
03344                                 $file = substr($file,strlen(PATH_site));
03345                                 $selIconFile = $this->backPath.'../'.$file;
03346                                 $selIconInfo = @getimagesize(PATH_site.$file);
03347                         }
03348                 } elseif (substr($icon,0,3)=='../')     {
03349                         $selIconFile = $this->backPath.t3lib_div::resolveBackPath($icon);
03350                         $selIconInfo = @getimagesize(PATH_site.t3lib_div::resolveBackPath(substr($icon,3)));
03351                 } elseif (substr($icon,0,4)=='ext/' || substr($icon,0,7)=='sysext/') {
03352                         $selIconFile = $this->backPath.$icon;
03353                         $selIconInfo = @getimagesize(PATH_typo3.$icon);
03354                 } else {
03355                         $selIconFile = $this->backPath.'gfx/'.$icon;
03356                         $selIconInfo = @getimagesize(PATH_t3lib.'gfx/'.$icon);
03357                 }
03358                 return array($selIconFile,$selIconInfo);
03359         }
03360 
03367         function optionTagStyle($iconString)    {
03368                 if ($iconString)        {
03369                         list($selIconFile,$selIconInfo) = $this->getIcon($iconString);
03370                         $padTop = t3lib_div::intInRange(($selIconInfo[1]-12)/2,0);
03371                         $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;';
03372                         return $styleAttr;
03373                 }
03374         }
03375 
03383         function extractValuesOnlyFromValueLabelList($itemFormElValue)  {
03384                         // Get values of selected items:
03385                 $itemArray = t3lib_div::trimExplode(',',$itemFormElValue,1);
03386                 foreach($itemArray as $tk => $tv) {
03387                         $tvP = explode('|',$tv,2);
03388                         $tvP[0] = rawurldecode($tvP[0]);
03389 
03390                         $itemArray[$tk] = $tvP[0];
03391                 }
03392                 return $itemArray;
03393         }
03394 
03405         function wrapOpenPalette($header,$table,$row,$palette,$retFunc=0)       {
03406                 $fieldL=array();
03407                 if (!is_array($this->palFieldArr[$palette]))    {$this->palFieldArr[$palette]=array();}
03408                 $palFieldN = is_array($this->palFieldArr[$palette]) ? count($this->palFieldArr[$palette]) : 0;
03409                 $palJSFunc = 'TBE_EDITOR_palUrl(\''.($table.':'.$row['uid'].':'.$palette).'\',\''.implode(',',$this->palFieldArr[$palette]).'\','.$palFieldN.',\''.$table.'\',\''.$row['uid'].'\',1);';
03410 
03411                 $aOnClick = $this->blur().substr($palJSFunc,0,-3).'0);return false;';
03412 
03413                 $iconCode = '<a href="#" onclick="'.htmlspecialchars($aOnClick).'" title="'.htmlspecialchars($table).'">'.
03414                                         $header.
03415                                         '</a>';
03416                 return $retFunc ? array($iconCode,$palJSFunc) : $iconCode;
03417         }
03418 
03429         function checkBoxParams($itemName,$thisValue,$c,$iCount,$addFunc='')    {
03430                 $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)).');'.
03431                                         $addFunc;
03432                 $str = ' onclick="'.htmlspecialchars($onClick).'"'.
03433                                 (($thisValue&pow(2,$c))?' checked="checked"':'');
03434                 return $str;
03435         }
03436 
03443         function elName($itemName)      {
03444                 return 'document.'.$this->formName."['".$itemName."']";
03445         }
03446 
03454         function noTitle($str,$wrapParts=array())       {
03455                 return strcmp($str,'') ? $str : $wrapParts[0].'['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title').']'.$wrapParts[1];
03456         }
03457 
03463         function blur() {
03464                 return $GLOBALS['CLIENT']['FORMSTYLE'] ? 'this.blur();':'';
03465         }
03466 
03472         function thisReturnUrl()        {
03473                 return $this->returnUrl ? $this->returnUrl : t3lib_div::linkThisScript();
03474         }
03475 
03485         function getSingleHiddenField($table,$field,$row)       {
03486                 global $TCA;
03487                 $out='';
03488                 t3lib_div::loadTCA($table);
03489                 if ($TCA[$table]['columns'][$field])    {
03490 
03491                         $uid=$row['uid'];
03492                         $itemName=$this->prependFormFieldNames.'['.$table.']['.$uid.']['.$field.']';
03493                         $itemValue=$row[$field];
03494                         $item.='<input type="hidden" name="'.$itemName.'" value="'.htmlspecialchars($itemValue).'" />';
03495                         $out = $item;
03496                 }
03497                 return $out;
03498         }
03499 
03507         function formWidth($size=48,$textarea=0) {
03508                         // Input or text-field attribute (size or cols)
03509                 if ($this->docLarge)    $size = round($size*$this->form_largeComp);
03510                 $wAttrib = $textarea?'cols':'size';
03511                 if (!$GLOBALS['CLIENT']['FORMSTYLE'])   {       // If not setting the width by style-attribute
03512                         $retVal = ' '.$wAttrib.'="'.$size.'"';
03513                 } else {        // Setting width by style-attribute. 'cols' MUST be avoided with NN6+
03514                         $pixels = ceil($size*$this->form_rowsToStylewidth);
03515                         $theStyle = 'width:'.$pixels.'px;'.$this->defStyle.$this->formElStyle($textarea?'text':'input');
03516                         $retVal = ' style="'.htmlspecialchars($theStyle).'"';
03517 
03518                         $class = $this->formElClass($textarea?'text':'input');
03519                         if ($class)     {
03520                                 $retVal.= ' class="'.htmlspecialchars($class).'"';
03521                         }
03522                 }
03523                 return $retVal;
03524         }
03525 
03534         function formWidthText($size=48,$wrap='') {
03535                 $wTags = $this->formWidth($size,1);
03536                         // 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...
03537                 if (strtolower(trim($wrap))!='off' && $GLOBALS['CLIENT']['BROWSER']=='net' && $GLOBALS['CLIENT']['VERSION']>=5) {
03538                         $wTags.=' cols="'.$size.'"';
03539                 }
03540                 return $wTags;
03541         }
03542 
03550         function formElStyle($type)     {
03551                 return $this->formElStyleClassValue($type);
03552         }
03553 
03561         function formElClass($type)     {
03562                 return $this->formElStyleClassValue($type, TRUE);
03563         }
03564 
03572         function formElStyleClassValue($type, $class=FALSE)     {
03573                         // Get value according to field:
03574                 if (isset($this->fieldStyle[$type]))    {
03575                         $style = trim($this->fieldStyle[$type]);
03576                 } else {
03577                         $style = trim($this->fieldStyle['all']);
03578                 }
03579 
03580                         // Check class prefixed:
03581                 if (substr($style,0,6)=='CLASS:')       {
03582                         return $class ? trim(substr($style,6)) : '';
03583                 } else {
03584                         return !$class ? $style : '';
03585                 }
03586         }
03587 
03594         function insertDefStyle($type)  {
03595                 $out = '';
03596 
03597                 $style = trim($this->defStyle.$this->formElStyle($type));
03598                 $out.= $style?' style="'.htmlspecialchars($style).'"':'';
03599 
03600                 $class = $this->formElClass($type);
03601                 $out.= $class?' class="'.htmlspecialchars($class).'"':'';
03602 
03603                 return $out;
03604         }
03605 
03613         function getDynTabMenu($parts, $idString) {
03614                 if (is_object($GLOBALS['TBE_TEMPLATE']))        {
03615                         return $GLOBALS['TBE_TEMPLATE']->getDynTabMenu($parts, $idString);
03616                 } else {
03617                         $output = '';
03618                         foreach($parts as $singlePad)   {
03619                                 $output.='
03620                                 <h3>'.htmlspecialchars($singlePad['label']).'</h3>
03621                                 '.($singlePad['description'] ? '<p class="c-descr">'.nl2br(htmlspecialchars($singlePad['description'])).'</p>' : '').'
03622                                 '.$singlePad['content'];
03623                         }
03624 
03625                         return '<div class="typo3-dyntabmenu-divs">'.$output.'</div>';
03626                 }
03627         }
03628 
03629 
03630 
03631 
03632 
03633 
03634 
03635 
03636 
03637 
03638 
03639         /************************************************************
03640          *
03641          * Item-array manipulation functions (check/select/radio)
03642          *
03643          ************************************************************/
03644 
03652         function initItemArray($fieldValue)     {
03653                 $items = array();
03654                 if (is_array($fieldValue['config']['items']))   {
03655                         reset ($fieldValue['config']['items']);
03656                         while (list($itemName,$itemValue) = each($fieldValue['config']['items']))       {
03657                                 $items[] = array($this->sL($itemValue[0]), $itemValue[1], $itemValue[2]);
03658                         }
03659                 }
03660                 return $items;
03661         }
03662 
03670         function addItems($items,$iArray)       {
03671                 global $TCA;
03672                 if (is_array($iArray))  {
03673                         reset($iArray);
03674                         while(list($value,$label)=each($iArray))        {
03675                                 $items[]=array($this->sl($label),$value);
03676                         }
03677                 }
03678                 return $items;
03679         }
03680 
03692         function procItems($items,$iArray,$config,$table,$row,$field)   {
03693                 global $TCA;
03694 
03695                 $params=array();
03696                 $params['items'] = &$items;
03697                 $params['config'] = $config;
03698                 $params['TSconfig'] = $iArray;
03699                 $params['table'] = $table;
03700                 $params['row'] = $row;
03701                 $params['field'] = $field;
03702 
03703                 t3lib_div::callUserFunction($config['itemsProcFunc'],$params,$this);
03704                 return $items;
03705         }
03706 
03716         function addSelectOptionsToItemArray($items,$fieldValue,$TSconfig,$field)       {
03717                 global $TCA;
03718 
03719                         // Values from foreign tables:
03720                 if ($fieldValue['config']['foreign_table'])     {
03721                         $items = $this->foreignTable($items,$fieldValue,$TSconfig,$field);
03722                         if ($fieldValue['config']['neg_foreign_table']) {
03723                                 $items = $this->foreignTable($items,$fieldValue,$TSconfig,$field,1);
03724                         }
03725                 }
03726 
03727                         // Values from a file folder:
03728                 if ($fieldValue['config']['fileFolder'])        {
03729                         $fileFolder = t3lib_div::getFileAbsFileName($fieldValue['config']['fileFolder']);
03730                         if (@is_dir($fileFolder))       {
03731 
03732                                         // Configurations:
03733                                 $extList = $fieldValue['config']['fileFolder_extList'];
03734                                 $recursivityLevels = isset($fieldValue['config']['fileFolder_recursions']) ? t3lib_div::intInRange($fieldValue['config']['fileFolder_recursions'],0,99) : 99;
03735 
03736                                         // Get files:
03737                                 $fileFolder = ereg_replace('\/$','',$fileFolder).'/';
03738                                 $fileArr = t3lib_div::getAllFilesAndFoldersInPath(array(),$fileFolder,$extList,0,$recursivityLevels);
03739                                 $fileArr = t3lib_div::removePrefixPathFromList($fileArr, $fileFolder);
03740 
03741                                 foreach($fileArr as $fileRef)   {
03742                                         $fI = pathinfo($fileRef);
03743                                         $icon = t3lib_div::inList('gif,png,jpeg,jpg', strtolower($fI['extension'])) ? '../'.substr($fileFolder,strlen(PATH_site)).$fileRef : '';
03744                                         $items[] = array(
03745                                                 $fileRef,
03746                                                 $fileRef,
03747                                                 $icon
03748                                         );
03749                                 }
03750                         }
03751                 }
03752 
03753                         // If 'special' is configured:
03754                 if ($fieldValue['config']['special'])   {
03755                         switch ($fieldValue['config']['special'])       {
03756                                 case 'tables':
03757                                         $temp_tc = array_keys($TCA);
03758                                         $descr = '';
03759 
03760                                         foreach($temp_tc as $theTableNames)     {
03761                                                 if (!$TCA[$theTableNames]['ctrl']['adminOnly']) {
03762 
03763                                                                 // Icon:
03764                                                         $icon = '../'.TYPO3_mainDir.t3lib_iconWorks::skinImg($this->backPath,t3lib_iconWorks::getIcon($theTableNames, array()),'',1);
03765 
03766                                                                 // Add description texts:
03767                                                         if ($this->edit_showFieldHelp)  {
03768                                                                 $GLOBALS['LANG']->loadSingleTableDescription($theTableNames);
03769                                                                 $fDat = $GLOBALS['TCA_DESCR'][$theTableNames]['columns'][''];
03770                                                                 $descr = $fDat['description'];
03771                                                         }
03772 
03773                                                                 // Item configuration:
03774                                                         $items[] = array(
03775                                                                 $this->sL($TCA[$theTableNames]['ctrl']['title']),
03776                                                                 $theTableNames,
03777                                                                 $icon,
03778                                                                 $descr
03779                                                         );
03780                                                 }
03781                                         }
03782                                 break;
03783                                 case 'pagetypes':
03784                                         $theTypes = $TCA['pages']['columns']['doktype']['config']['items'];
03785 
03786                                         foreach($theTypes as $theTypeArrays)    {
03787                                                         // Icon:
03788                                                 $icon = $theTypeArrays[1]!='--div--' ? '../'.TYPO3_mainDir.t3lib_iconWorks::skinImg($this->backPath,t3lib_iconWorks::getIcon('pages', array('doktype' => $theTypeArrays[1])),'',1) : '';
03789 
03790                                                         // Item configuration:
03791                                                 $items[] = array(
03792                                                         $this->sL($theTypeArrays[0]),
03793                                                         $theTypeArrays[1],
03794                                                         $icon
03795                                                 );
03796                                         }
03797                                 break;
03798                                 case 'exclude':
03799                                         $theTypes = t3lib_BEfunc::getExcludeFields();
03800                                         $descr = '';
03801 
03802                                         foreach($theTypes as $theTypeArrays)    {
03803                                                 list($theTable, $theField) = explode(':', $theTypeArrays[1]);
03804 
03805                                                         // Add description texts:
03806                                                 if ($this->edit_showFieldHelp)  {
03807                                                         $GLOBALS['LANG']->loadSingleTableDescription($theTable);
03808                                                         $fDat = $GLOBALS['TCA_DESCR'][$theTable]['columns'][$theField];
03809                                                         $descr = $fDat['description'];
03810                                                 }
03811 
03812                                                         // Item configuration:
03813                                                 $items[] = array(
03814                                                         ereg_replace(':$','',$theTypeArrays[0]),
03815                                                         $theTypeArrays[1],
03816                                                         '',
03817                                                         $descr
03818                                                 );
03819                                         }
03820                                 break;
03821                                 case 'explicitValues':
03822                                         $theTypes = t3lib_BEfunc::getExplicitAuthFieldValues();
03823 
03824                                                         // Icons:
03825                                         $icons = array(
03826                                                 'ALLOW' => '../'.TYPO3_mainDir.t3lib_iconWorks::skinImg($this->backPath,'gfx/icon_ok2.gif','',1),
03827                                                 'DENY' => '../'.TYPO3_mainDir.t3lib_iconWorks::skinImg($this->backPath,'gfx/icon_fatalerror.gif','',1),
03828                                         );
03829 
03830                                                 // Traverse types:
03831                                         foreach($theTypes as $tableFieldKey => $theTypeArrays)  {
03832 
03833                                                 if (is_array($theTypeArrays['items']))  {
03834                                                                 // Add header:
03835                                                         $items[] = array(
03836                                                                 $theTypeArrays['tableFieldLabel'],
03837                                                                 '--div--',
03838                                                         );
03839 
03840                                                                 // Traverse options for this field:
03841                                                         foreach($theTypeArrays['items'] as $itemValue => $itemContent)  {
03842                                                                         // Add item to be selected:
03843                                                                 $items[] = array(
03844                                                                         '['.$itemContent[2].'] '.$itemContent[1],
03845                                                                         $tableFieldKey.':'.ereg_replace('[:|,]','',$itemValue).':'.$itemContent[0],
03846                                                                         $icons[$itemContent[0]]
03847                                                                 );
03848                                                         }
03849                                                 }
03850                                         }
03851                                 break;
03852                                 case 'languages':
03853                                         $items = array_merge($items,t3lib_BEfunc::getSystemLanguages());
03854                                 break;
03855                                 case 'custom':
03856                                                 // Initialize:
03857                                         $customOptions = $GLOBALS['TYPO3_CONF_VARS']['BE']['customPermOptions'];
03858                                         if (is_array($customOptions))   {
03859                                                 foreach($customOptions as $coKey => $coValue) {
03860                                                         if (is_array($coValue['items']))        {
03861                                                                         // Add header:
03862                                                                 $items[] = array(
03863                                                                         $GLOBALS['LANG']->sl($coValue['header']),
03864                                                                         '--div--',
03865                                                                 );
03866 
03867                                                                         // Traverse items:
03868                                                                 foreach($coValue['items'] as $itemKey => $itemCfg)      {
03869                                                                                 // Icon:
03870                                                                         if ($itemCfg[1])        {
03871                                                                                 list($icon) = $this->getIcon($itemCfg[1]);
03872                                                                                 if ($icon)      $icon = '../'.TYPO3_mainDir.$icon;
03873                                                                         } else $icon = '';
03874 
03875                                                                                 // Add item to be selected:
03876                                                                         $items[] = array(
03877                                                                                 $GLOBALS['LANG']->sl($itemCfg[0]),
03878                                                                                 $coKey.':'.ereg_replace('[:|,]','',$itemKey),
03879                                                                                 $icon,
03880                                                                                 $GLOBALS['LANG']->sl($itemCfg[2]),
03881                                                                         );
03882                                                                 }
03883                                                         }
03884                                                 }
03885                                         }
03886                                 break;
03887                                 case 'modListGroup':
03888                                 case 'modListUser':
03889                                         $loadModules = t3lib_div::makeInstance('t3lib_loadModules');
03890                                         $loadModules->load($GLOBALS['TBE_MODULES']);
03891 
03892                                         $modList = $fieldValue['config']['special']=='modListUser' ? $loadModules->modListUser : $loadModules->modListGroup;
03893                                         if (is_array($modList)) {
03894                                                 $descr = '';
03895 
03896                                                 foreach($modList as $theMod)    {
03897 
03898                                                                 // Icon:
03899                                                         $icon = $GLOBALS['LANG']->moduleLabels['tabs_images'][$theMod.'_tab'];
03900                                                         if ($icon)      {
03901                                                                 $icon = '../'.substr($icon,strlen(PATH_site));
03902                                                         }
03903 
03904                                                                 // Description texts:
03905                                                         if ($this->edit_showFieldHelp)  {
03906                                                                 $descr = $GLOBALS['LANG']->moduleLabels['labels'][$theMod.'_tablabel'].
03907                                                                                         chr(10).
03908                                                                                         $GLOBALS['LANG']->moduleLabels['labels'][$theMod.'_tabdescr'];
03909                                                         }
03910 
03911                                                                 // Item configuration:
03912                                                         $items[] = array(
03913                                                                 $this->addSelectOptionsToItemArray_makeModuleData($theMod),
03914                                                                 $theMod,
03915                                                                 $icon,
03916                                                                 $descr
03917                                                         );
03918                                                 }
03919                                         }
03920                                 break;
03921                         }
03922                 }
03923 
03924                         // Return the items:
03925                 return $items;
03926         }
03927 
03936         function addSelectOptionsToItemArray_makeModuleData($value)     {
03937                 $label = '';
03938                         // Add label for main module:
03939                 $pp = explode('_',$value);
03940                 if (count($pp)>1)       $label.=$GLOBALS['LANG']->moduleLabels['tabs'][$pp[0].'_tab'].'>';
03941                         // Add modules own label now:
03942                 $label.= $GLOBALS['LANG']->moduleLabels['tabs'][$value.'_tab'];
03943 
03944                 return $label;
03945         }
03946 
03958         function foreignTable($items,$fieldValue,$TSconfig,$field,$pFFlag=0)    {
03959                 global $TCA;
03960 
03961                         // Init:
03962                 $pF=$pFFlag?'neg_':'';
03963                 $f_table = $fieldValue['config'][$pF.'foreign_table'];
03964                 $uidPre = $pFFlag?'-':'';
03965 
03966                         // Get query:
03967                 $res = t3lib_BEfunc::exec_foreign_table_where_query($fieldValue,$field,$TSconfig,$pF);
03968 
03969                         // Perform lookup
03970                 if ($GLOBALS['TYPO3_DB']->sql_error())  {
03971                         echo($GLOBALS['TYPO3_DB']->sql_error()."\n\nThis may indicate a table defined in tables.php is not existing in the database!");
03972                         return array();
03973                 }
03974 
03975                         // Get label prefix.
03976                 $lPrefix = $this->sL($fieldValue['config'][$pF.'foreign_table_prefix']);
03977 
03978                         // Get icon field + path if any:
03979                 $iField = $TCA[$f_table]['ctrl']['selicon_field'];
03980                 $iPath = trim($TCA[$f_table]['ctrl']['selicon_field_path']);
03981 
03982                         // Traverse the selected rows to add them:
03983                 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))      {
03984                         t3lib_BEfunc::workspaceOL($f_table, $row);
03985                                 // Prepare the icon if available:
03986                         if ($iField && $iPath && $row[$iField]) {
03987                                 $iParts = t3lib_div::trimExplode(',',$row[$iField],1);
03988                                 $icon = '../'.$iPath.'/'.trim($iParts[0]);
03989                         } elseif (t3lib_div::inList('singlebox,checkbox',$fieldValue['config']['renderMode'])) {
03990                                 $icon = '../'.TYPO3_mainDir.t3lib_iconWorks::skinImg($this->backPath,t3lib_iconWorks::getIcon($f_table, $row),'',1);
03991                         } else $icon = '';
03992 
03993                                 // Add the item:
03994                         $items[] = array(
03995                                 t3lib_div::fixed_lgd_cs($lPrefix.strip_tags(t3lib_BEfunc::getRecordTitle($f_table,$row)),$this->titleLen),
03996                                 $uidPre.$row['uid'],
03997                                 $icon
03998                         );
03999                 }
04000                 return $items;
04001         }
04002 
04003 
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          * Template functions
04030          *
04031          ********************************************/
04032 
04039         function setNewBEDesign()       {
04040 
04041                         // Wrapping all table rows for a particular record being edited:
04042                 $this->totalWrap='
04043                 <table border="0" cellspacing="0" cellpadding="0" width="'.($this->docLarge ? 440+150 : 440).'" class="typo3-TCEforms">'.
04044                         '<tr class="bgColor2">
04045                                 <td>&nbsp;</td>
04046                                 <td>###RECORD_ICON### <span class="typo3-TCEforms-recHeader">###TABLE_TITLE###</span> ###ID_NEW_INDICATOR### - ###RECORD_LABEL###</td>
04047                         </tr>'.
04048                         '|'.
04049                         '<tr>
04050                                 <td>&nbsp;</td>
04051                                 <td><img src="clear.gif" width="'.($this->docLarge ? 440+150 : 440).'" height="1" alt="" /></td>
04052                         </tr>
04053                 </table>';
04054 
04055                         // Wrapping a single field:
04056                 $this->fieldTemplate='
04057                         <tr ###BGCOLOR_HEAD######CLASSATTR_2###>
04058                                 <td>###FIELD_HELP_ICON###</td>
04059                                 <td width="99%"><span style="color:###FONTCOLOR_HEAD###;"###CLASSATTR_4###><b>###FIELD_NAME###</b></span>###FIELD_HELP_TEXT###</td>
04060                         </tr>
04061                         <tr ###BGCOLOR######CLASSATTR_1###>
04062                                 <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>
04063                                 <td valign="top">###FIELD_ITEM######FIELD_PAL_LINK_ICON###</td>
04064                         </tr>';
04065 
04066                 $this->palFieldTemplate='
04067                         <tr ###BGCOLOR######CLASSATTR_1###>
04068                                 <td>&nbsp;</td>
04069                                 <td nowrap="nowrap" valign="top">###FIELD_PALETTE###</td>
04070                         </tr>';
04071                 $this->palFieldTemplateHeader='
04072                         <tr ###BGCOLOR_HEAD######CLASSATTR_2###>
04073                                 <td>&nbsp;</td>
04074                                 <td nowrap="nowrap" valign="top"><strong>###FIELD_HEADER###</strong></td>
04075                         </tr>';
04076 
04077                 $this->sectionWrap='
04078                         <tr>
04079                                 <td colspan="2"><img src="clear.gif" width="1" height="###SPACE_BEFORE###" alt="" /></td>
04080                         </tr>
04081                         <tr>
04082                                 <td colspan="2"><table ###TABLE_ATTRIBS###>###CONTENT###</table></td>
04083                         </tr>
04084                         ';
04085         }
04086 
04094         function intoTemplate($inArr,$altTemplate='')   {
04095                                 // Put into template_
04096                 $fieldTemplateParts = explode('###FIELD_',$this->rplColorScheme($altTemplate?$altTemplate:$this->fieldTemplate));
04097                 reset($fieldTemplateParts);
04098                 $out=current($fieldTemplateParts);
04099                 while(list(,$part)=each($fieldTemplateParts))   {
04100                         list($key,$val)=explode('###',$part,2);
04101                         $out.=$inArr[$key];
04102                         $out.=$val;
04103                 }
04104                 return $out;
04105         }
04106 
04118         function addUserTemplateMarkers($marker,$table,$field,$row,&$PA)        {
04119                 return $marker;
04120         }
04121 
04129         function wrapLabels($str)       {
04130                 return $str;
04131         }
04132 
04142         function wrapTotal($c,$rec,$table)      {
04143                 $parts = $this->replaceTableWrap(explode('|',$this->totalWrap,2),$rec,$table);
04144                 return $parts[0].$c.$parts[1].implode('',$this->hiddenFieldAccum);
04145         }
04146 
04155         function replaceTableWrap($arr,$rec,$table)     {
04156                 global $TCA;
04157                 reset($arr);
04158                 while(list($k,$v)=each($arr))   {
04159 
04160                                 // Make "new"-label
04161                         if (strstr($rec['uid'],'NEW'))  {
04162                                 $newLabel = ' <span class="typo3-TCEforms-newToken">'.
04163                                                         $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.new',1).
04164                                                         '</span>';
04165 
04166                                 #t3lib_BEfunc::fixVersioningPid($table,$rec);   // Kasper: Should not be used here because NEW records are not offline workspace versions...
04167                                 $truePid = t3lib_BEfunc::getTSconfig_pidValue($table,$rec['uid'],$rec['pid']);
04168                                 $prec = t3lib_BEfunc::getRecordWSOL('pages',$truePid,'title');
04169                                 $rLabel = '<em>[PID: '.$truePid.'] '.htmlspecialchars(trim(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle('pages',$prec),40))).'</em>';
04170                         } else {
04171                                 $newLabel = ' <span class="typo3-TCEforms-recUid">['.$rec['uid'].']</span>';
04172                                 $rLabel  = htmlspecialchars(trim(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table,$rec),40)));
04173                         }
04174 
04175                                 // Make substitutions:
04176                         $arr[$k] = str_replace('###ID_NEW_INDICATOR###', $newLabel, $arr[$k]);
04177                         $arr[$k] = str_replace('###RECORD_LABEL###',$rLabel,$arr[$k]);
04178                         $arr[$k] = str_replace('###TABLE_TITLE###',htmlspecialchars($this->sL($TCA[$table]['ctrl']['title'])),$arr[$k]);
04179 
04180                         $titleA=t3lib_BEfunc::titleAltAttrib($this->getRecordPath($table,$rec));
04181                         $arr[$k]=str_replace('###RECORD_ICON###',t3lib_iconWorks::getIconImage($table,$rec,$this->backPath,'class="absmiddle"'.$titleA),$arr[$k]);
04182                 }
04183                 return $arr;
04184         }
04185 
04193         function wrapBorder(&$out_array,&$out_pointer)  {
04194                 if ($this->sectionWrap && $out_array[$out_pointer])     {
04195                         $tableAttribs='';
04196                         $tableAttribs.= $this->borderStyle[0] ? ' style="'.htmlspecialchars($this->borderStyle[0]).'"':'';
04197                         $tableAttribs.= $this->borderStyle[2] ? ' background="'.htmlspecialchars($this->backPath.$this->borderStyle[2]).'"':'';
04198                         $tableAttribs.= $this->borderStyle[3] ? ' class="'.htmlspecialchars($this->borderStyle[3]).'"':'';
04199                         if ($tableAttribs)      {
04200                                 $tableAttribs='border="0" cellspacing="0" cellpadding="0" width="100%"'.$tableAttribs;
04201                                 $out_array[$out_pointer] = str_replace('###CONTENT###',$out_array[$out_pointer],
04202                                         str_replace('###TABLE_ATTRIBS###',$tableAttribs,
04203                                                 str_replace('###SPACE_BEFORE###',intval($this->borderStyle[1]),$this->sectionWrap)));
04204                         }
04205                         $out_pointer++;
04206                 }
04207         }
04208 
04215         function rplColorScheme($inTemplate)    {
04216                         // Colors:
04217                 $inTemplate = str_replace('###BGCOLOR###',$this->colorScheme[0]?' bgcolor="'.$this->colorScheme[0].'"':'',$inTemplate);
04218                 $inTemplate = str_replace('###BGCOLOR_HEAD###',$this->colorScheme[1]?' bgcolor="'.$this->colorScheme[1].'"':'',$inTemplate);
04219                 $inTemplate = str_replace('###FONTCOLOR_HEAD###',$this->colorScheme[3],$inTemplate);
04220 
04221                         // Classes:
04222                 $inTemplate = str_replace('###CLASSATTR_1###',$this->classScheme[0]?' class="'.$this->classScheme[0].'"':'',$inTemplate);
04223                 $inTemplate = str_replace('###CLASSATTR_2###',$this->classScheme[1]?' class="'.$this->classScheme[1].'"':'',$inTemplate);
04224                 $inTemplate = str_replace('###CLASSATTR_4###',$this->classScheme[3]?' class="'.$this->classScheme[3].'"':'',$inTemplate);
04225 
04226                 return $inTemplate;
04227         }
04228 
04235         function getDivider()   {
04236                 //return "<hr />";
04237         }
04238 
04245         function printPalette($palArr)  {
04246 
04247                         // Init color/class attributes:
04248                 $ccAttr2 = $this->colorScheme[2] ? ' bgcolor="'.$this->colorScheme[2].'"' : '';
04249                 $ccAttr2.= $this->classScheme[2] ? ' class="'.$this->classScheme[2].'"' : '';
04250                 $ccAttr4 = $this->colorScheme[4] ? ' style="color:'.$this->colorScheme[4].'"' : '';
04251                 $ccAttr4.= $this->classScheme[4] ? ' class="'.$this->classScheme[4].'"' : '';
04252 
04253                         // Traverse palette fields and render them into table rows:
04254                 foreach($palArr as $content)    {
04255                         $hRow[]='<td'.$ccAttr2.'>&nbsp;</td>
04256                                         <td nowrap="nowrap"'.$ccAttr2.'>'.
04257                                                 '<span'.$ccAttr4.'>'.
04258                                                         $content['NAME'].
04259                                                 '</span>'.
04260                                         '</td>';
04261                         $iRow[]='<td valign="top">'.
04262                                                 '<img name="req_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="10" height="10" vspace="4" alt="" />'.
04263                                                 '<img name="cm_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="7" height="10" vspace="4" alt="" />'.
04264                                         '</td>
04265                                         <td nowrap="nowrap" valign="top">'.
04266                                                 $content['ITEM'].
04267                                                 $content['HELP_ICON'].
04268                                         '</td>';
04269                 }
04270 
04271                         // Final wrapping into the table:
04272                 $out='<table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-palette">
04273                         <tr>
04274                                 <td><img src="clear.gif" width="'.intval($this->paletteMargin).'" height="1" alt="" /></td>'.
04275                                         implode('
04276                                 ',$hRow).'
04277                         </tr>
04278                         <tr>
04279                                 <td></td>'.
04280                                         implode('
04281                                 ',$iRow).'
04282                         </tr>
04283                 </table>';
04284 
04285                 return $out;
04286         }
04287 
04296         function helpTextIcon($table,$field,$force=0)   {
04297                 if ($this->globalShowHelp && $GLOBALS['TCA_DESCR'][$table]['columns'][$field] && (($this->edit_showFieldHelp=='icon'&&!$this->doLoadTableDescr($table)) || $force))     {
04298                         $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;';
04299                         return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
04300                                         '<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="" />'.
04301                                         '</a>';
04302                 } else {
04303                                 // Detects fields with no CSH and outputs dummy line to insert into CSH locallang file:
04304                         #debug(array("'".$field.".description' => '[FILL IN] ".$table."->".$field."',"),$table);
04305                         return '&nbsp;';
04306                 }
04307         }
04308 
04316         function helpText($table,$field)        {
04317                 if ($this->globalShowHelp && $GLOBALS['TCA_DESCR'][$table]['columns'][$field] && ($this->edit_showFieldHelp=='text' || $this->doLoadTableDescr($table)))        {
04318                         $fDat = $GLOBALS['TCA_DESCR'][$table]['columns'][$field];
04319                         return '<table border="0" cellpadding="2" cellspacing="0" width="90%"><tr><td valign="top" width="14">'.
04320                                         $this->helpTextIcon(
04321                                                 $table,
04322                                                 $field,
04323                                                 $fDat['details']||$fDat['syntax']||$fDat['image_descr']||$fDat['image']||$fDat['seeAlso']
04324                                         ).
04325                                         '</td><td valign="top"><span class="typo3-TCEforms-helpText">'.
04326                                         $GLOBALS['LANG']->hscAndCharConv(strip_tags($fDat['description']),1).
04327                                         '</span></td></tr></table>';
04328                 }
04329         }
04330 
04337         function setColorScheme($scheme)        {
04338                 $this->colorScheme = $this->defColorScheme;
04339                 $this->classScheme = $this->defClassScheme;
04340 
04341                 $parts = t3lib_div::trimExplode(',',$scheme);
04342                 foreach($parts as $key => $col) {
04343                                 // Split for color|class:
04344                         list($color,$class) = t3lib_div::trimExplode('|',$col);
04345 
04346                                 // Handle color values:
04347                         if ($color)     $this->colorScheme[$key] = $color;
04348                         if ($color=='-')        $this->colorScheme[$key] = '';
04349 
04350                                 // Handle class values:
04351                         if ($class)     $this->classScheme[$key] = $class;
04352                         if ($class=='-')        $this->classScheme[$key] = '';
04353                 }
04354         }
04355 
04361         function resetSchemes() {
04362                 $this->setColorScheme($GLOBALS['TBE_STYLES']['colorschemes'][0]);
04363                 $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][0];
04364                 $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][0];
04365         }
04366 
04372         function storeSchemes() {
04373                 $this->savedSchemes['classScheme'] = $this->classScheme;
04374                 $this->savedSchemes['colorScheme'] = $this->colorScheme;
04375                 $this->savedSchemes['fieldStyle'] = $this->fieldStyle;
04376                 $this->savedSchemes['borderStyle'] = $this->borderStyle;
04377         }
04378 
04384         function restoreSchemes()       {
04385                 $this->classScheme = $this->savedSchemes['classScheme'];
04386                 $this->colorScheme = $this->savedSchemes['colorScheme'];
04387                 $this->fieldStyle = $this->savedSchemes['fieldStyle'];
04388                 $this->borderStyle = $this->savedSchemes['borderStyle'];
04389         }
04390 
04391 
04392 
04393 
04394 
04395 
04396 
04397 
04398 
04399 
04400 
04401 
04402 
04403         /********************************************
04404          *
04405          * JavaScript related functions
04406          *
04407          ********************************************/
04408 
04414         function JStop()        {
04415 
04416                 $out = '';
04417 
04418                         // Additional top HTML:
04419                 if (count($this->additionalCode_pre))   {
04420                         $out.= implode('
04421 
04422                                 <!-- NEXT: -->
04423                         ',$this->additionalCode_pre);
04424                 }
04425 
04426                         // Additional top JavaScript
04427                 if (count($this->additionalJS_pre))     {
04428                         $out.='
04429 
04430 
04431                 <!--
04432                         JavaScript in top of page (before form):
04433                 -->
04434 
04435                 <script type="text/javascript">
04436                         /*<![CDATA[*/
04437 
04438                         '.implode('
04439 
04440                                 // NEXT:
04441                         ',$this->additionalJS_pre).'
04442 
04443                         /*]]>*/
04444                 </script>
04445                         ';
04446                 }
04447 
04448                         // Return result:
04449                 return $out;
04450         }
04451 
04465         function JSbottom($formname='forms[0]') {
04466 
04467                                 // required
04468                         $reqLines=array();
04469                         $reqLinesCheck=array();
04470                         $reqLinesSet=array();
04471                         reset($this->requiredFields);
04472                         while(list($itemImgName,$itemName)=each($this->requiredFields)) {
04473                                 $reqLines[]="                                   TBE_REQUIRED['".$itemName."']=1;";
04474                                 $reqLinesCheck[]="                                      if (!document.".$formname."['".$itemName."'].value)     {OK=0;}";
04475                                 $reqLinesSet[]="                                        if (!document.".$formname."['".$itemName."'].value)     {TBE_EDITOR_setImage('req_".$itemImgName."','TBE_EDITOR_req');}";
04476                         }
04477 
04478                         $reqRange=array();
04479                         $reqRangeCheck=array();
04480                         $reqRangeSet=array();
04481                         reset($this->requiredElements);
04482                         while(list($itemName,$range)=each($this->requiredElements))     {
04483                                 $reqRange[]="                                   TBE_RANGE['".$itemName."']=1;";
04484                                 $reqRange[]="                                   TBE_RANGE_lower['".$itemName."']=".$range[0].";";
04485                                 $reqRange[]="                                   TBE_RANGE_upper['".$itemName."']=".$range[1].";";
04486                                 $reqRangeCheck[]="                                      if (!TBE_EDITOR_checkRange(document.".$formname."['".$itemName."_list'],".$range[0].",".$range[1]."))   {OK=0;}";
04487                                 $reqRangeSet[]="                                        if (!TBE_EDITOR_checkRange(document.".$formname."['".$itemName."_list'],".$range[0].",".$range[1]."))   {TBE_EDITOR_setImage('req_".$range['imgName']."','TBE_EDITOR_req');}";
04488                         }
04489 
04490                         $this->TBE_EDITOR_fieldChanged_func='TBE_EDITOR_fieldChanged_fName(fName,formObj[fName+"_list"]);';
04491 
04492                         if ($this->loadMD5_JS)  {
04493                         $out.='
04494                         <script type="text/javascript" src="'.$this->backPath.'md5.js"></script>';
04495                         }
04496                         $out.='
04497                         <script type="text/javascript" src="'.$this->backPath.'../t3lib/jsfunc.evalfield.js"></script>
04498                         <script type="text/javascript">
04499                                 /*<![CDATA[*/
04500 
04501                                 var TBE_EDITOR_req=new Image();         TBE_EDITOR_req.src = "'.t3lib_iconWorks::skinImg($this->backPath,'gfx/required_h.gif','',1).'";
04502                                 var TBE_EDITOR_cm=new Image();          TBE_EDITOR_cm.src = "'.t3lib_iconWorks::skinImg($this->backPath,'gfx/content_client.gif','',1).'";
04503                                 var TBE_EDITOR_sel=new Image();         TBE_EDITOR_sel.src = "'.t3lib_iconWorks::skinImg($this->backPath,'gfx/content_selected.gif','',1).'";
04504                                 var TBE_EDITOR_clear=new Image();       TBE_EDITOR_clear.src = "'.$this->backPath.'clear.gif";
04505                                 var TBE_REQUIRED=new Array();
04506 '.implode(chr(10),$reqLines).'
04507 
04508                                 var TBE_RANGE=new Array();
04509                                 var TBE_RANGE_lower=new Array();
04510                                 var TBE_RANGE_upper=new Array();
04511 '.implode(chr(10),$reqRange).'
04512 
04513                                 // $this->additionalJS_post:
04514 '.implode(chr(10),$this->additionalJS_post).'
04515 
04516                                 var TBE_EDITOR_loadTime = 0;
04517                                 var TBE_EDITOR_isChanged = 0;
04518 
04519                                 function TBE_EDITOR_loginRefreshed()    {       //
04520                                         var date = new Date();
04521                                         TBE_EDITOR_loadTime = Math.floor(date.getTime()/1000);
04522                                         if (top.busy && top.busy.loginRefreshed)        {top.busy.loginRefreshed();}
04523                                 }
04524                                 function TBE_EDITOR_checkLoginTimeout() {       //
04525                                         var date = new Date();
04526                                         var theTime = Math.floor(date.getTime()/1000);
04527                                         if (theTime > TBE_EDITOR_loadTime+'.intval($GLOBALS['BE_USER']->auth_timeout_field).'-10)       {
04528                                                 return true;
04529                                         }
04530                                 }
04531                                 function TBE_EDITOR_setHiddenContent(RTEcontent,theField)       {       //
04532                                         document.'.$formname.'[theField].value = RTEcontent;
04533                                         alert(document.'.$formname.'[theField].value);
04534                                 }
04535                                 function TBE_EDITOR_fieldChanged_fName(fName,el)        {       //
04536                                         var idx='.(2+substr_count($this->prependFormFieldNames,'[')).';
04537                                         var table = TBE_EDITOR_split(fName, "[", idx);
04538                                         var uid = TBE_EDITOR_split(fName, "[", idx+1);
04539                                         var field = TBE_EDITOR_split(fName, "[", idx+2);
04540 
04541                                         table = table.substr(0,table.length-1);
04542                                         uid = uid.substr(0,uid.length-1);
04543                                         field = field.substr(0,field.length-1);
04544                                         TBE_EDITOR_fieldChanged(table,uid,field,el);
04545                                 }
04546                                 function TBE_EDITOR_fieldChanged(table,uid,field,el)    {       //
04547                                         var theField = "'.$this->prependFormFieldNames.'["+table+"]["+uid+"]["+field+"]";
04548                                         TBE_EDITOR_isChanged = 1;
04549 
04550                                                 // Set change image:
04551                                         var imgObjName = "cm_"+table+"_"+uid+"_"+field;
04552                                         TBE_EDITOR_setImage(imgObjName,"TBE_EDITOR_cm");
04553 
04554                                                 // Set change image
04555                                         if (document.'.$formname.'[theField] && document.'.$formname.'[theField].type=="select-one" && document.'.$formname.'[theField+"_selIconVal"])  {
04556                                                 var imgObjName = "selIcon_"+table+"_"+uid+"_"+field+"_";
04557                                                 TBE_EDITOR_setImage(imgObjName+document.'.$formname.'[theField+"_selIconVal"].value,"TBE_EDITOR_clear");
04558                                                 document.'.$formname.'[theField+"_selIconVal"].value = document.'.$formname.'[theField].selectedIndex;
04559                                                 TBE_EDITOR_setImage(imgObjName+document.'.$formname.'[theField+"_selIconVal"].value,"TBE_EDITOR_sel");
04560                                         }
04561 
04562                                                 // Set required flag:
04563                                         var imgReqObjName = "req_"+table+"_"+uid+"_"+field;
04564                                         if (TBE_REQUIRED[theField] && document.'.$formname.'[theField]) {
04565                                                 if (document.'.$formname.'[theField].value)     {
04566                                                         TBE_EDITOR_setImage(imgReqObjName,"TBE_EDITOR_clear");
04567                                                 } else {
04568                                                         TBE_EDITOR_setImage(imgReqObjName,"TBE_EDITOR_req");
04569                                                 }
04570                                         }
04571                                         if (TBE_RANGE[theField] && document.'.$formname.'[theField])    {
04572                                                 if (TBE_EDITOR_checkRange(document.'.$formname.'[theField+"_list"],TBE_RANGE_lower[theField],TBE_RANGE_upper[theField]))        {
04573                                                         TBE_EDITOR_setImage(imgReqObjName,"TBE_EDITOR_clear");
04574                                                 } else {
04575                                                         TBE_EDITOR_setImage(imgReqObjName,"TBE_EDITOR_req");
04576                                                 }
04577                                         }
04578                                         '.(!$this->isPalettedoc?'':'
04579                                         TBE_EDITOR_setOriginalFormFieldValue(theField);
04580                                         ').'
04581                                 }
04582                                 '.($this->isPalettedoc?'
04583                                 function TBE_EDITOR_setOriginalFormFieldValue(theField) {       //
04584                                         if ('.$this->isPalettedoc.' && '.$this->isPalettedoc.'.document.'.$formname.' && '.$this->isPalettedoc.'.document.'.$formname.'[theField]) {
04585                                                 '.$this->isPalettedoc.'.document.'.$formname.'[theField].value = document.'.$formname.'[theField].value;
04586                                         }
04587                                 }
04588                                 ':'').'
04589                                 function TBE_EDITOR_isFormChanged(noAlert)      {       //
04590                                         if (TBE_EDITOR_isChanged && !noAlert && confirm('.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.fieldsChanged')).'))        {
04591                                                 return 0;
04592                                         }
04593                                         return TBE_EDITOR_isChanged;
04594                                 }
04595                                 function TBE_EDITOR_checkAndDoSubmit(sendAlert) {       //
04596                                         if (TBE_EDITOR_checkSubmit(sendAlert))  {
04597                                                 TBE_EDITOR_submitForm();
04598                                         }
04599                                 }
04600 
04607                                 function TBE_EDITOR_checkSubmit(sendAlert)      {       //
04608                                         if (TBE_EDITOR_checkLoginTimeout() && confirm('.$GLOBALS['LANG']->JScharCode($this->getLL('m_refresh_login')).'))       {
04609                                                 vHWin=window.open(\''.$this->backPath.'login_frameset.php?\',\'relogin\',\'height=300,width=400,status=0,menubar=0\');
04610                                                 vHWin.focus();
04611                                                 return false;
04612                                         }
04613                                         var OK=1;
04614 
04615                                         // $this->additionalJS_post:
04616 '.implode(chr(10),$this->additionalJS_submit).'
04617 
04618                                         if(!OK) {
04619                                                 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.")))  {
04620                                                         return false;
04621                                                 } else {
04622                                                         OK = 1;
04623                                                 }
04624                                         }
04625 
04626 '.implode(chr(10),$reqLinesCheck).'
04627 '.implode(chr(10),$reqRangeCheck).'
04628 
04629                                         if (OK || sendAlert==-1)        {
04630                                                 return true;
04631                                         } else {
04632                                                 if(sendAlert)   alert('.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.fieldsMissing')).');
04633                                                 return false;
04634                                         }
04635                                 }
04636                                 function TBE_EDITOR_checkRange(el,lower,upper)  {       //
04637                                         if (el && el.length>=lower && el.length<=upper) {
04638                                                 return true;
04639                                         } else {
04640                                                 return false;
04641                                         }
04642                                 }
04643                                 function TBE_EDITOR_initRequired()      {       //
04644 '.implode(chr(10),$reqLinesSet).'
04645 '.implode(chr(10),$reqRangeSet).'
04646                                 }
04647                                 function TBE_EDITOR_setImage(name,imgName)      {       //
04648                                         if (document[name]) {document[name].src = eval(imgName+".src");}
04649                                 }
04650                                 function TBE_EDITOR_submitForm()        {       //
04651                                         '.($this->doSaveFieldName?'document.'.$this->formName."['".$this->doSaveFieldName."'].value=1;":'').'
04652                                         document.'.$this->formName.'.submit();
04653                                 }
04654                                 function typoSetup      ()      {       //
04655                                         this.passwordDummy = "********";
04656                                         this.decimalSign = ".";
04657                                 }
04658                                 var TS = new typoSetup();
04659                                 var evalFunc = new evalFunc();
04660                                 evalFunc.USmode = '.($GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat']?'1':'0').';
04661 
04662                                 function typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue)  {       //
04663                                         if (document.'.$formname.'[theField])   {
04664                                                 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
04665                                                 var theValue = document.'.$formname.'[theField].value;
04666                                                 if (checkbox && theValue==checkboxValue)        {
04667                                                         document.'.$formname.'[theField+"_hr"].value="";
04668                                                         if (document.'.$formname.'[theField+"_cb"])     document.'.$formname.'[theField+"_cb"].checked = "";
04669                                                 } else {
04670                                                         document.'.$formname.'[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
04671                                                         if (document.'.$formname.'[theField+"_cb"])     document.'.$formname.'[theField+"_cb"].checked = "on";
04672                                                 }
04673                                         }
04674                                 }
04675                                 function typo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off, checkSetValue)     {       //
04676                                         if (document.'.$formname.'[theField])   {
04677                                                 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
04678                                                 if (checkbox_off)       {
04679                                                         if (document.'.$formname.'[theField+"_cb"].checked)     {
04680                                                                 document.'.$formname.'[theField].value=checkSetValue;
04681                                                         } else {
04682                                                                 document.'.$formname.'[theField].value=checkboxValue;
04683                                                         }
04684                                                 }else{
04685                                                         document.'.$formname.'[theField].value = evalFunc.evalObjValue(theFObj, document.'.$formname.'[theField+"_hr"].value);
04686                                                 }
04687                                                 typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue);
04688                                         }
04689                                 }
04690                                 function TBE_EDITOR_split(theStr1, delim, index) {              //
04691                                         var theStr = ""+theStr1;
04692                                         var lengthOfDelim = delim.length;
04693                                         sPos = -lengthOfDelim;
04694                                         if (index<1) {index=1;}
04695                                         for (var a=1; a<index; a++)     {
04696                                                 sPos = theStr.indexOf(delim, sPos+lengthOfDelim);
04697                                                 if (sPos==-1)   {return null;}
04698                                         }
04699                                         ePos = theStr.indexOf(delim, sPos+lengthOfDelim);
04700                                         if(ePos == -1)  {ePos = theStr.length;}
04701                                         return (theStr.substring(sPos+lengthOfDelim,ePos));
04702                                 }
04703                                 function TBE_EDITOR_palUrl(inData,fieldList,fieldNum,table,uid,isOnFocus) {             //
04704                                         var url = "'.$this->backPath.'alt_palette.php?inData="+inData+"&formName='.rawurlencode($this->formName).'"+"&prependFormFieldNames='.rawurlencode($this->prependFormFieldNames).'";
04705                                         var field = "";
04706                                         var theField="";
04707                                         for (var a=0; a<fieldNum;a++)   {
04708                                                 field = TBE_EDITOR_split(fieldList, ",", a+1);
04709                                                 theField = "'.$this->prependFormFieldNames.'["+table+"]["+uid+"]["+field+"]";
04710                                                 if (document.'.$formname.'[theField])           url+="&rec["+field+"]="+TBE_EDITOR_rawurlencode(document.'.$formname.'[theField].value);
04711                                         }
04712                                         if (top.topmenuFrame)   {
04713                                                 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");
04714                                         } else if (!isOnFocus) {
04715                                                 var vHWin=window.open(url,"palette","height=300,width=200,status=0,menubar=0,scrollbars=1");
04716                                                 vHWin.focus();
04717                                         }
04718                                 }
04719                                 function TBE_EDITOR_curSelected(theField)       {       //
04720                                         var fObjSel = document.'.$formname.'[theField];
04721                                         var retVal="";
04722                                         if (fObjSel)    {
04723                                                 if (fObjSel.type=="select-multiple" || fObjSel.type=="select-one")      {
04724                                                         var l=fObjSel.length;
04725                                                         for (a=0;a<l;a++)       {
04726                                                                 if (fObjSel.options[a].selected==1)     {
04727                                                                         retVal+=fObjSel.options[a].value+",";
04728                                                                 }
04729                                                         }
04730                                                 }
04731                                         }
04732                                         return retVal;
04733                                 }
04734                                 function TBE_EDITOR_rawurlencode(str,maxlen)    {       //
04735                                         var output = str;
04736                                         if (maxlen)     output = output.substr(0,200);
04737                                         output = escape(output);
04738                                         output = TBE_EDITOR_str_replace("*","%2A", output);
04739                                         output = TBE_EDITOR_str_replace("+","%2B", output);
04740                                         output = TBE_EDITOR_str_replace("/","%2F", output);
04741                                         output = TBE_EDITOR_str_replace("@","%40", output);
04742                                         return output;
04743                                 }
04744                                 function TBE_EDITOR_str_replace(match,replace,string)   {       //
04745                                         var input = ""+string;
04746                                         var matchStr = ""+match;
04747                                         if (!matchStr)  {return string;}
04748                                         var output = "";
04749                                         var pointer=0;
04750                                         var pos = input.indexOf(matchStr);
04751                                         while (pos!=-1) {
04752                                                 output+=""+input.substr(pointer, pos-pointer)+replace;
04753                                                 pointer=pos+matchStr.length;
04754                                                 pos = input.indexOf(match,pos+1);
04755                                         }
04756                                         output+=""+input.substr(pointer);
04757                                         return output;
04758                                 }
04759                                 /*]]>*/
04760                         </script>
04761                         <script type="text/javascript">
04762                                 /*<![CDATA[*/
04763 
04764                                 '.$this->extJSCODE.'
04765 
04766                                 TBE_EDITOR_initRequired();
04767                                 TBE_EDITOR_loginRefreshed();
04768                                 /*]]>*/
04769                         </script>';
04770                         return $out;
04771         }
04772 
04779         function dbFileCon($formObj='document.forms[0]')        {
04780                 $str='
04781 
04782                         // ***************
04783                         // Used to connect the db/file browser with this document and the formfields on it!
04784                         // ***************
04785 
04786                         var browserWin="";
04787 
04788                         function setFormValueOpenBrowser(mode,params) { //
04789                                 var url = "'.$this->backPath.'browser.php?mode="+mode+"&bparams="+params;
04790 
04791                                 browserWin = window.open(url,"Typo3WinBrowser","height=350,width="+(mode=="db"?650:600)+",status=0,menubar=0,resizable=1,scrollbars=1");
04792                                 browserWin.focus();
04793                         }
04794                         function setFormValueFromBrowseWin(fName,value,label)   {       //
04795                                 var formObj = setFormValue_getFObj(fName)
04796                                 if (formObj && value!="--div--")        {
04797                                         fObj = formObj[fName+"_list"];
04798                                                 // Inserting element
04799                                         var l=fObj.length;
04800                                         var setOK=1;
04801                                         if (!formObj[fName+"_mul"] || formObj[fName+"_mul"].value==0)   {
04802                                                 for (a=0;a<l;a++)       {
04803                                                         if (fObj.options[a].value==value)       {
04804                                                                 setOK=0;
04805                                                         }
04806                                                 }
04807                                         }
04808                                         if (setOK)      {
04809                                                 fObj.length++;
04810                                                 fObj.options[l].value=value;
04811                                                 fObj.options[l].text=unescape(label);
04812 
04813                                                         // Traversing list and set the hidden-field
04814                                                 setHiddenFromList(fObj,formObj[fName]);
04815                                                 '.$this->TBE_EDITOR_fieldChanged_func.'
04816                                         }
04817                                 }
04818                         }
04819                         function setHiddenFromList(fObjSel,fObjHid)     {       //
04820                                 l=fObjSel.length;
04821                                 fObjHid.value="";
04822                                 for (a=0;a<l;a++)       {
04823                                         fObjHid.value+=fObjSel.options[a].value+",";
04824                                 }
04825                         }
04826                         function setFormValueManipulate(fName,type)     {       //
04827                                 var formObj = setFormValue_getFObj(fName)
04828                                 if (formObj)    {
04829                                         var localArray_V = new Array();
04830                                         var localArray_L = new Array();
04831                                         var localArray_S = new Array();
04832                                         var fObjSel = formObj[fName+"_list"];
04833                                         var l=fObjSel.length;
04834                                         var c=0;
04835                                         if (type=="Remove" || type=="Top" || type=="Bottom")    {
04836                                                 if (type=="Top")        {
04837                                                         for (a=0;a<l;a++)       {
04838                                                                 if (fObjSel.options[a].selected==1)     {
04839                                                                         localArray_V[c]=fObjSel.options[a].value;
04840                                                                         localArray_L[c]=fObjSel.options[a].text;
04841                                                                         localArray_S[c]=1;
04842                                                                         c++;
04843                                                                 }
04844                                                         }
04845                                                 }
04846                                                 for (a=0;a<l;a++)       {
04847                                                         if (fObjSel.options[a].selected!=1)     {
04848                                                                 localArray_V[c]=fObjSel.options[a].value;
04849                                                                 localArray_L[c]=fObjSel.options[a].text;
04850                                                                 localArray_S[c]=0;
04851                                                                 c++;
04852                                                         }
04853                                                 }
04854                                                 if (type=="Bottom")     {
04855                                                         for (a=0;a<l;a++)       {
04856                                                                 if (fObjSel.options[a].selected==1)     {
04857                                                                         localArray_V[c]=fObjSel.options[a].value;
04858                                                                         localArray_L[c]=fObjSel.options[a].text;
04859                                                                         localArray_S[c]=1;
04860                                                                         c++;
04861                                                                 }
04862                                                         }
04863                                                 }
04864                                         }
04865                                         if (type=="Down")       {
04866                                                 var tC = 0;
04867                                                 var tA = new Array();
04868 
04869                                                 for (a=0;a<l;a++)       {
04870                                                         if (fObjSel.options[a].selected!=1)     {
04871                                                                         // Add non-selected element:
04872                                                                 localArray_V[c]=fObjSel.options[a].value;
04873                                                                 localArray_L[c]=fObjSel.options[a].text;
04874                                                                 localArray_S[c]=0;
04875                                                                 c++;
04876 
04877                                                                         // Transfer any accumulated and reset:
04878                                                                 if (tA.length > 0)      {
04879                                                                         for (aa=0;aa<tA.length;aa++)    {
04880                                                                                 localArray_V[c]=fObjSel.options[tA[aa]].value;
04881                                                                                 localArray_L[c]=fObjSel.options[tA[aa]].text;
04882                                                                                 localArray_S[c]=1;
04883                                                                                 c++;
04884                                                                         }
04885 
04886                                                                         var tC = 0;
04887                                                                         var tA = new Array();
04888                                                                 }
04889                                                         } else {
04890                                                                 tA[tC] = a;
04891                                                                 tC++;
04892                                                         }
04893                                                 }
04894                                                         // Transfer any remaining:
04895                                                 if (tA.length > 0)      {
04896                                                         for (aa=0;aa<tA.length;aa++)    {
04897                                                                 localArray_V[c]=fObjSel.options[tA[aa]].value;
04898                                                                 localArray_L[c]=fObjSel.options[tA[aa]].text;
04899                                                                 localArray_S[c]=1;
04900                                                                 c++;
04901                                                         }
04902                                                 }
04903                                         }
04904                                         if (type=="Up") {
04905                                                 var tC = 0;
04906                                                 var tA = new Array();
04907                                                 var c = l-1;
04908 
04909                                                 for (a=l-1;a>=0;a--)    {
04910                                                         if (fObjSel.options[a].selected!=1)     {
04911 
04912                                                                         // Add non-selected element:
04913                                                                 localArray_V[c]=fObjSel.options[a].value;
04914                                                                 localArray_L[c]=fObjSel.options[a].text;
04915                                                                 localArray_S[c]=0;
04916                                                                 c--;
04917 
04918                                                                         // Transfer any accumulated and reset:
04919                                                                 if (tA.length > 0)      {
04920                                                                         for (aa=0;aa<tA.length;aa++)    {
04921                                                                                 localArray_V[c]=fObjSel.options[tA[aa]].value;
04922                                                                                 localArray_L[c]=fObjSel.options[tA[aa]].text;
04923                                                                                 localArray_S[c]=1;
04924                                                                                 c--;
04925                                                                         }
04926 
04927                                                                         var tC = 0;
04928                                                                         var tA = new Array();
04929                                                                 }
04930                                                         } else {
04931                                                                 tA[tC] = a;
04932                                                                 tC++;
04933                                                         }
04934                                                 }
04935                                                         // Transfer any remaining:
04936                                                 if (tA.length > 0)      {
04937                                                         for (aa=0;aa<tA.length;aa++)    {
04938                                                                 localArray_V[c]=fObjSel.options[tA[aa]].value;
04939                                                                 localArray_L[c]=fObjSel.options[tA[aa]].text;
04940                                                                 localArray_S[c]=1;
04941                                                                 c--;
04942                                                         }
04943                                                 }
04944                                                 c=l;    // Restore length value in "c"
04945                                         }
04946 
04947                                                 // Transfer items in temporary storage to list object:
04948                                         fObjSel.length = c;
04949                                         for (a=0;a<c;a++)       {
04950                                                 fObjSel.options[a].value = localArray_V[a];
04951                                                 fObjSel.options[a].text = localArray_L[a];
04952                                                 fObjSel.options[a].selected = localArray_S[a];
04953                                         }
04954                                         setHiddenFromList(fObjSel,formObj[fName]);
04955 
04956                                         '.$this->TBE_EDITOR_fieldChanged_func.'
04957                                 }
04958                         }
04959                         function setFormValue_getFObj(fName)    {       //
04960                                 var formObj = '.$formObj.';
04961                                 if (formObj)    {
04962                                         if (formObj[fName] && formObj[fName+"_list"] && formObj[fName+"_list"].type=="select-multiple") {
04963                                                 return formObj;
04964                                         } else {
04965                                                 alert("Formfields missing:\n fName: "+formObj[fName]+"\n fName_list:"+formObj[fName+"_list"]+"\n type:"+formObj[fName+"_list"].type+"\n fName:"+fName);
04966                                         }
04967                                 }
04968                                 return "";
04969                         }
04970 
04971                         // END: dbFileCon parts.
04972                 ';
04973                 return $str;
04974         }
04975 
04981         function printNeededJSFunctions()       {
04982                         // JS evaluation:
04983                 $out = $this->JSbottom($this->formName);
04984                         //
04985                 if ($this->printNeededJS['dbFileIcons'])        {
04986                         $out.= '
04987 
04988 
04989 
04990                         <!--
04991                                 JavaScript after the form has been drawn:
04992                         -->
04993 
04994                         <script type="text/javascript">
04995                                 /*<![CDATA[*/
04996                         '.$this->dbFileCon('document.'.$this->formName).'
04997                                 /*]]>*/
04998                         </script>';
04999                 }
05000                 return $out;
05001         }
05002 
05008         function printNeededJSFunctions_top()   {
05009                         // JS evaluation:
05010                 $out = $this->JStop($this->formName);
05011                 return $out;
05012         }
05013 
05014 
05015 
05016 
05017 
05018 
05019 
05020 
05021 
05022 
05023 
05024 
05025 
05026 
05027 
05028 
05029 
05030 
05031 
05032 
05033 
05034 
05035 
05036 
05037 
05038 
05039 
05040 
05041 
05042         /********************************************
05043          *
05044          * Various helper functions
05045          *
05046          ********************************************/
05047 
05048 
05056         function getDefaultRecord($table,$pid=0)        {
05057                 global $TCA;
05058                 if ($TCA[$table])       {
05059                         t3lib_div::loadTCA($table);
05060                         $row = array();
05061 
05062                         if ($pid<0 && $TCA[$table]['ctrl']['useColumnsForDefaultValues'])       {
05063                                         // Fetches the previous record:
05064                                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'uid='.abs($pid).t3lib_BEfunc::deleteClause($table));
05065                                 if ($drow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))        {
05066                                                 // Gets the list of fields to copy from the previous record.
05067                                         $fArr = explode(',',$TCA[$table]['ctrl']['useColumnsForDefaultValues']);
05068                                         foreach($fArr as $theF) {
05069                                                 if ($TCA[$table]['columns'][$theF])     {
05070                                                         $row[$theF] = $drow[$theF];
05071                                                 }
05072                                         }
05073                                 }
05074                                 $GLOBALS['TYPO3_DB']->sql_free_result($res);
05075                         }
05076 
05077                         foreach($TCA[$table]['columns'] as $field => $info)     {
05078                                 if (isset($info['config']['default']))  {
05079                                         $row[$field] = $info['config']['default'];
05080                                 }
05081                         }
05082 
05083                         return $row;
05084                 }
05085         }
05086 
05095         function getRecordPath($table,$rec)     {
05096                 t3lib_BEfunc::fixVersioningPid($table,$rec);
05097                 list($tscPID,$thePidValue)=$this->getTSCpid($table,$rec['uid'],$rec['pid']);
05098                 if ($thePidValue>=0)    {
05099                         return t3lib_BEfunc::getRecordPath($tscPID,$this->readPerms(),15);
05100                 }
05101         }
05102 
05109         function readPerms()    {
05110                 if (!$this->perms_clause_set)   {
05111                         $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
05112                         $this->perms_clause_set=1;
05113                 }
05114                 return $this->perms_clause;
05115         }
05116 
05123         function sL($str)       {
05124                 return $GLOBALS['LANG']->sL($str);
05125         }
05126 
05136         function getLL($str)    {
05137                 $content = '';
05138 
05139                 switch(substr($str,0,2))        {
05140                         case 'l_':
05141                                 $content = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.'.substr($str,2));
05142                         break;
05143                         case 'm_':
05144                                 $content = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.'.substr($str,2));
05145                         break;
05146                 }
05147                 return $content;
05148         }
05149 
05157         function isPalettesCollapsed($table,$palette)   {
05158                 global $TCA;
05159 
05160                 if ($TCA[$table]['ctrl']['canNotCollapse']) return 0;
05161                 if (is_array($TCA[$table]['palettes'][$palette]) && $TCA[$table]['palettes'][$palette]['canNotCollapse'])       return 0;
05162                 return $this->palettesCollapsed;
05163         }
05164 
05173         function isDisplayCondition($displayCond,$row,$ffValueKey='')   {
05174                 $output = FALSE;
05175 
05176                 $parts = explode(':',$displayCond);
05177                 switch((string)$parts[0])       {       // Type of condition:
05178                         case 'FIELD':
05179                                 $theFieldValue = $ffValueKey ? $row[$parts[1]][$ffValueKey] : $row[$parts[1]];
05180 
05181                                 switch((string)$parts[2])       {
05182                                         case 'REQ':
05183                                                 if (strtolower($parts[3])=='true')      {
05184                                                         $output = $theFieldValue ? TRUE : FALSE;
05185                                                 } elseif (strtolower($parts[3])=='false') {
05186                                                         $output = !$theFieldValue ? TRUE : FALSE;
05187                                                 }
05188                                         break;
05189                                         case '>':
05190                                                 $output = $theFieldValue > $parts[3];
05191                                         break;
05192                                         case '<':
05193                                                 $output = $theFieldValue < $parts[3];
05194                                         break;
05195                                         case '>=':
05196                                                 $output = $theFieldValue >= $parts[3];
05197                                         break;
05198                                         case '<=':
05199                                                 $output = $theFieldValue <= $parts[3];
05200                                         break;
05201                                         case '-':
05202                                         case '!-':
05203                                                 $cmpParts = explode('-',$parts[3]);
05204                                                 $output = $theFieldValue >= $cmpParts[0] && $theFieldValue <= $cmpParts[1];
05205                                                 if ($parts[2]{0}=='!')  $output = !$output;
05206                                         break;
05207                                         case 'IN':
05208                                         case '!IN':
05209                                                 $output = t3lib_div::inList($parts[3],$theFieldValue);
05210                                                 if ($parts[2]{0}=='!')  $output = !$output;
05211                                         break;
05212                                         case '=':
05213                                         case '!=':
05214                                                 $output = t3lib_div::inList($parts[3],$theFieldValue);
05215                                                 if ($parts[2]{0}=='!')  $output = !$output;
05216                                         break;
05217                                 }
05218                         break;
05219                         case 'EXT':
05220                                 switch((string)$parts[2])       {
05221                                         case 'LOADED':
05222                                                 if (strtolower($parts[3])=='true')      {
05223                                                         $output = t3lib_extMgm::isLoaded($parts[1]) ? TRUE : FALSE;
05224                                                 } elseif (strtolower($parts[3])=='false') {
05225                                                         $output = !t3lib_extMgm::isLoaded($parts[1]) ? TRUE : FALSE;
05226                                                 }
05227                                         break;
05228                                 }
05229                         break;
05230                         case 'REC':
05231                                 switch((string)$parts[1])       {
05232                                         case 'NEW':
05233                                                 if (strtolower($parts[2])=='true')      {
05234                                                         $output = !(intval($row['uid']) > 0) ? TRUE : FALSE;
05235                                                 } elseif (strtolower($parts[2])=='false') {
05236                                                         $output = (intval($row['uid']) > 0) ? TRUE : FALSE;
05237                                                 }
05238                                         break;
05239                                 }
05240                         break;
05241                         case 'HIDE_L10N_SIBLINGS':
05242                                 if ($ffValueKey==='vDEF')       {
05243                                         $output = TRUE;
05244                                 } elseif ($parts[1]==='except_admin' && $GLOBALS['BE_USER']->isAdmin()) {
05245                                         $output = TRUE;
05246                                 }
05247                         break;
05248                         case 'HIDE_FOR_NON_ADMINS':
05249                                 $output = $GLOBALS['BE_USER']->isAdmin() ? TRUE : FALSE;
05250                         break;
05251                         case 'VERSION':
05252                                 switch((string)$parts[1])       {
05253                                         case 'IS':
05254                                                 if (strtolower($parts[2])=='true')      {
05255                                                         $output = intval($row['pid'])==-1 ? TRUE : FALSE;
05256                                                 } elseif (strtolower($parts[2])=='false') {
05257                                                         $output = !(intval($row['pid'])==-1) ? TRUE : FALSE;
05258                                                 }
05259                                         break;
05260                                 }
05261                         break;
05262                 }
05263 
05264                 return $output;
05265         }
05266 
05277         function getTSCpid($table,$uid,$pid)    {
05278                 $key = $table.':'.$uid.':'.$pid;
05279                 if (!isset($this->cache_getTSCpid[$key]))       {
05280                         $this->cache_getTSCpid[$key] = t3lib_BEfunc::getTSCpid($table,$uid,$pid);
05281                 }
05282                 return $this->cache_getTSCpid[$key];
05283         }
05284 
05291         function doLoadTableDescr($table)       {
05292                 global $TCA;
05293                 return $TCA[$table]['interface']['always_description'];
05294         }
05295 
05303         function getAvailableLanguages($onlyIsoCoded=1,$setDefault=1)   {
05304                 $isL = t3lib_extMgm::isLoaded('static_info_tables');
05305 
05306                         // Find all language records in the system:
05307                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('static_lang_isocode,title,uid', 'sys_language', 'pid=0 AND hidden=0'.t3lib_BEfunc::deleteClause('sys_language'), '', 'title');
05308 
05309                         // Traverse them:
05310                 $output=array();
05311                 if ($setDefault)        {
05312                         $output[0]=array(
05313                                 'uid' => 0,
05314                                 'title' => 'Default language',
05315                                 'ISOcode' => 'DEF'
05316                         );
05317                 }
05318                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
05319                         $output[$row['uid']]=$row;
05320 
05321                         if ($isL && $row['static_lang_isocode'])        {
05322                                 $rr = t3lib_BEfunc::getRecord('static_languages',$row['static_lang_isocode'],'lg_iso_2');
05323                                 if ($rr['lg_iso_2'])    $output[$row['uid']]['ISOcode']=$rr['lg_iso_2'];
05324                         }
05325 
05326                         if ($onlyIsoCoded && !$output[$row['uid']]['ISOcode'])  unset($output[$row['uid']]);
05327                 }
05328                 return $output;
05329         }
05330 }
05331 
05332 
05333 
05334 
05335 
05336 
05337 
05338 
05339 
05345 class t3lib_TCEforms_FE extends t3lib_TCEforms {
05346 
05353         function wrapLabels($str)       {
05354                 return '<font face="verdana" size="1" color="black">'.$str.'</font>';
05355         }
05356 
05363         function printPalette($palArr)  {
05364                 $out='';
05365                 reset($palArr);
05366                 $bgColor=' bgcolor="#D6DAD0"';
05367                 while(list(,$content)=each($palArr))    {
05368                         $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>';
05369                         $iRow[]='<td valign="top">'.
05370                                                 '<img name="req_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="10" height="10" alt="" />'.
05371                                                 '<img name="cm_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="7" height="10" alt="" />'.
05372                                                 '</td><td nowrap="nowrap" valign="top">'.$content['ITEM'].$content['HELP_ICON'].'</td>';
05373                 }
05374                 $out='<table border="0" cellpadding="0" cellspacing="0">
05375                         <tr><td><img src="clear.gif" width="'.intval($this->paletteMargin).'" height="1" alt="" /></td>'.implode('',$hRow).'</tr>
05376                         <tr><td></td>'.implode('',$iRow).'</tr>
05377                 </table>';
05378 
05379                 return $out;
05380         }
05381 
05388         function setFancyDesign()       {
05389                 $this->fieldTemplate='
05390         <tr>
05391                 <td nowrap="nowrap" bgcolor="#F6F2E6">###FIELD_HELP_ICON###<font face="verdana" size="1" color="black"><b>###FIELD_NAME###</b></font>###FIELD_HELP_TEXT###</td>
05392         </tr>
05393         <tr>
05394                 <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>
05395         </tr>   ';
05396 
05397                 $this->totalWrap='<table border="0" cellpadding="1" cellspacing="0" bgcolor="black"><tr><td><table border="0" cellpadding="2" cellspacing="0">|</table></td></tr></table>';
05398 
05399                 $this->palFieldTemplate='
05400         <tr>
05401                 <td nowrap="nowrap" bgcolor="#ABBBB4"><font face="verdana" size="1" color="black">###FIELD_PALETTE###</font></td>
05402         </tr>   ';
05403                 $this->palFieldTemplateHeader='
05404         <tr>
05405                 <td nowrap="nowrap" bgcolor="#F6F2E6"><font face="verdana" size="1" color="black"><b>###FIELD_HEADER###</b></font></td>
05406         </tr>   ';
05407         }
05408 }
05409 
05410 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tceforms.php'])  {
05411         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tceforms.php']);
05412 }
05413 ?>


Généré par L'expert TYPO3 avec  doxygen 1.4.6