Documentation TYPO3 par Ameos

class.t3lib_tceforms.php

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


Généré par Les spécialistes TYPO3 avec  doxygen 1.4.6