Documentation TYPO3 par Ameos

class.t3lib_tceforms.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2006 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00183 require_once(PATH_t3lib.'class.t3lib_diff.php');
00184 require_once(PATH_t3lib.'class.t3lib_tceforms_inline.php');
00185 
00186 
00187 
00196 class t3lib_TCEforms    {
00197 
00198                 // variables not commented yet.... (do so...)
00199         var $palFieldArr = array();
00200         var $disableWizards = 0;
00201         var $isPalettedoc = 0;
00202         var $paletteMargin = 1;
00203         var $defStyle = ''; // 'font-family:Verdana;font-size:10px;';
00204         var $cachedTSconfig = array();
00205         var $cachedTSconfig_fieldLevel = array();
00206         var $cachedLanguageFlag = array();
00207         var $cachedAdditionalPreviewLanguages = NULL;
00208         var $transformedRow = array();
00209         var $extJSCODE = '';
00210         var $printNeededJS = array();
00211         var $hiddenFieldAccum=array();
00212         var $TBE_EDITOR_fieldChanged_func='';
00213         var $loadMD5_JS=1;
00214         var $prevBorderStyle='[nothing here...]';       // Something unique...
00215         var $allowUpload=0;                             // If set direct upload fields will be shown
00216         var $titleLen=15;                                       // @deprecated: $BE_USER->uc['titleLen'] but what is default??
00217         var $defaultLanguageData = array();     // Array where records in the default language is stored. (processed by transferdata)
00218         var $defaultLanguageData_diff = array();        // Array where records in the default language is stored (raw without any processing. used for making diff)
00219         var $additionalPreviewLanguageData = array();
00220 
00221 
00222                 // EXTERNAL, static
00223         var $backPath='';                                       // Set this to the 'backPath' pointing back to the typo3 admin directory from the script where this form is displayed.
00224         var $returnUrl='';                                      // Alternative return URL path (default is t3lib_div::linkThisScript())
00225         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.
00226         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.
00227         var $disableRTE=0;                                      // If set, the RTE is disabled (from form display, eg. by checkbox in the bottom of the page!)
00228         var $globalShowHelp=1;                          // If false, then all CSH will be disabled, regardless of settings in $this->edit_showFieldHelp
00229         var $localizationMode='';               // If true, the forms are rendering only localization relevant fields of the records.
00230         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.
00231         var $doPrintPalette=1;                          // If set to false, palettes will NEVER be rendered.
00232         var $clipObj=FALSE;                                     // Set to initialized clipboard object; Then the element browser will offer a link to paste in records from clipboard.
00233         var $enableClickMenu=FALSE;                     // Enable click menu on reference icons.
00234         var $enableTabMenu = FALSE;                     // Enable Tab Menus. If set to true, the JavaScript content from template::getDynTabMenuJScode() must be included in the document.
00235         var $renderReadonly = FALSE;            // When enabled all fields are rendered non-editable.
00236 
00237         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)
00238         var $form_largeComp = 1.33;                     // Form field width compensation: Compensation for large documents, doc-tab (editing)
00239         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.
00240         var $maxTextareaWidth=48;                       // The maximum abstract value for textareas
00241         var $maxInputWidth=48;                          // The maximum abstract value for input fields
00242         var $defaultMultipleSelectorStyle='width:250px;';       // Default style for the selector boxes used for multiple items in "select" and "group" types.
00243 
00244 
00245                 // INTERNAL, static
00246         var $prependFormFieldNames = 'data';            // The string to prepend formfield names with.
00247         var $prependCmdFieldNames = 'cmd';                      // The string to prepend commands for tcemain::process_cmdmap with.
00248         var $prependFormFieldNames_file = 'data_files';         // The string to prepend FILE form field names with.
00249         var $formName = 'editform';                                     // The name attribute of the form.
00250         var $allowOverrideMatrix = array();                     // Whitelist that allows TCA field configuration to be overridden by TSconfig, @see overrideFieldConf()
00251 
00252 
00253 
00254                 // INTERNAL, dynamic
00255         var $perms_clause='';                                           // Set by readPerms()  (caching)
00256         var $perms_clause_set=0;                                        // Set by readPerms()  (caching-flag)
00257         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).
00258         var $docLarge=0;                                                        // If set, the forms will be rendered a little wider, more precisely with a factor of $this->form_largeComp.
00259         var $clientInfo=array();                                        // Loaded with info about the browser when class is instantiated.
00260         var $RTEenabled=0;                                                      // True, if RTE is possible for the current user (based on result from BE_USER->isRTE())
00261         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)
00262         var $RTEcounter = 0;                                            // Counter that is incremented before an RTE is created. Can be used for unique ids etc.
00263 
00264         var $colorScheme;                                                       // Contains current color scheme
00265         var $classScheme;                                                       // Contains current class scheme
00266         var $defColorScheme;                                            // Contains the default color scheme
00267         var $defClassScheme;                                            // Contains the default class scheme
00268         var $fieldStyle;                                                        // Contains field style values
00269         var $borderStyle;                                                       // Contains border style values.
00270 
00271         var $commentMessages=array();                           // An accumulation of messages from the class.
00272 
00273                 // INTERNAL, templates
00274         var $totalWrap='<hr />|<hr />';                         // Total wrapping for the table rows.
00275         var $fieldTemplate='<b>###FIELD_NAME###</b><br />###FIELD_ITEM###<hr />';       // Field template
00276         var $sectionWrap='';                                            // Wrapping template code for a section
00277         var $palFieldTemplateHeader='';                         // Template for palette headers
00278         var $palFieldTemplate='';                                       // Template for palettes
00279 
00280                 // INTERNAL, working memory
00281         var $excludeElements='';                                        // Set to the fields NOT to display, if any.
00282         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)
00283         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!
00284         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.
00285         var $requiredElements=array();                          // Used to register the min and max number of elements for selectorboxes where that apply (in the "group" type for instance)
00286         var $renderDepth=0;                                                     // Keeps track of the rendering depth of nested records.
00287         var $savedSchemes=array();                                      // Color scheme buffer.
00288         var $dynTabLevelStack = array();                        // holds tab dividers which were cascaded, required for RTE&IRRE
00289 
00290                 // Internal, registers for user defined functions etc.
00291         var $additionalCode_pre = array();                      // Additional HTML code, printed before the form.
00292         var $additionalJS_pre = array();                        // Additional JavaScript, printed before the form
00293         var $additionalJS_post = array();                       // Additional JavaScript printed after the form
00294         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.
00295 
00296         var $inline;                                                            // Instance of t3lib_tceforms_inline
00297         var $hookObjectsMainFields = array();                   // Array containing hook class instances called once for a form
00298         var $hookObjectsSingleField = array();                  // Array containing hook class instances called for each field
00299         var $extraFormHeaders = array();                        // Rows gettings inserted into the alt_doc headers (when called from alt_doc.php)
00300 
00301 
00302 
00303 
00304 
00310         function t3lib_TCEforms()       {
00311                 global $CLIENT, $TYPO3_CONF_VARS;
00312 
00313                 $this->clientInfo = t3lib_div::clientInfo();
00314 
00315                 $this->RTEenabled = $GLOBALS['BE_USER']->isRTE();
00316                 if (!$this->RTEenabled) {
00317                         $this->RTEenabled_notReasons = implode(chr(10),$GLOBALS['BE_USER']->RTE_errors);
00318                         $this->commentMessages[] = 'RTE NOT ENABLED IN SYSTEM due to:'.chr(10).$this->RTEenabled_notReasons;
00319                 }
00320 
00321                         // Default color+class scheme
00322                 $this->defColorScheme = array(
00323                         $GLOBALS['SOBE']->doc->bgColor, // Background for the field AND palette
00324                         t3lib_div::modifyHTMLColorAll($GLOBALS['SOBE']->doc->bgColor,-20),      // Background for the field header
00325                         t3lib_div::modifyHTMLColorAll($GLOBALS['SOBE']->doc->bgColor,-10),      // Background for the palette field header
00326                         'black',        // Field header font color
00327                         '#666666'       // Palette field header font color
00328                 );
00329                 $this->defColorScheme = array();
00330 
00331                         // Override / Setting defaults from TBE_STYLES array
00332                 $this->resetSchemes();
00333 
00334                         // Setting the current colorScheme to default.
00335                 $this->defColorScheme = $this->colorScheme;
00336                 $this->defClassScheme = $this->classScheme;
00337 
00338                         // Define whitelist that allows TCA field configuration to be overridden by TSconfig, @see overrideFieldConf():
00339                 $this->allowOverrideMatrix = array(
00340                         'input' => array('size', 'max'),
00341                         'text' => array('cols', 'rows', 'wrap'),
00342                         'check' => array('cols', 'showIfRTE'),
00343                         'select' => array('size', 'autoSizeMax', 'maxitems', 'minitems'),
00344                         'group' => array('size', 'autoSizeMax', 'max_size', 'show_thumbs', 'maxitems', 'minitems'),
00345                         'inline' => array('appearance', 'foreign_label', 'foreign_selector', 'foreign_unique', 'maxitems', 'minitems', 'size', 'autoSizeMax', 'symmetric_label'),
00346                 );
00347 
00348                 $this->inline = t3lib_div::makeInstance('t3lib_TCEforms_inline');
00349 
00350                         // Prepare user defined objects (if any) for hooks which extend this function:
00351                 $this->hookObjectsMainFields = array();
00352                 if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass']))  {
00353                         foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'] as $classRef)   {
00354                                 $this->hookObjectsMainFields[] = &t3lib_div::getUserObj($classRef);
00355                         }
00356                 }
00357                 $this->hookObjectsSingleField = array();
00358                 if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getSingleFieldClass'])) {
00359                         foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getSingleFieldClass'] as $classRef)  {
00360                                 $this->hookObjectsSingleField[] = &t3lib_div::getUserObj($classRef);
00361                         }
00362                 }
00363 
00364         }
00365 
00371         function initDefaultBEmode()    {
00372                 global $BE_USER;
00373                 $this->prependFormFieldNames = 'data';
00374                 $this->formName = 'editform';
00375                 $this->setNewBEDesign();
00376                 $this->docLarge = $BE_USER->uc['edit_wideDocument'] ? 1 : 0;
00377                 $this->edit_showFieldHelp = $BE_USER->uc['edit_showFieldHelp'];
00378 
00379                 $this->edit_docModuleUpload = $BE_USER->uc['edit_docModuleUpload'];
00380                 $this->titleLen = $BE_USER->uc['titleLen'];             // @deprecated
00381 
00382                 $this->inline->init($this);
00383         }
00384 
00385 
00386 
00387 
00388 
00389 
00390 
00391 
00392 
00393 
00394 
00395 
00396 
00397 
00398 
00399 
00400 
00401         /*******************************************************
00402          *
00403          * Rendering the forms, fields etc
00404          *
00405          *******************************************************/
00406 
00418         function getSoloField($table,$row,$theFieldToReturn)    {
00419                 global $TCA;
00420 
00421                 if ($TCA[$table])       {
00422                         t3lib_div::loadTCA($table);
00423                         $typeNum = $this->getRTypeNum($table,$row);
00424                         if ($TCA[$table]['types'][$typeNum])    {
00425                                 $itemList = $TCA[$table]['types'][$typeNum]['showitem'];
00426                                 if ($itemList)  {
00427                                         $fields = t3lib_div::trimExplode(',',$itemList,1);
00428                                         $excludeElements = $this->excludeElements = $this->getExcludeElements($table,$row,$typeNum);
00429 
00430                                         reset($fields);
00431                                         while(list(,$fieldInfo)=each($fields))  {
00432                                                 $parts = explode(';',$fieldInfo);
00433 
00434                                                 $theField = trim($parts[0]);
00435                                                 if (!in_array($theField,$excludeElements) && !strcmp($theField,$theFieldToReturn))      {
00436                                                         if ($TCA[$table]['columns'][$theField]) {
00437                                                                 $sField = $this->getSingleField($table,$theField,$row,$parts[1],1,$parts[3],$parts[2]);
00438                                                                 return $sField['ITEM'];
00439                                                         }
00440                                                 }
00441                                         }
00442                                 }
00443                         }
00444                 }
00445         }
00446 
00457         function getMainFields($table,$row,$depth=0)    {
00458                 global $TCA, $TYPO3_CONF_VARS;
00459 
00460                 $this->renderDepth=$depth;
00461 
00462                         // Init vars:
00463                 $out_array = array(array());
00464                 $out_array_meta = array(array(
00465                         'title' => $this->getLL('l_generalTab')
00466                 ));
00467 
00468                 $out_pointer=0;
00469                 $out_sheet=0;
00470                 $this->palettesRendered=array();
00471                 $this->palettesRendered[$this->renderDepth][$table]=array();
00472 
00473                         // Hook: getMainFields_preProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
00474                 foreach ($this->hookObjectsMainFields as $hookObj)      {
00475                         if (method_exists($hookObj,'getMainFields_preProcess')) {
00476                                 $hookObj->getMainFields_preProcess($table,$row,$this);
00477                         }
00478                 }
00479 
00480                 if ($TCA[$table])       {
00481 
00482                                 // Load the full TCA for the table.
00483                         t3lib_div::loadTCA($table);
00484 
00485                                 // Load the description content for the table.
00486                         if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table))       {
00487                                 $GLOBALS['LANG']->loadSingleTableDescription($table);
00488                         }
00489                                 // Get the current "type" value for the record.
00490                         $typeNum = $this->getRTypeNum($table,$row);
00491 
00492                                 // Find the list of fields to display:
00493                         if ($TCA[$table]['types'][$typeNum])    {
00494                                 $itemList = $TCA[$table]['types'][$typeNum]['showitem'];
00495                                 if ($itemList)  {       // If such a list existed...
00496                                                 // if TCEforms will render a tab menu in the next step, push the name to the tab stack
00497                                         if (strstr($itemList, '--div--') !== false && $this->enableTabMenu && $TCA[$table]['ctrl']['dividers2tabs']) {
00498                                                 $tabIdentString = 'TCEforms:'.$table.':'.$row['uid'];
00499                                                 $tabIdentStringMD5 = $GLOBALS['TBE_TEMPLATE']->getDynTabMenuId('TCEforms:'.$table.':'.$row['uid']);
00500                                                 $this->dynTabLevelStack[$tabIdentStringMD5] = 1;
00501                                         }
00502 
00503                                                 // Explode the field list and possibly rearrange the order of the fields, if configured for
00504                                         $fields = t3lib_div::trimExplode(',',$itemList,1);
00505                                         if ($this->fieldOrder)  {
00506                                                 $fields = $this->rearrange($fields);
00507                                         }
00508 
00509                                                 // Get excluded fields, added fiels and put it together:
00510                                         $excludeElements = $this->excludeElements = $this->getExcludeElements($table,$row,$typeNum);
00511                                         $fields = $this->mergeFieldsWithAddedFields($fields,$this->getFieldsToAdd($table,$row,$typeNum));
00512 
00513                                                 // Traverse the fields to render:
00514                                         $cc=0;
00515                                         foreach($fields as $fieldInfo)  {
00516                                                         // Exploding subparts of the field configuration:
00517                                                 $parts = explode(';',$fieldInfo);
00518 
00519                                                         // Getting the style information out:
00520                                                 $color_style_parts = t3lib_div::trimExplode('-',$parts[4]);
00521                                                 if (strcmp($color_style_parts[0],''))   {
00522                                                         $this->setColorScheme($GLOBALS['TBE_STYLES']['colorschemes'][intval($color_style_parts[0])]);
00523                                                 }
00524                                                 if (strcmp($color_style_parts[1],''))   {
00525                                                         $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][intval($color_style_parts[1])];
00526                                                         if (!isset($this->fieldStyle))  $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][0];
00527                                                 }
00528                                                 if (strcmp($color_style_parts[2],''))   {
00529                                                         $this->wrapBorder($out_array[$out_sheet],$out_pointer);
00530                                                         $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][intval($color_style_parts[2])];
00531                                                         if (!isset($this->borderStyle)) $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][0];
00532                                                 }
00533 
00534                                                         // Render the field:
00535                                                 $theField = $parts[0];
00536                                                 if (!in_array($theField,$excludeElements))      {
00537                                                         if ($TCA[$table]['columns'][$theField]) {
00538                                                                 $sFieldPal='';
00539 
00540                                                                 if ($parts[2] && !isset($this->palettesRendered[$this->renderDepth][$table][$parts[2]]))        {
00541                                                                         $sFieldPal=$this->getPaletteFields($table,$row,$parts[2]);
00542                                                                         $this->palettesRendered[$this->renderDepth][$table][$parts[2]] = 1;
00543                                                                 }
00544                                                                 $sField = $this->getSingleField($table,$theField,$row,$parts[1],0,$parts[3],$parts[2]);
00545                                                                 if ($sField)    { $sField.= $sFieldPal; }
00546 
00547                                                                 $out_array[$out_sheet][$out_pointer].= $sField;
00548                                                         } elseif ($theField=='--div--') {
00549                                                                 if ($cc>0)      {
00550                                                                         $out_array[$out_sheet][$out_pointer].=$this->getDivider();
00551 
00552                                                                         if ($this->enableTabMenu && $TCA[$table]['ctrl']['dividers2tabs'])      {
00553                                                                                 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
00554                                                                                 $out_sheet++;
00555                                                                                         // remember what sheet we're currently in
00556                                                                                 $this->dynTabLevelStack[$tabIdentStringMD5] = $out_sheet+1;
00557                                                                                 $out_array[$out_sheet] = array();
00558                                                                                 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
00559                                                                         }
00560                                                                 } else {        // Setting alternative title for "General" tab if "--div--" is the very first element.
00561                                                                         $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
00562                                                                 }
00563                                                         } elseif($theField=='--palette--')      {
00564                                                                 if ($parts[2] && !isset($this->palettesRendered[$this->renderDepth][$table][$parts[2]]))        {
00565                                                                                 // render a 'header' if not collapsed
00566                                                                         if ($TCA[$table]['palettes'][$parts[2]]['canNotCollapse'] AND $parts[1]) {
00567                                                                                 $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$parts[2],$this->sL($parts[1]));
00568                                                                         } else {
00569                                                                                 $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$parts[2],'','',$this->sL($parts[1]));
00570                                                                         }
00571                                                                         $this->palettesRendered[$this->renderDepth][$table][$parts[2]] = 1;
00572                                                                 }
00573                                                         }
00574                                                 }
00575 
00576                                                 $cc++;
00577                                         }
00578                                 }
00579                         }
00580                 }
00581 
00582                         // Hook: getMainFields_postProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
00583                 foreach ($this->hookObjectsMainFields as $hookObj)      {
00584                         if (method_exists($hookObj,'getMainFields_postProcess'))        {
00585                                 $hookObj->getMainFields_postProcess($table,$row,$this);
00586                         }
00587                 }
00588 
00589                         // Wrapping a border around it all:
00590                 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
00591 
00592                         // Resetting styles:
00593                 $this->resetSchemes();
00594 
00595                         // Rendering Main palettes, if any
00596                 $mParr = t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['mainpalette']);
00597                 $i = 0;
00598                 if (count($mParr))      {
00599                         foreach ($mParr as $mP) {
00600                                 if (!isset($this->palettesRendered[$this->renderDepth][$table][$mP]))   {
00601                                         $temp_palettesCollapsed=$this->palettesCollapsed;
00602                                         $this->palettesCollapsed=0;
00603                                         $label = ($i==0?$this->getLL('l_generalOptions'):$this->getLL('l_generalOptions_more'));
00604                                         $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$mP,$label);
00605                                         $this->palettesCollapsed=$temp_palettesCollapsed;
00606                                         $this->palettesRendered[$this->renderDepth][$table][$mP] = 1;
00607                                 }
00608                                 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
00609                                 $i++;
00610                                 if ($this->renderDepth) {
00611                                         $this->renderDepth--;
00612                                 }
00613                         }
00614                 }
00615 
00616                         // Return the imploded $out_array:
00617                 if ($out_sheet>0)       {       // There were --div-- dividers around...
00618 
00619                                 // Create parts array for the tab menu:
00620                         $parts = array();
00621                         foreach ($out_array as $idx => $sheetContent)   {
00622                                 $parts[] = array(
00623                                         'label' => $out_array_meta[$idx]['title'],
00624                                         'content' => '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.
00625                                                         implode('',$sheetContent).
00626                                                 '</table>'
00627                                 );
00628                         }
00629 
00630                                 // unset the current level of tab menus
00631                         unset($this->dynTabLevelStack[$tabIdentStringMD5]);
00632 
00633                         return '
00634                                 <tr>
00635                                         <td colspan="2">
00636                                         '.$this->getDynTabMenu($parts, $tabIdentString).'
00637                                         </td>
00638                                 </tr>';
00639                 } else {        // Only one, so just implode:
00640                         return implode('',$out_array[$out_sheet]);
00641                 }
00642         }
00643 
00654         function getListedFields($table,$row,$list)     {
00655                 global $TCA;
00656 
00657                 t3lib_div::loadTCA($table);
00658                 if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table))       {
00659                         $GLOBALS['LANG']->loadSingleTableDescription($table);
00660                 }
00661 
00662                 $out = '';
00663                 $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table,$row,1);
00664 
00665                 $editFieldList=array_unique(t3lib_div::trimExplode(',',$list,1));
00666                 foreach($editFieldList as $theFieldC)   {
00667                         list($theField,$palFields) = split('\[|\]',$theFieldC);
00668                         $theField = trim($theField);
00669                         $palFields = trim($palFields);
00670                         if ($TCA[$table]['columns'][$theField]) {
00671                                 $parts = t3lib_div::trimExplode(';',$types_fieldConfig[$theField]['origString']);
00672                                 $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.
00673                                 $out.= $sField;
00674                         } elseif($theField=='--div--')  {
00675                                 $out.= $this->getDivider();
00676                         }
00677                         if ($palFields) {
00678                                 $out.= $this->getPaletteFields($table,$row,'','',implode(',',t3lib_div::trimExplode('|',$palFields,1)));
00679                         }
00680                 }
00681 
00682                 return $out;
00683         }
00684 
00696         function getPaletteFields($table,$row,$palette,$header='',$itemList='',$collapsedHeader='')     {
00697                 global $TCA;
00698                 if (!$this->doPrintPalette)     return '';
00699 
00700                 $out='';
00701                 $palParts = array();
00702                 t3lib_div::loadTCA($table);
00703 
00704                         // Getting excludeElements, if any.
00705                 if (!is_array($this->excludeElements))  {
00706                         $this->excludeElements = $this->getExcludeElements($table,$row,$this->getRTypeNum($table,$row));
00707                 }
00708 
00709                         // Render the palette TCEform elements.
00710                 if ($TCA[$table] && (is_array($TCA[$table]['palettes'][$palette]) || $itemList))        {
00711                         $itemList = $itemList?$itemList:$TCA[$table]['palettes'][$palette]['showitem'];
00712                         if ($itemList)  {
00713                                 $fields = t3lib_div::trimExplode(',',$itemList,1);
00714                                 reset($fields);
00715                                 while(list(,$fieldInfo)=each($fields))  {
00716                                         $parts = t3lib_div::trimExplode(';',$fieldInfo);
00717                                         $theField = $parts[0];
00718 
00719                                         if (!in_array($theField,$this->excludeElements) && $TCA[$table]['columns'][$theField])  {
00720                                                 $this->palFieldArr[$palette][] = $theField;
00721                                                 if ($this->isPalettesCollapsed($table,$palette))        {
00722                                                         $this->hiddenFieldListArr[] = $theField;
00723                                                 }
00724 
00725                                                 $part = $this->getSingleField($table,$theField,$row,$parts[1],1,'',$parts[2]);
00726                                                 if (is_array($part))    {
00727                                                         $palParts[] = $part;
00728                                                 }
00729                                         }
00730                                 }
00731                         }
00732                 }
00733                         // Put palette together if there are fields in it:
00734                 if (count($palParts))   {
00735                         if ($header)    {
00736                                 $out.= $this->intoTemplate(array(
00737                                                                 'HEADER' => htmlspecialchars($header)
00738                                                         ),
00739                                                         $this->palFieldTemplateHeader
00740                                                 );
00741                         }
00742                         $out.= $this->intoTemplate(array(
00743                                                         'PALETTE' => $this->printPalette($palParts)
00744                                                 ),
00745                                                 $this->palFieldTemplate
00746                                         );
00747                 }
00748                         // 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.
00749                 if ($this->isPalettesCollapsed($table,$palette) && $collapsedHeader)    {
00750                         $pC = $this->intoTemplate(array(
00751                                                         '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),
00752                                                 ),
00753                                                 $this->palFieldTemplate
00754                                         );
00755                         $out.= $pC;
00756                 }
00757 
00758                 return $out;
00759         }
00760 
00773         function getSingleField($table,$field,$row,$altName='',$palette=0,$extra='',$pal=0)     {
00774                 global $TCA,$BE_USER;
00775 
00776                         // Hook: getSingleField_preProcess
00777                 foreach ($this->hookObjectsSingleField as $hookObj)     {
00778                         if (method_exists($hookObj,'getSingleField_preProcess'))        {
00779                                 $hookObj->getSingleField_preProcess($table, $field, $row, $altName, $palette, $extra, $pal, $this);
00780                         }
00781                 }
00782 
00783                 $out = '';
00784                 $PA = array();
00785                 $PA['altName'] = $altName;
00786                 $PA['palette'] = $palette;
00787                 $PA['extra'] = $extra;
00788                 $PA['pal'] = $pal;
00789 
00790                         // Make sure to load full $TCA array for the table:
00791                 t3lib_div::loadTCA($table);
00792 
00793                         // Get the TCA configuration for the current field:
00794                 $PA['fieldConf'] = $TCA[$table]['columns'][$field];
00795                 $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
00796 
00797                 $skipThisField = $this->inline->skipField($table, $field, $row, $PA['fieldConf']['config']);
00798 
00799                         // Now, check if this field is configured and editable (according to excludefields + other configuration)
00800                 if (    is_array($PA['fieldConf']) &&
00801                                 !$skipThisField &&
00802                                 (!$PA['fieldConf']['exclude'] || $BE_USER->check('non_exclude_fields',$table.':'.$field)) &&
00803                                 $PA['fieldConf']['config']['form_type']!='passthrough' &&
00804                                 ($this->RTEenabled || !$PA['fieldConf']['config']['showIfRTE']) &&
00805                                 (!$PA['fieldConf']['displayCond'] || $this->isDisplayCondition($PA['fieldConf']['displayCond'],$row)) &&
00806                                 (!$TCA[$table]['ctrl']['languageField'] || $PA['fieldConf']['l10n_display'] || strcmp($PA['fieldConf']['l10n_mode'],'exclude') || $row[$TCA[$table]['ctrl']['languageField']]<=0) &&
00807                                 (!$TCA[$table]['ctrl']['languageField'] || !$this->localizationMode || $this->localizationMode===$PA['fieldConf']['l10n_cat'])
00808                         )       {
00809 
00810 
00811 
00812                                 // Fetching the TSconfig for the current table/field. This includes the $row which means that
00813                         $PA['fieldTSConfig'] = $this->setTSconfig($table,$row,$field);
00814 
00815                                 // If the field is NOT disabled from TSconfig (which it could have been) then render it
00816                         if (!$PA['fieldTSConfig']['disabled'])  {
00817                                         // Override fieldConf by fieldTSconfig:
00818                                 $PA['fieldConf']['config'] = $this->overrideFieldConf($PA['fieldConf']['config'], $PA['fieldTSConfig']);
00819 
00820                                         // Init variables:
00821                                 $PA['itemFormElName']=$this->prependFormFieldNames.'['.$table.']['.$row['uid'].']['.$field.']';         // Form field name
00822                                 $PA['itemFormElName_file']=$this->prependFormFieldNames_file.'['.$table.']['.$row['uid'].']['.$field.']';       // Form field name, in case of file uploads
00823                                 $PA['itemFormElValue']=$row[$field];            // The value to show in the form field.
00824                                 $PA['itemFormElID']=$this->prependFormFieldNames.'_'.$table.'_'.$row['uid'].'_'.$field;
00825 
00826                                         // set field to read-only if configured for translated records to show default language content as readonly
00827                                 if ($PA['fieldConf']['l10n_display'] AND t3lib_div::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly') AND $row[$TCA[$table]['ctrl']['languageField']]) {
00828                                         $PA['fieldConf']['config']['readOnly'] =  true;
00829                                         $PA['itemFormElValue'] = $this->defaultLanguageData[$table.':'.$row['uid']][$field];
00830                                 }
00831 
00832                                         // 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"
00833                                 if (
00834                                         ($TCA[$table]['ctrl']['type'] && !strcmp($field,$TCA[$table]['ctrl']['type'])) ||
00835                                         ($TCA[$table]['ctrl']['requestUpdate'] && t3lib_div::inList($TCA[$table]['ctrl']['requestUpdate'],$field))) {
00836                                         if($GLOBALS['BE_USER']->jsConfirmation(1))      {
00837                                                 $alertMsgOnChange = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
00838                                         } else {
00839                                                 $alertMsgOnChange = 'if (TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
00840                                         }
00841                                 } else {
00842                                         $alertMsgOnChange = '';
00843                                 }
00844 
00845                                         // Render as a hidden field?
00846                                 if (in_array($field,$this->hiddenFieldListArr)) {
00847                                         $this->hiddenFieldAccum[]='<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
00848                                 } else {        // Render as a normal field:
00849 
00850                                                 // 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.
00851                                         if (!$PA['palette'])    {
00852                                                 if ($PA['pal'] && $this->isPalettesCollapsed($table,$PA['pal']))        {
00853                                                         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);
00854                                                 } else {
00855                                                         $thePalIcon = '';
00856                                                         $palJSfunc = '';
00857                                                 }
00858                                         }
00859                                                 // onFocus attribute to add to the field:
00860                                         $PA['onFocus'] = ($palJSfunc && !$BE_USER->uc['dontShowPalettesOnFocusInAB']) ? ' onfocus="'.htmlspecialchars($palJSfunc).'"' : '';
00861 
00862                                                 // Find item
00863                                         $item='';
00864                                         $PA['label'] = $PA['altName'] ? $PA['altName'] : $PA['fieldConf']['label'];
00865                                         $PA['label'] = $this->sL($PA['label']);
00866                                                 // JavaScript code for event handlers:
00867                                         $PA['fieldChangeFunc']=array();
00868                                         $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = "TBE_EDITOR.fieldChanged('".$table."','".$row['uid']."','".$field."','".$PA['itemFormElName']."');";
00869                                         $PA['fieldChangeFunc']['alert']=$alertMsgOnChange;
00870                                                 // if this is the child of an inline type and it is the field creating the label
00871                                         if ($this->inline->isInlineChildAndLabelField($table, $field)) {
00872                                                 $PA['fieldChangeFunc']['inline'] = "inline.handleChangedField('".$PA['itemFormElName']."','".$this->inline->inlineNames['object']."[$table][".$row['uid']."]');";
00873                                         }
00874 
00875                                                 // Based on the type of the item, call a render function:
00876                                         $item = $this->getSingleField_SW($table,$field,$row,$PA);
00877 
00878                                                 // Add language + diff
00879                                         if ($PA['fieldConf']['l10n_display'] && (t3lib_div::inList($PA['fieldConf']['l10n_display'], 'hideDiff') || t3lib_div::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly'))) {
00880                                                 $renderLanguageDiff = false;
00881                                         } else {
00882                                                 $renderLanguageDiff = true;
00883                                         }
00884 
00885                                         if ($renderLanguageDiff) {
00886                                                 $item = $this->renderDefaultLanguageContent($table,$field,$row,$item);
00887                                                 $item = $this->renderDefaultLanguageDiff($table,$field,$row,$item);
00888                                         }
00889 
00890                                                 // 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
00891                                         $PA['label'] = t3lib_div::deHSCentities(htmlspecialchars($PA['label']));
00892                                         if (t3lib_div::testInt($row['uid']) && $PA['fieldTSConfig']['linkTitleToSelf']) {
00893                                                 $lTTS_url = $this->backPath.'alt_doc.php?edit['.$table.']['.$row['uid'].']=edit&columnsOnly='.$field.
00894                                                                         ($PA['fieldTSConfig']['linkTitleToSelf.']['returnUrl']?'&returnUrl='.rawurlencode($this->thisReturnUrl()):'');
00895                                                 $PA['label'] = '<a href="'.htmlspecialchars($lTTS_url).'">'.$PA['label'].'</a>';
00896                                         }
00897 
00898                                                 // Create output value:
00899                                         if ($PA['fieldConf']['config']['form_type']=='user' && $PA['fieldConf']['config']['noTableWrapping'])   {
00900                                                 $out = $item;
00901                                         } elseif ($PA['palette'])       {
00902                                                         // Array:
00903                                                 $out=array(
00904                                                         'NAME'=>$PA['label'],
00905                                                         'ID'=>$row['uid'],
00906                                                         'FIELD'=>$field,
00907                                                         'TABLE'=>$table,
00908                                                         'ITEM'=>$item,
00909                                                         'HELP_ICON' => $this->helpTextIcon($table,$field,1)
00910                                                 );
00911                                                 $out = $this->addUserTemplateMarkers($out,$table,$field,$row,$PA);
00912                                         } else {
00913                                                         // String:
00914                                                 $out=array(
00915                                                         'NAME'=>$PA['label'],
00916                                                         'ITEM'=>$item,
00917                                                         'TABLE'=>$table,
00918                                                         'ID'=>$row['uid'],
00919                                                         'HELP_ICON'=>$this->helpTextIcon($table,$field),
00920                                                         'HELP_TEXT'=>$this->helpText($table,$field),
00921                                                         'PAL_LINK_ICON'=>$thePalIcon,
00922                                                         'FIELD'=>$field
00923                                                 );
00924                                                 $out = $this->addUserTemplateMarkers($out,$table,$field,$row,$PA);
00925                                                         // String:
00926                                                 $out=$this->intoTemplate($out);
00927                                         }
00928                                 }
00929                         } else $this->commentMessages[]=$this->prependFormFieldNames.'['.$table.']['.$row['uid'].']['.$field.']: Disabled by TSconfig';
00930                 }
00931                         // Hook: getSingleField_postProcess
00932                 foreach ($this->hookObjectsSingleField as $hookObj)     {
00933                         if (method_exists($hookObj,'getSingleField_postProcess'))       {
00934                                 $hookObj->getSingleField_postProcess($table, $field, $row, $out, $PA, $this);
00935                         }
00936                 }
00937                         // Return value (string or array)
00938                 return $out;
00939         }
00940 
00952         function getSingleField_SW($table,$field,$row,&$PA)     {
00953                 $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
00954 
00955                 switch($PA['fieldConf']['config']['form_type']) {
00956                         case 'input':
00957                                 $item = $this->getSingleField_typeInput($table,$field,$row,$PA);
00958                         break;
00959                         case 'text':
00960                                 $item = $this->getSingleField_typeText($table,$field,$row,$PA);
00961                         break;
00962                         case 'check':
00963                                 $item = $this->getSingleField_typeCheck($table,$field,$row,$PA);
00964                         break;
00965                         case 'radio':
00966                                 $item = $this->getSingleField_typeRadio($table,$field,$row,$PA);
00967                         break;
00968                         case 'select':
00969                                 $item = $this->getSingleField_typeSelect($table,$field,$row,$PA);
00970                         break;
00971                         case 'group':
00972                                 $item = $this->getSingleField_typeGroup($table,$field,$row,$PA);
00973                         break;
00974                         case 'inline':
00975                                 $item = $this->inline->getSingleField_typeInline($table,$field,$row,$PA);
00976                         break;
00977                         case 'none':
00978                                 $item = $this->getSingleField_typeNone($table,$field,$row,$PA);
00979                         break;
00980                         case 'user':
00981                                 $item = $this->getSingleField_typeUser($table,$field,$row,$PA);
00982                         break;
00983                         case 'flex':
00984                                 $item = $this->getSingleField_typeFlex($table,$field,$row,$PA);
00985                         break;
00986                         default:
00987                                 $item = $this->getSingleField_typeUnknown($table,$field,$row,$PA);
00988                         break;
00989                 }
00990 
00991                 return $item;
00992         }
00993 
00994 
00995 
00996 
00997 
00998 
00999 
01000 
01001 
01002 
01003 
01004 
01005 
01006 
01007 
01008 
01009 
01010 
01011 
01012         /**********************************************************
01013          *
01014          * Rendering of each TCEform field type
01015          *
01016          ************************************************************/
01017 
01028         function getSingleField_typeInput($table,$field,$row,&$PA)      {
01029                 // typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue)
01030                 // typo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off)
01031 
01032                 $config = $PA['fieldConf']['config'];
01033 
01034 #               $specConf = $this->getSpecConfForField($table,$row,$field);
01035                 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
01036                 $size = t3lib_div::intInRange($config['size']?$config['size']:30,5,$this->maxInputWidth);
01037                 $evalList = t3lib_div::trimExplode(',',$config['eval'],1);
01038 
01039 
01040                 if($this->renderReadonly || $config['readOnly'])  {
01041                         $itemFormElValue = $PA['itemFormElValue'];
01042                         if (in_array('date',$evalList)) {
01043                                 $config['format'] = 'date';
01044                         } elseif (in_array('date',$evalList))   {
01045                                 $config['format'] = 'date';
01046                         } elseif (in_array('datetime',$evalList))       {
01047                                 $config['format'] = 'datetime';
01048                         } elseif (in_array('time',$evalList))   {
01049                                 $config['format'] = 'time';
01050                         }
01051                         if (in_array('password',$evalList))     {
01052                                 $itemFormElValue = $itemFormElValue ? '*********' : '';
01053                         }
01054                         return $this->getSingleField_typeNone_render($config, $itemFormElValue);
01055                 }
01056 
01057                 if (in_array('required',$evalList))     {
01058                         $this->requiredFields[$table.'_'.$row['uid'].'_'.$field]=$PA['itemFormElName'];
01059                 }
01060 
01061                 $paramsList = "'".$PA['itemFormElName']."','".implode(',',$evalList)."','".trim($config['is_in'])."',".(isset($config['checkbox'])?1:0).",'".$config['checkbox']."'";
01062                 if (isset($config['checkbox'])) {
01063                                 // Setting default "click-checkbox" values for eval types "date" and "datetime":
01064                         $thisMidnight = mktime(0,0,0);
01065                         $checkSetValue = in_array('date',$evalList) ? $thisMidnight : '';
01066                         $checkSetValue = in_array('datetime',$evalList) ? time() : $checkSetValue;
01067 
01068                         $cOnClick = 'typo3form.fieldGet('.$paramsList.',1,\''.$checkSetValue.'\');'.implode('',$PA['fieldChangeFunc']);
01069                         $item.='<input type="checkbox"'.$this->insertDefStyle('check').' name="'.$PA['itemFormElName'].'_cb" onclick="'.htmlspecialchars($cOnClick).'" />';
01070                 }
01071 
01072                 $PA['fieldChangeFunc'] = array_merge(array('typo3form.fieldGet'=>'typo3form.fieldGet('.$paramsList.');'), $PA['fieldChangeFunc']);
01073                 $mLgd = ($config['max']?$config['max']:256);
01074                 $iOnChange = implode('',$PA['fieldChangeFunc']);
01075                 $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.
01076                 $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.
01077                 $this->extJSCODE.='typo3form.fieldSet('.$paramsList.');';
01078 
01079                         // going through all custom evaluations configured for this field
01080                 foreach ($evalList as $evalData) {
01081                         if (substr($evalData, 0, 3) == 'tx_')   {
01082                                 $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$evalData].':&'.$evalData);
01083                                 if(is_object($evalObj) && method_exists($evalObj, 'returnFieldJS'))     {
01084                                         $this->extJSCODE .= "\n\nfunction ".$evalData."(value) {\n".$evalObj->returnFieldJS()."\n}\n";
01085                                 }
01086                         }
01087                 }
01088 
01089                         // Creating an alternative item without the JavaScript handlers.
01090                 $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'_hr" value="" />';
01091                 $altItem.= '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
01092 
01093                         // Wrap a wizard around the item?
01094                 $item= $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'].'_hr',$specConf);
01095 
01096                 return $item;
01097         }
01098 
01109         function getSingleField_typeText($table,$field,$row,&$PA)       {
01110 
01111                         // Init config:
01112                 $config = $PA['fieldConf']['config'];
01113 
01114                 if($this->renderReadonly || $config['readOnly'])  {
01115                         return $this->getSingleField_typeNone_render($config, $PA['itemFormElValue']);
01116                 }
01117 
01118                         // Setting columns number:
01119                 $cols = t3lib_div::intInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
01120 
01121                         // Setting number of rows:
01122                 $origRows = $rows = t3lib_div::intInRange($config['rows'] ? $config['rows'] : 5, 1, 20);
01123                 if (strlen($PA['itemFormElValue']) > $this->charsPerRow*2)      {
01124                         $cols = $this->maxTextareaWidth;
01125                         $rows = t3lib_div::intInRange(round(strlen($PA['itemFormElValue'])/$this->charsPerRow), count(explode(chr(10),$PA['itemFormElValue'])), 20);
01126                         if ($rows<$origRows)    $rows = $origRows;
01127                 }
01128 
01129                         // Init RTE vars:
01130                 $RTEwasLoaded = 0;                              // Set true, if the RTE is loaded; If not a normal textarea is shown.
01131                 $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...
01132 
01133                         // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. Traditionally, this is where RTE configuration has been found.
01134                 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
01135 
01136                         // Setting up the altItem form field, which is a hidden field containing the value
01137                 $altItem = '<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
01138 
01139                         // If RTE is generally enabled (TYPO3_CONF_VARS and user settings)
01140                 if ($this->RTEenabled) {
01141                         $p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
01142                         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.
01143                                 t3lib_BEfunc::fixVersioningPid($table,$row);
01144                                 list($tscPID,$thePidValue) = $this->getTSCpid($table,$row['uid'],$row['pid']);
01145 
01146                                         // If the pid-value is not negative (that is, a pid could NOT be fetched)
01147                                 if ($thePidValue >= 0)  {
01148                                         $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($tscPID));
01149                                         $RTEtypeVal = t3lib_BEfunc::getTCAtypeValue($table,$row);
01150                                         $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$table,$field,$RTEtypeVal);
01151 
01152                                         if (!$thisConfig['disabled'])   {
01153                                                 if (!$this->disableRTE) {
01154                                                         $this->RTEcounter++;
01155 
01156                                                                 // Find alternative relative path for RTE images/links:
01157                                                         $eFile = t3lib_parsehtml_proc::evalWriteFile($specConf['static_write'], $row);
01158                                                         $RTErelPath = is_array($eFile) ? dirname($eFile['relEditFile']) : '';
01159 
01160                                                                 // Get RTE object, draw form and set flag:
01161                                                         $RTEobj = &t3lib_BEfunc::RTEgetObj();
01162                                                         $item = $RTEobj->drawRTE($this,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue);
01163 
01164                                                                 // Wizard:
01165                                                         $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf,1);
01166 
01167                                                         $RTEwasLoaded = 1;
01168                                                 } else {
01169                                                         $RTEwouldHaveBeenLoaded = 1;
01170                                                         $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!)';
01171                                                 }
01172                                         } else $this->commentMessages[] = $PA['itemFormElName'].': RTE is disabled by the Page TSconfig, "RTE"-key (eg. by RTE.default.disabled=0 or such)';
01173                                 } else $this->commentMessages[] = $PA['itemFormElName'].': PID value could NOT be fetched. Rare error, normally with new records.';
01174                         } else {
01175                                 if (!isset($specConf['richtext']))      $this->commentMessages[] = $PA['itemFormElName'].': RTE was not configured for this field in TCA-types';
01176                                 if (!(!$p['flag'] || !$row[$p['flag']]))         $this->commentMessages[] = $PA['itemFormElName'].': Field-flag ('.$PA['flag'].') has been set to disable RTE!';
01177                         }
01178                 }
01179 
01180                         // Display ordinary field if RTE was not loaded.
01181                 if (!$RTEwasLoaded) {
01182                         if ($specConf['rte_only'])      {       // Show message, if no RTE (field can only be edited with RTE!)
01183                                 $item = '<p><em>'.htmlspecialchars($this->getLL('l_noRTEfound')).'</em></p>';
01184                         } else {
01185                                 if ($specConf['nowrap'])        {
01186                                         $wrap = 'off';
01187                                 } else {
01188                                         $wrap = ($config['wrap'] ? $config['wrap'] : 'virtual');
01189                                 }
01190 
01191                                 $classes = array();
01192                                 if ($specConf['fixed-font'])    { $classes[] = 'fixed-font'; }
01193                                 if ($specConf['enable-tab'])    { $classes[] = 'enable-tab'; }
01194 
01195                                 $formWidthText = $this->formWidthText($cols,$wrap);
01196 
01197                                         // Extract class attributes from $formWidthText (otherwise it would be added twice to the output)
01198                                 if (preg_match('/ class="(.+?)"/',$formWidthText,$res)) {
01199                                         $formWidthText = str_replace(' class="'.$res[1].'"','',$formWidthText);
01200                                         $classes = array_merge($classes, explode(' ',$res[1]));
01201                                 }
01202 
01203                                 if (count($classes))    {
01204                                         $class = ' class="'.implode(' ',$classes).'"';
01205                                 } else $class='';
01206 
01207                                 $iOnChange = implode('',$PA['fieldChangeFunc']);
01208                                 $item.= '
01209                                                         <textarea name="'.$PA['itemFormElName'].'"'.$formWidthText.$class.' rows="'.$rows.'" wrap="'.$wrap.'" onchange="'.htmlspecialchars($iOnChange).'"'.$PA['onFocus'].'>'.
01210                                                         t3lib_div::formatForTextarea($PA['itemFormElValue']).
01211                                                         '</textarea>';
01212                                 $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf,$RTEwouldHaveBeenLoaded);
01213                         }
01214                 }
01215 
01216                         // Return field HTML:
01217                 return $item;
01218         }
01219 
01230         function getSingleField_typeCheck($table,$field,$row,&$PA)      {
01231                 $config = $PA['fieldConf']['config'];
01232 
01233                 $disabled = '';
01234                 if($this->renderReadonly || $config['readOnly'])  {
01235                         $disabled = ' disabled="disabled"';
01236                 }
01237 
01238                         // Traversing the array of items:
01239                 $selItems = $this->initItemArray($PA['fieldConf']);
01240                 if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
01241 
01242                 if (!count($selItems))  {
01243                         $selItems[]=array('','');
01244                 }
01245                 $thisValue = intval($PA['itemFormElValue']);
01246 
01247                 $cols = intval($config['cols']);
01248                 if ($cols > 1)  {
01249                         $item.= '<table border="0" cellspacing="0" cellpadding="0" class="typo3-TCEforms-checkboxArray">';
01250                         for ($c=0;$c<count($selItems);$c++) {
01251                                 $p = $selItems[$c];
01252                                 if(!($c%$cols)) { $item.='<tr>'; }
01253                                 $cBP = $this->checkBoxParams($PA['itemFormElName'],$thisValue,$c,count($selItems),implode('',$PA['fieldChangeFunc']));
01254                                 $cBName = $PA['itemFormElName'].'_'.$c;
01255                                 $cBID = $PA['itemFormElID'].'_'.$c;
01256                                 $item.= '<td nowrap="nowrap">'.
01257                                                 '<input type="checkbox"'.$this->insertDefStyle('check').' value="1" name="'.$cBName.'"'.$cBP.$disabled.' id="'.$cBID.'" />'.
01258                                                 $this->wrapLabels('<label for="'.$cBID.'">'.htmlspecialchars($p[0]).'</label>&nbsp;').
01259                                                 '</td>';
01260                                 if(($c%$cols)+1==$cols) {$item.='</tr>';}
01261                         }
01262                         if ($c%$cols)   {
01263                                 $rest=$cols-($c%$cols);
01264                                 for ($c=0;$c<$rest;$c++) {
01265                                         $item.= '<td></td>';
01266                                 }
01267                                 if ($c>0)       { $item.= '</tr>'; }
01268                         }
01269                         $item.= '</table>';
01270                 } else {
01271                         for ($c=0;$c<count($selItems);$c++) {
01272                                 $p = $selItems[$c];
01273                                 $cBP = $this->checkBoxParams($PA['itemFormElName'],$thisValue,$c,count($selItems),implode('',$PA['fieldChangeFunc']));
01274                                 $cBName = $PA['itemFormElName'].'_'.$c;
01275                                 $cBID = $PA['itemFormElID'].'_'.$c;
01276                                 $item.= ($c>0?'<br />':'').
01277                                                 '<input type="checkbox"'.$this->insertDefStyle('check').' value="1" name="'.$cBName.'"'.$cBP.$PA['onFocus'].$disabled.' id="'.$cBID.'" />'.
01278                                                 htmlspecialchars($p[0]);
01279                         }
01280                 }
01281                 if (!$disabled) {
01282                         $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($thisValue).'" />';
01283                 }
01284 
01285                 return $item;
01286         }
01287 
01298         function getSingleField_typeRadio($table,$field,$row,&$PA)      {
01299                 $config = $PA['fieldConf']['config'];
01300 
01301                 $disabled = '';
01302                 if($this->renderReadonly || $config['readOnly'])  {
01303                         $disabled = ' disabled="disabled"';
01304                 }
01305 
01306                         // Get items for the array:
01307                 $selItems = $this->initItemArray($PA['fieldConf']);
01308                 if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
01309 
01310                         // Traverse the items, making the form elements:
01311                 for ($c=0;$c<count($selItems);$c++) {
01312                         $p = $selItems[$c];
01313                         $rID = $PA['itemFormElID'].'_'.$c;
01314                         $rOnClick = implode('',$PA['fieldChangeFunc']);
01315                         $rChecked = (!strcmp($p[1],$PA['itemFormElValue'])?' checked="checked"':'');
01316                         $item.= '<input type="radio"'.$this->insertDefStyle('radio').' name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($p[1]).'" onclick="'.htmlspecialchars($rOnClick).'"'.$rChecked.$PA['onFocus'].$disabled.' id="'.$rID.'" />
01317                                         <label for="'.$rID.'">'.htmlspecialchars($p[0]).'</label>
01318                                         <br />';
01319                 }
01320 
01321                 return $item;
01322         }
01323 
01334         function getSingleField_typeSelect($table,$field,$row,&$PA)     {
01335                 global $TCA;
01336 
01337                         // Field configuration from TCA:
01338                 $config = $PA['fieldConf']['config'];
01339 
01340                 $disabled = '';
01341                 if($this->renderReadonly || $config['readOnly'])  {
01342                         $disabled = ' disabled="disabled"';
01343                 }
01344 
01345                         // "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/.
01346                 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
01347 
01348                         // Getting the selector box items from the system
01349                 $selItems = $this->addSelectOptionsToItemArray($this->initItemArray($PA['fieldConf']),$PA['fieldConf'],$this->setTSconfig($table,$row),$field);
01350                 $selItems = $this->addItems($selItems,$PA['fieldTSConfig']['addItems.']);
01351                 if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
01352 
01353                         // Possibly remove some items:
01354                 $removeItems = t3lib_div::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
01355                 foreach($selItems as $tk => $p) {
01356 
01357                                 // Checking languages and authMode:
01358                         $languageDeny = $TCA[$table]['ctrl']['languageField'] && !strcmp($TCA[$table]['ctrl']['languageField'], $field) && !$GLOBALS['BE_USER']->checkLanguageAccess($p[1]);
01359                         $authModeDeny = $config['form_type']=='select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table,$field,$p[1],$config['authMode']);
01360                         if (in_array($p[1],$removeItems) || $languageDeny || $authModeDeny)     {
01361                                 unset($selItems[$tk]);
01362                         } elseif (isset($PA['fieldTSConfig']['altLabels.'][$p[1]])) {
01363                                 $selItems[$tk][0]=$this->sL($PA['fieldTSConfig']['altLabels.'][$p[1]]);
01364                         }
01365 
01366                                 // Removing doktypes with no access:
01367                         if ($table.'.'.$field == 'pages.doktype')       {
01368                                 if (!($GLOBALS['BE_USER']->isAdmin() || t3lib_div::inList($GLOBALS['BE_USER']->groupData['pagetypes_select'],$p[1])))   {
01369                                         unset($selItems[$tk]);
01370                                 }
01371                         }
01372                 }
01373 
01374                         // Creating the label for the "No Matching Value" entry.
01375                 $nMV_label = isset($PA['fieldTSConfig']['noMatchingValue_label']) ? $this->sL($PA['fieldTSConfig']['noMatchingValue_label']) : '[ '.$this->getLL('l_noMatchingValue').' ]';
01376 
01377                         // Prepare some values:
01378                 $maxitems = intval($config['maxitems']);
01379 
01380                         // If a SINGLE selector box...
01381                 if ($maxitems<=1)       {
01382                         $item = $this->getSingleField_typeSelect_single($table,$field,$row,$PA,$config,$selItems,$nMV_label);
01383                 } elseif (!strcmp($config['renderMode'],'checkbox'))    {       // Checkbox renderMode
01384                         $item = $this->getSingleField_typeSelect_checkbox($table,$field,$row,$PA,$config,$selItems,$nMV_label);
01385                 } elseif (!strcmp($config['renderMode'],'singlebox'))   {       // Single selector box renderMode
01386                         $item = $this->getSingleField_typeSelect_singlebox($table,$field,$row,$PA,$config,$selItems,$nMV_label);
01387                 } else {        // Traditional multiple selector box:
01388                         $item = $this->getSingleField_typeSelect_multiple($table,$field,$row,$PA,$config,$selItems,$nMV_label);
01389                 }
01390 
01391                         // Wizards:
01392                 if (!$disabled) {
01393                         $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
01394                         $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf);
01395                 }
01396 
01397                 return $item;
01398         }
01399 
01414         function getSingleField_typeSelect_single($table,$field,$row,&$PA,$config,$selItems,$nMV_label) {
01415                         // check against inline uniqueness
01416                 $inlineParent = $this->inline->getStructureLevel(-1);
01417                 if(is_array($inlineParent) && $inlineParent['uid']) {
01418                         if ($inlineParent['config']['foreign_table'] == $table && $inlineParent['config']['foreign_unique'] == $field) {
01419                                 $uniqueIds = $this->inline->inlineData['unique'][$this->inline->inlineNames['object'].'['.$table.']']['used'];
01420                                 $PA['fieldChangeFunc']['inlineUnique'] = "inline.updateUnique(this,'".$this->inline->inlineNames['object'].'['.$table."]','".$this->inline->inlineNames['form']."','".$row['uid']."');";
01421                         }
01422                                 // hide uid of parent record for symmetric relations
01423                         if ($inlineParent['config']['foreign_table'] == $table && ($inlineParent['config']['foreign_field'] == $field || $inlineParent['config']['symmetric_field'] == $field)) {
01424                                 $uniqueIds[] = $inlineParent['uid'];
01425                         }
01426                 }
01427 
01428                         // Initialization:
01429                 $c = 0;
01430                 $sI = 0;
01431                 $noMatchingValue = 1;
01432                 $opt = array();
01433                 $selicons = array();
01434                 $onlySelectedIconShown = 0;
01435                 $size = intval($config['size']);
01436 
01437                 $disabled = '';
01438                 if($this->renderReadonly || $config['readOnly'])  {
01439                         $disabled = ' disabled="disabled"';
01440                         $onlySelectedIconShown = 1;
01441                 }
01442 
01443                         // Icon configuration:
01444                 if ($config['suppress_icons']=='IF_VALUE_FALSE')        {
01445                         $suppressIcons = !$PA['itemFormElValue'] ? 1 : 0;
01446                 } elseif ($config['suppress_icons']=='ONLY_SELECTED')   {
01447                         $suppressIcons=0;
01448                         $onlySelectedIconShown=1;
01449                 } elseif ($config['suppress_icons'])    {
01450                         $suppressIcons = 1;
01451                 } else $suppressIcons = 0;
01452 
01453                         // Traverse the Array of selector box items:
01454                 foreach($selItems as $p)        {
01455                         $sM = (!strcmp($PA['itemFormElValue'],$p[1])?' selected="selected"':'');
01456                         if ($sM)        {
01457                                 $sI = $c;
01458                                 $noMatchingValue = 0;
01459                         }
01460 
01461                                 // Getting style attribute value (for icons):
01462                         if ($config['iconsInOptionTags'])       {
01463                                 $styleAttrValue = $this->optionTagStyle($p[2]);
01464                         }
01465 
01466                                 // Compiling the <option> tag:
01467                         if (!($p[1] != $PA['itemFormElValue'] && is_array($uniqueIds) && in_array($p[1], $uniqueIds))) {
01468                                 $opt[]= '<option value="'.htmlspecialchars($p[1]).'"'.
01469                                                         $sM.
01470                                                         ($styleAttrValue ? ' style="'.htmlspecialchars($styleAttrValue).'"' : '').
01471                                                         (!strcmp($p[1],'--div--') ? ' class="c-divider"' : '').
01472                                                         '>'.t3lib_div::deHSCentities(htmlspecialchars($p[0])).'</option>';
01473                         }
01474 
01475                                 // If there is an icon for the selector box (rendered in table under)...:
01476                         if ($p[2] && !$suppressIcons && (!$onlySelectedIconShown || $sM))       {
01477                                 list($selIconFile,$selIconInfo)=$this->getIcon($p[2]);
01478                                 $iOnClick = $this->elName($PA['itemFormElName']).'.selectedIndex='.$c.'; '.implode('',$PA['fieldChangeFunc']).$this->blur().'return false;';
01479                                 $selicons[]=array(
01480                                         (!$onlySelectedIconShown ? '<a href="#" onclick="'.htmlspecialchars($iOnClick).'">' : '').
01481                                         '<img src="'.$selIconFile.'" '.$selIconInfo[3].' vspace="2" border="0" title="'.htmlspecialchars($p[0]).'" alt="'.htmlspecialchars($p[0]).'" />'.
01482                                         (!$onlySelectedIconShown ? '</a>' : ''),
01483                                         $c,$sM);
01484                         }
01485                         $c++;
01486                 }
01487 
01488                         // No-matching-value:
01489                 if ($PA['itemFormElValue'] && $noMatchingValue && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement'])  {
01490                         $nMV_label = @sprintf($nMV_label, $PA['itemFormElValue']);
01491                         $opt[]= '<option value="'.htmlspecialchars($PA['itemFormElValue']).'" selected="selected">'.htmlspecialchars($nMV_label).'</option>';
01492                 }
01493 
01494                         // Create item form fields:
01495                 $sOnChange = 'if (this.options[this.selectedIndex].value==\'--div--\') {this.selectedIndex='.$sI.';} '.implode('',$PA['fieldChangeFunc']);
01496                 if(!$disabled) {
01497                         $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...
01498                 }
01499                 $item.= '<select name="'.$PA['itemFormElName'].'"'.
01500                                         $this->insertDefStyle('select').
01501                                         ($size?' size="'.$size.'"':'').
01502                                         ' onchange="'.htmlspecialchars($sOnChange).'"'.
01503                                         $PA['onFocus'].$disabled.'>';
01504                 $item.= implode('',$opt);
01505                 $item.= '</select>';
01506 
01507                         // Create icon table:
01508                 if (count($selicons))   {
01509                         $item.='<table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-selectIcons">';
01510                         $selicon_cols = intval($config['selicon_cols']);
01511                         if (!$selicon_cols)     $selicon_cols=count($selicons);
01512                         $sR = ceil(count($selicons)/$selicon_cols);
01513                         $selicons = array_pad($selicons,$sR*$selicon_cols,'');
01514                         for($sa=0;$sa<$sR;$sa++)        {
01515                                 $item.='<tr>';
01516                                 for($sb=0;$sb<$selicon_cols;$sb++)      {
01517                                         $sk=($sa*$selicon_cols+$sb);
01518                                         $imgN = 'selIcon_'.$table.'_'.$row['uid'].'_'.$field.'_'.$selicons[$sk][1];
01519                                         $imgS = ($selicons[$sk][2]?$this->backPath.'gfx/content_selected.gif':'clear.gif');
01520                                         $item.='<td><img name="'.htmlspecialchars($imgN).'" src="'.$imgS.'" width="7" height="10" alt="" /></td>';
01521                                         $item.='<td>'.$selicons[$sk][0].'</td>';
01522                                 }
01523                                 $item.='</tr>';
01524                         }
01525                         $item.='</table>';
01526                 }
01527 
01528                 return $item;
01529         }
01530 
01545         function getSingleField_typeSelect_checkbox($table,$field,$row,&$PA,$config,$selItems,$nMV_label)       {
01546 
01547                         // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
01548                 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
01549 
01550                 $disabled = '';
01551                 if($this->renderReadonly || $config['readOnly'])  {
01552                         $disabled = ' disabled="disabled"';
01553                 }
01554 
01555                         // Traverse the Array of selector box items:
01556                 $tRows = array();
01557                 $c=0;
01558                 if (!$disabled) {
01559                         $sOnChange = implode('',$PA['fieldChangeFunc']);
01560                         $setAll = array();      // Used to accumulate the JS needed to restore the original selection.
01561                         foreach($selItems as $p)        {
01562                                         // Non-selectable element:
01563                                 if (!strcmp($p[1],'--div--'))   {
01564                                         if (count($setAll))     {
01565                                                         $tRows[] = '
01566                                                                 <tr>
01567                                                                         <td colspan="2">'.
01568                                                                         '<a href="#" onclick="'.htmlspecialchars(implode('',$setAll).' return false;').'">'.
01569                                                                         htmlspecialchars($this->getLL('l_setAllCheckboxes')).
01570                                                                         '</a></td>
01571                                                                 </tr>';
01572                                                         $setAll = array();
01573                                         }
01574 
01575                                         $tRows[] = '
01576                                                 <tr class="c-header">
01577                                                         <td colspan="2">'.htmlspecialchars($p[0]).'</td>
01578                                                 </tr>';
01579                                 } else {
01580                                                 // Selected or not by default:
01581                                         $sM = '';
01582                                         if (isset($itemArray[$p[1]]))   {
01583                                                 $sM = ' checked="checked"';
01584                                                 unset($itemArray[$p[1]]);
01585                                         }
01586 
01587                                                 // Icon:
01588                                         $selIconFile = '';
01589                                         if ($p[2])      {
01590                                                 list($selIconFile,$selIconInfo) = $this->getIcon($p[2]);
01591                                         }
01592 
01593                                                 // Compile row:
01594                                         $onClickCell = $this->elName($PA['itemFormElName'].'['.$c.']').'.checked=!'.$this->elName($PA['itemFormElName'].'['.$c.']').'.checked;';
01595                                         $onClick = 'this.attributes.getNamedItem("class").nodeValue = '.$this->elName($PA['itemFormElName'].'['.$c.']').'.checked ? "c-selectedItem" : "";';
01596                                         $setAll[] = $this->elName($PA['itemFormElName'].'['.$c.']').'.checked=1;';
01597                                         $tRows[] = '
01598                                                 <tr class="'.($sM ? 'c-selectedItem' : '').'" onclick="'.htmlspecialchars($onClick).'" style="cursor: pointer;">
01599                                                         <td><input type="checkbox"'.$this->insertDefStyle('check').' name="'.htmlspecialchars($PA['itemFormElName'].'['.$c.']').'" value="'.htmlspecialchars($p[1]).'"'.$sM.' onclick="'.htmlspecialchars($sOnChange).'"'.$PA['onFocus'].' /></td>
01600                                                         <td class="c-labelCell" onclick="'.htmlspecialchars($onClickCell).'">'.
01601                                                                 ($selIconFile ? '<img src="'.$selIconFile.'" '.$selIconInfo[3].' vspace="2" border="0" class="absmiddle" style="margin-right: 4px;" alt="" />' : '').
01602                                                                 t3lib_div::deHSCentities(htmlspecialchars($p[0])).
01603                                                                 (strcmp($p[3],'') ? '<br/><p class="c-descr">'.nl2br(trim(htmlspecialchars($p[3]))).'</p>' : '').
01604                                                                 '</td>
01605                                                 </tr>';
01606                                         $c++;
01607                                 }
01608                         }
01609 
01610                                 // Remaining checkboxes will get their set-all link:
01611                         if (count($setAll))     {
01612                                         $tRows[] = '
01613                                                 <tr>
01614                                                         <td colspan="2">'.
01615                                                         '<a href="#" onclick="'.htmlspecialchars(implode('',$setAll).' return false;').'">'.
01616                                                         htmlspecialchars($this->getLL('l_setAllCheckboxes')).
01617                                                         '</a></td>
01618                                                 </tr>';
01619                         }
01620                 }
01621 
01622                         // Remaining values (invalid):
01623                 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement'])   {
01624                         foreach($itemArray as $theNoMatchValue => $temp)        {
01625                                         // Compile <checkboxes> tag:
01626                                 array_unshift($tRows,'
01627                                                 <tr class="c-invalidItem">
01628                                                         <td><input type="checkbox"'.$this->insertDefStyle('check').' name="'.htmlspecialchars($PA['itemFormElName'].'['.$c.']').'" value="'.htmlspecialchars($theNoMatchValue).'" checked="checked" onclick="'.htmlspecialchars($sOnChange).'"'.$PA['onFocus'].$disabled.' /></td>
01629                                                         <td class="c-labelCell">'.
01630                                                                 t3lib_div::deHSCentities(htmlspecialchars(@sprintf($nMV_label, $theNoMatchValue))).
01631                                                                 '</td>
01632                                                 </tr>');
01633                                 $c++;
01634                         }
01635                 }
01636 
01637                         // Add an empty hidden field which will send a blank value if all items are unselected.
01638                 $item.='<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="" />';
01639 
01640                         // Implode rows in table:
01641                 $item.= '
01642                         <table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-select-checkbox">'.
01643                                 implode('',$tRows).'
01644                         </table>
01645                         ';
01646 
01647                 return $item;
01648         }
01649 
01664         function getSingleField_typeSelect_singlebox($table,$field,$row,&$PA,$config,$selItems,$nMV_label)      {
01665 
01666                         // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
01667                 $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
01668 
01669                 $disabled = '';
01670                 if($this->renderReadonly || $config['readOnly'])  {
01671                         $disabled = ' disabled="disabled"';
01672                 }
01673 
01674                         // Traverse the Array of selector box items:
01675                 $opt = array();
01676                 $restoreCmd = array();  // Used to accumulate the JS needed to restore the original selection.
01677                 $c = 0;
01678                 foreach($selItems as $p)        {
01679                                 // Selected or not by default:
01680                         $sM = '';
01681                         if (isset($itemArray[$p[1]]))   {
01682                                 $sM = ' selected="selected"';
01683                                 $restoreCmd[] = $this->elName($PA['itemFormElName'].'[]').'.options['.$c.'].selected=1;';
01684                                 unset($itemArray[$p[1]]);
01685                         }
01686 
01687                                 // Non-selectable element:
01688                         $nonSel = '';
01689                         if (!strcmp($p[1],'--div--'))   {
01690                                 $nonSel = ' onclick="this.selected=0;" class="c-divider"';
01691                         }
01692 
01693                                 // Icon style for option tag:
01694                         if ($config['iconsInOptionTags']) {
01695                                 $styleAttrValue = $this->optionTagStyle($p[2]);
01696                         }
01697 
01698                                 // Compile <option> tag:
01699                         $opt[] = '<option value="'.htmlspecialchars($p[1]).'"'.
01700                                                 $sM.
01701                                                 $nonSel.
01702                                                 ($styleAttrValue ? ' style="'.htmlspecialchars($styleAttrValue).'"' : '').
01703                                                 '>'.t3lib_div::deHSCentities(htmlspecialchars($p[0])).'</option>';
01704                         $c++;
01705                 }
01706 
01707                         // Remaining values:
01708                 if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement'])   {
01709                         foreach($itemArray as $theNoMatchValue => $temp)        {
01710                                         // Compile <option> tag:
01711                                 array_unshift($opt,'<option value="'.htmlspecialchars($theNoMatchValue).'" selected="selected">'.t3lib_div::deHSCentities(htmlspecialchars(@sprintf($nMV_label, $theNoMatchValue))).'</option>');
01712                         }
01713                 }
01714 
01715                         // Compile selector box:
01716                 $sOnChange = implode('',$PA['fieldChangeFunc']);
01717                 $selector_itemListStyle = isset($config['itemListStyle']) ? ' style="'.htmlspecialchars($config['itemListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"';
01718                 $size = intval($config['size']);
01719                 $size = $config['autoSizeMax'] ? t3lib_div::intInRange(count($selItems)+1,t3lib_div::intInRange($size,1),$config['autoSizeMax']) : $size;
01720                 $selectBox = '<select name="'.$PA['itemFormElName'].'[]"'.
01721                                                 $this->insertDefStyle('select').
01722                                                 ($size ? ' size="'.$size.'"' : '').
01723                                                 ' multiple="multiple" onchange="'.htmlspecialchars($sOnChange).'"'.
01724                                                 $PA['onFocus'].
01725                                                 $selector_itemListStyle.
01726                                                 $disabled.'>
01727                                                 '.
01728                                         implode('
01729                                                 ',$opt).'
01730                                         </select>';
01731 
01732                         // Add an empty hidden field which will send a blank value if all items are unselected.
01733                 if (!$disabled) {
01734                         $item.='<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="" />';
01735                 }
01736 
01737                         // Put it all into a table:
01738                 $item.= '
01739                         <table border="0" cellspacing="0" cellpadding="0" width="1" class="typo3-TCEforms-select-singlebox">
01740                                 <tr>
01741                                         <td>
01742                                         '.$selectBox.'
01743                                         <br/>
01744                                         <em>'.
01745                                                 htmlspecialchars($this->getLL('l_holdDownCTRL')).
01746                                                 '</em>
01747                                         </td>
01748                                         <td valign="top">
01749                                         <a href="#" onclick="'.htmlspecialchars($this->elName($PA['itemFormElName'].'[]').'.selectedIndex=-1;'.implode('',$restoreCmd).' return false;').'">'.
01750                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/history.gif','width="13" height="12"').' title="'.htmlspecialchars($this->getLL('l_revertSelection')).'" alt="" />'.
01751                                                 '</a>
01752                                         </td>
01753                                 </tr>
01754                         </table>
01755                                 ';
01756 
01757                 return $item;
01758         }
01759 
01774         function getSingleField_typeSelect_multiple($table,$field,$row,&$PA,$config,$selItems,$nMV_label)       {
01775 
01776                 $disabled = '';
01777                 if($this->renderReadonly || $config['readOnly'])  {
01778                         $disabled = ' disabled="disabled"';
01779                 }
01780 
01781                         // Setting this hidden field (as a flag that JavaScript can read out)
01782                 if (!$disabled) {
01783                         $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'_mul" value="'.($config['multiple']?1:0).'" />';
01784                 }
01785 
01786                         // Set max and min items:
01787                 $maxitems = t3lib_div::intInRange($config['maxitems'],0);
01788                 if (!$maxitems) $maxitems=100000;
01789                 $minitems = t3lib_div::intInRange($config['minitems'],0);
01790 
01791                         // Register the required number of elements:
01792                 $this->requiredElements[$PA['itemFormElName']] = array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field);
01793 
01794                         // Get "removeItems":
01795                 $removeItems = t3lib_div::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
01796 
01797                         // Perform modification of the selected items array:
01798                 $itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
01799                 foreach($itemArray as $tk => $tv) {
01800                         $tvP = explode('|',$tv,2);
01801                         $evalValue = rawurldecode($tvP[0]);
01802                         $isRemoved = in_array($evalValue,$removeItems)  || ($config['form_type']=='select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table,$field,$evalValue,$config['authMode']));
01803                         if ($isRemoved && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement'])  {
01804                                 $tvP[1] = rawurlencode(@sprintf($nMV_label, $evalValue));
01805                         } elseif (isset($PA['fieldTSConfig']['altLabels.'][$evalValue])) {
01806                                 $tvP[1] = rawurlencode($this->sL($PA['fieldTSConfig']['altLabels.'][$evalValue]));
01807                         }
01808                         $itemArray[$tk] = implode('|',$tvP);
01809                 }
01810                 $itemsToSelect = '';
01811 
01812                 if(!$disabled) {
01813                                 // Create option tags:
01814                         $opt = array();
01815                         $styleAttrValue = '';
01816                         foreach($selItems as $p)        {
01817                                 if ($config['iconsInOptionTags'])       {
01818                                         $styleAttrValue = $this->optionTagStyle($p[2]);
01819                                 }
01820                                 $opt[]= '<option value="'.htmlspecialchars($p[1]).'"'.
01821                                                                 ($styleAttrValue ? ' style="'.htmlspecialchars($styleAttrValue).'"' : '').
01822                                                                 '>'.htmlspecialchars($p[0]).'</option>';
01823                         }
01824 
01825                                 // Put together the selector box:
01826                         $selector_itemListStyle = isset($config['itemListStyle']) ? ' style="'.htmlspecialchars($config['itemListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"';
01827                         $size = intval($config['size']);
01828                         $size = $config['autoSizeMax'] ? t3lib_div::intInRange(count($itemArray)+1,t3lib_div::intInRange($size,1),$config['autoSizeMax']) : $size;
01829                         if ($config['exclusiveKeys'])   {
01830                                 $sOnChange = 'setFormValueFromBrowseWin(\''.$PA['itemFormElName'].'\',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text,\''.$config['exclusiveKeys'].'\'); ';
01831                         } else {
01832                                 $sOnChange = 'setFormValueFromBrowseWin(\''.$PA['itemFormElName'].'\',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text); ';
01833                         }
01834                         $sOnChange .= implode('',$PA['fieldChangeFunc']);
01835                         $itemsToSelect = '
01836                                 <select name="'.$PA['itemFormElName'].'_sel"'.
01837                                                         $this->insertDefStyle('select').
01838                                                         ($size ? ' size="'.$size.'"' : '').
01839                                                         ' onchange="'.htmlspecialchars($sOnChange).'"'.
01840                                                         $PA['onFocus'].
01841                                                         $selector_itemListStyle.'>
01842                                         '.implode('
01843                                         ',$opt).'
01844                                 </select>';
01845                 }
01846 
01847                         // Pass to "dbFileIcons" function:
01848                 $params = array(
01849                         'size' => $size,
01850                         'autoSizeMax' => t3lib_div::intInRange($config['autoSizeMax'],0),
01851                         'style' => isset($config['selectedListStyle']) ? ' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"',
01852                         'dontShowMoveIcons' => ($maxitems<=1),
01853                         'maxitems' => $maxitems,
01854                         'info' => '',
01855                         'headers' => array(
01856                                 'selector' => $this->getLL('l_selected').':<br />',
01857                                 'items' => $this->getLL('l_items').':<br />'
01858                         ),
01859                         'noBrowser' => 1,
01860                         'thumbnails' => $itemsToSelect,
01861                         'readOnly' => $disabled
01862                 );
01863                 $item.= $this->dbFileIcons($PA['itemFormElName'],'','',$itemArray,'',$params,$PA['onFocus']);
01864 
01865                 return $item;
01866         }
01867 
01878         function getSingleField_typeGroup($table,$field,$row,&$PA)      {
01879                         // Init:
01880                 $config = $PA['fieldConf']['config'];
01881                 $internal_type = $config['internal_type'];
01882                 $show_thumbs = $config['show_thumbs'];
01883                 $size = intval($config['size']);
01884                 $maxitems = t3lib_div::intInRange($config['maxitems'],0);
01885                 if (!$maxitems) $maxitems=100000;
01886                 $minitems = t3lib_div::intInRange($config['minitems'],0);
01887                 $allowed = $config['allowed'];
01888                 $disallowed = $config['disallowed'];
01889 
01890                 $disabled = '';
01891                 if($this->renderReadonly || $config['readOnly'])  {
01892                         $disabled = ' disabled="disabled"';
01893                 }
01894 
01895                 $item.= '<input type="hidden" name="'.$PA['itemFormElName'].'_mul" value="'.($config['multiple']?1:0).'"'.$disabled.' />';
01896                 $this->requiredElements[$PA['itemFormElName']] = array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field);
01897                 $info='';
01898 
01899                         // "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/.
01900                 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
01901 
01902                         // Acting according to either "file" or "db" type:
01903                 switch((string)$config['internal_type'])        {
01904                         case 'file':    // If the element is of the internal type "file":
01905 
01906                                         // Creating string showing allowed types:
01907                                 $tempFT = t3lib_div::trimExplode(',',$allowed,1);
01908                                 if (!count($tempFT))    {$info.='*';}
01909                                 foreach($tempFT as $ext)        {
01910                                         if ($ext)       {
01911                                                 $info.=strtoupper($ext).' ';
01912                                         }
01913                                 }
01914                                         // Creating string, showing disallowed types:
01915                                 $tempFT_dis = t3lib_div::trimExplode(',',$disallowed,1);
01916                                 if (count($tempFT_dis)) {$info.='<br />';}
01917                                 foreach($tempFT_dis as $ext)    {
01918                                         if ($ext)       {
01919                                                 $info.='-'.strtoupper($ext).' ';
01920                                         }
01921                                 }
01922 
01923                                         // Making the array of file items:
01924                                 $itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
01925 
01926                                         // Showing thumbnails:
01927                                 $thumbsnail = '';
01928                                 if ($show_thumbs)       {
01929                                         $imgs = array();
01930                                         foreach($itemArray as $imgRead) {
01931                                                 $imgP = explode('|',$imgRead);
01932                                                 $imgPath = rawurldecode($imgP[0]);
01933 
01934                                                 $rowCopy = array();
01935                                                 $rowCopy[$field] = $imgPath;
01936 
01937                                                         // Icon + clickmenu:
01938                                                 $absFilePath = t3lib_div::getFileAbsFileName($config['uploadfolder'].'/'.$imgPath);
01939 
01940                                                 $fI = pathinfo($imgPath);
01941                                                 $fileIcon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
01942                                                 $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="" />';
01943 
01944                                                 $imgs[] = '<span class="nobr">'.t3lib_BEfunc::thumbCode($rowCopy,$table,$field,$this->backPath,'thumbs.php',$config['uploadfolder'],0,' align="middle"').
01945                                                                         ($absFilePath ? $this->getClickMenu($fileIcon, $absFilePath) : $fileIcon).
01946                                                                         $imgPath.
01947                                                                         '</span>';
01948                                         }
01949                                         $thumbsnail = implode('<br />',$imgs);
01950                                 }
01951 
01952                                         // Creating the element:
01953                                 $params = array(
01954                                         'size' => $size,
01955                                         'dontShowMoveIcons' => ($maxitems<=1),
01956                                         'autoSizeMax' => t3lib_div::intInRange($config['autoSizeMax'],0),
01957                                         'maxitems' => $maxitems,
01958                                         'style' => isset($config['selectedListStyle']) ? ' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"',
01959                                         'info' => $info,
01960                                         'thumbnails' => $thumbsnail,
01961                                         'readOnly' => $disabled
01962                                 );
01963                                 $item.= $this->dbFileIcons($PA['itemFormElName'],'file',implode(',',$tempFT),$itemArray,'',$params,$PA['onFocus']);
01964 
01965                                 if(!$disabled) {
01966                                                 // Adding the upload field:
01967                                         if ($this->edit_docModuleUpload)        $item.='<input type="file" name="'.$PA['itemFormElName_file'].'"'.$this->formWidth().' size="60" />';
01968                                 }
01969                         break;
01970                         case 'db':      // If the element is of the internal type "db":
01971 
01972                                         // Creating string showing allowed types:
01973                                 $tempFT = t3lib_div::trimExplode(',',$allowed,1);
01974                                 if (!strcmp(trim($tempFT[0]),'*'))      {
01975                                         $info.='<span class="nobr">&nbsp;&nbsp;&nbsp;&nbsp;'.
01976                                                         htmlspecialchars($this->getLL('l_allTables')).
01977                                                         '</span><br />';
01978                                 } else {
01979                                         while(list(,$theT)=each($tempFT))       {
01980                                                 if ($theT)      {
01981                                                         $info.='<span class="nobr">&nbsp;&nbsp;&nbsp;&nbsp;'.
01982                                                                         t3lib_iconWorks::getIconImage($theT,array(),$this->backPath,'align="top"').
01983                                                                         htmlspecialchars($this->sL($GLOBALS['TCA'][$theT]['ctrl']['title'])).
01984                                                                         '</span><br />';
01985                                                 }
01986                                         }
01987                                 }
01988 
01989                                 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
01990                                 $itemArray = array();
01991                                 $imgs = array();
01992 
01993                                         // Thumbnails:
01994                                 $temp_itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
01995                                 foreach($temp_itemArray as $dbRead)     {
01996                                         $recordParts = explode('|',$dbRead);
01997                                         list($this_table,$this_uid) = t3lib_BEfunc::splitTable_Uid($recordParts[0]);
01998                                         $itemArray[] = array('table'=>$this_table, 'id'=>$this_uid);
01999                                         if (!$disabled && $show_thumbs) {
02000                                                 $rr = t3lib_BEfunc::getRecordWSOL($this_table,$this_uid);
02001                                                 $imgs[] = '<span class="nobr">'.
02002                                                                 $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).
02003                                                                 '&nbsp;'.
02004                                                                 t3lib_BEfunc::getRecordTitle($this_table,$rr,TRUE).' <span class="typo3-dimmed"><em>['.$rr['uid'].']</em></span>'.
02005                                                                 '</span>';
02006                                         }
02007                                 }
02008                                 $thumbsnail='';
02009                                 if (!$disabled && $show_thumbs) {
02010                                         $thumbsnail = implode('<br />',$imgs);
02011                                 }
02012 
02013                                         // Creating the element:
02014                                 $params = array(
02015                                         'size' => $size,
02016                                         'dontShowMoveIcons' => ($maxitems<=1),
02017                                         'autoSizeMax' => t3lib_div::intInRange($config['autoSizeMax'],0),
02018                                         'maxitems' => $maxitems,
02019                                         'style' => isset($config['selectedListStyle']) ? ' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"',
02020                                         'info' => $info,
02021                                         'thumbnails' => $thumbsnail,
02022                                         'readOnly' => $disabled
02023                                 );
02024                                 $item.= $this->dbFileIcons($PA['itemFormElName'],'db',implode(',',$tempFT),$itemArray,'',$params,$PA['onFocus'],$table,$field,$row['uid']);
02025 
02026                         break;
02027                 }
02028 
02029                         // Wizards:
02030                 $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
02031                 if (!$disabled) {
02032                         $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf);
02033                 }
02034 
02035                 return $item;
02036         }
02037 
02048         function getSingleField_typeNone($table,$field,$row,&$PA)       {
02049                         // Init:
02050                 $config = $PA['fieldConf']['config'];
02051                 $itemValue = $PA['itemFormElValue'];
02052 
02053                 return $this->getSingleField_typeNone_render($config,$itemValue);
02054         }
02055 
02064         function getSingleField_typeNone_render($config,$itemValue)     {
02065 
02066                                 // is colorScheme[0] the right value?
02067                 $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;';
02068 
02069                 if ($config['format'])  {
02070                         $itemValue = $this->formatValue($config, $itemValue);
02071                 }
02072 
02073                 $rows = intval($config['rows']);
02074                 if ($rows > 1) {
02075                         if(!$config['pass_content']) {
02076                                 $itemValue = nl2br(htmlspecialchars($itemValue));
02077                         }
02078                                 // like textarea
02079                         $cols = t3lib_div::intInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
02080                         if (!$config['fixedRows']) {
02081                                 $origRows = $rows = t3lib_div::intInRange($rows, 1, 20);
02082                                 if (strlen($itemValue)>$this->charsPerRow*2)    {
02083                                         $cols = $this->maxTextareaWidth;
02084                                         $rows = t3lib_div::intInRange(round(strlen($itemValue)/$this->charsPerRow),count(explode(chr(10),$itemValue)),20);
02085                                         if ($rows<$origRows)    $rows=$origRows;
02086                                 }
02087                         }
02088 
02089                         if ($this->docLarge)    $cols = round($cols*$this->form_largeComp);
02090                         $width = ceil($cols*$this->form_rowsToStylewidth);
02091                                 // hardcoded: 12 is the height of the font
02092                         $height=$rows*12;
02093 
02094                         $item='
02095                                 <div style="'.htmlspecialchars($divStyle.' overflow:auto; height:'.$height.'px; width:'.$width.'px;').'" class="'.htmlspecialchars($this->formElClass('none')).'">'.
02096                                 $itemValue.
02097                                 '</div>';
02098                 } else {
02099                         if(!$config['pass_content']) {
02100                                 $itemValue = htmlspecialchars($itemValue);
02101                         }
02102 
02103                         $cols = $config['cols']?$config['cols']:($config['size']?$config['size']:$this->maxInputWidth);
02104                         if ($this->docLarge)    $cols = round($cols*$this->form_largeComp);
02105                         $width = ceil($cols*$this->form_rowsToStylewidth);
02106 
02107                                 // overflow:auto crashes mozilla here. Title tag is usefull when text is longer than the div box (overflow:hidden).
02108                         $item = '
02109                                 <div style="'.htmlspecialchars($divStyle.' overflow:hidden; width:'.$width.'px;').'" class="'.htmlspecialchars($this->formElClass('none')).'" title="'.$itemValue.'">'.
02110                                 '<span class="nobr">'.(strcmp($itemValue,'')?$itemValue:'&nbsp;').'</span>'.
02111                                 '</div>';
02112                 }
02113 
02114                 return $item;
02115         }
02116 
02126         function getSingleField_typeFlex($table,$field,$row,&$PA)       {
02127 
02128                         // Data Structure:
02129                 $dataStructArray = t3lib_BEfunc::getFlexFormDS($PA['fieldConf']['config'],$row,$table);
02130 
02131                         // Get data structure:
02132                 if (is_array($dataStructArray)) {
02133 
02134                                 // Get data:
02135                         $xmlData = $PA['itemFormElValue'];
02136                         $xmlHeaderAttributes = t3lib_div::xmlGetHeaderAttribs($xmlData);
02137                         $storeInCharset = strtolower($xmlHeaderAttributes['encoding']);
02138                         if ($storeInCharset)    {
02139                                 $currentCharset=$GLOBALS['LANG']->charSet;
02140                                 $xmlData = $GLOBALS['LANG']->csConvObj->conv($xmlData,$storeInCharset,$currentCharset,1);
02141                         }
02142                         $editData=t3lib_div::xml2array($xmlData);
02143                         if (!is_array($editData))       {       // Must be XML parsing error...
02144                                 $editData=array();
02145                         } elseif (!isset($editData['meta']) || !is_array($editData['meta']))    {
02146                             $editData['meta'] = array();
02147                         }
02148 
02149                                 // Find the data structure if sheets are found:
02150                         $sheet = $editData['meta']['currentSheetId'] ? $editData['meta']['currentSheetId'] : 'sDEF';    // Sheet to display
02151 
02152                                 // Create sheet menu:
02153 //                      if (is_array($dataStructArray['sheets']))       {
02154 //                              #$item.=$this->getSingleField_typeFlex_sheetMenu($dataStructArray['sheets'], $PA['itemFormElName'].'[meta][currentSheetId]', $sheet).'<br />';
02155 //                      }
02156 
02157                                 // Create language menu:
02158                         $langChildren = $dataStructArray['meta']['langChildren'] ? 1 : 0;
02159                         $langDisabled = $dataStructArray['meta']['langDisable'] ? 1 : 0;
02160 
02161                         $editData['meta']['currentLangId']=array();
02162                         $languages = $this->getAvailableLanguages();
02163 
02164                         foreach($languages as $lInfo)   {
02165                                 if ($GLOBALS['BE_USER']->checkLanguageAccess($lInfo['uid']))    {
02166                                         $editData['meta']['currentLangId'][] =  $lInfo['ISOcode'];
02167                                 }
02168                         }
02169                         if (!is_array($editData['meta']['currentLangId']) || !count($editData['meta']['currentLangId']))        {
02170                                 $editData['meta']['currentLangId']=array('DEF');
02171                         }
02172 
02173                         $editData['meta']['currentLangId'] = array_unique($editData['meta']['currentLangId']);
02174 
02175 
02176 //                      if (!$langDisabled && count($languages) > 1)    {
02177 //                              $item.=$this->getSingleField_typeFlex_langMenu($languages, $PA['itemFormElName'].'[meta][currentLangId]', $editData['meta']['currentLangId']).'<br />';
02178 //                      }
02179 
02180                         $PA['_noEditDEF'] = FALSE;
02181                         if ($langChildren || $langDisabled)     {
02182                                 $rotateLang = array('DEF');
02183                         } else {
02184                                 if (!in_array('DEF',$editData['meta']['currentLangId']))        {
02185                                         array_unshift($editData['meta']['currentLangId'],'DEF');
02186                                         $PA['_noEditDEF'] = TRUE;
02187                                 }
02188                                 $rotateLang = $editData['meta']['currentLangId'];
02189                         }
02190 
02191                                 // Tabs sheets
02192                         if (is_array($dataStructArray['sheets']))       {
02193                                 $tabsToTraverse = array_keys($dataStructArray['sheets']);
02194                         } else {
02195                                 $tabsToTraverse = array($sheet);
02196                         }
02197 
02198                         foreach ($rotateLang as $lKey)  {
02199                                 if (!$langChildren && !$langDisabled)   {
02200                                         $item.= '<b>'.$this->getLanguageIcon($table,$row,'v'.$lKey).$lKey.':</b>';
02201                                 }
02202 
02203                                 $tabParts = array();
02204                                 foreach ($tabsToTraverse as $sheet)     {
02205                                         $sheetCfg = $dataStructArray['sheets'][$sheet];
02206                                         list ($dataStruct, $sheet) = t3lib_div::resolveSheetDefInDS($dataStructArray,$sheet);
02207 
02208                                                 // Render sheet:
02209                                         if (is_array($dataStruct['ROOT']) && is_array($dataStruct['ROOT']['el']))               {
02210                                                 $cmdData = t3lib_div::_GP('flexFormsCmdData');
02211                                                 $lang = 'l'.$lKey;      // Default language, other options are "lUK" or whatever country code (independant of system!!!)
02212                                                 $PA['_valLang'] = $langChildren && !$langDisabled ? $editData['meta']['currentLangId'] : 'DEF'; // Default language, other options are "lUK" or whatever country code (independant of system!!!)
02213                                                 $PA['_lang'] = $lang;
02214 
02215                                                         // Render flexform:
02216                                                 $tRows = $this->getSingleField_typeFlex_draw(
02217                                                                         $dataStruct['ROOT']['el'],
02218                                                                         $editData['data'][$sheet][$lang],
02219                                                                         $cmdData['data'][$sheet][$lang],
02220                                                                         $table,
02221                                                                         $field,
02222                                                                         $row,
02223                                                                         $PA,
02224                                                                         '[data]['.$sheet.']['.$lang.']'
02225                                                                 );
02226                                                 $sheetContent= '<table border="0" cellpadding="1" cellspacing="1" class="typo3-TCEforms-flexForm">'.implode('',$tRows).'</table>';
02227 
02228                         #                       $item = '<div style=" position:absolute;">'.$item.'</div>';
02229                                                 //visibility:hidden;
02230                                         } else $sheetContent='Data Structure ERROR: No ROOT element found for sheet "'.$sheet.'".';
02231 
02232                                                 // Add to tab:
02233                                         $tabParts[] = array(
02234                                                 'label' => ($sheetCfg['ROOT']['TCEforms']['sheetTitle'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetTitle']) : $sheet),
02235                                                 'description' => ($sheetCfg['ROOT']['TCEforms']['sheetDescription'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetDescription']) : ''),
02236                                                 'linkTitle' => ($sheetCfg['ROOT']['TCEforms']['sheetShortDescr'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetShortDescr']) : ''),
02237                                                 'content' => $sheetContent
02238                                         );
02239                                 }
02240 
02241                                 if (is_array($dataStructArray['sheets']))       {
02242                                         $item.= $this->getDynTabMenu($tabParts,'TCEFORMS:flexform:'.$PA['itemFormElName'].$PA['_lang']);
02243                                 } else {
02244                                         $item.= $sheetContent;
02245                                 }
02246                         }
02247                 } else $item='Data Structure ERROR: '.$dataStructArray;
02248 
02249                 return $item;
02250         }
02251 
02261         function getSingleField_typeFlex_langMenu($languages,$elName,$selectedLanguage,$multi=1)        {
02262                 $opt=array();
02263                 foreach($languages as $lArr)    {
02264                         $opt[]='<option value="'.htmlspecialchars($lArr['ISOcode']).'"'.(in_array($lArr['ISOcode'],$selectedLanguage)?' selected="selected"':'').'>'.htmlspecialchars($lArr['title']).'</option>';
02265                 }
02266 
02267                 $output = '<select name="'.$elName.'[]"'.($multi ? ' multiple="multiple" size="'.count($languages).'"' : '').'>'.implode('',$opt).'</select>';
02268 
02269                 return $output;
02270         }
02271 
02280         function getSingleField_typeFlex_sheetMenu($sArr,$elName,$sheetKey)     {
02281 
02282                 $tCells =array();
02283                 $pct = round(100/count($sArr));
02284                 foreach($sArr as $sKey => $sheetCfg)    {
02285                         if ($GLOBALS['BE_USER']->jsConfirmation(1))     {
02286                                 $onClick = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){'.$this->elName($elName).".value='".$sKey."'; TBE_EDITOR.submitForm()};";
02287                         } else {
02288                                 $onClick = 'if(TBE_EDITOR.checkSubmit(-1)){ '.$this->elName($elName).".value='".$sKey."'; TBE_EDITOR.submitForm();}";
02289                         }
02290 
02291 
02292                         $tCells[]='<td width="'.$pct.'%" style="'.($sKey==$sheetKey ? 'background-color: #9999cc; font-weight: bold;' : 'background-color: #aaaaaa;').' cursor: hand;" onclick="'.htmlspecialchars($onClick).'" align="center">'.
02293                                         ($sheetCfg['ROOT']['TCEforms']['sheetTitle'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetTitle']) : $sKey).
02294                                         '</td>';
02295                 }
02296 
02297                 return '<table border="0" cellpadding="0" cellspacing="2" class="typo3-TCEforms-flexForm-sheetMenu"><tr>'.implode('',$tCells).'</tr></table>';
02298         }
02299 
02315         function getSingleField_typeFlex_draw($dataStruct,$editData,$cmdData,$table,$field,$row,&$PA,$formPrefix='',$level=0,$tRows=array())    {
02316 
02317                         // Data Structure array must be ... and array of course...
02318                 if (is_array($dataStruct))      {
02319                         foreach($dataStruct as $key => $value)  {
02320                                 if (is_array($value))   {       // The value of each entry must be an array.
02321 
02322                                                 // ********************
02323                                                 // Making the row:
02324                                                 // ********************
02325                                         $rowCells=array();
02326 
02327                                                 // Icon:
02328                                         $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>';;
02329 
02330                                         $rowCells['formEl']='';
02331                                         if ($value['type']=='array')    {
02332                                                 if ($value['section'])  {
02333                                                                 // Render "NEW [container]" selectorbox:
02334                                                         if (is_array($value['el']))     {
02335                                                                 $opt=array();
02336                                                                 $opt[]='<option value=""></option>';
02337                                                                 foreach($value['el'] as $kk => $vv)     {
02338                                                                         $opt[]='<option value="'.$kk.'">'.htmlspecialchars($this->getLL('l_new') . ' "'.$this->sL($value['el'][$kk]['tx_templavoila']['title']).'"').'</option>';
02339                                                                 }
02340                                                                 $rowCells['formEl']='<select name="flexFormsCmdData'.$formPrefix.'['.$key.'][value]">'.implode('',$opt).'</select>';
02341                                                         }
02342 
02343                                                                 // Put row together
02344                                                         $tRows[]='<tr class="bgColor2">
02345                                                                 <td nowrap="nowrap" valign="top">'.$rowCells['title'].'</td>
02346                                                                 <td>'.$rowCells['formEl'].'</td>
02347                                                         </tr>';
02348 
02349                                                         $cc=0;
02350                                                         if (is_array($editData[$key]['el']))    {
02351                                                                 foreach ($editData[$key]['el'] as $k3 => $v3)   {
02352                                                                         $cc=$k3;
02353                                                                         $theType = key($v3);
02354                                                                         $theDat = $v3[$theType];
02355                                                                         $newSectionEl = $value['el'][$theType];
02356                                                                         if (is_array($newSectionEl))    {
02357                                                                                 $tRows = $this->getSingleField_typeFlex_draw(
02358                                                                                         array($theType => $newSectionEl),
02359                                                                                         array($theType => $theDat),
02360                                                                                         $cmdData[$key]['el'][$cc],
02361                                                                                         $table,
02362                                                                                         $field,
02363                                                                                         $row,
02364                                                                                         $PA,
02365                                                                                         $formPrefix.'['.$key.'][el]['.$cc.']',
02366                                                                                         $level+1,
02367                                                                                         $tRows
02368                                                                                 );
02369                                                                         }
02370                                                                 }
02371                                                         }
02372 
02373 
02374 
02375                                                                 // New form?
02376                                                         if ($cmdData[$key]['value'])    {
02377                                                                 $newSectionEl = $value['el'][$cmdData[$key]['value']];
02378                                                                 if (is_array($newSectionEl))    {
02379                                                                         $tRows = $this->getSingleField_typeFlex_draw(
02380                                                                                 array($cmdData[$key]['value'] => $newSectionEl),
02381                                                                                 array(),
02382                                                                                 array(),
02383                                                                                 $table,
02384                                                                                 $field,
02385                                                                                 $row,
02386                                                                                 $PA,
02387                                                                                 $formPrefix.'['.$key.'][el]['.($cc+1).']',
02388                                                                                 $level+1,
02389                                                                                 $tRows
02390                                                                         );
02391                                                                 }
02392                                                         }
02393                                                 } else {
02394                                                         $idTagPrefix = uniqid('id',true); // ID attributes are used for the move and delete checkboxes for referencing to them in the label tag (<label for="the form field id">) that's rendered around the icons
02395 
02396                                                                 // Put row together
02397                                                         $tRows[]='<tr class="bgColor2">
02398                                                                 <td nowrap="nowrap" valign="top">'.
02399                                                                 '<input name="_DELETE_FLEX_FORM'.$PA['itemFormElName'].$formPrefix.'" id="'.$idTagPrefix.'-del" type="checkbox"'.$this->insertDefStyle('check').' value="1" /><label for="'.$idTagPrefix.'-del"><img src="'.$this->backPath.'gfx/garbage.gif" border="0" alt="" /></label>'.
02400                                                                 '<input name="_MOVEUP_FLEX_FORM'.$PA['itemFormElName'].$formPrefix.'" id="'.$idTagPrefix.'-mvup" type="checkbox"'.$this->insertDefStyle('check').' value="1" /><label for="'.$idTagPrefix.'-mvup"><img src="'.$this->backPath.'gfx/button_up.gif" border="0" alt="" /></label>'.
02401                                                                 '<input name="_MOVEDOWN_FLEX_FORM'.$PA['itemFormElName'].$formPrefix.'" id="'.$idTagPrefix.'-mvdown" type="checkbox"'.$this->insertDefStyle('check').' value="1" /><label for="'.$idTagPrefix.'-mvdown"><img src="'.$this->backPath.'gfx/button_down.gif" border="0" alt="" /></label>'.
02402                                                                 $rowCells['title'].'</td>
02403                                                                 <td>'.$rowCells['formEl'].'</td>
02404                                                         </tr>';
02405 
02406                                                         $tRows = $this->getSingleField_typeFlex_draw(
02407                                                                 $value['el'],
02408                                                                 $editData[$key]['el'],
02409                                                                 $cmdData[$key]['el'],
02410                                                                 $table,
02411                                                                 $field,
02412                                                                 $row,
02413                                                                 $PA,
02414                                                                 $formPrefix.'['.$key.'][el]',
02415                                                                 $level+1,
02416                                                                 $tRows
02417                                                         );
02418                                                 }
02419 
02420                                         } elseif (is_array($value['TCEforms']['config'])) {     // Rendering a single form element:
02421 
02422                                                 if (is_array($PA['_valLang']))  {
02423                                                         $rotateLang = $PA['_valLang'];
02424                                                 } else {
02425                                                         $rotateLang = array($PA['_valLang']);
02426                                                 }
02427 
02428                                                 foreach($rotateLang as $vDEFkey)        {
02429                                                         $vDEFkey = 'v'.$vDEFkey;
02430 
02431                                                         if (!$value['TCEforms']['displayCond'] || $this->isDisplayCondition($value['TCEforms']['displayCond'],$editData,$vDEFkey)) {
02432                                                                 $fakePA=array();
02433                                                                 $fakePA['fieldConf']=array(
02434                                                                         'label' => $this->sL(trim($value['TCEforms']['label'])),
02435                                                                         'config' => $value['TCEforms']['config'],
02436                                                                         'defaultExtras' => $value['TCEforms']['defaultExtras'],
02437                                     'onChange' => $value['TCEforms']['onChange']
02438                                                                 );
02439                                                                 if ($PA['_noEditDEF'] && $PA['_lang']==='lDEF') {
02440                                                                         $fakePA['fieldConf']['config'] = array(
02441                                                                                 'type' => 'none',
02442                                                                                 'rows' => 2
02443                                                                         );
02444                                                                 }
02445 
02446                                                                 if (
02447                                     $fakePA['fieldConf']['onChange'] == 'reload' ||
02448                                                                         ($GLOBALS['TCA'][$table]['ctrl']['type'] && !strcmp($key,$GLOBALS['TCA'][$table]['ctrl']['type'])) ||
02449                                                                         ($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'] && t3lib_div::inList($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'],$key))) {
02450                                                                         if ($GLOBALS['BE_USER']->jsConfirmation(1))     {
02451                                                                                 $alertMsgOnChange = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
02452                                                                         } else {
02453                                                                                 $alertMsgOnChange = 'if(TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm();}';
02454                                                                         }
02455                                                                 } else {
02456                                                                         $alertMsgOnChange = '';
02457                                                                 }
02458 
02459                                                                 $fakePA['fieldChangeFunc']=$PA['fieldChangeFunc'];
02460                                                                 if (strlen($alertMsgOnChange)) {
02461                                                                         $fakePA['fieldChangeFunc']['alert']=$alertMsgOnChange;
02462                                                                 }
02463                                                                 $fakePA['onFocus']=$PA['onFocus'];
02464                                                                 $fakePA['label']=$PA['label'];
02465 
02466                                                                 $fakePA['itemFormElName']=$PA['itemFormElName'].$formPrefix.'['.$key.']['.$vDEFkey.']';
02467                                                                 $fakePA['itemFormElName_file']=$PA['itemFormElName_file'].$formPrefix.'['.$key.']['.$vDEFkey.']';
02468 
02469                                                                 if(isset($editData[$key][$vDEFkey])) {
02470                                                                         $fakePA['itemFormElValue']=$editData[$key][$vDEFkey];
02471                                                                 } else {
02472                                                                         $fakePA['itemFormElValue']=$fakePA['fieldConf']['config']['default'];
02473                                                                 }
02474 
02475                                                                 $rowCells['formEl']= $this->getSingleField_SW($table,$field,$row,$fakePA);
02476                                                                 $rowCells['title']= htmlspecialchars($fakePA['fieldConf']['label']);
02477 
02478                                                                 if (!in_array('DEF',$rotateLang))       {
02479                                                                         $defInfo = '<div class="typo3-TCEforms-originalLanguageValue">'.$this->getLanguageIcon($table,$row,0).$this->previewFieldValue($editData[$key]['vDEF'], $fakePA['fieldConf']).'&nbsp;</div>';
02480                                                                 } else {
02481                                                                         $defInfo = '';
02482                                                                 }
02483                                                                 
02484                                                                 if (!$PA['_noEditDEF']) {
02485                                                                         $prLang = $this->getAdditionalPreviewLanguages();
02486                                                                         foreach($prLang as $prL)        {
02487                                                                                 $defInfo.= '<div class="typo3-TCEforms-originalLanguageValue">'.$this->getLanguageIcon($table,$row,'v'.$prL['ISOcode']).$this->previewFieldValue($editData[$key]['v'.$prL['ISOcode']], $fakePA['fieldConf']).'&nbsp;</div>';
02488                                                                         }
02489                                                                 }
02490 
02491                                                                         // Put row together
02492                                                                 $tRows[]='<tr>
02493                                                                         <td nowrap="nowrap" valign="top" class="bgColor5">'.($vDEFkey=='vDEF' ? '' : $this->getLanguageIcon($table,$row,$vDEFkey)).$rowCells['title'].'</td>
02494                                                                         <td class="bgColor4">'.$rowCells['formEl'].$defInfo.'</td>
02495                                                                 </tr>';
02496                                                         }
02497                                                 }
02498                                         }
02499                                 }
02500                         }
02501                 }
02502 
02503                 return $tRows;
02504         }
02505 
02515         function getSingleField_typeUnknown($table,$field,$row,&$PA)    {
02516                 $item='Unknown type: '.$PA['fieldConf']['config']['form_type'].'<br />';
02517 
02518                 return $item;
02519         }
02520 
02530         function getSingleField_typeUser($table,$field,$row,&$PA)       {
02531                 $PA['table']=$table;
02532                 $PA['field']=$field;
02533                 $PA['row']=$row;
02534 
02535                 $PA['pObj']=&$this;
02536 
02537                 return t3lib_div::callUserFunction($PA['fieldConf']['config']['userFunc'],$PA,$this);
02538         }
02539 
02540 
02541 
02542 
02543 
02544 
02545         /************************************************************
02546          *
02547          * Field content processing
02548          *
02549          ************************************************************/
02550 
02559         function formatValue ($config, $itemValue)      {
02560                 $format = trim($config['format']);
02561                 switch($format) {
02562                         case 'date':
02563                                 if ($itemValue) {
02564                                         $option = trim($config['format.']['option']);
02565                                         if ($option)    {
02566                                                 if ($config['format.']['strftime'])     {
02567                                                         $value = strftime($option,$itemValue);
02568                                                 } else {
02569                                                         $value = date($option,$itemValue);
02570                                                 }
02571                                         } else {
02572                                                 $value = date('d-m-Y',$itemValue);
02573                                         }
02574                                 } else {
02575                                         $value = '';
02576                                 }
02577                                 if ($config['format.']['appendAge'])    {
02578                                         $value .= ' ('.t3lib_BEfunc::calcAge((time()-$itemValue), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')).')';
02579                                 }
02580                                 $itemValue = $value;
02581                                 break;
02582                         case 'datetime':        // compatibility with "eval" (type "input")
02583                                 $itemValue = date('H:i d-m-Y',$itemValue);
02584                                 break;
02585                         case 'time':    // compatibility with "eval" (type "input")
02586                                 $itemValue = date('H:i',$itemValue);
02587                                 break;
02588                         case 'timesec': // compatibility with "eval" (type "input")
02589                                 $itemValue = date('H:i:s',$itemValue);
02590                                 break;
02591                         case 'year':    // compatibility with "eval" (type "input")
02592                                 $itemValue = date('Y',$itemValue);
02593                                 break;
02594                         case 'int':
02595                                 $baseArr = array('dec'=>'d','hex'=>'x','HEX'=>'X','oct'=>'o','bin'=>'b');
02596                                 $base = trim($config['format.']['base']);
02597                                 $format = $baseArr[$base] ? $baseArr[$base] : 'd';
02598                                 $itemValue = sprintf('%'.$format,$itemValue);
02599                                 break;
02600                         case 'float':
02601                                 $precision = t3lib_div::intInRange($config['format.']['precision'],1,10,2);
02602                                 $itemValue = sprintf('%.'.$precision.'f',$itemValue);
02603                                 break;
02604                         case 'number':
02605                                 $format = trim($config['format.']['option']);
02606                                 $itemValue = sprintf('%'.$format,$itemValue);
02607                                 break;
02608                         case 'md5':
02609                                 $itemValue = md5($itemValue);
02610                                 break;
02611                         case 'filesize':
02612                                 $value = t3lib_div::formatSize(intval($itemValue));
02613                                 if ($config['format.']['appendByteSize'])       {
02614                                         $value .= ' ('.$itemValue.')';
02615                                 }
02616                                 $itemValue = $value;
02617                                 break;
02618                         case 'user':
02619                                 $func = trim($config['format.']['userFunc']);
02620                                 if ($func)      {
02621                                         $params = array(
02622                                                 'value' => $itemValue,
02623                                                 'args' => $config['format.']['userFunc'],
02624                                                 'config' => $config,
02625                                                 'pObj' => &$this
02626                                         );
02627                                         $itemValue = t3lib_div::callUserFunction($func,$params,$this);
02628                                 }
02629                                 break;
02630                         default:
02631                         break;
02632                 }
02633 
02634                 return $itemValue;
02635         }
02636 
02637 
02638 
02639 
02640 
02641 
02642         /************************************************************
02643          *
02644          * "Configuration" fetching/processing functions
02645          *
02646          ************************************************************/
02647 
02655         function getRTypeNum($table,$row)       {
02656                 global $TCA;
02657                         // If there is a "type" field configured...
02658                 if ($TCA[$table]['ctrl']['type'])       {
02659                         $typeFieldName = $TCA[$table]['ctrl']['type'];
02660                         $typeNum=$row[$typeFieldName];  // Get value of the row from the record which contains the type value.
02661                         if (!strcmp($typeNum,''))       $typeNum=0;                     // If that value is an empty string, set it to "0" (zero)
02662                 } else {
02663                         $typeNum = 0;   // If no "type" field, then set to "0" (zero)
02664                 }
02665 
02666                 $typeNum = (string)$typeNum;            // Force to string. Necessary for eg '-1' to be recognized as a type value.
02667                 if (!$TCA[$table]['types'][$typeNum])   {       // However, if the type "0" is not found in the "types" array, then default to "1" (for historical reasons)
02668                         $typeNum = 1;
02669                 }
02670 
02671                 return $typeNum;
02672         }
02673 
02681         function rearrange($fields)     {
02682                 $fO = array_flip(t3lib_div::trimExplode(',',$this->fieldOrder,1));
02683                 reset($fields);
02684                 $newFields=array();
02685                 while(list($cc,$content)=each($fields)) {
02686                         $cP = t3lib_div::trimExplode(';',$content);
02687                         if (isset($fO[$cP[0]])) {
02688                                 $newFields[$fO[$cP[0]]] = $content;
02689                                 unset($fields[$cc]);
02690                         }
02691                 }
02692                 ksort($newFields);
02693                 $fields=array_merge($newFields,$fields);                // Candidate for t3lib_div::array_merge() if integer-keys will some day make trouble...
02694                 return $fields;
02695         }
02696 
02707         function getExcludeElements($table,$row,$typeNum)       {
02708                 global $TCA;
02709 
02710                         // Init:
02711                 $excludeElements=array();
02712 
02713                         // If a subtype field is defined for the type
02714                 if ($TCA[$table]['types'][$typeNum]['subtype_value_field'])     {
02715                         $sTfield = $TCA[$table]['types'][$typeNum]['subtype_value_field'];
02716                         if (trim($TCA[$table]['types'][$typeNum]['subtypes_excludelist'][$row[$sTfield]]))      {
02717                                 $excludeElements=t3lib_div::trimExplode(',',$TCA[$table]['types'][$typeNum]['subtypes_excludelist'][$row[$sTfield]],1);
02718                         }
02719                 }
02720 
02721                         // If a bitmask-value field has been configured, then find possible fields to exclude based on that:
02722                 if ($TCA[$table]['types'][$typeNum]['bitmask_value_field'])     {
02723                         $sTfield = $TCA[$table]['types'][$typeNum]['bitmask_value_field'];
02724                         $sTValue = t3lib_div::intInRange($row[$sTfield],0);
02725                         if (is_array($TCA[$table]['types'][$typeNum]['bitmask_excludelist_bits']))      {
02726                                 reset($TCA[$table]['types'][$typeNum]['bitmask_excludelist_bits']);
02727                                 while(list($bitKey,$eList)=each($TCA[$table]['types'][$typeNum]['bitmask_excludelist_bits']))   {
02728                                         $bit=substr($bitKey,1);
02729                                         if (t3lib_div::testInt($bit))   {
02730                                                 $bit = t3lib_div::intInRange($bit,0,30);
02731                                                 if (
02732                                                                 (substr($bitKey,0,1)=='-' && !($sTValue&pow(2,$bit))) ||
02733                                                                 (substr($bitKey,0,1)=='+' && ($sTValue&pow(2,$bit)))
02734                                                         )       {
02735                                                         $excludeElements = array_merge($excludeElements,t3lib_div::trimExplode(',',$eList,1));
02736                                                 }
02737                                         }
02738                                 }
02739                         }
02740                 }
02741 
02742                         // Return the array of elements:
02743                 return $excludeElements;
02744         }
02745 
02755         function getFieldsToAdd($table,$row,$typeNum)   {
02756                 global $TCA;
02757 
02758                         // Init:
02759                 $addElements=array();
02760 
02761                         // If a subtype field is defined for the type
02762                 if ($TCA[$table]['types'][$typeNum]['subtype_value_field'])     {
02763                         $sTfield = $TCA[$table]['types'][$typeNum]['subtype_value_field'];
02764                         if (trim($TCA[$table]['types'][$typeNum]['subtypes_addlist'][$row[$sTfield]]))  {
02765                                 $addElements=t3lib_div::trimExplode(',',$TCA[$table]['types'][$typeNum]['subtypes_addlist'][$row[$sTfield]],1);
02766                         }
02767                 }
02768                         // Return the return
02769                 return array($addElements,$sTfield);
02770         }
02771 
02780         function mergeFieldsWithAddedFields($fields,$fieldsToAdd)       {
02781                 if (count($fieldsToAdd[0]))     {
02782                         reset($fields);
02783                         $c=0;
02784                         while(list(,$fieldInfo)=each($fields))  {
02785                                 $parts = explode(';',$fieldInfo);
02786                                 if (!strcmp(trim($parts[0]),$fieldsToAdd[1]))   {
02787                                         array_splice(
02788                                                 $fields,
02789                                                 $c+1,
02790                                                 0,
02791                                                 $fieldsToAdd[0]
02792                                         );
02793                                         break;
02794                                 }
02795                                 $c++;
02796                         }
02797                 }
02798                 return $fields;
02799         }
02800 
02801 
02812         function setTSconfig($table,$row,$field='')     {
02813                 $mainKey = $table.':'.$row['uid'];
02814                 if (!isset($this->cachedTSconfig[$mainKey]))    {
02815                         $this->cachedTSconfig[$mainKey]=t3lib_BEfunc::getTCEFORM_TSconfig($table,$row);
02816                 }
02817                 if ($field)     {
02818                         return $this->cachedTSconfig[$mainKey][$field];
02819                 } else {
02820                         return $this->cachedTSconfig[$mainKey];
02821                 }
02822         }
02823 
02834         function overrideFieldConf($fieldConfig, $TSconfig) {
02835                 if (is_array($TSconfig)) {
02836                         $TSconfig = t3lib_div::removeDotsFromTS($TSconfig);
02837                         $type = $fieldConfig['type'];
02838                         if (is_array($TSconfig['config']) && is_array($this->allowOverrideMatrix[$type])) {
02839                                         // Check if the keys in TSconfig['config'] are allowed to override TCA field config:                    
02840                                 foreach (array_keys($TSconfig['config']) as $key) {
02841                                         if (!in_array($key, $this->allowOverrideMatrix[$type], true)) {
02842                                                 unset($TSconfig['config'][$key]);
02843                                         }
02844                                 }
02845                                         // Override TCA field config by remaining TSconfig['config']:
02846                                 if (count($TSconfig['config'])) {
02847                                         $fieldConfig = array_merge($fieldConfig, $TSconfig['config']);
02848                                 }
02849                         }
02850                 }
02851 
02852                 return $fieldConfig;
02853         }
02854 
02865         function getSpecConfForField($table,$row,$field)        {
02866                         // Finds the current "types" configuration for the table/row:
02867                 $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table,$row);
02868 
02869                         // If this is an array, then traverse it:
02870                 if (is_array($types_fieldConfig))       {
02871                         foreach($types_fieldConfig as $vconf)   {
02872                                         // If the input field name matches one found in the 'types' list, then return the 'special' configuration.
02873                                 if ($vconf['field']==$field)    return $vconf['spec'];
02874                         }
02875                 }
02876         }
02877 
02886         function getSpecConfFromString($extraString, $defaultExtras)    {
02887                 return t3lib_BEfunc::getSpecConfParts($extraString, $defaultExtras);
02888         }
02889 
02890 
02891 
02892 
02893 
02894 
02895 
02896 
02897 
02898 
02899         /************************************************************
02900          *
02901          * Display of localized content etc.
02902          *
02903          ************************************************************/
02904 
02914         function registerDefaultLanguageData($table,$rec)       {
02915                 global $TCA;
02916 
02917                         // Add default language:
02918                 if ($TCA[$table]['ctrl']['languageField']
02919                                 && $rec[$TCA[$table]['ctrl']['languageField']] > 0
02920                                 && $TCA[$table]['ctrl']['transOrigPointerField']
02921                                 && intval($rec[$TCA[$table]['ctrl']['transOrigPointerField']]) > 0)     {
02922 
02923                         $lookUpTable = $TCA[$table]['ctrl']['transOrigPointerTable'] ? $TCA[$table]['ctrl']['transOrigPointerTable'] : $table;
02924 
02925                                 // Get data formatted:
02926                         $this->defaultLanguageData[$table.':'.$rec['uid']] = t3lib_BEfunc::getRecordWSOL($lookUpTable, intval($rec[$TCA[$table]['ctrl']['transOrigPointerField']]));
02927 
02928                                 // Get data for diff:
02929                         if ($TCA[$table]['ctrl']['transOrigDiffSourceField'])   {
02930                                 $this->defaultLanguageData_diff[$table.':'.$rec['uid']] = unserialize($rec[$TCA[$table]['ctrl']['transOrigDiffSourceField']]);
02931                         }
02932 
02933                                 // If there are additional preview languages, load information for them also:
02934                         $prLang = $this->getAdditionalPreviewLanguages();
02935                         foreach($prLang as $prL)        {
02936                                 $t8Tools = t3lib_div::makeInstance('t3lib_transl8tools');
02937                                 $tInfo = $t8Tools->translationInfo($lookUpTable,intval($rec[$TCA[$table]['ctrl']['transOrigPointerField']]),$prL['uid']);
02938                                 if (is_array($tInfo['translations'][$prL['uid']]))      {
02939                                         $this->additionalPreviewLanguageData[$table.':'.$rec['uid']][$prL['uid']] = t3lib_BEfunc::getRecordWSOL($lookUpTable, intval($tInfo['translations'][$prL['uid']]['uid']));
02940                                 }
02941                         }
02942                 }
02943         }
02944 
02956         function getLanguageOverlayRawValue($table, $row, $field, $fieldConf)   {
02957                 global $TCA;
02958 
02959                 $value = $row[$field];
02960 
02961                 if (is_array($this->defaultLanguageData[$table.':'.$row['uid']]))       {
02962 
02963                         if ($fieldConf['l10n_mode']=='exclude'
02964                                         || ($fieldConf['l10n_mode']=='mergeIfNotBlank' && strcmp(trim($this->defaultLanguageData[$table.':'.$row['uid']][$field]),''))) {
02965                                 $value = $this->defaultLanguageData[$table.':'.$row['uid']][$field];
02966                         }
02967 
02968                 }
02969 
02970                 return $value;
02971         }
02972 
02984         function renderDefaultLanguageContent($table,$field,$row,$item) {
02985                 if (is_array($this->defaultLanguageData[$table.':'.$row['uid']]))       {
02986                         $dLVal = t3lib_BEfunc::getProcessedValue($table,$field,$this->defaultLanguageData[$table.':'.$row['uid']][$field],0,1);
02987                         $fCfg = $GLOBALS['TCA'][$table]['columns'][$field];
02988 
02989                         if (strcmp($dLVal,''))  {
02990                                 $item.='<div class="typo3-TCEforms-originalLanguageValue">'.$this->getLanguageIcon($table,$row,0).$this->previewFieldValue($dLVal,$fCfg).'&nbsp;</div>';
02991                         }
02992                         
02993                         $prLang = $this->getAdditionalPreviewLanguages();
02994                         foreach($prLang as $prL)        {
02995                                 $dlVal = t3lib_BEfunc::getProcessedValue($table,$field,$this->additionalPreviewLanguageData[$table.':'.$row['uid']][$prL['uid']][$field],0,1);
02996                                 $item.= '<div class="typo3-TCEforms-originalLanguageValue">'.$this->getLanguageIcon($table,$row,'v'.$prL['ISOcode']).$this->previewFieldValue($dlVal, $fCfg).'&nbsp;</div>';
02997                         }
02998                         
02999                 }
03000 
03001                 return $item;
03002         }
03003 
03015         function renderDefaultLanguageDiff($table,$field,$row,$item)    {
03016                 if (is_array($this->defaultLanguageData_diff[$table.':'.$row['uid']]))  {
03017 
03018                                 // Initialize:
03019                         $dLVal = array(
03020                                 'old' => $this->defaultLanguageData_diff[$table.':'.$row['uid']],
03021                                 'new' => $this->defaultLanguageData[$table.':'.$row['uid']],
03022                         );
03023 
03024                         if (isset($dLVal['old'][$field]))       {       // There must be diff-data:
03025                                 if (strcmp($dLVal['old'][$field],$dLVal['new'][$field]))        {
03026 
03027                                                 // Create diff-result:
03028                                         $t3lib_diff_Obj = t3lib_div::makeInstance('t3lib_diff');
03029                                         $diffres = $t3lib_diff_Obj->makeDiffDisplay(
03030                                                 t3lib_BEfunc::getProcessedValue($table,$field,$dLVal['old'][$field],0,1),
03031                                                 t3lib_BEfunc::getProcessedValue($table,$field,$dLVal['new'][$field],0,1)
03032                                         );
03033 
03034                                         $item.='<div class="typo3-TCEforms-diffBox">'.
03035                                                 '<div class="typo3-TCEforms-diffBox-header">'.htmlspecialchars($this->getLL('l_changeInOrig')).':</div>'.
03036                                                 $diffres.
03037                                         '</div>';
03038                                 }
03039                         }
03040                 }
03041 
03042                 return $item;
03043         }
03044 
03045 
03046 
03047 
03048 
03049 
03050 
03051 
03052 
03053         /************************************************************
03054          *
03055          * Form element helper functions
03056          *
03057          ************************************************************/
03058 
03074         function dbFileIcons($fName,$mode,$allowed,$itemArray,$selector='',$params=array(),$onFocus='',$table='',$field='',$uid='')     {
03075 
03076 
03077                 $disabled = '';
03078                 if($this->renderReadonly || $params['readOnly'])  {
03079                         $disabled = ' disabled="disabled"';
03080                 }
03081 
03082                         // Sets a flag which means some JavaScript is included on the page to support this element.
03083                 $this->printNeededJS['dbFileIcons']=1;
03084 
03085                         // INIT
03086                 $uidList=array();
03087                 $opt=array();
03088                 $itemArrayC=0;
03089 
03090                         // Creating <option> elements:
03091                 if (is_array($itemArray))       {
03092                         $itemArrayC=count($itemArray);
03093                         reset($itemArray);
03094                         switch($mode)   {
03095                                 case 'db':
03096                                         while(list(,$pp)=each($itemArray))      {
03097                                                 $pRec = t3lib_BEfunc::getRecordWSOL($pp['table'],$pp['id']);
03098                                                 if (is_array($pRec))    {
03099                                                         $pTitle = t3lib_BEfunc::getRecordTitle($pp['table'], $pRec, FALSE, TRUE);
03100                                                         $pUid = $pp['table'].'_'.$pp['id'];
03101                                                         $uidList[]=$pUid;
03102                                                         $opt[]='<option value="'.htmlspecialchars($pUid).'">'.htmlspecialchars($pTitle).'</option>';
03103                                                 }
03104                                         }
03105                                 break;
03106                                 case 'file':
03107                                         while(list(,$pp)=each($itemArray))      {
03108                                                 $pParts = explode('|',$pp);
03109                                                 $uidList[]=$pUid=$pTitle = $pParts[0];
03110                                                 $opt[]='<option value="'.htmlspecialchars(rawurldecode($pParts[0])).'">'.htmlspecialchars(rawurldecode($pParts[0])).'</option>';
03111                                         }
03112                                 break;
03113                                 default:
03114                                         while(list(,$pp)=each($itemArray))      {
03115                                                 $pParts = explode('|',$pp, 2);
03116                                                 $uidList[]=$pUid=$pParts[0];
03117                                                 $pTitle = $pParts[1];
03118                                                 $opt[]='<option value="'.htmlspecialchars(rawurldecode($pUid)).'">'.htmlspecialchars(rawurldecode($pTitle)).'</option>';
03119                                         }
03120                                 break;
03121                         }
03122                 }
03123 
03124                         // Create selector box of the options
03125                 $sSize = $params['autoSizeMax'] ? t3lib_div::intInRange($itemArrayC+1,t3lib_div::intInRange($params['size'],1),$params['autoSizeMax']) : $params['size'];
03126                 if (!$selector) {
03127                         $selector = '<select size="'.$sSize.'"'.$this->insertDefStyle('group').' multiple="multiple" name="'.$fName.'_list" '.$onFocus.$params['style'].$disabled.'>'.implode('',$opt).'</select>';
03128                 }
03129 
03130 
03131                 $icons = array(
03132                         'L' => array(),
03133                         'R' => array(),
03134                 );
03135                 if (!$params['readOnly']) {
03136                         if (!$params['noBrowser'])      {
03137                                         // check against inline uniqueness
03138                                 $inlineParent = $this->inline->getStructureLevel(-1);
03139                                 if(is_array($inlineParent) && $inlineParent['uid']) {
03140                                         if ($inlineParent['config']['foreign_table'] == $table && $inlineParent['config']['foreign_unique'] == $field) {
03141                                                 $objectPrefix = $this->inline->inlineNames['object'].'['.$table.']';
03142                                                 $aOnClickInline = $objectPrefix.'|inline.checkUniqueElement|inline.setUniqueElement';
03143                                                 $rOnClickInline = 'inline.revertUnique(\''.$objectPrefix.'\',null,\''.$uid.'\');';
03144                                         }
03145                                 }
03146                                 $aOnClick='setFormValueOpenBrowser(\''.$mode.'\',\''.($fName.'|||'.$allowed.'|'.$aOnClickInline).'\'); return false;';
03147                                 $icons['R'][]='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
03148                                                 '<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'))).' />'.
03149                                                 '</a>';
03150                         }
03151                         if (!$params['dontShowMoveIcons'])      {
03152                                 if ($sSize>=5)  {
03153                                         $icons['L'][]='<a href="#" onclick="setFormValueManipulate(\''.$fName.'\',\'Top\'); return false;">'.
03154                                                         '<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')).' />'.
03155                                                         '</a>';
03156                                 }
03157                                 $icons['L'][]='<a href="#" onclick="setFormValueManipulate(\''.$fName.'\',\'Up\'); return false;">'.
03158                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/up.gif','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib($this->getLL('l_move_up')).' />'.
03159                                                 '</a>';
03160                                 $icons['L'][]='<a href="#" onclick="setFormValueManipulate(\''.$fName.'\',\'Down\'); return false;">'.
03161                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/down.gif','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib($this->getLL('l_move_down')).' />'.
03162                                                 '</a>';
03163                                 if ($sSize>=5)  {
03164                                         $icons['L'][]='<a href="#" onclick="setFormValueManipulate(\''.$fName.'\',\'Bottom\'); return false;">'.
03165                                                         '<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')).' />'.
03166                                                         '</a>';
03167                                 }
03168                         }
03169 
03170                         $clipElements = $this->getClipboardElements($allowed,$mode);
03171                         if (count($clipElements))       {
03172                                 $aOnClick = '';
03173         #                       $counter = 0;
03174                                 foreach($clipElements as $elValue)      {
03175                                         if ($mode=='file')      {
03176                                                 $itemTitle = 'unescape(\''.rawurlencode(basename($elValue)).'\')';
03177                                         } else {        // 'db' mode assumed
03178                                                 list($itemTable,$itemUid) = explode('|', $elValue);
03179                                                 $itemTitle = $GLOBALS['LANG']->JScharCode(t3lib_BEfunc::getRecordTitle($itemTable, t3lib_BEfunc::getRecordWSOL($itemTable,$itemUid)));
03180                                                 $elValue = $itemTable.'_'.$itemUid;
03181                                         }
03182                                         $aOnClick.= 'setFormValueFromBrowseWin(\''.$fName.'\',unescape(\''.rawurlencode(str_replace('%20',' ',$elValue)).'\'),'.$itemTitle.');';
03183 
03184         #                               $counter++;
03185         #                               if ($params['maxitems'] && $counter >= $params['maxitems'])     {       break;  }       // Makes sure that no more than the max items are inserted... for convenience.
03186                                 }
03187                                 $aOnClick.= 'return false;';
03188                                 $icons['R'][]='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
03189                                                 '<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))).' />'.
03190                                                 '</a>';
03191                         }
03192                         $rOnClick = $rOnClickInline.'setFormValueManipulate(\''.$fName.'\',\'Remove\'); return false';
03193                         $icons['L'][]='<a href="#" onclick="'.htmlspecialchars($rOnClick).'">'.
03194                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/group_clear.gif','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib($this->getLL('l_remove_selected')).' />'.
03195                                         '</a>';
03196                 }
03197 
03198                 $str='<table border="0" cellpadding="0" cellspacing="0" width="1">
03199                         '.($params['headers']?'
03200                                 <tr>
03201                                         <td>'.$this->wrapLabels($params['headers']['selector']).'</td>
03202                                         <td></td>
03203                                         <td></td>
03204                                         <td></td>
03205                                         <td>'.($params['thumbnails'] ? $this->wrapLabels($params['headers']['items']) : '').'</td>
03206                                 </tr>':'').
03207                         '
03208                         <tr>
03209                                 <td valign="top">'.
03210                                         $selector.'<br />'.
03211                                         $this->wrapLabels($params['info']).
03212                                 '</td>
03213                                 <td valign="top">'.
03214                                         implode('<br />',$icons['L']).'</td>
03215                                 <td valign="top">'.
03216                                         implode('<br />',$icons['R']).'</td>
03217                                 <td><img src="clear.gif" width="5" height="1" alt="" /></td>
03218                                 <td valign="top">'.
03219                                         $this->wrapLabels($params['thumbnails']).
03220                                 '</td>
03221                         </tr>
03222                 </table>';
03223 
03224                         // Creating the hidden field which contains the actual value as a comma list.
03225                 $str.='<input type="hidden" name="'.$fName.'" value="'.htmlspecialchars(implode(',',$uidList)).'" />';
03226 
03227                 return $str;
03228         }
03229 
03237         function getClipboardElements($allowed,$mode)   {
03238 
03239                 $output = array();
03240 
03241                 if (is_object($this->clipObj))  {
03242                         switch($mode)   {
03243                                 case 'file':
03244                                         $elFromTable = $this->clipObj->elFromTable('_FILE');
03245                                         $allowedExts = t3lib_div::trimExplode(',', $allowed, 1);
03246 
03247                                         if ($allowedExts)       {       // If there are a set of allowed extensions, filter the content:
03248                                                 foreach($elFromTable as $elValue)       {
03249                                                         $pI = pathinfo($elValue);
03250                                                         $ext = strtolower($pI['extension']);
03251                                                         if (in_array($ext, $allowedExts))       {
03252                                                                 $output[] = $elValue;
03253                                                         }
03254                                                 }
03255                                         } else {        // If all is allowed, insert all: (This does NOT respect any disallowed extensions, but those will be filtered away by the backend TCEmain)
03256                                                 $output = $elFromTable;
03257                                         }
03258                                 break;
03259                                 case 'db':
03260                                         $allowedTables = t3lib_div::trimExplode(',', $allowed, 1);
03261                                         if (!strcmp(trim($allowedTables[0]),'*'))       {       // All tables allowed for relation:
03262                                                 $output = $this->clipObj->elFromTable('');
03263                                         } else {        // Only some tables, filter them:
03264                                                 foreach($allowedTables as $tablename)   {
03265                                                         $elFromTable = $this->clipObj->elFromTable($tablename);
03266                                                         $output = array_merge($output,$elFromTable);
03267                                                 }
03268                                         }
03269                                         $output = array_keys($output);
03270                                 break;
03271                         }
03272                 }
03273 
03274                 return $output;
03275         }
03276 
03286         function getClickMenu($str,$table,$uid='')      {
03287                 if ($this->enableClickMenu)     {
03288                         $onClick = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($str,$table,$uid,1,'','+copy,info,edit,view', TRUE);
03289                         return '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.$str.'</a>';
03290                 }
03291         }
03292 
03307         function renderWizards($itemKinds,$wizConf,$table,$row,$field,&$PA,$itemName,$specConf,$RTE=0)  {
03308 
03309                         // Init:
03310                 $fieldChangeFunc = $PA['fieldChangeFunc'];
03311                 $item = $itemKinds[0];
03312                 $outArr = array();
03313                 $colorBoxLinks = array();
03314                 $fName = '['.$table.']['.$row['uid'].']['.$field.']';
03315                 $md5ID = 'ID'.t3lib_div::shortmd5($itemName);
03316                 $listFlag = '_list';
03317 
03318                         // 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":
03319                 if ($PA['fieldConf']['config']['form_type']=='select')  {
03320                         if ($PA['fieldConf']['config']['maxitems']<=1)  {       // Single select situation:
03321                                 $listFlag = '';
03322                         } elseif ($PA['fieldConf']['config']['renderMode']=='singlebox')        {
03323                                 $itemName.='[]';
03324                                 $listFlag = '';
03325                         }
03326                 }
03327 
03328                         // traverse wizards:
03329                 if (is_array($wizConf) && !$this->disableWizards)       {
03330                         foreach($wizConf as $wid => $wConf)     {
03331                                 if (substr($wid,0,1)!='_'
03332                                                 && (!$wConf['enableByTypeConfig'] || @in_array($wid,$specConf['wizards']['parameters']))
03333                                                 && ($RTE || !$wConf['RTEonly'])
03334                                         )       {
03335 
03336                                                 // Title / icon:
03337                                         $iTitle = htmlspecialchars($this->sL($wConf['title']));
03338                                         if ($wConf['icon'])     {
03339                                                 $iDat = $this->getIcon($wConf['icon']);
03340                                                 $icon = '<img src="'.$iDat[0].'" '.$iDat[1][3].' border="0"'.t3lib_BEfunc::titleAltAttrib($iTitle).' />';
03341                                         } else {
03342                                                 $icon = $iTitle;
03343                                         }
03344 
03345                                                 //
03346                                         switch((string)$wConf['type'])  {
03347                                                 case 'userFunc':
03348                                                 case 'script':
03349                                                 case 'popup':
03350                                                 case 'colorbox':
03351                                                         if (!$wConf['notNewRecords'] || t3lib_div::testInt($row['uid']))        {
03352 
03353                                                                         // Setting &P array contents:
03354                                                                 $params = array();
03355                                                                 $params['params'] = $wConf['params'];
03356                                                                 $params['exampleImg'] = $wConf['exampleImg'];
03357                                                                 $params['table'] = $table;
03358                                                                 $params['uid'] = $row['uid'];
03359                                                                 $params['pid'] = $row['pid'];
03360                                                                 $params['field'] = $field;
03361                                                                 $params['md5ID'] = $md5ID;
03362                                                                 $params['returnUrl'] = $this->thisReturnUrl();
03363 
03364                                                                         // Resolving script filename and setting URL.
03365                                                                 if (!strcmp(substr($wConf['script'],0,4), 'EXT:')) {
03366                                                                         $wScript = t3lib_div::getFileAbsFileName($wConf['script']);
03367                                                                         if ($wScript)   {
03368                                                                                 $wScript = '../'.substr($wScript,strlen(PATH_site));
03369                                                                         } else break;
03370                                                                 } else {
03371                                                                         $wScript = $wConf['script'];
03372                                                                 }
03373                                                                 $url = $this->backPath.$wScript.(strstr($wScript,'?') ? '' : '?');
03374 
03375                                                                         // If there is no script and the type is "colorbox", break right away:
03376                                                                 if ((string)$wConf['type']=='colorbox' && !$wConf['script'])    { break; }
03377 
03378                                                                         // If "script" type, create the links around the icon:
03379                                                                 if ((string)$wConf['type']=='script')   {
03380                                                                         $aUrl = $url.t3lib_div::implodeArrayForUrl('',array('P'=>$params));
03381                                                                         $outArr[]='<a href="'.htmlspecialchars($aUrl).'" onclick="'.$this->blur().'return !TBE_EDITOR.isFormChanged();">'.
03382                                                                                 $icon.
03383                                                                                 '</a>';
03384                                                                 } else {
03385 
03386                                                                                 // ... else types "popup", "colorbox" and "userFunc" will need additional parameters:
03387                                                                         $params['formName'] = $this->formName;
03388                                                                         $params['itemName'] = $itemName;
03389                                                                         $params['fieldChangeFunc'] = $fieldChangeFunc;
03390 
03391                                                                         switch((string)$wConf['type'])  {
03392                                                                                 case 'popup':
03393                                                                                 case 'colorbox':
03394                                                                                                 // Current form value is passed as P[currentValue]!
03395                                                                                         $addJS = $wConf['popup_onlyOpenIfSelected']?'if (!TBE_EDITOR.curSelected(\''.$itemName.$listFlag.'\')){alert('.$GLOBALS['LANG']->JScharCode($this->getLL('m_noSelItemForEdit')).'); return false;}':'';
03396                                                                                         $curSelectedValues='+\'&P[currentSelectedValues]=\'+TBE_EDITOR.curSelected(\''.$itemName.$listFlag.'\')';
03397                                                                                         $aOnClick=      $this->blur().
03398                                                                                                                 $addJS.
03399                                                                                                                 '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'].'\');'.
03400                                                                                                                 'vHWin.focus();return false;';
03401                                                                                                 // Setting "colorBoxLinks" - user LATER to wrap around the color box as well:
03402                                                                                         $colorBoxLinks = Array('<a href="#" onclick="'.htmlspecialchars($aOnClick).'">','</a>');
03403                                                                                         if ((string)$wConf['type']=='popup')    {
03404                                                                                                 $outArr[] = $colorBoxLinks[0].$icon.$colorBoxLinks[1];
03405                                                                                         }
03406                                                                                 break;
03407                                                                                 case 'userFunc':
03408                                                                                         $params['item'] = &$item;       // Reference set!
03409                                                                                         $params['icon'] = $icon;
03410                                                                                         $params['iTitle'] = $iTitle;
03411                                                                                         $params['wConf'] = $wConf;
03412                                                                                         $params['row'] = $row;
03413                                                                                         $outArr[] = t3lib_div::callUserFunction($wConf['userFunc'],$params,$this);
03414                                                                                 break;
03415                                                                         }
03416                                                                 }
03417 
03418                                                                         // Hide the real form element?
03419                                                                 if (is_array($wConf['hideParent']) || $wConf['hideParent'])     {
03420                                                                         $item = $itemKinds[1];  // Setting the item to a hidden-field.
03421                                                                         if (is_array($wConf['hideParent']))     {
03422                                                                                 $item.= $this->getSingleField_typeNone_render($wConf['hideParent'], $PA['itemFormElValue']);
03423                                                                         }
03424                                                                 }
03425                                                         }
03426                                                 break;
03427                                                 case 'select':
03428                                                         $fieldValue = array('config' => $wConf);
03429                                                         $TSconfig = $this->setTSconfig($table, $row);
03430                                                         $TSconfig[$field] = $TSconfig[$field]['wizards.'][$wid.'.'];
03431                                                         $selItems = $this->addSelectOptionsToItemArray($this->initItemArray($fieldValue), $fieldValue, $TSconfig, $field);
03432 
03433                                                         $opt = array();
03434                                                         $opt[] = '<option>'.$iTitle.'</option>';
03435                                                         foreach($selItems as $p)        {
03436                                                                 $opt[] = '<option value="'.htmlspecialchars($p[1]).'">'.htmlspecialchars($p[0]).'</option>';
03437                                                         }
03438                                                         if ($wConf['mode']=='append')   {
03439                                                                 $assignValue = $this->elName($itemName).'.value=\'\'+this.options[this.selectedIndex].value+'.$this->elName($itemName).'.value';
03440                                                         } elseif ($wConf['mode']=='prepend')    {
03441                                                                 $assignValue = $this->elName($itemName).'.value+=\'\'+this.options[this.selectedIndex].value';
03442                                                         } else {
03443                                                                 $assignValue = $this->elName($itemName).'.value=this.options[this.selectedIndex].value';
03444                                                         }
03445                                                         $sOnChange = $assignValue.';this.selectedIndex=0;'.implode('',$fieldChangeFunc);
03446                                                         $outArr[] = '<select name="_WIZARD'.$fName.'" onchange="'.htmlspecialchars($sOnChange).'">'.implode('',$opt).'</select>';
03447                                                 break;
03448                                         }
03449 
03450                                                 // Color wizard colorbox:
03451                                         if ((string)$wConf['type']=='colorbox') {
03452                                                 $dim = t3lib_div::intExplode('x',$wConf['dim']);
03453                                                 $dX = t3lib_div::intInRange($dim[0],1,200,20);
03454                                                 $dY = t3lib_div::intInRange($dim[1],1,200,20);
03455                                                 $color = $row[$field] ? ' bgcolor="'.htmlspecialchars($row[$field]).'"' : '';
03456                                                 $outArr[] = '<table border="0" cellpadding="0" cellspacing="0" id="'.$md5ID.'"'.$color.' style="'.htmlspecialchars($wConf['tableStyle']).'">
03457                                                                         <tr>
03458                                                                                 <td>'.
03459                                                                                         $colorBoxLinks[0].
03460                                                                                         '<img src="clear.gif" width="'.$dX.'" height="'.$dY.'"'.t3lib_BEfunc::titleAltAttrib(trim($iTitle.' '.$row[$field])).' border="0" />'.
03461                                                                                         $colorBoxLinks[1].
03462                                                                                         '</td>
03463                                                                         </tr>
03464                                                                 </table>';
03465                                         }
03466                                 }
03467                         }
03468 
03469                                 // For each rendered wizard, put them together around the item.
03470                         if (count($outArr))     {
03471                                 if ($wizConf['_HIDDENFIELD'])   $item = $itemKinds[1];
03472 
03473                                 $outStr = '';
03474                                 $vAlign = $wizConf['_VALIGN'] ? ' valign="'.$wizConf['_VALIGN'].'"' : '';
03475                                 if (count($outArr)>1 || $wizConf['_PADDING'])   {
03476                                         $dist = intval($wizConf['_DISTANCE']);
03477                                         if ($wizConf['_VERTICAL'])      {
03478                                                 $dist = $dist ? '<tr><td><img src="clear.gif" width="1" height="'.$dist.'" alt="" /></td></tr>' : '';
03479                                                 $outStr = '<tr><td>'.implode('</td></tr>'.$dist.'<tr><td>',$outArr).'</td></tr>';
03480                                         } else {
03481                                                 $dist = $dist ? '<td><img src="clear.gif" height="1" width="'.$dist.'" alt="" /></td>' : '';
03482                                                 $outStr = '<tr><td'.$vAlign.'>'.implode('</td>'.$dist.'<td'.$vAlign.'>',$outArr).'</td></tr>';
03483                                         }
03484                                         $outStr = '<table border="0" cellpadding="'.intval($wizConf['_PADDING']).'" cellspacing="0">'.$outStr.'</table>';
03485                                 } else {
03486                                         $outStr = implode('',$outArr);
03487                                 }
03488 
03489                                 if (!strcmp($wizConf['_POSITION'],'left'))      {
03490                                         $outStr = '<tr><td'.$vAlign.'>'.$outStr.'</td><td'.$vAlign.'>'.$item.'</td></tr>';
03491                                 } elseif (!strcmp($wizConf['_POSITION'],'top')) {
03492                                         $outStr = '<tr><td>'.$outStr.'</td></tr><tr><td>'.$item.'</td></tr>';
03493                                 } elseif (!strcmp($wizConf['_POSITION'],'bottom'))      {
03494                                         $outStr = '<tr><td>'.$item.'</td></tr><tr><td>'.$outStr.'</td></tr>';
03495                                 } else {
03496                                         $outStr = '<tr><td'.$vAlign.'>'.$item.'</td><td'.$vAlign.'>'.$outStr.'</td></tr>';
03497                                 }
03498 
03499                                 $item = '<table border="0" cellpadding="0" cellspacing="0">'.$outStr.'</table>';
03500                         }
03501                 }
03502                 return $item;
03503         }
03504 
03511         function getIcon($icon) {
03512                 if (substr($icon,0,4)=='EXT:')  {
03513                         $file = t3lib_div::getFileAbsFileName($icon);
03514                         if ($file)      {
03515                                 $file = substr($file,strlen(PATH_site));
03516                                 $selIconFile = $this->backPath.'../'.$file;
03517                                 $selIconInfo = @getimagesize(PATH_site.$file);
03518                         }
03519                 } elseif (substr($icon,0,3)=='../')     {
03520                         $selIconFile = $this->backPath.t3lib_div::resolveBackPath($icon);
03521                         $selIconInfo = @getimagesize(PATH_site.t3lib_div::resolveBackPath(substr($icon,3)));
03522                 } elseif (substr($icon,0,4)=='ext/' || substr($icon,0,7)=='sysext/') {
03523                         $selIconFile = $this->backPath.$icon;
03524                         $selIconInfo = @getimagesize(PATH_typo3.$icon);
03525                 } else {
03526                         $selIconFile = t3lib_iconWorks::skinImg($this->backPath,'gfx/'.$icon,'',1);
03527                         $selIconInfo = @getimagesize(PATH_typo3.$selIconFile);
03528                 }
03529                 return array($selIconFile,$selIconInfo);
03530         }
03531 
03538         function optionTagStyle($iconString)    {
03539                 if ($iconString)        {
03540                         list($selIconFile,$selIconInfo) = $this->getIcon($iconString);
03541                         $padTop = t3lib_div::intInRange(($selIconInfo[1]-12)/2,0);
03542                         $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;';
03543                         return $styleAttr;
03544                 }
03545         }
03546 
03554         function extractValuesOnlyFromValueLabelList($itemFormElValue)  {
03555                         // Get values of selected items:
03556                 $itemArray = t3lib_div::trimExplode(',',$itemFormElValue,1);
03557                 foreach($itemArray as $tk => $tv) {
03558                         $tvP = explode('|',$tv,2);
03559                         $tvP[0] = rawurldecode($tvP[0]);
03560 
03561                         $itemArray[$tk] = $tvP[0];
03562                 }
03563                 return $itemArray;
03564         }
03565 
03576         function wrapOpenPalette($header,$table,$row,$palette,$retFunc=0)       {
03577                 $fieldL=array();
03578                 if (!is_array($this->palFieldArr[$palette]))    {$this->palFieldArr[$palette]=array();}
03579                 $palFieldN = is_array($this->palFieldArr[$palette]) ? count($this->palFieldArr[$palette]) : 0;
03580                 $palJSFunc = 'TBE_EDITOR.palUrl(\''.($table.':'.$row['uid'].':'.$palette).'\',\''.implode(',',$this->palFieldArr[$palette]).'\','.$palFieldN.',\''.$table.'\',\''.$row['uid'].'\',1);';
03581 
03582                 $aOnClick = $this->blur().substr($palJSFunc,0,-3).'0);return false;';
03583 
03584                 $iconCode = '<a href="#" onclick="'.htmlspecialchars($aOnClick).'" title="'.htmlspecialchars($table).'">'.
03585                                         $header.
03586                                         '</a>';
03587                 return $retFunc ? array($iconCode,$palJSFunc) : $iconCode;
03588         }
03589 
03600         function checkBoxParams($itemName,$thisValue,$c,$iCount,$addFunc='')    {
03601                 $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)).');'.
03602                                         $addFunc;
03603                 $str = ' onclick="'.htmlspecialchars($onClick).'"'.
03604                                 (($thisValue&pow(2,$c))?' checked="checked"':'');
03605                 return $str;
03606         }
03607 
03614         function elName($itemName)      {
03615                 return 'document.'.$this->formName."['".$itemName."']";
03616         }
03617 
03628         function noTitle($str,$wrapParts=array())       {
03629                 return strcmp($str,'') ? $str : $wrapParts[0].'['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title').']'.$wrapParts[1];
03630         }
03631 
03637         function blur() {
03638                 return $GLOBALS['CLIENT']['FORMSTYLE'] ? 'this.blur();':'';
03639         }
03640 
03646         function thisReturnUrl()        {
03647                 return $this->returnUrl ? $this->returnUrl : t3lib_div::linkThisScript();
03648         }
03649 
03659         function getSingleHiddenField($table,$field,$row)       {
03660                 global $TCA;
03661                 $out='';
03662                 t3lib_div::loadTCA($table);
03663                 if ($TCA[$table]['columns'][$field])    {
03664 
03665                         $uid=$row['uid'];
03666                         $itemName=$this->prependFormFieldNames.'['.$table.']['.$uid.']['.$field.']';
03667                         $itemValue=$row[$field];
03668                         $item.='<input type="hidden" name="'.$itemName.'" value="'.htmlspecialchars($itemValue).'" />';
03669                         $out = $item;
03670                 }
03671                 return $out;
03672         }
03673 
03681         function formWidth($size=48,$textarea=0)        {
03682                         // Input or text-field attribute (size or cols)
03683                 if ($this->docLarge)    $size = round($size*$this->form_largeComp);
03684                 $wAttrib = $textarea?'cols':'size';
03685                 if (!$GLOBALS['CLIENT']['FORMSTYLE'])   {       // If not setting the width by style-attribute
03686                         $retVal = ' '.$wAttrib.'="'.$size.'"';
03687                 } else {        // Setting width by style-attribute. 'cols' MUST be avoided with NN6+
03688                         $pixels = ceil($size*$this->form_rowsToStylewidth);
03689                         $theStyle = 'width:'.$pixels.'px;'.$this->defStyle.$this->formElStyle($textarea?'text':'input');
03690                         $retVal = ' style="'.htmlspecialchars($theStyle).'"';
03691 
03692                         $class = $this->formElClass($textarea?'text':'input');
03693                         if ($class)     {
03694                                 $retVal.= ' class="'.htmlspecialchars($class).'"';
03695                         }
03696                 }
03697                 return $retVal;
03698         }
03699 
03708         function formWidthText($size=48,$wrap='')       {
03709                 $wTags = $this->formWidth($size,1);
03710                         // 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...
03711                 if (strtolower(trim($wrap))!='off' && $GLOBALS['CLIENT']['BROWSER']=='net' && $GLOBALS['CLIENT']['VERSION']>=5) {
03712                         $wTags.= ' cols="'.$size.'"';
03713                 }
03714                 return $wTags;
03715         }
03716 
03724         function formElStyle($type)     {
03725                 return $this->formElStyleClassValue($type);
03726         }
03727 
03735         function formElClass($type)     {
03736                 return $this->formElStyleClassValue($type, TRUE);
03737         }
03738 
03746         function formElStyleClassValue($type, $class=FALSE)     {
03747                         // Get value according to field:
03748                 if (isset($this->fieldStyle[$type]))    {
03749                         $style = trim($this->fieldStyle[$type]);
03750                 } else {
03751                         $style = trim($this->fieldStyle['all']);
03752                 }
03753 
03754                         // Check class prefixed:
03755                 if (substr($style,0,6)=='CLASS:')       {
03756                         $out = $class ? trim(substr($style,6)) : '';
03757                 } else {
03758                         $out = !$class ? $style : '';
03759                 }
03760 
03761                 return $out;
03762         }
03763 
03770         function insertDefStyle($type)  {
03771                 $out = '';
03772 
03773                 $style = trim($this->defStyle.$this->formElStyle($type));
03774                 $out.= $style?' style="'.htmlspecialchars($style).'"':'';
03775 
03776                 $class = $this->formElClass($type);
03777                 $out.= $class?' class="'.htmlspecialchars($class).'"':'';
03778 
03779                 return $out;
03780         }
03781 
03789         function getDynTabMenu($parts, $idString) {
03790                 if (is_object($GLOBALS['TBE_TEMPLATE']))        {
03791                         return $GLOBALS['TBE_TEMPLATE']->getDynTabMenu($parts, $idString);
03792                 } else {
03793                         $output = '';
03794                         foreach($parts as $singlePad)   {
03795                                 $output.='
03796                                 <h3>'.htmlspecialchars($singlePad['label']).'</h3>
03797                                 '.($singlePad['description'] ? '<p class="c-descr">'.nl2br(htmlspecialchars($singlePad['description'])).'</p>' : '').'
03798                                 '.$singlePad['content'];
03799                         }
03800 
03801                         return '<div class="typo3-dyntabmenu-divs">'.$output.'</div>';
03802                 }
03803         }
03804 
03805 
03806 
03807 
03808 
03809 
03810 
03811 
03812 
03813 
03814 
03815         /************************************************************
03816          *
03817          * Item-array manipulation functions (check/select/radio)
03818          *
03819          ************************************************************/
03820 
03828         function initItemArray($fieldValue)     {
03829                 $items = array();
03830                 if (is_array($fieldValue['config']['items']))   {
03831                         reset ($fieldValue['config']['items']);
03832                         while (list($itemName,$itemValue) = each($fieldValue['config']['items']))       {
03833                                 $items[] = array($this->sL($itemValue[0]), $itemValue[1], $itemValue[2]);
03834                         }
03835                 }
03836                 return $items;
03837         }
03838 
03846         function addItems($items,$iArray)       {
03847                 global $TCA;
03848                 if (is_array($iArray))  {
03849                         reset($iArray);
03850                         while(list($value,$label)=each($iArray))        {
03851                                 $items[]=array($this->sl($label),$value);
03852                         }
03853                 }
03854                 return $items;
03855         }
03856 
03868         function procItems($items,$iArray,$config,$table,$row,$field)   {
03869                 global $TCA;
03870 
03871                 $params=array();
03872                 $params['items'] = &$items;
03873                 $params['config'] = $config;
03874                 $params['TSconfig'] = $iArray;
03875                 $params['table'] = $table;
03876                 $params['row'] = $row;
03877                 $params['field'] = $field;
03878 
03879                 t3lib_div::callUserFunction($config['itemsProcFunc'],$params,$this);
03880                 return $items;
03881         }
03882 
03892         function addSelectOptionsToItemArray($items,$fieldValue,$TSconfig,$field)       {
03893                 global $TCA;
03894 
03895                         // Values from foreign tables:
03896                 if ($fieldValue['config']['foreign_table'])     {
03897                         $items = $this->foreignTable($items,$fieldValue,$TSconfig,$field);
03898                         if ($fieldValue['config']['neg_foreign_table']) {
03899                                 $items = $this->foreignTable($items,$fieldValue,$TSconfig,$field,1);
03900                         }
03901                 }
03902 
03903                         // Values from a file folder:
03904                 if ($fieldValue['config']['fileFolder'])        {
03905                         $fileFolder = t3lib_div::getFileAbsFileName($fieldValue['config']['fileFolder']);
03906                         if (@is_dir($fileFolder))       {
03907 
03908                                         // Configurations:
03909                                 $extList = $fieldValue['config']['fileFolder_extList'];
03910                                 $recursivityLevels = isset($fieldValue['config']['fileFolder_recursions']) ? t3lib_div::intInRange($fieldValue['config']['fileFolder_recursions'],0,99) : 99;
03911 
03912                                         // Get files:
03913                                 $fileFolder = ereg_replace('\/$','',$fileFolder).'/';
03914                                 $fileArr = t3lib_div::getAllFilesAndFoldersInPath(array(),$fileFolder,$extList,0,$recursivityLevels);
03915                                 $fileArr = t3lib_div::removePrefixPathFromList($fileArr, $fileFolder);
03916 
03917                                 foreach($fileArr as $fileRef)   {
03918                                         $fI = pathinfo($fileRef);
03919                                         $icon = t3lib_div::inList('gif,png,jpeg,jpg', strtolower($fI['extension'])) ? '../'.substr($fileFolder,strlen(PATH_site)).$fileRef : '';
03920                                         $items[] = array(
03921                                                 $fileRef,
03922                                                 $fileRef,
03923                                                 $icon
03924                                         );
03925                                 }
03926                         }
03927                 }
03928 
03929                         // If 'special' is configured:
03930                 if ($fieldValue['config']['special'])   {
03931                         switch ($fieldValue['config']['special'])       {
03932                                 case 'tables':
03933                                         $temp_tc = array_keys($TCA);
03934                                         $descr = '';
03935 
03936                                         foreach($temp_tc as $theTableNames)     {
03937                                                 if (!$TCA[$theTableNames]['ctrl']['adminOnly']) {
03938 
03939                                                                 // Icon:
03940                                                         $icon = '../'.TYPO3_mainDir.t3lib_iconWorks::skinImg($this->backPath,t3lib_iconWorks::getIcon($theTableNames, array()),'',1);
03941 
03942                                                                 // Add description texts:
03943                                                         if ($this->edit_showFieldHelp)  {
03944                                                                 $GLOBALS['LANG']->loadSingleTableDescription($theTableNames);
03945                                                                 $fDat = $GLOBALS['TCA_DESCR'][$theTableNames]['columns'][''];
03946                                                                 $descr = $fDat['description'];
03947                                                         }
03948 
03949                                                                 // Item configuration:
03950                                                         $items[] = array(
03951                                                                 $this->sL($TCA[$theTableNames]['ctrl']['title']),
03952                                                                 $theTableNames,
03953                                                                 $icon,
03954                                                                 $descr
03955                                                         );
03956                                                 }
03957                                         }
03958                                 break;
03959                                 case 'pagetypes':
03960                                         $theTypes = $TCA['pages']['columns']['doktype']['config']['items'];
03961 
03962                                         foreach($theTypes as $theTypeArrays)    {
03963                                                         // Icon:
03964                                                 $icon = $theTypeArrays[1]!='--div--' ? '../'.TYPO3_mainDir.t3lib_iconWorks::skinImg($this->backPath,t3lib_iconWorks::getIcon('pages', array('doktype' => $theTypeArrays[1])),'',1) : '';
03965 
03966                                                         // Item configuration:
03967                                                 $items[] = array(
03968                                                         $this->sL($theTypeArrays[0]),
03969                                                         $theTypeArrays[1],
03970                                                         $icon
03971                                                 );
03972                                         }
03973                                 break;
03974                                 case 'exclude':
03975                                         $theTypes = t3lib_BEfunc::getExcludeFields();
03976                                         $descr = '';
03977 
03978                                         foreach($theTypes as $theTypeArrays)    {
03979                                                 list($theTable, $theField) = explode(':', $theTypeArrays[1]);
03980 
03981                                                         // Add description texts:
03982                                                 if ($this->edit_showFieldHelp)  {
03983                                                         $GLOBALS['LANG']->loadSingleTableDescription($theTable);
03984                                                         $fDat = $GLOBALS['TCA_DESCR'][$theTable]['columns'][$theField];
03985                                                         $descr = $fDat['description'];
03986                                                 }
03987 
03988                                                         // Item configuration:
03989                                                 $items[] = array(
03990                                                         ereg_replace(':$','',$theTypeArrays[0]),
03991                                                         $theTypeArrays[1],
03992                                                         '',
03993                                                         $descr
03994                                                 );
03995                                         }
03996                                 break;
03997                                 case 'explicitValues':
03998                                         $theTypes = t3lib_BEfunc::getExplicitAuthFieldValues();
03999 
04000                                                         // Icons:
04001                                         $icons = array(
04002                                                 'ALLOW' => '../'.TYPO3_mainDir.t3lib_iconWorks::skinImg($this->backPath,'gfx/icon_ok2.gif','',1),
04003                                                 'DENY' => '../'.TYPO3_mainDir.t3lib_iconWorks::skinImg($this->backPath,'gfx/icon_fatalerror.gif','',1),
04004                                         );
04005 
04006                                                 // Traverse types:
04007                                         foreach($theTypes as $tableFieldKey => $theTypeArrays)  {
04008 
04009                                                 if (is_array($theTypeArrays['items']))  {
04010                                                                 // Add header:
04011                                                         $items[] = array(
04012                                                                 $theTypeArrays['tableFieldLabel'],
04013                                                                 '--div--',
04014                                                         );
04015 
04016                                                                 // Traverse options for this field:
04017                                                         foreach($theTypeArrays['items'] as $itemValue => $itemContent)  {
04018                                                                         // Add item to be selected:
04019                                                                 $items[] = array(
04020                                                                         '['.$itemContent[2].'] '.$itemContent[1],
04021                                                                         $tableFieldKey.':'.ereg_replace('[:|,]','',$itemValue).':'.$itemContent[0],
04022                                                                         $icons[$itemContent[0]]
04023                                                                 );
04024                                                         }
04025                                                 }
04026                                         }
04027                                 break;
04028                                 case 'languages':
04029                                         $items = array_merge($items,t3lib_BEfunc::getSystemLanguages());
04030                                 break;
04031                                 case 'custom':
04032                                                 // Initialize:
04033                                         $customOptions = $GLOBALS['TYPO3_CONF_VARS']['BE']['customPermOptions'];
04034                                         if (is_array($customOptions))   {
04035                                                 foreach($customOptions as $coKey => $coValue) {
04036                                                         if (is_array($coValue['items']))        {
04037                                                                         // Add header:
04038                                                                 $items[] = array(
04039                                                                         $GLOBALS['LANG']->sl($coValue['header']),
04040                                                                         '--div--',
04041                                                                 );
04042 
04043                                                                         // Traverse items:
04044                                                                 foreach($coValue['items'] as $itemKey => $itemCfg)      {
04045                                                                                 // Icon:
04046                                                                         if ($itemCfg[1])        {
04047                                                                                 list($icon) = $this->getIcon($itemCfg[1]);
04048                                                                                 if ($icon)      $icon = '../'.TYPO3_mainDir.$icon;
04049                                                                         } else $icon = '';
04050 
04051                                                                                 // Add item to be selected:
04052                                                                         $items[] = array(
04053                                                                                 $GLOBALS['LANG']->sl($itemCfg[0]),
04054                                                                                 $coKey.':'.ereg_replace('[:|,]','',$itemKey),
04055                                                                                 $icon,
04056                                                                                 $GLOBALS['LANG']->sl($itemCfg[2]),
04057                                                                         );
04058                                                                 }
04059                                                         }
04060                                                 }
04061                                         }
04062                                 break;
04063                                 case 'modListGroup':
04064                                 case 'modListUser':
04065                                         $loadModules = t3lib_div::makeInstance('t3lib_loadModules');
04066                                         $loadModules->load($GLOBALS['TBE_MODULES']);
04067 
04068                                         $modList = $fieldValue['config']['special']=='modListUser' ? $loadModules->modListUser : $loadModules->modListGroup;
04069                                         if (is_array($modList)) {
04070                                                 $descr = '';
04071 
04072                                                 foreach($modList as $theMod)    {
04073 
04074                                                                 // Icon:
04075                                                         $icon = $GLOBALS['LANG']->moduleLabels['tabs_images'][$theMod.'_tab'];
04076                                                         if ($icon)      {
04077                                                                 $icon = '../'.substr($icon,strlen(PATH_site));
04078                                                         }
04079 
04080                                                                 // Description texts:
04081                                                         if ($this->edit_showFieldHelp)  {
04082                                                                 $descr = $GLOBALS['LANG']->moduleLabels['labels'][$theMod.'_tablabel'].
04083                                                                                         chr(10).
04084                                                                                         $GLOBALS['LANG']->moduleLabels['labels'][$theMod.'_tabdescr'];
04085                                                         }
04086 
04087                                                                 // Item configuration:
04088                                                         $items[] = array(
04089                                                                 $this->addSelectOptionsToItemArray_makeModuleData($theMod),
04090                                                                 $theMod,
04091                                                                 $icon,
04092                                                                 $descr
04093                                                         );
04094                                                 }
04095                                         }
04096                                 break;
04097                         }
04098                 }
04099 
04100                         // Return the items:
04101                 return $items;
04102         }
04103 
04112         function addSelectOptionsToItemArray_makeModuleData($value)     {
04113                 $label = '';
04114                         // Add label for main module:
04115                 $pp = explode('_',$value);
04116                 if (count($pp)>1)       $label.=$GLOBALS['LANG']->moduleLabels['tabs'][$pp[0].'_tab'].'>';
04117                         // Add modules own label now:
04118                 $label.= $GLOBALS['LANG']->moduleLabels['tabs'][$value.'_tab'];
04119 
04120                 return $label;
04121         }
04122 
04134         function foreignTable($items,$fieldValue,$TSconfig,$field,$pFFlag=0)    {
04135                 global $TCA;
04136 
04137                         // Init:
04138                 $pF=$pFFlag?'neg_':'';
04139                 $f_table = $fieldValue['config'][$pF.'foreign_table'];
04140                 $uidPre = $pFFlag?'-':'';
04141 
04142                         // Get query:
04143                 $res = t3lib_BEfunc::exec_foreign_table_where_query($fieldValue,$field,$TSconfig,$pF);
04144 
04145                         // Perform lookup
04146                 if ($GLOBALS['TYPO3_DB']->sql_error())  {
04147                         echo($GLOBALS['TYPO3_DB']->sql_error()."\n\nThis may indicate a table defined in tables.php is not existing in the database!");
04148                         return array();
04149                 }
04150 
04151                         // Get label prefix.
04152                 $lPrefix = $this->sL($fieldValue['config'][$pF.'foreign_table_prefix']);
04153 
04154                         // Get icon field + path if any:
04155                 $iField = $TCA[$f_table]['ctrl']['selicon_field'];
04156                 $iPath = trim($TCA[$f_table]['ctrl']['selicon_field_path']);
04157 
04158                         // Traverse the selected rows to add them:
04159                 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))      {
04160                         t3lib_BEfunc::workspaceOL($f_table, $row);
04161                                 // Prepare the icon if available:
04162                         if ($iField && $iPath && $row[$iField]) {
04163                                 $iParts = t3lib_div::trimExplode(',',$row[$iField],1);
04164                                 $icon = '../'.$iPath.'/'.trim($iParts[0]);
04165                         } elseif (t3lib_div::inList('singlebox,checkbox',$fieldValue['config']['renderMode'])) {
04166                                 $icon = '../'.TYPO3_mainDir.t3lib_iconWorks::skinImg($this->backPath,t3lib_iconWorks::getIcon($f_table, $row),'',1);
04167                         } else $icon = '';
04168 
04169                                 // Add the item:
04170                         $items[] = array(
04171                                 $lPrefix.strip_tags(t3lib_BEfunc::getRecordTitle($f_table,$row)),
04172                                 $uidPre.$row['uid'],
04173                                 $icon
04174                         );
04175                 }
04176                 return $items;
04177         }
04178 
04179 
04180 
04181 
04182 
04183 
04184 
04185 
04186 
04187 
04188 
04189 
04190 
04191 
04192 
04193 
04194 
04195 
04196 
04197 
04198 
04199 
04200 
04201 
04202 
04203         /********************************************
04204          *
04205          * Template functions
04206          *
04207          ********************************************/
04208 
04215         function setNewBEDesign()       {
04216 
04217                         // Wrapping all table rows for a particular record being edited:
04218                 $this->totalWrap='
04219                 <table border="0" cellspacing="0" cellpadding="0" width="'.($this->docLarge ? 440+150 : 440).'" class="typo3-TCEforms">'.
04220                         '<tr class="bgColor2">
04221                                 <td>&nbsp;</td>
04222                                 <td>###RECORD_ICON### <span class="typo3-TCEforms-recHeader">###TABLE_TITLE###</span> ###ID_NEW_INDICATOR### - ###RECORD_LABEL###</td>
04223                         </tr>'.
04224                         '|'.
04225                         '<tr>
04226                                 <td>&nbsp;</td>
04227                                 <td><img src="clear.gif" width="'.($this->docLarge ? 440+150 : 440).'" height="1" alt="" /></td>
04228                         </tr>
04229                 </table>';
04230 
04231                         // Wrapping a single field:
04232                 $this->fieldTemplate='
04233                         <tr ###BGCOLOR_HEAD######CLASSATTR_2###>
04234                                 <td>###FIELD_HELP_ICON###</td>
04235                                 <td width="99%"><span style="color:###FONTCOLOR_HEAD###;"###CLASSATTR_4###><b>###FIELD_NAME###</b></span>###FIELD_HELP_TEXT###</td>
04236                         </tr>
04237                         <tr ###BGCOLOR######CLASSATTR_1###>
04238                                 <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>
04239                                 <td valign="top">###FIELD_ITEM######FIELD_PAL_LINK_ICON###</td>
04240                         </tr>';
04241 
04242                 $this->palFieldTemplate='
04243                         <tr ###BGCOLOR######CLASSATTR_1###>
04244                                 <td>&nbsp;</td>
04245                                 <td nowrap="nowrap" valign="top">###FIELD_PALETTE###</td>
04246                         </tr>';
04247                 $this->palFieldTemplateHeader='
04248                         <tr ###BGCOLOR_HEAD######CLASSATTR_2###>
04249                                 <td>&nbsp;</td>
04250                                 <td nowrap="nowrap" valign="top"><strong>###FIELD_HEADER###</strong></td>
04251                         </tr>';
04252 
04253                 $this->sectionWrap='
04254                         <tr>
04255                                 <td colspan="2"><img src="clear.gif" width="1" height="###SPACE_BEFORE###" alt="" /></td>
04256                         </tr>
04257                         <tr>
04258                                 <td colspan="2"><table ###TABLE_ATTRIBS###>###CONTENT###</table></td>
04259                         </tr>
04260                         ';
04261         }
04262 
04270         function intoTemplate($inArr,$altTemplate='')   {
04271                                 // Put into template_
04272                 $fieldTemplateParts = explode('###FIELD_',$this->rplColorScheme($altTemplate?$altTemplate:$this->fieldTemplate));
04273                 reset($fieldTemplateParts);
04274                 $out=current($fieldTemplateParts);
04275                 while(list(,$part)=each($fieldTemplateParts))   {
04276                         list($key,$val)=explode('###',$part,2);
04277                         $out.=$inArr[$key];
04278                         $out.=$val;
04279                 }
04280                 return $out;
04281         }
04282 
04294         function addUserTemplateMarkers($marker,$table,$field,$row,&$PA)        {
04295                 return $marker;
04296         }
04297 
04305         function wrapLabels($str)       {
04306                 return $str;
04307         }
04308 
04318         function wrapTotal($c,$rec,$table)      {
04319                 $parts = $this->replaceTableWrap(explode('|',$this->totalWrap,2),$rec,$table);
04320                 return $parts[0].$c.$parts[1].implode('',$this->hiddenFieldAccum);
04321         }
04322 
04331         function replaceTableWrap($arr,$rec,$table)     {
04332                 global $TCA;
04333 
04334                         // Make "new"-label
04335                 if (strstr($rec['uid'],'NEW'))  {
04336                         $newLabel = ' <span class="typo3-TCEforms-newToken">'.
04337                                                 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.new',1).
04338                                                 '</span>';
04339 
04340                         #t3lib_BEfunc::fixVersioningPid($table,$rec);   // Kasper: Should not be used here because NEW records are not offline workspace versions...
04341                         $truePid = t3lib_BEfunc::getTSconfig_pidValue($table,$rec['uid'],$rec['pid']);
04342                         $prec = t3lib_BEfunc::getRecordWSOL('pages',$truePid,'title');
04343                         $rLabel = '<em>[PID: '.$truePid.'] '.htmlspecialchars(trim(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle('pages',$prec),40))).'</em>';
04344                 } else {
04345                         $newLabel = ' <span class="typo3-TCEforms-recUid">['.$rec['uid'].']</span>';
04346                         $rLabel  = htmlspecialchars(trim(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table,$rec),40)));
04347                 }
04348 
04349                 foreach ($arr as $k => $v)      {
04350                                 // Make substitutions:
04351                         $arr[$k] = str_replace('###ID_NEW_INDICATOR###', $newLabel, $arr[$k]);
04352                         $arr[$k] = str_replace('###RECORD_LABEL###',$rLabel,$arr[$k]);
04353                         $arr[$k] = str_replace('###TABLE_TITLE###',htmlspecialchars($this->sL($TCA[$table]['ctrl']['title'])),$arr[$k]);
04354 
04355                         $titleA=t3lib_BEfunc::titleAltAttrib($this->getRecordPath($table,$rec));
04356                         $arr[$k]=str_replace('###RECORD_ICON###',t3lib_iconWorks::getIconImage($table,$rec,$this->backPath,'class="absmiddle"'.$titleA),$arr[$k]);
04357                 }
04358                 return $arr;
04359         }
04360 
04368         function wrapBorder(&$out_array,&$out_pointer)  {
04369                 if ($this->sectionWrap && $out_array[$out_pointer])     {
04370                         $tableAttribs='';
04371                         $tableAttribs.= $this->borderStyle[0] ? ' style="'.htmlspecialchars($this->borderStyle[0]).'"':'';
04372                         $tableAttribs.= $this->borderStyle[2] ? ' background="'.htmlspecialchars($this->backPath.$this->borderStyle[2]).'"':'';
04373                         $tableAttribs.= $this->borderStyle[3] ? ' class="'.htmlspecialchars($this->borderStyle[3]).'"':'';
04374                         if ($tableAttribs)      {
04375                                 $tableAttribs='border="0" cellspacing="0" cellpadding="0" width="100%"'.$tableAttribs;
04376                                 $out_array[$out_pointer] = str_replace('###CONTENT###',$out_array[$out_pointer],
04377                                         str_replace('###TABLE_ATTRIBS###',$tableAttribs,
04378                                                 str_replace('###SPACE_BEFORE###',intval($this->borderStyle[1]),$this->sectionWrap)));
04379                         }
04380                         $out_pointer++;
04381                 }
04382         }
04383 
04390         function rplColorScheme($inTemplate)    {
04391                         // Colors:
04392                 $inTemplate = str_replace('###BGCOLOR###',$this->colorScheme[0]?' bgcolor="'.$this->colorScheme[0].'"':'',$inTemplate);
04393                 $inTemplate = str_replace('###BGCOLOR_HEAD###',$this->colorScheme[1]?' bgcolor="'.$this->colorScheme[1].'"':'',$inTemplate);
04394                 $inTemplate = str_replace('###FONTCOLOR_HEAD###',$this->colorScheme[3],$inTemplate);
04395 
04396                         // Classes:
04397                 $inTemplate = str_replace('###CLASSATTR_1###',$this->classScheme[0]?' class="'.$this->classScheme[0].'"':'',$inTemplate);
04398                 $inTemplate = str_replace('###CLASSATTR_2###',$this->classScheme[1]?' class="'.$this->classScheme[1].'"':'',$inTemplate);
04399                 $inTemplate = str_replace('###CLASSATTR_4###',$this->classScheme[3]?' class="'.$this->classScheme[3].'"':'',$inTemplate);
04400 
04401                 return $inTemplate;
04402         }
04403 
04410         function getDivider()   {
04411                 //return "<hr />";
04412         }
04413 
04420         function printPalette($palArr)  {
04421 
04422                         // Init color/class attributes:
04423                 $ccAttr2 = $this->colorScheme[2] ? ' bgcolor="'.$this->colorScheme[2].'"' : '';
04424                 $ccAttr2.= $this->classScheme[2] ? ' class="'.$this->classScheme[2].'"' : '';
04425                 $ccAttr4 = $this->colorScheme[4] ? ' style="color:'.$this->colorScheme[4].'"' : '';
04426                 $ccAttr4.= $this->classScheme[4] ? ' class="'.$this->classScheme[4].'"' : '';
04427 
04428                         // Traverse palette fields and render them into table rows:
04429                 foreach($palArr as $content)    {
04430                         $hRow[]='<td'.$ccAttr2.'>&nbsp;</td>
04431                                         <td nowrap="nowrap"'.$ccAttr2.'>'.
04432                                                 '<span'.$ccAttr4.'>'.
04433                                                         $content['NAME'].
04434                                                 '</span>'.
04435                                         '</td>';
04436                         $iRow[]='<td valign="top">'.
04437                                                 '<img name="req_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="10" height="10" vspace="4" alt="" />'.
04438                                                 '<img name="cm_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="7" height="10" vspace="4" alt="" />'.
04439                                         '</td>
04440                                         <td nowrap="nowrap" valign="top">'.
04441                                                 $content['ITEM'].
04442                                                 $content['HELP_ICON'].
04443                                         '</td>';
04444                 }
04445 
04446                         // Final wrapping into the table:
04447                 $out='<table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-palette">
04448                         <tr>
04449                                 <td><img src="clear.gif" width="'.intval($this->paletteMargin).'" height="1" alt="" /></td>'.
04450                                         implode('
04451                                 ',$hRow).'
04452                         </tr>
04453                         <tr>
04454                                 <td></td>'.
04455                                         implode('
04456                                 ',$iRow).'
04457                         </tr>
04458                 </table>';
04459 
04460                 return $out;
04461         }
04462 
04471         function helpTextIcon($table,$field,$force=0)   {
04472                 if ($this->globalShowHelp && $GLOBALS['TCA_DESCR'][$table]['columns'][$field] && (($this->edit_showFieldHelp=='icon'&&!$this->doLoadTableDescr($table)) || $force))     {
04473                         $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;';
04474                         return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
04475                                         '<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="" />'.
04476                                         '</a>';
04477                 } else {
04478                                 // Detects fields with no CSH and outputs dummy line to insert into CSH locallang file:
04479                         #debug(array("'".$field.".description' => '[FILL IN] ".$table."->".$field."',"),$table);
04480                         return '<span class="nbsp">&nbsp;</span>';
04481                 }
04482         }
04483 
04491         function helpText($table,$field)        {
04492                 if ($this->globalShowHelp && $GLOBALS['TCA_DESCR'][$table]['columns'][$field] && ($this->edit_showFieldHelp=='text' || $this->doLoadTableDescr($table)))        {
04493                         $fDat = $GLOBALS['TCA_DESCR'][$table]['columns'][$field];
04494                         return '<table border="0" cellpadding="2" cellspacing="0" width="90%"><tr><td valign="top" width="14">'.
04495                                         $this->helpTextIcon(
04496                                                 $table,
04497                                                 $field,
04498                                                 $fDat['details']||$fDat['syntax']||$fDat['image_descr']||$fDat['image']||$fDat['seeAlso']
04499                                         ).
04500                                         '</td><td valign="top"><span class="typo3-TCEforms-helpText">'.
04501                                         $GLOBALS['LANG']->hscAndCharConv(strip_tags($fDat['description']),1).
04502                                         '</span></td></tr></table>';
04503                 }
04504         }
04505 
04512         function setColorScheme($scheme)        {
04513                 $this->colorScheme = $this->defColorScheme;
04514                 $this->classScheme = $this->defClassScheme;
04515 
04516                 $parts = t3lib_div::trimExplode(',',$scheme);
04517                 foreach($parts as $key => $col) {
04518                                 // Split for color|class:
04519                         list($color,$class) = t3lib_div::trimExplode('|',$col);
04520 
04521                                 // Handle color values:
04522                         if ($color)     $this->colorScheme[$key] = $color;
04523                         if ($color=='-')        $this->colorScheme[$key] = '';
04524 
04525                                 // Handle class values:
04526                         if ($class)     $this->classScheme[$key] = $class;
04527                         if ($class=='-')        $this->classScheme[$key] = '';
04528                 }
04529         }
04530 
04536         function resetSchemes() {
04537                 $this->setColorScheme($GLOBALS['TBE_STYLES']['colorschemes'][0]);
04538                 $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][0];
04539                 $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][0];
04540         }
04541 
04547         function storeSchemes() {
04548                 $this->savedSchemes['classScheme'] = $this->classScheme;
04549                 $this->savedSchemes['colorScheme'] = $this->colorScheme;
04550                 $this->savedSchemes['fieldStyle'] = $this->fieldStyle;
04551                 $this->savedSchemes['borderStyle'] = $this->borderStyle;
04552         }
04553 
04559         function restoreSchemes()       {
04560                 $this->classScheme = $this->savedSchemes['classScheme'];
04561                 $this->colorScheme = $this->savedSchemes['colorScheme'];
04562                 $this->fieldStyle = $this->savedSchemes['fieldStyle'];
04563                 $this->borderStyle = $this->savedSchemes['borderStyle'];
04564         }
04565 
04566 
04567 
04568 
04569 
04570 
04571 
04572 
04573 
04574 
04575 
04576 
04577 
04578         /********************************************
04579          *
04580          * JavaScript related functions
04581          *
04582          ********************************************/
04583 
04589         function JStop()        {
04590 
04591                 $out = '';
04592 
04593                         // Additional top HTML:
04594                 if (count($this->additionalCode_pre))   {
04595                         $out.= implode('
04596 
04597                                 <!-- NEXT: -->
04598                         ',$this->additionalCode_pre);
04599                 }
04600 
04601                         // Additional top JavaScript
04602                 if (count($this->additionalJS_pre))     {
04603                         $out.='
04604 
04605 
04606                 <!--
04607                         JavaScript in top of page (before form):
04608                 -->
04609 
04610                 <script type="text/javascript">
04611                         /*<![CDATA[*/
04612 
04613                         '.implode('
04614 
04615                                 // NEXT:
04616                         ',$this->additionalJS_pre).'
04617 
04618                         /*]]>*/
04619                 </script>
04620                         ';
04621                 }
04622 
04623                         // Return result:
04624                 return $out;
04625         }
04626 
04641         function JSbottom($formname='forms[0]', $update = false)        {
04642                 $jsFile = array();
04643                 $elements = array();
04644 
04645                         // required:
04646                 foreach ($this->requiredFields as $itemImgName => $itemName) {
04647                         if (preg_match('/^(.+)\[((\w|\d|_)+)\]$/', $itemName, $match)) {
04648                                 $record = $match[1];
04649                                 $field = $match[2];
04650                                 $elements[$record][$field]['required'] = 1;
04651                                 $elements[$record][$field]['requiredImg'] = $itemImgName;
04652                         }
04653                 }
04654                         // range:
04655                 foreach ($this->requiredElements as $itemName => $range) {
04656                         if (preg_match('/^(.+)\[((\w|\d|_)+)\]$/', $itemName, $match)) {
04657                                 $record = $match[1];
04658                                 $field = $match[2];
04659                                 $elements[$record][$field]['range'] = array($range[0], $range[1]);
04660                                 $elements[$record][$field]['rangeImg'] = $range['imgName'];
04661                         }
04662                 }
04663 
04664                 $this->TBE_EDITOR_fieldChanged_func='TBE_EDITOR.fieldChanged_fName(fName,formObj[fName+"_list"]);';
04665 
04666                 if (!$update) {
04667                         if ($this->loadMD5_JS) {
04668                                 $jsFile[] =     '<script type="text/javascript" src="'.$this->backPath.'md5.js"></script>';
04669                         }
04670 
04671                         $jsFile[] = '<script type="text/javascript" src="'.$this->backPath.'contrib/prototype/prototype.js"></script>';
04672                         $jsFile[] =     '<script type="text/javascript" src="'.$this->backPath.'../t3lib/jsfunc.evalfield.js"></script>';
04673                         $jsFile[] =     '<script type="text/javascript" src="'.$this->backPath.'jsfunc.tbe_editor.js"></script>';
04674 
04675                                 // if IRRE fields were processed, add the JavaScript functions:
04676                         if ($this->inline->inlineCount) {
04677                                 $jsFile[] = '<script src="'.$this->backPath.'contrib/scriptaculous/scriptaculous.js" type="text/javascript"></script>';
04678                                 $jsFile[] = '<script src="'.$this->backPath.'../t3lib/jsfunc.inline.js" type="text/javascript"></script>';
04679                                 $out .= '
04680                                 inline.setPrependFormFieldNames("'.$this->inline->prependNaming.'");
04681                                 inline.setNoTitleString("'.addslashes(t3lib_BEfunc::getNoRecordTitle(true)).'");
04682                                 ';
04683                         }
04684 
04685                         $out .= '
04686                         TBE_EDITOR.images.req.src = "'.t3lib_iconWorks::skinImg($this->backPath,'gfx/required_h.gif','',1).'";
04687                         TBE_EDITOR.images.cm.src = "'.t3lib_iconWorks::skinImg($this->backPath,'gfx/content_client.gif','',1).'";
04688                         TBE_EDITOR.images.sel.src = "'.t3lib_iconWorks::skinImg($this->backPath,'gfx/content_selected.gif','',1).'";
04689                         TBE_EDITOR.images.clear.src = "'.$this->backPath.'clear.gif";
04690 
04691                         TBE_EDITOR.auth_timeout_field = '.intval($GLOBALS['BE_USER']->auth_timeout_field).';
04692                         TBE_EDITOR.formname = "'.$formname.'";
04693                         TBE_EDITOR.formnameUENC = "'.rawurlencode($formname).'";
04694                         TBE_EDITOR.backPath = "'.addslashes($this->backPath).'";
04695                         TBE_EDITOR.prependFormFieldNames = "'.$this->prependFormFieldNames.'";
04696                         TBE_EDITOR.prependFormFieldNamesUENC = "'.rawurlencode($this->prependFormFieldNames).'";
04697                         TBE_EDITOR.prependFormFieldNamesCnt = '.substr_count($this->prependFormFieldNames,'[').';
04698                         TBE_EDITOR.isPalettedoc = '.($this->isPalettedoc ? addslashes($this->isPalettedoc) : 'null').';
04699                         TBE_EDITOR.doSaveFieldName = "'.($this->doSaveFieldName ? addslashes($this->doSaveFieldName) : '').'";
04700                         TBE_EDITOR.labels.fieldsChanged = '.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.fieldsChanged')).';
04701                         TBE_EDITOR.labels.fieldsMissing = '.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.fieldsMissing')).';
04702                         TBE_EDITOR.labels.refresh_login = '.$GLOBALS['LANG']->JScharCode($this->getLL('m_refresh_login')).';
04703                         TBE_EDITOR.labels.onChangeAlert = '.$GLOBALS['LANG']->JScharCode($this->getLL('m_onChangeAlert')).';
04704                         evalFunc.USmode = '.($GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat']?'1':'0').';
04705                         ';
04706                 }
04707 
04708                         // add JS required for inline fields
04709                 if (count($this->inline->inlineData)) {
04710                         $out .= '
04711                         inline.addToDataArray('.$this->inline->getJSON($this->inline->inlineData).');
04712                         ';
04713                 }
04714                         // elements which are required or have a range definition:
04715                 if (count($elements)) {
04716                         $out .= '
04717                         TBE_EDITOR.addElements('.$this->inline->getJSON($elements).');
04718                         TBE_EDITOR.initRequired()
04719                         ';
04720                 }
04721                         // $this->additionalJS_post:
04722                 if ($this->additionalJS_submit) {
04723                         $additionalJS_submit = implode('', $this->additionalJS_submit);
04724                         $additionalJS_submit = str_replace("\r", '', $additionalJS_submit);
04725                         $additionalJS_submit = str_replace("\n", '', $additionalJS_submit);
04726                         $out .= '
04727                         TBE_EDITOR.addActionChecks("submit", "'.addslashes($additionalJS_submit).'");
04728                         ';
04729                 }
04730 
04731                 $out .= chr(10).implode(chr(10),$this->additionalJS_post).chr(10).$this->extJSCODE;
04732                 $out .= '
04733                         TBE_EDITOR.loginRefreshed();
04734                 ';
04735 
04736                         // Regular direct output:
04737                 if (!$update) {
04738                         $spacer = chr(10).chr(9);
04739                         $out  = $spacer.implode($spacer, $jsFile).t3lib_div::wrapJS($out);
04740                 }
04741 
04742                 return $out;
04743         }
04744 
04751         function dbFileCon($formObj='document.forms[0]')        {
04752                         // @TODO: Export this to an own file, it is more static than dynamic JavaScript -- olly
04753                 $str='
04754 
04755                         // ***************
04756                         // Used to connect the db/file browser with this document and the formfields on it!
04757                         // ***************
04758 
04759                         var browserWin="";
04760 
04761                         function setFormValueOpenBrowser(mode,params) { //
04762                                 var url = "'.$this->backPath.'browser.php?mode="+mode+"&bparams="+params;
04763 
04764                                 browserWin = window.open(url,"Typo3WinBrowser","height=350,width="+(mode=="db"?650:600)+",status=0,menubar=0,resizable=1,scrollbars=1");
04765                                 browserWin.focus();
04766                         }
04767                         function setFormValueFromBrowseWin(fName,value,label,exclusiveValues)   {       //
04768                                 var formObj = setFormValue_getFObj(fName)
04769                                 if (formObj && value!="--div--")        {
04770                                         fObj = formObj[fName+"_list"];
04771                                         var len = fObj.length;
04772                                                 // Clear elements if exclusive values are found
04773                                         if (exclusiveValues)    {
04774                                                 var m = new RegExp("(^|,)"+value+"($|,)");
04775                                                 if (exclusiveValues.match(m))   {
04776                                                                 // the new value is exclusive
04777                                                         for (a=len-1;a>=0;a--)  fObj[a] = null;
04778                                                         len = 0;
04779                                                 } else if (len == 1)    {
04780                                                         m = new RegExp("(^|,)"+fObj.options[0].value+"($|,)");
04781                                                         if (exclusiveValues.match(m))   {
04782                                                                         // the old value is exclusive
04783                                                                 fObj[0] = null;
04784                                                                 len = 0;
04785                                                         }
04786                                                 }
04787                                         }
04788                                                 // Inserting element
04789                                         var setOK = 1;
04790                                         if (!formObj[fName+"_mul"] || formObj[fName+"_mul"].value==0)   {
04791                                                 for (a=0;a<len;a++)     {
04792                                                         if (fObj.options[a].value==value)       {
04793                                                                 setOK = 0;
04794                                                         }
04795                                                 }
04796                                         }
04797                                         if (setOK)      {
04798                                                 fObj.length++;
04799                                                 fObj.options[len].value = value;
04800                                                 fObj.options[len].text = unescape(label);
04801 
04802                                                         // Traversing list and set the hidden-field
04803                                                 setHiddenFromList(fObj,formObj[fName]);
04804                                                 '.$this->TBE_EDITOR_fieldChanged_func.'
04805                                         }
04806                                 }
04807                         }
04808                         function setHiddenFromList(fObjSel,fObjHid)     {       //
04809                                 l=fObjSel.length;
04810                                 fObjHid.value="";
04811                                 for (a=0;a<l;a++)       {
04812                                         fObjHid.value+=fObjSel.options[a].value+",";
04813                                 }
04814                         }
04815                         function setFormValueManipulate(fName,type)     {       //
04816                                 var formObj = setFormValue_getFObj(fName)
04817                                 if (formObj)    {
04818                                         var localArray_V = new Array();
04819                                         var localArray_L = new Array();
04820                                         var localArray_S = new Array();
04821                                         var fObjSel = formObj[fName+"_list"];
04822                                         var l=fObjSel.length;
04823                                         var c=0;
04824                                         if (type=="Remove" || type=="Top" || type=="Bottom")    {
04825                                                 if (type=="Top")        {
04826                                                         for (a=0;a<l;a++)       {
04827                                                                 if (fObjSel.options[a].selected==1)     {
04828                                                                         localArray_V[c]=fObjSel.options[a].value;
04829                                                                         localArray_L[c]=fObjSel.options[a].text;
04830                                                                         localArray_S[c]=1;
04831                                                                         c++;
04832                                                                 }
04833                                                         }
04834                                                 }
04835                                                 for (a=0;a<l;a++)       {
04836                                                         if (fObjSel.options[a].selected!=1)     {
04837                                                                 localArray_V[c]=fObjSel.options[a].value;
04838                                                                 localArray_L[c]=fObjSel.options[a].text;
04839                                                                 localArray_S[c]=0;
04840                                                                 c++;
04841                                                         }
04842                                                 }
04843                                                 if (type=="Bottom")     {
04844                                                         for (a=0;a<l;a++)       {
04845                                                                 if (fObjSel.options[a].selected==1)     {
04846                                                                         localArray_V[c]=fObjSel.options[a].value;
04847                                                                         localArray_L[c]=fObjSel.options[a].text;
04848                                                                         localArray_S[c]=1;
04849                                                                         c++;
04850                                                                 }
04851                                                         }
04852                                                 }
04853                                         }
04854                                         if (type=="Down")       {
04855                                                 var tC = 0;
04856                                                 var tA = new Array();
04857 
04858                                                 for (a=0;a<l;a++)       {
04859                                                         if (fObjSel.options[a].selected!=1)     {
04860                                                                         // Add non-selected element:
04861                                                                 localArray_V[c]=fObjSel.options[a].value;
04862                                                                 localArray_L[c]=fObjSel.options[a].text;
04863                                                                 localArray_S[c]=0;
04864                                                                 c++;
04865 
04866                                                                         // Transfer any accumulated and reset:
04867                                                                 if (tA.length > 0)      {
04868                                                                         for (aa=0;aa<tA.length;aa++)    {
04869                                                                                 localArray_V[c]=fObjSel.options[tA[aa]].value;
04870                                                                                 localArray_L[c]=fObjSel.options[tA[aa]].text;
04871                                                                                 localArray_S[c]=1;
04872                                                                                 c++;
04873                                                                         }
04874 
04875                                                                         var tC = 0;
04876                                                                         var tA = new Array();
04877                                                                 }
04878                                                         } else {
04879                                                                 tA[tC] = a;
04880                                                                 tC++;
04881                                                         }
04882                                                 }
04883                                                         // Transfer any remaining:
04884                                                 if (tA.length > 0)      {
04885                                                         for (aa=0;aa<tA.length;aa++)    {
04886                                                                 localArray_V[c]=fObjSel.options[tA[aa]].value;
04887                                                                 localArray_L[c]=fObjSel.options[tA[aa]].text;
04888                                                                 localArray_S[c]=1;
04889                                                                 c++;
04890                                                         }
04891                                                 }
04892                                         }
04893                                         if (type=="Up") {
04894                                                 var tC = 0;
04895                                                 var tA = new Array();
04896                                                 var c = l-1;
04897 
04898                                                 for (a=l-1;a>=0;a--)    {
04899                                                         if (fObjSel.options[a].selected!=1)     {
04900 
04901                                                                         // Add non-selected element:
04902                                                                 localArray_V[c]=fObjSel.options[a].value;
04903                                                                 localArray_L[c]=fObjSel.options[a].text;
04904                                                                 localArray_S[c]=0;
04905                                                                 c--;
04906 
04907                                                                         // Transfer any accumulated and reset:
04908                                                                 if (tA.length > 0)      {
04909                                                                         for (aa=0;aa<tA.length;aa++)    {
04910                                                                                 localArray_V[c]=fObjSel.options[tA[aa]].value;
04911                                                                                 localArray_L[c]=fObjSel.options[tA[aa]].text;
04912                                                                                 localArray_S[c]=1;
04913                                                                                 c--;
04914                                                                         }
04915 
04916                                                                         var tC = 0;
04917                                                                         var tA = new Array();
04918                                                                 }
04919                                                         } else {
04920                                                                 tA[tC] = a;
04921                                                                 tC++;
04922                                                         }
04923                                                 }
04924                                                         // Transfer any remaining:
04925                                                 if (tA.length > 0)      {
04926                                                         for (aa=0;aa<tA.length;aa++)    {
04927                                                                 localArray_V[c]=fObjSel.options[tA[aa]].value;
04928                                                                 localArray_L[c]=fObjSel.options[tA[aa]].text;
04929                                                                 localArray_S[c]=1;
04930                                                                 c--;
04931                                                         }
04932                                                 }
04933                                                 c=l;    // Restore length value in "c"
04934                                         }
04935 
04936                                                 // Transfer items in temporary storage to list object:
04937                                         fObjSel.length = c;
04938                                         for (a=0;a<c;a++)       {
04939                                                 fObjSel.options[a].value = localArray_V[a];
04940                                                 fObjSel.options[a].text = localArray_L[a];
04941                                                 fObjSel.options[a].selected = localArray_S[a];
04942                                         }
04943                                         setHiddenFromList(fObjSel,formObj[fName]);
04944 
04945                                         '.$this->TBE_EDITOR_fieldChanged_func.'
04946                                 }
04947                         }
04948                         function setFormValue_getFObj(fName)    {       //
04949                                 var formObj = '.$formObj.';
04950                                 if (formObj)    {
04951                                         if (formObj[fName] && formObj[fName+"_list"] && formObj[fName+"_list"].type=="select-multiple") {
04952                                                 return formObj;
04953                                         } else {
04954                                                 alert("Formfields missing:\n fName: "+formObj[fName]+"\n fName_list:"+formObj[fName+"_list"]+"\n type:"+formObj[fName+"_list"].type+"\n fName:"+fName);
04955                                         }
04956                                 }
04957                                 return "";
04958                         }
04959 
04960                         // END: dbFileCon parts.
04961                 ';
04962                 return $str;
04963         }
04964 
04970         function printNeededJSFunctions()       {
04971                         // JS evaluation:
04972                 $out = $this->JSbottom($this->formName);
04973                         //
04974                 if ($this->printNeededJS['dbFileIcons'])        {
04975                         $out.= '
04976 
04977 
04978 
04979                         <!--
04980                                 JavaScript after the form has been drawn:
04981                         -->
04982 
04983                         <script type="text/javascript">
04984                                 /*<![CDATA[*/
04985                         '.$this->dbFileCon('document.'.$this->formName).'
04986                                 /*]]>*/
04987                         </script>';
04988                 }
04989                 return $out;
04990         }
04991 
04997         function printNeededJSFunctions_top()   {
04998                         // JS evaluation:
04999                 $out = $this->JStop($this->formName);
05000                 return $out;
05001         }
05002 
05003 
05004 
05005 
05006 
05007 
05008 
05009 
05010 
05011 
05012 
05013 
05014 
05015 
05016 
05017 
05018 
05019 
05020 
05021 
05022 
05023 
05024 
05025 
05026 
05027 
05028 
05029 
05030 
05031         /********************************************
05032          *
05033          * Various helper functions
05034          *
05035          ********************************************/
05036 
05037 
05045         function getDefaultRecord($table,$pid=0)        {
05046                 global $TCA;
05047                 if ($TCA[$table])       {
05048                         t3lib_div::loadTCA($table);
05049                         $row = array();
05050 
05051                         if ($pid<0 && $TCA[$table]['ctrl']['useColumnsForDefaultValues'])       {
05052                                         // Fetches the previous record:
05053                                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'uid='.abs($pid).t3lib_BEfunc::deleteClause($table));
05054                                 if ($drow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))        {
05055                                                 // Gets the list of fields to copy from the previous record.
05056                                         $fArr = explode(',',$TCA[$table]['ctrl']['useColumnsForDefaultValues']);
05057                                         foreach($fArr as $theF) {
05058                                                 if ($TCA[$table]['columns'][$theF])     {
05059                                                         $row[$theF] = $drow[$theF];
05060                                                 }
05061                                         }
05062                                 }
05063                                 $GLOBALS['TYPO3_DB']->sql_free_result($res);
05064                         }
05065 
05066                         foreach($TCA[$table]['columns'] as $field => $info)     {
05067                                 if (isset($info['config']['default']))  {
05068                                         $row[$field] = $info['config']['default'];
05069                                 }
05070                         }
05071 
05072                         return $row;
05073                 }
05074         }
05075 
05084         function getRecordPath($table,$rec)     {
05085                 t3lib_BEfunc::fixVersioningPid($table,$rec);
05086                 list($tscPID,$thePidValue)=$this->getTSCpid($table,$rec['uid'],$rec['pid']);
05087                 if ($thePidValue>=0)    {
05088                         return t3lib_BEfunc::getRecordPath($tscPID,$this->readPerms(),15);
05089                 }
05090         }
05091 
05098         function readPerms()    {
05099                 if (!$this->perms_clause_set)   {
05100                         $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
05101                         $this->perms_clause_set=1;
05102                 }
05103                 return $this->perms_clause;
05104         }
05105 
05112         function sL($str)       {
05113                 return $GLOBALS['LANG']->sL($str);
05114         }
05115 
05125         function getLL($str)    {
05126                 $content = '';
05127 
05128                 switch(substr($str,0,2))        {
05129                         case 'l_':
05130                                 $content = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.'.substr($str,2));
05131                         break;
05132                         case 'm_':
05133                                 $content = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.'.substr($str,2));
05134                         break;
05135                 }
05136                 return $content;
05137         }
05138 
05146         function isPalettesCollapsed($table,$palette)   {
05147                 global $TCA;
05148 
05149                 if ($TCA[$table]['ctrl']['canNotCollapse']) return 0;
05150                 if (is_array($TCA[$table]['palettes'][$palette]) && $TCA[$table]['palettes'][$palette]['canNotCollapse'])       return 0;
05151                 return $this->palettesCollapsed;
05152         }
05153 
05162         function isDisplayCondition($displayCond,$row,$ffValueKey='')   {
05163                 $output = FALSE;
05164 
05165                 $parts = explode(':',$displayCond);
05166                 switch((string)$parts[0])       {       // Type of condition:
05167                         case 'FIELD':
05168                                 $theFieldValue = $ffValueKey ? $row[$parts[1]][$ffValueKey] : $row[$parts[1]];
05169 
05170                                 switch((string)$parts[2])       {
05171                                         case 'REQ':
05172                                                 if (strtolower($parts[3])=='true')      {
05173                                                         $output = $theFieldValue ? TRUE : FALSE;
05174                                                 } elseif (strtolower($parts[3])=='false') {
05175                                                         $output = !$theFieldValue ? TRUE : FALSE;
05176                                                 }
05177                                         break;
05178                                         case '>':
05179                                                 $output = $theFieldValue > $parts[3];
05180                                         break;
05181                                         case '<':
05182                                                 $output = $theFieldValue < $parts[3];
05183                                         break;
05184                                         case '>=':
05185                                                 $output = $theFieldValue >= $parts[3];
05186                                         break;
05187                                         case '<=':
05188                                                 $output = $theFieldValue <= $parts[3];
05189                                         break;
05190                                         case '-':
05191                                         case '!-':
05192                                                 $cmpParts = explode('-',$parts[3]);
05193                                                 $output = $theFieldValue >= $cmpParts[0] && $theFieldValue <= $cmpParts[1];
05194                                                 if ($parts[2]{0}=='!')  $output = !$output;
05195                                         break;
05196                                         case 'IN':
05197                                         case '!IN':
05198                                                 $output = t3lib_div::inList($parts[3],$theFieldValue);
05199                                                 if ($parts[2]{0}=='!')  $output = !$output;
05200                                         break;
05201                                         case '=':
05202                                         case '!=':
05203                                                 $output = t3lib_div::inList($parts[3],$theFieldValue);
05204                                                 if ($parts[2]{0}=='!')  $output = !$output;
05205                                         break;
05206                                 }
05207                         break;
05208                         case 'EXT':
05209                                 switch((string)$parts[2])       {
05210                                         case 'LOADED':
05211                                                 if (strtolower($parts[3])=='true')      {
05212                                                         $output = t3lib_extMgm::isLoaded($parts[1]) ? TRUE : FALSE;
05213                                                 } elseif (strtolower($parts[3])=='false') {
05214                                                         $output = !t3lib_extMgm::isLoaded($parts[1]) ? TRUE : FALSE;
05215                                                 }
05216                                         break;
05217                                 }
05218                         break;
05219                         case 'REC':
05220                                 switch((string)$parts[1])       {
05221                                         case 'NEW':
05222                                                 if (strtolower($parts[2])=='true')      {
05223                                                         $output = !(intval($row['uid']) > 0) ? TRUE : FALSE;
05224                                                 } elseif (strtolower($parts[2])=='false') {
05225                                                         $output = (intval($row['uid']) > 0) ? TRUE : FALSE;
05226                                                 }
05227                                         break;
05228                                 }
05229                         break;
05230                         case 'HIDE_L10N_SIBLINGS':
05231                                 if ($ffValueKey==='vDEF')       {
05232                                         $output = TRUE;
05233                                 } elseif ($parts[1]==='except_admin' && $GLOBALS['BE_USER']->isAdmin()) {
05234                                         $output = TRUE;
05235                                 }
05236                         break;
05237                         case 'HIDE_FOR_NON_ADMINS':
05238                                 $output = $GLOBALS['BE_USER']->isAdmin() ? TRUE : FALSE;
05239                         break;
05240                         case 'VERSION':
05241                                 switch((string)$parts[1])       {
05242                                         case 'IS':
05243                                                 if (strtolower($parts[2])=='true')      {
05244                                                         $output = intval($row['pid'])==-1 ? TRUE : FALSE;
05245                                                 } elseif (strtolower($parts[2])=='false') {
05246                                                         $output = !(intval($row['pid'])==-1) ? TRUE : FALSE;
05247                                                 }
05248                                         break;
05249                                 }
05250                         break;
05251                 }
05252 
05253                 return $output;
05254         }
05255 
05266         function getTSCpid($table,$uid,$pid)    {
05267                 $key = $table.':'.$uid.':'.$pid;
05268                 if (!isset($this->cache_getTSCpid[$key]))       {
05269                         $this->cache_getTSCpid[$key] = t3lib_BEfunc::getTSCpid($table,$uid,$pid);
05270                 }
05271                 return $this->cache_getTSCpid[$key];
05272         }
05273 
05280         function doLoadTableDescr($table)       {
05281                 global $TCA;
05282                 return $TCA[$table]['interface']['always_description'];
05283         }
05284 
05292         function getAvailableLanguages($onlyIsoCoded=1,$setDefault=1)   {
05293                 $isL = t3lib_extMgm::isLoaded('static_info_tables');
05294 
05295                         // Find all language records in the system:
05296                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('static_lang_isocode,title,uid', 'sys_language', 'pid=0 AND hidden=0'.t3lib_BEfunc::deleteClause('sys_language'), '', 'title');
05297 
05298                         // Traverse them:
05299                 $output=array();
05300                 if ($setDefault)        {
05301                         $output[0]=array(
05302                                 'uid' => 0,
05303                                 'title' => 'Default language',
05304                                 'ISOcode' => 'DEF'
05305                         );
05306                 }
05307                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
05308                         $output[$row['uid']]=$row;
05309 
05310                         if ($isL && $row['static_lang_isocode'])        {
05311                                 $rr = t3lib_BEfunc::getRecord('static_languages',$row['static_lang_isocode'],'lg_iso_2');
05312                                 if ($rr['lg_iso_2'])    $output[$row['uid']]['ISOcode']=$rr['lg_iso_2'];
05313                         }
05314 
05315                         if ($onlyIsoCoded && !$output[$row['uid']]['ISOcode'])  unset($output[$row['uid']]);
05316                 }
05317                 return $output;
05318         }
05319         
05328         function getLanguageIcon($table,$row,$sys_language_uid) {
05329                 global $TCA,$LANG;
05330 
05331                 $mainKey = $table.':'.$row['uid'];
05332 
05333                 if (!isset($this->cachedLanguageFlag[$mainKey]))        {
05334                         t3lib_BEfunc::fixVersioningPid($table,$row);
05335                         list($tscPID,$thePidValue) = $this->getTSCpid($table,$row['uid'],$row['pid']);
05336 
05337                         $t8Tools = t3lib_div::makeInstance('t3lib_transl8tools');
05338                         $this->cachedLanguageFlag[$mainKey] = $t8Tools->getSystemLanguages($tscPID, $this->backPath);
05339                 }
05340 
05341                         // Convert sys_language_uid to sys_language_uid if input was in fact a string (ISO code expected then)
05342                 if (!t3lib_div::testInt($sys_language_uid))     {
05343                         foreach($this->cachedLanguageFlag[$mainKey] as $rUid => $cD)    {
05344                                 if ('v'.$cD['ISOcode']===$sys_language_uid)     {
05345                                         $sys_language_uid = $rUid;
05346                                 }
05347                         }
05348                 }
05349 
05350                 return ($this->cachedLanguageFlag[$mainKey][$sys_language_uid]['flagIcon'] ? '<img src="'.$this->cachedLanguageFlag[$mainKey][$sys_language_uid]['flagIcon'].'" class="absmiddle" alt="" />' : ($this->cachedLanguageFlag[$mainKey][$sys_language_uid]['title'] ? '['.$this->cachedLanguageFlag[$mainKey][$sys_language_uid]['title'].']' : '')).'&nbsp;';
05351         }
05352 
05360         function previewFieldValue($value, $config)     {
05361                 if ($config['config']['type']==='group' && $config['config']['internal_type'] === 'file')       {
05362                         $show_thumbs = TRUE;
05363                         $table = 'tt_content';
05364 
05365                                 // Making the array of file items:
05366                         $itemArray = t3lib_div::trimExplode(',',$value,1);
05367 
05368                                 // Showing thumbnails:
05369                         $thumbsnail = '';
05370                         if ($show_thumbs)       {
05371                                 $imgs = array();
05372                                 foreach($itemArray as $imgRead) {
05373                                         $imgP = explode('|',$imgRead);
05374                                         $imgPath = rawurldecode($imgP[0]);
05375 
05376                                         $rowCopy = array();
05377                                         $rowCopy[$field] = $imgPath;
05378 
05379                                                 // Icon + clickmenu:
05380                                         $absFilePath = t3lib_div::getFileAbsFileName($config['config']['uploadfolder'].'/'.$imgPath);
05381 
05382                                         $fI = pathinfo($imgPath);
05383                                         $fileIcon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
05384                                         $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="" />';
05385 
05386                                         $imgs[] = '<span class="nobr">'.t3lib_BEfunc::thumbCode($rowCopy,$table,$field,$this->backPath,'thumbs.php',$config['config']['uploadfolder'],0,' align="middle"').
05387                                                                 ($absFilePath ? $this->getClickMenu($fileIcon, $absFilePath) : $fileIcon).
05388                                                                 $imgPath.
05389                                                                 '</span>';
05390                                 }
05391                                 $thumbsnail = implode('<br />',$imgs);
05392                         }
05393 
05394                         return $thumbsnail;
05395                 } else {
05396                         return nl2br(htmlspecialchars($value));
05397                 }
05398         }
05399 
05405         function getAdditionalPreviewLanguages()        {
05406                 if (!isset($this->cachedAdditionalPreviewLanguages))    {
05407                         if ($GLOBALS['BE_USER']->getTSConfigVal('options.additionalPreviewLanguages'))  {
05408                                 $uids = t3lib_div::intExplode(',',$GLOBALS['BE_USER']->getTSConfigVal('options.additionalPreviewLanguages'));
05409                                 foreach($uids as $uid)  {
05410                                         if ($sys_language_rec = t3lib_BEfunc::getRecord('sys_language',$uid))   {
05411                                                 $this->cachedAdditionalPreviewLanguages[$uid] = array('uid' => $uid);
05412 
05413                                                 if ($sys_language_rec['static_lang_isocode'] && t3lib_extMgm::isLoaded('static_info_tables'))   {
05414                                                         $staticLangRow = t3lib_BEfunc::getRecord('static_languages',$sys_language_rec['static_lang_isocode'],'lg_iso_2');
05415                                                         if ($staticLangRow['lg_iso_2']) {
05416                                                                 $this->cachedAdditionalPreviewLanguages[$uid]['uid'] = $uid;
05417                                                                 $this->cachedAdditionalPreviewLanguages[$uid]['ISOcode'] = $staticLangRow['lg_iso_2'];
05418                                                         }
05419                                                 }
05420                                         }
05421                                 }
05422                         } else {
05423                                         // None:
05424                                 $this->cachedAdditionalPreviewLanguages = array();
05425                         }
05426                 }
05427                 return $this->cachedAdditionalPreviewLanguages;
05428         }
05429         
05437         function getDynTabLevelState($appendString = '') {
05438                 $levels = array();
05439                 foreach ($this->dynTabLevelStack as $tabIdent => $divId) {
05440                         $levels[] = $tabIdent.'-'.$divId.$appendString;
05441                 }
05442                 return implode(',', $levels);
05443         }
05444 }
05445 
05446 
05447 
05448 
05449 
05450 
05451 
05452 
05453 
05459 class t3lib_TCEforms_FE extends t3lib_TCEforms {
05460 
05467         function wrapLabels($str)       {
05468                 return '<font face="verdana" size="1" color="black">'.$str.'</font>';
05469         }
05470 
05477         function printPalette($palArr)  {
05478                 $out='';
05479                 reset($palArr);
05480                 $bgColor=' bgcolor="#D6DAD0"';
05481                 while(list(,$content)=each($palArr))    {
05482                         $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>';
05483                         $iRow[]='<td valign="top">'.
05484                                                 '<img name="req_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="10" height="10" alt="" />'.
05485                                                 '<img name="cm_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="7" height="10" alt="" />'.
05486                                                 '</td><td nowrap="nowrap" valign="top">'.$content['ITEM'].$content['HELP_ICON'].'</td>';
05487                 }
05488                 $out='<table border="0" cellpadding="0" cellspacing="0">
05489                         <tr><td><img src="clear.gif" width="'.intval($this->paletteMargin).'" height="1" alt="" /></td>'.implode('',$hRow).'</tr>
05490                         <tr><td></td>'.implode('',$iRow).'</tr>
05491                 </table>';
05492 
05493                 return $out;
05494         }
05495 
05502         function setFancyDesign()       {
05503                 $this->fieldTemplate='
05504         <tr>
05505                 <td nowrap="nowrap" bgcolor="#F6F2E6">###FIELD_HELP_ICON###<font face="verdana" size="1" color="black"><b>###FIELD_NAME###</b></font>###FIELD_HELP_TEXT###</td>
05506         </tr>
05507         <tr>
05508                 <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>
05509         </tr>   ';
05510 
05511                 $this->totalWrap='<table border="0" cellpadding="1" cellspacing="0" bgcolor="black"><tr><td><table border="0" cellpadding="2" cellspacing="0">|</table></td></tr></table>';
05512 
05513                 $this->palFieldTemplate='
05514         <tr>
05515                 <td nowrap="nowrap" bgcolor="#ABBBB4"><font face="verdana" size="1" color="black">###FIELD_PALETTE###</font></td>
05516         </tr>   ';
05517                 $this->palFieldTemplateHeader='
05518         <tr>
05519                 <td nowrap="nowrap" bgcolor="#F6F2E6"><font face="verdana" size="1" color="black"><b>###FIELD_HEADER###</b></font></td>
05520         </tr>   ';
05521         }
05522 }
05523 
05524 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tceforms.php'])  {
05525         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tceforms.php']);
05526 }
05527 ?>


Généré par Les experts TYPO3 avec  doxygen 1.4.6