/src/typo3_src-4.1.2/t3lib/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 $dynNestedStack = array();                          // holds the path an element is nested in (e.g. required for RTEhtmlarea)
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                                                 // Explode the field list and possibly rearrange the order of the fields, if configured for
00497                                         $fields = t3lib_div::trimExplode(',',$itemList,1);
00498                                         if ($this->fieldOrder)  {
00499                                                 $fields = $this->rearrange($fields);
00500                                         }
00501 
00502                                                 // Get excluded fields, added fiels and put it together:
00503                                         $excludeElements = $this->excludeElements = $this->getExcludeElements($table,$row,$typeNum);
00504                                         $fields = $this->mergeFieldsWithAddedFields($fields,$this->getFieldsToAdd($table,$row,$typeNum));
00505 
00506                                                 // If TCEforms will render a tab menu in the next step, push the name to the tab stack:
00507                                         if (strstr($itemList, '--div--') !== false && $this->enableTabMenu && $TCA[$table]['ctrl']['dividers2tabs']) {
00508                                                 $tabIdentString = 'TCEforms:'.$table.':'.$row['uid'];
00509                                                 $tabIdentStringMD5 = $GLOBALS['TBE_TEMPLATE']->getDynTabMenuId('TCEforms:'.$table.':'.$row['uid']);
00510                                                         // Remember that were currently working on the general tab:
00511                                                 if (isset($fields[0]) && strpos($fields[0], '--div--') !== 0) {
00512                                                         $this->pushToDynNestedStack('tab', $tabIdentStringMD5.'-1');
00513                                                 }
00514                                         }
00515 
00516                                                 // Traverse the fields to render:
00517                                         $cc=0;
00518                                         foreach($fields as $fieldInfo)  {
00519                                                         // Exploding subparts of the field configuration:
00520                                                 $parts = explode(';',$fieldInfo);
00521 
00522                                                         // Getting the style information out:
00523                                                 $color_style_parts = t3lib_div::trimExplode('-',$parts[4]);
00524                                                 if (strcmp($color_style_parts[0],''))   {
00525                                                         $this->setColorScheme($GLOBALS['TBE_STYLES']['colorschemes'][intval($color_style_parts[0])]);
00526                                                 }
00527                                                 if (strcmp($color_style_parts[1],''))   {
00528                                                         $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][intval($color_style_parts[1])];
00529                                                         if (!isset($this->fieldStyle))  $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][0];
00530                                                 }
00531                                                 if (strcmp($color_style_parts[2],''))   {
00532                                                         $this->wrapBorder($out_array[$out_sheet],$out_pointer);
00533                                                         $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][intval($color_style_parts[2])];
00534                                                         if (!isset($this->borderStyle)) $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][0];
00535                                                 }
00536 
00537                                                         // Render the field:
00538                                                 $theField = $parts[0];
00539                                                 if (!in_array($theField,$excludeElements))      {
00540                                                         if ($TCA[$table]['columns'][$theField]) {
00541                                                                 $sFieldPal='';
00542 
00543                                                                 if ($parts[2] && !isset($this->palettesRendered[$this->renderDepth][$table][$parts[2]]))        {
00544                                                                         $sFieldPal=$this->getPaletteFields($table,$row,$parts[2]);
00545                                                                         $this->palettesRendered[$this->renderDepth][$table][$parts[2]] = 1;
00546                                                                 }
00547                                                                 $sField = $this->getSingleField($table,$theField,$row,$parts[1],0,$parts[3],$parts[2]);
00548                                                                 if ($sField)    { $sField.= $sFieldPal; }
00549 
00550                                                                 $out_array[$out_sheet][$out_pointer].= $sField;
00551                                                         } elseif ($theField=='--div--') {
00552                                                                 if ($cc>0)      {
00553                                                                         $out_array[$out_sheet][$out_pointer].=$this->getDivider();
00554 
00555                                                                         if ($this->enableTabMenu && $TCA[$table]['ctrl']['dividers2tabs'])      {
00556                                                                                 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
00557                                                                                         // Remove last tab entry from the dynNestedStack:
00558                                                                                 $out_sheet++;
00559                                                                                         // Remove the previous sheet from stack (if any):
00560                                                                                 $this->popFromDynNestedStack('tab', $tabIdentStringMD5.'-'.($out_sheet));
00561                                                                                         // Remember on which sheet we're currently working:
00562                                                                                 $this->pushToDynNestedStack('tab', $tabIdentStringMD5.'-'.($out_sheet+1));
00563                                                                                 $out_array[$out_sheet] = array();
00564                                                                                 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
00565                                                                         }
00566                                                                 } else {        // Setting alternative title for "General" tab if "--div--" is the very first element.
00567                                                                         $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
00568                                                                                 // Only add the first tab to the dynNestedStack if there are more tabs:
00569                                                                         if (strpos($itemList, '--div--', strlen($fieldInfo))) {
00570                                                                                 $this->pushToDynNestedStack('tab', $tabIdentStringMD5.'-1');
00571                                                                         }
00572                                                                 }
00573                                                         } elseif($theField=='--palette--')      {
00574                                                                 if ($parts[2] && !isset($this->palettesRendered[$this->renderDepth][$table][$parts[2]]))        {
00575                                                                                 // render a 'header' if not collapsed
00576                                                                         if ($TCA[$table]['palettes'][$parts[2]]['canNotCollapse'] AND $parts[1]) {
00577                                                                                 $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$parts[2],$this->sL($parts[1]));
00578                                                                         } else {
00579                                                                                 $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$parts[2],'','',$this->sL($parts[1]));
00580                                                                         }
00581                                                                         $this->palettesRendered[$this->renderDepth][$table][$parts[2]] = 1;
00582                                                                 }
00583                                                         }
00584                                                 }
00585 
00586                                                 $cc++;
00587                                         }
00588                                 }
00589                         }
00590                 }
00591 
00592                         // Hook: getMainFields_postProcess (requested by Thomas Hempel for use with the "dynaflex" extension)
00593                 foreach ($this->hookObjectsMainFields as $hookObj)      {
00594                         if (method_exists($hookObj,'getMainFields_postProcess'))        {
00595                                 $hookObj->getMainFields_postProcess($table,$row,$this);
00596                         }
00597                 }
00598 
00599                         // Wrapping a border around it all:
00600                 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
00601 
00602                         // Resetting styles:
00603                 $this->resetSchemes();
00604 
00605                         // Rendering Main palettes, if any
00606                 $mParr = t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['mainpalette']);
00607                 $i = 0;
00608                 if (count($mParr))      {
00609                         foreach ($mParr as $mP) {
00610                                 if (!isset($this->palettesRendered[$this->renderDepth][$table][$mP]))   {
00611                                         $temp_palettesCollapsed=$this->palettesCollapsed;
00612                                         $this->palettesCollapsed=0;
00613                                         $label = ($i==0?$this->getLL('l_generalOptions'):$this->getLL('l_generalOptions_more'));
00614                                         $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$mP,$label);
00615                                         $this->palettesCollapsed=$temp_palettesCollapsed;
00616                                         $this->palettesRendered[$this->renderDepth][$table][$mP] = 1;
00617                                 }
00618                                 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
00619                                 $i++;
00620                                 if ($this->renderDepth) {
00621                                         $this->renderDepth--;
00622                                 }
00623                         }
00624                 }
00625 
00626                         // Return the imploded $out_array:
00627                 if ($out_sheet>0)       {       // There were --div-- dividers around...
00628 
00629                                 // Create parts array for the tab menu:
00630                         $parts = array();
00631                         foreach ($out_array as $idx => $sheetContent)   {
00632                                 $parts[] = array(
00633                                         'label' => $out_array_meta[$idx]['title'],
00634                                         'content' => '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.
00635                                                         implode('',$sheetContent).
00636                                                 '</table>'
00637                                 );
00638                         }
00639 
00640                                 // Unset the current level of tab menus:
00641                         $this->popFromDynNestedStack('tab', $tabIdentStringMD5.'-'.($out_sheet+1));
00642 
00643                         return '
00644                                 <tr>
00645                                         <td colspan="2">
00646                                         '.$this->getDynTabMenu($parts, $tabIdentString).'
00647                                         </td>
00648                                 </tr>';
00649                 } else {        // Only one, so just implode:
00650                         return implode('',$out_array[$out_sheet]);
00651                 }
00652         }
00653 
00664         function getListedFields($table,$row,$list)     {
00665                 global $TCA;
00666 
00667                 t3lib_div::loadTCA($table);
00668                 if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table))       {
00669                         $GLOBALS['LANG']->loadSingleTableDescription($table);
00670                 }
00671 
00672                 $out = '';
00673                 $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table,$row,1);
00674 
00675                 $editFieldList=array_unique(t3lib_div::trimExplode(',',$list,1));
00676                 foreach($editFieldList as $theFieldC)   {
00677                         list($theField,$palFields) = split('\[|\]',$theFieldC);
00678                         $theField = trim($theField);
00679                         $palFields = trim($palFields);
00680                         if ($TCA[$table]['columns'][$theField]) {
00681                                 $parts = t3lib_div::trimExplode(';',$types_fieldConfig[$theField]['origString']);
00682                                 $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.
00683                                 $out.= $sField;
00684                         } elseif($theField=='--div--')  {
00685                                 $out.= $this->getDivider();
00686                         }
00687                         if ($palFields) {
00688                                 $out.= $this->getPaletteFields($table,$row,'','',implode(',',t3lib_div::trimExplode('|',$palFields,1)));
00689                         }
00690                 }
00691 
00692                 return $out;
00693         }
00694 
00706         function getPaletteFields($table,$row,$palette,$header='',$itemList='',$collapsedHeader='')     {
00707                 global $TCA;
00708                 if (!$this->doPrintPalette)     return '';
00709 
00710                 $out='';
00711                 $palParts = array();
00712                 t3lib_div::loadTCA($table);
00713 
00714                         // Getting excludeElements, if any.
00715                 if (!is_array($this->excludeElements))  {
00716                         $this->excludeElements = $this->getExcludeElements($table,$row,$this->getRTypeNum($table,$row));
00717                 }
00718 
00719                         // Render the palette TCEform elements.
00720                 if ($TCA[$table] && (is_array($TCA[$table]['palettes'][$palette]) || $itemList))        {
00721                         $itemList = $itemList?$itemList:$TCA[$table]['palettes'][$palette]['showitem'];
00722                         if ($itemList)  {
00723                                 $fields = t3lib_div::trimExplode(',',$itemList,1);
00724                                 reset($fields);
00725                                 while(list(,$fieldInfo)=each($fields))  {
00726                                         $parts = t3lib_div::trimExplode(';',$fieldInfo);
00727                                         $theField = $parts[0];
00728 
00729                                         if (!in_array($theField,$this->excludeElements) && $TCA[$table]['columns'][$theField])  {
00730                                                 $this->palFieldArr[$palette][] = $theField;
00731                                                 if ($this->isPalettesCollapsed($table,$palette))        {
00732                                                         $this->hiddenFieldListArr[] = $theField;
00733                                                 }
00734 
00735                                                 $part = $this->getSingleField($table,$theField,$row,$parts[1],1,'',$parts[2]);
00736                                                 if (is_array($part))    {
00737                                                         $palParts[] = $part;
00738                                                 }
00739                                         }
00740                                 }
00741                         }
00742                 }
00743                         // Put palette together if there are fields in it:
00744                 if (count($palParts))   {
00745                         if ($header)    {
00746                                 $out.= $this->intoTemplate(array(
00747                                                                 'HEADER' => htmlspecialchars($header)
00748                                                         ),
00749                                                         $this->palFieldTemplateHeader
00750                                                 );
00751                         }
00752                         $out.= $this->intoTemplate(array(
00753                                                         'PALETTE' => $this->printPalette($palParts)
00754                                                 ),
00755                                                 $this->palFieldTemplate
00756                                         );
00757                 }
00758                         // 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.
00759                 if ($this->isPalettesCollapsed($table,$palette) && $collapsedHeader)    {
00760                         $pC = $this->intoTemplate(array(
00761                                                         '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),
00762                                                 ),
00763                                                 $this->palFieldTemplate
00764                                         );
00765                         $out.= $pC;
00766                 }
00767 
00768                 return $out;
00769         }
00770 
00783         function getSingleField($table,$field,$row,$altName='',$palette=0,$extra='',$pal=0)     {
00784                 global $TCA,$BE_USER;
00785 
00786                         // Hook: getSingleField_preProcess
00787                 foreach ($this->hookObjectsSingleField as $hookObj)     {
00788                         if (method_exists($hookObj,'getSingleField_preProcess'))        {
00789                                 $hookObj->getSingleField_preProcess($table, $field, $row, $altName, $palette, $extra, $pal, $this);
00790                         }
00791                 }
00792 
00793                 $out = '';
00794                 $PA = array();
00795                 $PA['altName'] = $altName;
00796                 $PA['palette'] = $palette;
00797                 $PA['extra'] = $extra;
00798                 $PA['pal'] = $pal;
00799 
00800                         // Make sure to load full $TCA array for the table:
00801                 t3lib_div::loadTCA($table);
00802 
00803                         // Get the TCA configuration for the current field:
00804                 $PA['fieldConf'] = $TCA[$table]['columns'][$field];
00805                 $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
00806 
00807                 $skipThisField = $this->inline->skipField($table, $field, $row, $PA['fieldConf']['config']);
00808 
00809                         // Now, check if this field is configured and editable (according to excludefields + other configuration)
00810                 if (    is_array($PA['fieldConf']) &&
00811                                 !$skipThisField &&
00812                                 (!$PA['fieldConf']['exclude'] || $BE_USER->check('non_exclude_fields',$table.':'.$field)) &&
00813                                 $PA['fieldConf']['config']['form_type']!='passthrough' &&
00814                                 ($this->RTEenabled || !$PA['fieldConf']['config']['showIfRTE']) &&
00815                                 (!$PA['fieldConf']['displayCond'] || $this->isDisplayCondition($PA['fieldConf']['displayCond'],$row)) &&
00816                                 (!$TCA[$table]['ctrl']['languageField'] || $PA['fieldConf']['l10n_display'] || strcmp($PA['fieldConf']['l10n_mode'],'exclude') || $row[$TCA[$table]['ctrl']['languageField']]<=0) &&
00817                                 (!$TCA[$table]['ctrl']['languageField'] || !$this->localizationMode || $this->localizationMode===$PA['fieldConf']['l10n_cat'])
00818                         )       {
00819 
00820 
00821 
00822                                 // Fetching the TSconfig for the current table/field. This includes the $row which means that
00823                         $PA['fieldTSConfig'] = $this->setTSconfig($table,$row,$field);
00824 
00825                                 // If the field is NOT disabled from TSconfig (which it could have been) then render it
00826                         if (!$PA['fieldTSConfig']['disabled'])  {
00827                                         // Override fieldConf by fieldTSconfig:
00828                                 $PA['fieldConf']['config'] = $this->overrideFieldConf($PA['fieldConf']['config'], $PA['fieldTSConfig']);
00829 
00830                                         // Init variables:
00831                                 $PA['itemFormElName']=$this->prependFormFieldNames.'['.$table.']['.$row['uid'].']['.$field.']';         // Form field name
00832                                 $PA['itemFormElName_file']=$this->prependFormFieldNames_file.'['.$table.']['.$row['uid'].']['.$field.']';       // Form field name, in case of file uploads
00833                                 $PA['itemFormElValue']=$row[$field];            // The value to show in the form field.
00834                                 $PA['itemFormElID']=$this->prependFormFieldNames.'_'.$table.'_'.$row['uid'].'_'.$field;
00835 
00836                                         // set field to read-only if configured for translated records to show default language content as readonly
00837                                 if ($PA['fieldConf']['l10n_display'] AND t3lib_div::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly') AND $row[$TCA[$table]['ctrl']['languageField']]) {
00838                                         $PA['fieldConf']['config']['readOnly'] =  true;
00839                                         $PA['itemFormElValue'] = $this->defaultLanguageData[$table.':'.$row['uid']][$field];
00840                                 }
00841 
00842                                         // 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"
00843                                 if (
00844                                         ($TCA[$table]['ctrl']['type'] && !strcmp($field,$TCA[$table]['ctrl']['type'])) ||
00845                                         ($TCA[$table]['ctrl']['requestUpdate'] && t3lib_div::inList($TCA[$table]['ctrl']['requestUpdate'],$field))) {
00846                                         if($GLOBALS['BE_USER']->jsConfirmation(1))      {
00847                                                 $alertMsgOnChange = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
00848                                         } else {
00849                                                 $alertMsgOnChange = 'if (TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
00850                                         }
00851                                 } else {
00852                                         $alertMsgOnChange = '';
00853                                 }
00854 
00855                                         // Render as a hidden field?
00856                                 if (in_array($field,$this->hiddenFieldListArr)) {
00857                                         $this->hiddenFieldAccum[]='<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
00858                                 } else {        // Render as a normal field:
00859 
00860                                                 // 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.
00861                                         if (!$PA['palette'])    {
00862                                                 if ($PA['pal'] && $this->isPalettesCollapsed($table,$PA['pal']))        {
00863                                                         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);
00864                                                 } else {
00865                                                         $thePalIcon = '';
00866                                                         $palJSfunc = '';
00867                                                 }
00868                                         }
00869                                                 // onFocus attribute to add to the field:
00870                                         $PA['onFocus'] = ($palJSfunc && !$BE_USER->uc['dontShowPalettesOnFocusInAB']) ? ' onfocus="'.htmlspecialchars($palJSfunc).'"' : '';
00871 
00872                                                 // Find item
00873                                         $item='';
00874                                         $PA['label'] = $PA['altName'] ? $PA['altName'] : $PA['fieldConf']['label'];
00875                                         $PA['label'] = $this->sL($PA['label']);
00876                                                 // JavaScript code for event handlers:
00877                                         $PA['fieldChangeFunc']=array();
00878                                         $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = "TBE_EDITOR.fieldChanged('".$table."','".$row['uid']."','".$field."','".$PA['itemFormElName']."');";
00879                                         $PA['fieldChangeFunc']['alert']=$alertMsgOnChange;
00880                                                 // if this is the child of an inline type and it is the field creating the label
00881                                         if ($this->inline->isInlineChildAndLabelField($table, $field)) {
00882                                                 $PA['fieldChangeFunc']['inline'] = "inline.handleChangedField('".$PA['itemFormElName']."','".$this->inline->inlineNames['object']."[$table][".$row['uid']."]');";
00883                                         }
00884 
00885                                                 // Based on the type of the item, call a render function:
00886                                         $item = $this->getSingleField_SW($table,$field,$row,$PA);
00887 
00888                                                 // Add language + diff
00889                                         if ($PA['fieldConf']['l10n_display'] && (t3lib_div::inList($PA['fieldConf']['l10n_display'], 'hideDiff') || t3lib_div::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly'))) {
00890                                                 $renderLanguageDiff = false;
00891                                         } else {
00892                                                 $renderLanguageDiff = true;
00893                                         }
00894 
00895                                         if ($renderLanguageDiff) {
00896                                                 $item = $this->renderDefaultLanguageContent($table,$field,$row,$item);
00897                                                 $item = $this->renderDefaultLanguageDiff($table,$field,$row,$item);
00898                                         }
00899 
00900                                                 // 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
00901                                         $PA['label'] = t3lib_div::deHSCentities(htmlspecialchars($PA['label']));
00902                                         if (t3lib_div::testInt($row['uid']) && $PA['fieldTSConfig']['linkTitleToSelf']) {
00903                                                 $lTTS_url = $this->backPath.'alt_doc.php?edit['.$table.']['.$row['uid'].']=edit&columnsOnly='.$field.
00904                                                                         ($PA['fieldTSConfig']['linkTitleToSelf.']['returnUrl']?'&returnUrl='.rawurlencode($this->thisReturnUrl()):'');
00905                                                 $PA['label'] = '<a href="'.htmlspecialchars($lTTS_url).'">'.$PA['label'].'</a>';
00906                                         }
00907 
00908                                                 // Create output value:
00909                                         if ($PA['fieldConf']['config']['form_type']=='user' && $PA['fieldConf']['config']['noTableWrapping'])   {
00910                                                 $out = $item;
00911                                         } elseif ($PA['palette'])       {
00912                                                         // Array:
00913                                                 $out=array(
00914                                                         'NAME'=>$PA['label'],
00915                                                         'ID'=>$row['uid'],
00916                                                         'FIELD'=>$field,
00917                                                         'TABLE'=>$table,
00918                                                         'ITEM'=>$item,
00919                                                         'HELP_ICON' => $this->helpTextIcon($table,$field,1)
00920                                                 );
00921                                                 $out = $this->addUserTemplateMarkers($out,$table,$field,$row,$PA);
00922                                         } else {
00923                                                         // String:
00924                                                 $out=array(
00925                                                         'NAME'=>$PA['label'],
00926                                                         'ITEM'=>$item,
00927                                                         'TABLE'=>$table,
00928                                                         'ID'=>$row['uid'],
00929                                                         'HELP_ICON'=>$this->helpTextIcon($table,$field),
00930                                                         'HELP_TEXT'=>$this->helpText($table,$field),
00931                                                         'PAL_LINK_ICON'=>$thePalIcon,
00932                                                         'FIELD'=>$field
00933                                                 );
00934                                                 $out = $this->addUserTemplateMarkers($out,$table,$field,$row,$PA);
00935                                                         // String:
00936                                                 $out=$this->intoTemplate($out);
00937                                         }
00938                                 }
00939                         } else $this->commentMessages[]=$this->prependFormFieldNames.'['.$table.']['.$row['uid'].']['.$field.']: Disabled by TSconfig';
00940                 }
00941                         // Hook: getSingleField_postProcess
00942                 foreach ($this->hookObjectsSingleField as $hookObj)     {
00943                         if (method_exists($hookObj,'getSingleField_postProcess'))       {
00944                                 $hookObj->getSingleField_postProcess($table, $field, $row, $out, $PA, $this);
00945                         }
00946                 }
00947                         // Return value (string or array)
00948                 return $out;
00949         }
00950 
00962         function getSingleField_SW($table,$field,$row,&$PA)     {
00963                 $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
00964 
00965                 switch($PA['fieldConf']['config']['form_type']) {
00966                         case 'input':
00967                                 $item = $this->getSingleField_typeInput($table,$field,$row,$PA);
00968                         break;
00969                         case 'text':
00970                                 $item = $this->getSingleField_typeText($table,$field,$row,$PA);
00971                         break;
00972                         case 'check':
00973                                 $item = $this->getSingleField_typeCheck($table,$field,$row,$PA);
00974                         break;
00975                         case 'radio':
00976                                 $item = $this->getSingleField_typeRadio($table,$field,$row,$PA);
00977                         break;
00978                         case 'select':
00979                                 $item = $this->getSingleField_typeSelect($table,$field,$row,$PA);
00980                         break;
00981                         case 'group':
00982                                 $item = $this->getSingleField_typeGroup($table,$field,$row,$PA);
00983                         break;
00984                         case 'inline':
00985                                 $item = $this->inline->getSingleField_typeInline($table,$field,$row,$PA);
00986                         break;
00987                         case 'none':
00988                                 $item = $this->getSingleField_typeNone($table,$field,$row,$PA);
00989                         break;
00990                         case 'user':
00991                                 $item = $this->getSingleField_typeUser($table,$field,$row,$PA);
00992                         break;
00993                         case 'flex':
00994                                 $item = $this->getSingleField_typeFlex($table,$field,$row,$PA);
00995                         break;
00996                         default:
00997                                 $item = $this->getSingleField_typeUnknown($table,$field,$row,$PA);
00998                         break;
00999                 }
01000 
01001                 return $item;
01002         }
01003 
01004 
01005 
01006 
01007 
01008 
01009 
01010 
01011 
01012 
01013 
01014 
01015 
01016 
01017 
01018 
01019 
01020 
01021 
01022         /**********************************************************
01023          *
01024          * Rendering of each TCEform field type
01025          *
01026          ************************************************************/
01027 
01038         function getSingleField_typeInput($table,$field,$row,&$PA)      {
01039                 // typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue)
01040                 // typo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off)
01041 
01042                 $config = $PA['fieldConf']['config'];
01043 
01044 #               $specConf = $this->getSpecConfForField($table,$row,$field);
01045                 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
01046                 $size = t3lib_div::intInRange($config['size']?$config['size']:30,5,$this->maxInputWidth);
01047                 $evalList = t3lib_div::trimExplode(',',$config['eval'],1);
01048 
01049 
01050                 if($this->renderReadonly || $config['readOnly'])  {
01051                         $itemFormElValue = $PA['itemFormElValue'];
01052                         if (in_array('date',$evalList)) {
01053                                 $config['format'] = 'date';
01054                         } elseif (in_array('date',$evalList))   {
01055                                 $config['format'] = 'date';
01056                         } elseif (in_array('datetime',$evalList))       {
01057                                 $config['format'] = 'datetime';
01058                         } elseif (in_array('time',$evalList))   {
01059                                 $config['format'] = 'time';
01060                         }
01061                         if (in_array('password',$evalList))     {
01062                                 $itemFormElValue = $itemFormElValue ? '*********' : '';
01063                         }
01064                         return $this->getSingleField_typeNone_render($config, $itemFormElValue);
01065                 }
01066 
01067                 if (in_array('required',$evalList))     {
01068                         $this->requiredFields[$table.'_'.$row['uid'].'_'.$field]=$PA['itemFormElName'];
01069                 }
01070 
01071                 $paramsList = "'".$PA['itemFormElName']."','".implode(',',$evalList)."','".trim($config['is_in'])."',".(isset($config['checkbox'])?1:0).",'".$config['checkbox']."'";
01072                 if (isset($config['checkbox'])) {
01073                                 // Setting default "click-checkbox" values for eval types "date" and "datetime":
01074                         $thisMidnight = mktime(0,0,0);
01075                         $checkSetValue = in_array('date',$evalList) ? $thisMidnight : '';
01076                         $checkSetValue = in_array('datetime',$evalList) ? time() : $checkSetValue;
01077 
01078                         $cOnClick = 'typo3form.fieldGet('.$paramsList.',1,\''.$checkSetValue.'\');'.implode('',$PA['fieldChangeFunc']);
01079                         $item.='<input type="checkbox"'.$this->insertDefStyle('check').' name="'.$PA['itemFormElName'].'_cb" onclick="'.htmlspecialchars($cOnClick).'" />';
01080                 }
01081 
01082                 $PA['fieldChangeFunc'] = array_merge(array('typo3form.fieldGet'=>'typo3form.fieldGet('.$paramsList.');'), $PA['fieldChangeFunc']);
01083                 $mLgd = ($config['max']?$config['max']:256);
01084                 $iOnChange = implode('',$PA['fieldChangeFunc']);
01085                 $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.
01086                 $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.
01087                 $this->extJSCODE.='typo3form.fieldSet('.$paramsList.');';
01088 
01089                         // going through all custom evaluations configured for this field
01090                 foreach ($evalList as $evalData) {
01091                         if (substr($evalData, 0, 3) == 'tx_')   {
01092                                 $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$evalData].':&'.$evalData);
01093                                 if(is_object($evalObj) && method_exists($evalObj, 'returnFieldJS'))     {
01094                                         $this->extJSCODE .= "\n\nfunction ".$evalData."(value) {\n".$evalObj->returnFieldJS()."\n}\n";
01095                                 }
01096                         }
01097                 }
01098 
01099                         // Creating an alternative item without the JavaScript handlers.
01100                 $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'_hr" value="" />';
01101                 $altItem.= '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
01102 
01103                         // Wrap a wizard around the item?
01104                 $item= $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'].'_hr',$specConf);
01105 
01106                 return $item;
01107         }
01108 
01119         function getSingleField_typeText($table,$field,$row,&$PA)       {
01120 
01121                         // Init config:
01122                 $config = $PA['fieldConf']['config'];
01123 
01124                 if($this->renderReadonly || $config['readOnly'])  {
01125                         return $this->getSingleField_typeNone_render($config, $PA['itemFormElValue']);
01126                 }
01127 
01128                         // Setting columns number:
01129                 $cols = t3lib_div::intInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
01130 
01131                         // Setting number of rows:
01132                 $origRows = $rows = t3lib_div::intInRange($config['rows'] ? $config['rows'] : 5, 1, 20);
01133                 if (strlen($PA['itemFormElValue']) > $this->charsPerRow*2)      {
01134                         $cols = $this->maxTextareaWidth;
01135                         $rows = t3lib_div::intInRange(round(strlen($PA['itemFormElValue'])/$this->charsPerRow), count(explode(chr(10),$PA['itemFormElValue'])), 20);
01136                         if ($rows<$origRows)    $rows = $origRows;
01137                 }
01138 
01139                         // Init RTE vars:
01140                 $RTEwasLoaded = 0;                              // Set true, if the RTE is loaded; If not a normal textarea is shown.
01141                 $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...
01142 
01143                         // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. Traditionally, this is where RTE configuration has been found.
01144                 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
01145 
01146                         // Setting up the altItem form field, which is a hidden field containing the value
01147                 $altItem = '<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
01148 
01149                         // If RTE is generally enabled (TYPO3_CONF_VARS and user settings)
01150                 if ($this->RTEenabled) {
01151                         $p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
01152                         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.
01153                                 t3lib_BEfunc::fixVersioningPid($table,$row);
01154                                 list($tscPID,$thePidValue) = $this->getTSCpid($table,$row['uid'],$row['pid']);
01155 
01156                                         // If the pid-value is not negative (that is, a pid could NOT be fetched)
01157                                 if ($thePidValue >= 0)  {
01158                                         $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',