Fixed bug #12508: Log usage of XLLfile to deprecation log (thanks to Steffen Gebert)
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_tceforms.php
index bf86f61..7322ad6 100644 (file)
@@ -361,18 +361,22 @@ class t3lib_TCEforms      {
                if (!isset($GLOBALS['ajaxID']) || strpos($GLOBALS['ajaxID'], 't3lib_TCEforms_inline::')!==0) {
                        $this->inline = t3lib_div::makeInstance('t3lib_TCEforms_inline');
                }
+                       // Create instance of t3lib_TCEforms_suggest only if this a non-Suggest-AJAX call:
+               if (!isset($GLOBALS['ajaxID']) || strpos($GLOBALS['ajaxID'], 't3lib_TCEforms_suggest::')!==0) {
+                       $this->suggest = t3lib_div::makeInstance('t3lib_TCEforms_suggest');
+               }
 
                        // Prepare user defined objects (if any) for hooks which extend this function:
                $this->hookObjectsMainFields = array();
                if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass']))  {
                        foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'] as $classRef)   {
-                               $this->hookObjectsMainFields[] = &t3lib_div::getUserObj($classRef);
+                               $this->hookObjectsMainFields[] = t3lib_div::getUserObj($classRef);
                        }
                }
                $this->hookObjectsSingleField = array();
                if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getSingleFieldClass'])) {
                        foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getSingleFieldClass'] as $classRef)  {
-                               $this->hookObjectsSingleField[] = &t3lib_div::getUserObj($classRef);
+                               $this->hookObjectsSingleField[] = t3lib_div::getUserObj($classRef);
                        }
                }
 
@@ -395,6 +399,7 @@ class t3lib_TCEforms        {
                $this->titleLen = $BE_USER->uc['titleLen'];             // @deprecated since TYPO3 4.1
 
                $this->inline->init($this);
+               $this->suggest->init($this);
        }
 
 
@@ -889,7 +894,15 @@ class t3lib_TCEforms       {
                                        $PA['fieldChangeFunc']['alert']=$alertMsgOnChange;
                                                // if this is the child of an inline type and it is the field creating the label
                                        if ($this->inline->isInlineChildAndLabelField($table, $field)) {
-                                               $PA['fieldChangeFunc']['inline'] = "inline.handleChangedField('".$PA['itemFormElName']."','".$this->inline->inlineNames['object']."[$table][".$row['uid']."]');";
+                                               $inlineObjectId = implode(
+                                                       t3lib_TCEforms_inline::Structure_Separator,
+                                                       array(
+                                                               $this->inline->inlineNames['object'],
+                                                               $table,
+                                                               $row['uid']
+                                                       )
+                                               );
+                                               $PA['fieldChangeFunc']['inline'] = "inline.handleChangedField('" . $PA['itemFormElName'] . "','" . $inlineObjectId . "');";
                                        }
 
                                                // Based on the type of the item, call a render function:
@@ -1263,7 +1276,7 @@ class t3lib_TCEforms      {
                                                        $RTErelPath = is_array($eFile) ? dirname($eFile['relEditFile']) : '';
 
                                                                // Get RTE object, draw form and set flag:
-                                                       $RTEobj = &t3lib_BEfunc::RTEgetObj();
+                                                       $RTEobj = t3lib_BEfunc::RTEgetObj();
                                                        $item = $RTEobj->drawRTE($this,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue);
 
                                                                // Wizard:
@@ -2020,6 +2033,15 @@ class t3lib_TCEforms     {
                        } elseif (isset($PA['fieldTSConfig']['altLabels.'][$evalValue])) {
                                $tvP[1] = rawurlencode($this->sL($PA['fieldTSConfig']['altLabels.'][$evalValue]));
                        }
+                       if ($tvP[1] == '') {
+                                       // Case: flexform, default values supplied, no label provided (bug #9795)
+                               foreach ($selItems as $selItem) {
+                                       if ($selItem[1] == $tvP[0]) {
+                                               $tvP[1] = $selItem[0];
+                                               break;
+                                       }
+                               }
+                       }
                        $itemArray[$tk] = implode('|',$tvP);
                }
                $itemsToSelect = '';
@@ -2414,10 +2436,26 @@ class t3lib_TCEforms    {
                        $langDisabled = $dataStructArray['meta']['langDisable'] ? 1 : 0;
 
                        $editData['meta']['currentLangId']=array();
+
+                               // Look up page overlays:
+                       $checkPageLanguageOverlay = $GLOBALS['BE_USER']->getTSConfigVal('options.checkPageLanguageOverlay')?TRUE:FALSE;
+                       if ($checkPageLanguageOverlay)  {
+                               $pageOverlays = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                                       '*',
+                                       'pages_language_overlay',
+                                       'pid='.intval($row['pid']).
+                                               t3lib_BEfunc::deleteClause('pages_language_overlay').
+                                               t3lib_BEfunc::versioningPlaceholderClause('pages_language_overlay'),
+                                       '',
+                                       '',
+                                       '',
+                                       'sys_language_uid'
+                               );
+                       }
                        $languages = $this->getAvailableLanguages();
 
                        foreach($languages as $lInfo)   {
-                               if ($GLOBALS['BE_USER']->checkLanguageAccess($lInfo['uid']))    {
+                               if ($GLOBALS['BE_USER']->checkLanguageAccess($lInfo['uid']) && (!$checkPageLanguageOverlay || $lInfo['uid']<=0 || is_array($pageOverlays[$lInfo['uid']])))      {
                                        $editData['meta']['currentLangId'][] =  $lInfo['ISOcode'];
                                }
                        }
@@ -2595,7 +2633,7 @@ class t3lib_TCEforms      {
                                                if ($value['section'])  {
 
                                                                // Load script.aculo.us if flexform sections can be moved by drag'n'drop:
-                                                       $GLOBALS['SOBE']->doc->loadScriptaculous();
+                                                       $GLOBALS['SOBE']->doc->getPageRenderer()->loadScriptaculous();
                                                                // Render header of section:
                                                        $output.= '<div class="bgColor2"><strong>'.$theTitle.'</strong></div>';
 
@@ -3759,9 +3797,11 @@ class t3lib_TCEforms     {
 
                        // traverse wizards:
                if (is_array($wizConf) && !$this->disableWizards)       {
+                       $parametersOfWizards =& $specConf['wizards']['parameters'];
+
                        foreach($wizConf as $wid => $wConf)     {
                                if (substr($wid,0,1)!='_'
-                                               && (!$wConf['enableByTypeConfig'] || @in_array($wid,$specConf['wizards']['parameters']))
+                                               && (!$wConf['enableByTypeConfig'] || is_array($parametersOfWizards) && in_array($wid, $parametersOfWizards))
                                                && ($RTE || !$wConf['RTEonly'])
                                        )       {
 
@@ -3878,6 +3918,13 @@ class t3lib_TCEforms     {
                                                        $sOnChange = $assignValue.';this.blur();this.selectedIndex=0;'.implode('',$fieldChangeFunc);
                                                        $outArr[] = '<select id="' . uniqid('tceforms-select-') . '" class="tceforms-select tceforms-wizardselect" name="_WIZARD'.$fName.'" onchange="'.htmlspecialchars($sOnChange).'">'.implode('',$opt).'</select>';
                                                break;
+                                               case 'suggest':
+                                                       if (isset($PA['fieldTSConfig']['suggest.']['default.']['hide']) &&
+                                                               ((bool)$PA['fieldTSConfig']['suggest.']['default.']['hide'] == TRUE)) {
+                                                               break;
+                                                       }
+                                                       $outArr[] = $this->suggest->renderSuggestSelector($PA['itemFormElName'], $table, $field, $row, $PA);
+                                               break;
                                        }
 
                                                // Color wizard colorbox:
@@ -3904,7 +3951,7 @@ class t3lib_TCEforms      {
                                if ($wizConf['_HIDDENFIELD'])   $item = $itemKinds[1];
 
                                $outStr = '';
-                               $vAlign = $wizConf['_VALIGN'] ? ' valign="'.$wizConf['_VALIGN'].'"' : '';
+                               $vAlign = $wizConf['_VALIGN'] ? ' style="vertical-align:'.$wizConf['_VALIGN'].'"' : '';
                                if (count($outArr)>1 || $wizConf['_PADDING'])   {
                                        $dist = intval($wizConf['_DISTANCE']);
                                        if ($wizConf['_VERTICAL'])      {
@@ -3914,7 +3961,7 @@ class t3lib_TCEforms      {
                                                $dist = $dist ? '<td><img src="clear.gif" height="1" width="'.$dist.'" alt="" /></td>' : '';
                                                $outStr = '<tr><td'.$vAlign.'>'.implode('</td>'.$dist.'<td'.$vAlign.'>',$outArr).'</td></tr>';
                                        }
-                                       $outStr = '<table border="0" cellpadding="'.intval($wizConf['_PADDING']).'" cellspacing="0">'.$outStr.'</table>';
+                                       $outStr = '<table border="0" cellpadding="'.intval($wizConf['_PADDING']).'" cellspacing="'.intval($wizConf['_PADDING']).'">'.$outStr.'</table>';
                                } else {
                                        $outStr = implode('',$outArr);
                                }
@@ -4070,9 +4117,11 @@ class t3lib_TCEforms     {
         * @param       string          The string which - if empty - will become the no-title string.
         * @param       array           Array with wrappin parts for the no-title output (in keys [0]/[1])
         * @return      string
-        * @deprecated since TYPO3 4.1
+        * @deprecated since TYPO3 4.1, this function will be removed in TYPO3 4.5.
         */
        function noTitle($str,$wrapParts=array())       {
+               t3lib_div::logDeprecatedFunction();
+
                return strcmp($str,'') ? $str : $wrapParts[0].'['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title').']'.$wrapParts[1];
        }
 
@@ -4269,6 +4318,7 @@ class t3lib_TCEforms      {
         */
        function getDynTabMenu($parts, $idString, $dividersToTabsBehaviour = 1) {
                if (is_object($GLOBALS['TBE_TEMPLATE'])) {
+                       $GLOBALS['TBE_TEMPLATE']->backPath = $this->backPath;
                        return $GLOBALS['TBE_TEMPLATE']->getDynTabMenu($parts, $idString, 0, false, 50, 1, false, 1, $dividersToTabsBehaviour);
                } else {
                        $output = '';
@@ -4885,10 +4935,10 @@ class t3lib_TCEforms    {
         * Returns divider.
         * Currently not implemented and returns only blank value.
         *
-        * @return      string
+        * @return      string          Empty string
         */
-       function getDivider()   {
-               //return "<hr />";
+       function getDivider() {
+               return '';
        }
 
        /**
@@ -5232,13 +5282,25 @@ class t3lib_TCEforms    {
                                $this->loadJavascriptLib('md5.js');
                        }
 
-                       $GLOBALS['SOBE']->doc->loadPrototype();
-                       $GLOBALS['SOBE']->doc->loadExtJS();
-                       $GLOBALS['SOBE']->doc->addStyleSheet('ext.resizable', $this->backPath . '../t3lib/js/extjs/ux/resize.css');
+                       /** @var $pageRenderer t3lib_PageRenderer */
+                       $pageRenderer = $GLOBALS['SOBE']->doc->getPageRenderer();
+                       $pageRenderer->loadPrototype();
+                       $pageRenderer->loadExtJS();
+
+                               // make textareas resizable and flexible
+                       if (!($GLOBALS['BE_USER']->uc['resizeTextareas'] == '0' && $GLOBALS['BE_USER']->uc['resizeTextareas_Flexible'] == '0')) {
+                               $pageRenderer->addCssFile($this->backPath . '../t3lib/js/extjs/ux/resize.css');
+                               $this->loadJavascriptLib('../t3lib/js/extjs/ux/ext.resizable.js');
+                       }
+                       $resizableSettings = array(
+                               'textareaMaxHeight' => $GLOBALS['BE_USER']->uc['resizeTextareas_MaxHeight'] >0 ? $GLOBALS['BE_USER']->uc['resizeTextareas_MaxHeight'] : '600',
+                               'textareaFlexible' => (!$GLOBALS['BE_USER']->uc['resizeTextareas_Flexible'] == '0'),
+                               'textareaResize' => (!$GLOBALS['BE_USER']->uc['resizeTextareas'] == '0'),
+                       );
+                       $pageRenderer->addInlineSettingArray('', $resizableSettings);
+
                        $this->loadJavascriptLib('../t3lib/jsfunc.evalfield.js');
-                       $this->loadJavascriptLib('../t3lib/js/extjs/ux/ext.resizable.js');
-                       // @TODO: Change to loadJavascriptLib(), but fix "TS = new typoScript()" issue first - see bug #9494
-                       $jsFile[] = '<script type="text/javascript" src="'.$this->backPath.'jsfunc.tbe_editor.js"></script>';
+                       $this->loadJavascriptLib('jsfunc.tbe_editor.js');
 
                                // needed for tceform manipulation (date picker)
                        $typo3Settings = array(
@@ -5246,15 +5308,13 @@ class t3lib_TCEforms    {
                                'dateFormat'       => array('j-n-Y', 'G:i j-n-Y'),
                                'dateFormatUS'     => array('n-j-Y', 'G:i n-j-Y'),
                        );
-                       $out .= '
-                       Ext.ns("TYPO3");
-                       TYPO3.settings = ' . json_encode($typo3Settings) . ';';
+                       $pageRenderer->addInlineSettingArray('', $typo3Settings);
 
                        $this->loadJavascriptLib('../t3lib/js/extjs/tceforms.js');
 
                                // if IRRE fields were processed, add the JavaScript functions:
                        if ($this->inline->inlineCount) {
-                               $GLOBALS['SOBE']->doc->loadScriptaculous();
+                               $GLOBALS['SOBE']->doc->getPageRenderer()->loadScriptaculous();
                                $this->loadJavascriptLib('../t3lib/jsfunc.inline.js');
                                $out .= '
                                inline.setPrependFormFieldNames("'.$this->inline->prependNaming.'");
@@ -5262,6 +5322,12 @@ class t3lib_TCEforms     {
                                ';
                        }
 
+                               // if Suggest fields were processed, add the JS functions
+                       if ($this->suggest->suggestCount > 0) {
+                               $pageRenderer->loadScriptaculous();
+                               $this->loadJavascriptLib('../t3lib/js/jsfunc.tceforms_suggest.js');
+                       }
+
                                // Toggle icons:
                        $toggleIcon_open = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/pil2down.gif','width="12" height="7"').' hspace="2" alt="Open" title="Open" />';
                        $toggleIcon_close = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/pil2right.gif','width="7" height="12"').' hspace="2" alt="Close" title="Close" />';