Fixed bug #10086: Core uses deprecated function t3lib_db->sql()
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_tceforms.php
index 03066a2..a34250d 100755 (executable)
@@ -214,7 +214,7 @@ class t3lib_TCEforms        {
        var $loadMD5_JS=1;
        var $prevBorderStyle='[nothing here...]';       // Something unique...
        var $allowUpload=0;                             // If set direct upload fields will be shown
-       var $titleLen=15;                                       // @deprecated: $BE_USER->uc['titleLen'] but what is default??
+       var $titleLen=15;                                       // @deprecated since TYPO3 4.1: $BE_USER->uc['titleLen'] but what is default??
        var $defaultLanguageData = array();     // Array where records in the default language is stored. (processed by transferdata)
        var $defaultLanguageData_diff = array();        // Array where records in the default language is stored (raw without any processing. used for making diff)
        var $additionalPreviewLanguageData = array();
@@ -395,7 +395,7 @@ class t3lib_TCEforms        {
                $this->edit_showFieldHelp = $BE_USER->uc['edit_showFieldHelp'];
 
                $this->edit_docModuleUpload = $BE_USER->uc['edit_docModuleUpload'];
-               $this->titleLen = $BE_USER->uc['titleLen'];             // @deprecated
+               $this->titleLen = $BE_USER->uc['titleLen'];             // @deprecated since TYPO3 4.1
 
                $this->inline->init($this);
        }
@@ -1119,7 +1119,7 @@ class t3lib_TCEforms      {
                                $checkSetValue = gmdate('Y');
                        }
                        $cOnClick = 'typo3form.fieldGet('.$paramsList.',1,\''.$checkSetValue.'\');'.implode('',$PA['fieldChangeFunc']);
-                       $item.='<input type="checkbox"'.$this->insertDefStyle('check').' name="'.$PA['itemFormElName'].'_cb" onclick="'.htmlspecialchars($cOnClick).'" />';
+                       $item .= '<input type="checkbox" class="' . $this->formElStyleClassValue('check', TRUE) . ' alignToInputText" name="' . $PA['itemFormElName'] . '_cb" onclick="' . htmlspecialchars($cOnClick) . '" />';
                }
                if ((in_array('date',$evalList) || in_array('datetime',$evalList)) && $PA['itemFormElValue']>0){
                                // Add server timezone offset to UTC to our stored date
@@ -1425,9 +1425,21 @@ class t3lib_TCEforms     {
                $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
 
                        // Getting the selector box items from the system
-               $selItems = $this->addSelectOptionsToItemArray($this->initItemArray($PA['fieldConf']),$PA['fieldConf'],$this->setTSconfig($table,$row),$field);
-               $selItems = $this->addItems($selItems,$PA['fieldTSConfig']['addItems.']);
-               if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
+               $selItems = $this->addSelectOptionsToItemArray(
+                       $this->initItemArray($PA['fieldConf']),
+                       $PA['fieldConf'],
+                       $this->setTSconfig($table, $row),
+                       $field
+               );
+                       // Possibly filter some items:
+               $keepItemsFunc = create_function('$value', 'return $value[1];');
+               $selItems = t3lib_div::keepItemsInArray($selItems, $PA['fieldTSConfig']['keepItems'], $keepItemsFunc);
+                       // Possibly add some items:
+               $selItems = $this->addItems($selItems, $PA['fieldTSConfig']['addItems.']);
+                       // Process items by a user function:
+               if (isset($config['itemsProcFunc']) && $config['itemsProcFunc']) {
+                       $selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
+               }
 
                        // Possibly remove some items:
                $removeItems = t3lib_div::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
@@ -1939,8 +1951,14 @@ class t3lib_TCEforms     {
                        // Get "removeItems":
                $removeItems = t3lib_div::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
 
+                       // Get the array with selected items:
+               $itemArray = t3lib_div::trimExplode(',', $PA['itemFormElValue'], 1);
+
+                       // Possibly filter some items:
+               $keepItemsFunc = create_function('$value', '$parts=explode(\'|\',$value,2); return rawurldecode($parts[0]);');
+               $itemArray = t3lib_div::keepItemsInArray($itemArray, $PA['fieldTSConfig']['keepItems'], $keepItemsFunc);
+
                        // Perform modification of the selected items array:
-               $itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
                foreach($itemArray as $tk => $tv) {
                        $tvP = explode('|',$tv,2);
                        $evalValue = rawurldecode($tvP[0]);
@@ -2519,6 +2537,8 @@ class t3lib_TCEforms      {
                                                        // If it's a "section" containing other elements:
                                                if ($value['section'])  {
 
+                                                               // Load script.aculo.us if flexform sections can be moved by drag'n'drop:
+                                                       $this->loadJavascriptLib('contrib/scriptaculous/scriptaculous.js');
                                                                // Render header of section:
                                                        $output.= '<div class="bgColor2"><strong>'.$theTitle.'</strong></div>';
 
@@ -3967,7 +3987,7 @@ 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
+        * @deprecated since TYPO3 4.1
         */
        function noTitle($str,$wrapParts=array())       {
                return strcmp($str,'') ? $str : $wrapParts[0].'['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title').']'.$wrapParts[1];
@@ -5046,6 +5066,7 @@ class t3lib_TCEforms      {
         * @return      string          A section with JavaScript - if $update is false, embedded in <script></script>
         */
        function JSbottom($formname='forms[0]', $update = false)        {
+               $jsFile = array();
                $elements = array();
 
                        // required:
@@ -5075,17 +5096,18 @@ class t3lib_TCEforms    {
 
                if (!$update) {
                        if ($this->loadMD5_JS) {
-                               $GLOBALS['TBE_TEMPLATE']->loadJavascriptLib('md5.js');
+                               $this->loadJavascriptLib('md5.js');
                        }
 
-                       $GLOBALS['TBE_TEMPLATE']->loadJavascriptLib('contrib/prototype/prototype.js');
-                       $GLOBALS['TBE_TEMPLATE']->loadJavascriptLib('../t3lib/jsfunc.evalfield.js');
-                       $GLOBALS['TBE_TEMPLATE']->loadJavascriptLib('jsfunc.tbe_editor.js');
+                       $this->loadJavascriptLib('contrib/prototype/prototype.js');
+                       $this->loadJavascriptLib('../t3lib/jsfunc.evalfield.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>';
 
                                // if IRRE fields were processed, add the JavaScript functions:
                        if ($this->inline->inlineCount) {
-                               $GLOBALS['TBE_TEMPLATE']->loadJavascriptLib('contrib/scriptaculous/scriptaculous.js');
-                               $GLOBALS['TBE_TEMPLATE']->loadJavascriptLib('../t3lib/jsfunc.inline.js');
+                               $this->loadJavascriptLib('contrib/scriptaculous/scriptaculous.js');
+                               $this->loadJavascriptLib('../t3lib/jsfunc.inline.js');
                                $out .= '
                                inline.setPrependFormFieldNames("'.$this->inline->prependNaming.'");
                                inline.setNoTitleString("'.addslashes(t3lib_BEfunc::getNoRecordTitle(true)).'");
@@ -5179,25 +5201,26 @@ class t3lib_TCEforms    {
                        TBE_EDITOR.labels.refresh_login = '.$GLOBALS['LANG']->JScharCode($this->getLL('m_refresh_login')).';
                        TBE_EDITOR.labels.onChangeAlert = '.$GLOBALS['LANG']->JScharCode($this->getLL('m_onChangeAlert')).';
                        evalFunc.USmode = '.($GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat']?'1':'0').';
+                       TBE_EDITOR.backend_interface = "'.$GLOBALS['BE_USER']->uc['interfaceSetup'].'";
                        ';
                }
 
                        // add JS required for inline fields
                if (count($this->inline->inlineData)) {
                        $out .= '
-                       inline.addToDataArray('.t3lib_div::array2json($this->inline->inlineData).');
+                       inline.addToDataArray(' . json_encode($this->inline->inlineData) . ');
                        ';
                }
                        // Registered nested elements for tabs or inline levels:
                if (count($this->requiredNested)) {
                        $out .= '
-                       TBE_EDITOR.addNested('.t3lib_div::array2json($this->requiredNested).');
+                       TBE_EDITOR.addNested(' . json_encode($this->requiredNested) . ');
                        ';
                }
                        // elements which are required or have a range definition:
                if (count($elements)) {
                        $out .= '
-                       TBE_EDITOR.addElements('.t3lib_div::array2json($elements).');
+                       TBE_EDITOR.addElements(' . json_encode($elements) . ');
                        TBE_EDITOR.initRequired();
                        ';
                }
@@ -5218,7 +5241,8 @@ class t3lib_TCEforms      {
 
                        // Regular direct output:
                if (!$update) {
-                       $out  = chr(10) . chr(9) . t3lib_div::wrapJS($out);
+                       $spacer = chr(10) . chr(9);
+                       $out  = $spacer . implode($spacer, $jsFile) . t3lib_div::wrapJS($out);
                }
 
                return $out;
@@ -5484,6 +5508,18 @@ class t3lib_TCEforms     {
                return $out;
        }
 
+       /**
+        * Includes a javascript library that exists in the core /typo3/ directory. The
+        * backpath is automatically applied.
+        * This method acts as wrapper for $GLOBALS['SOBE']->doc->loadJavascriptLib($lib).
+        *
+        * @param       string          $lib: Library name. Call it with the full path like "contrib/prototype/prototype.js" to load it
+        * @return      void
+        */
+       public function loadJavascriptLib($lib) {
+               $GLOBALS['SOBE']->doc->loadJavascriptLib($lib);
+       }
+
 
 
 
@@ -5956,7 +5992,7 @@ class t3lib_TCEforms      {
                if ($skipFirst) {
                        array_shift($result);
                }
-               return ($json ? t3lib_div::array2json($result) : $result);
+               return ($json ? json_encode($result) : $result);
        }
 
        /**
@@ -6000,6 +6036,19 @@ class t3lib_TCEforms     {
                        );
                }
        }
+
+       /**
+        * Insert additional style sheet link
+        *
+        * @param       string          $key: some key identifying the style sheet
+        * @param       string          $href: uri to the style sheet file
+        * @param       string          $title: value for the title attribute of the link element
+        * @return      string          $relation: value for the rel attribute of the link element
+        * @return      void
+        */
+       public function addStyleSheet($key, $href, $title='', $relation='stylesheet') {
+               $GLOBALS['SOBE']->doc->addStyleSheet($key, $href, $title, $relation);
+        }
 }
 
 
@@ -6078,9 +6127,39 @@ class t3lib_TCEforms_FE extends t3lib_TCEforms {
                <td nowrap="nowrap" bgcolor="#F6F2E6"><font face="verdana" size="1" color="black"><b>###FIELD_HEADER###</b></font></td>
        </tr>   ';
        }
+
+       /**
+        * Includes a javascript library that exists in the core /typo3/ directory. The
+        * backpath is automatically applied.
+        * This method adds the library to $GLOBALS['TSFE']->additionalHeaderData[$lib].
+        *
+        * @param       string          $lib: Library name. Call it with the full path like "contrib/prototype/prototype.js" to load it
+        * @return      void
+        */
+       public function loadJavascriptLib($lib) {
+               if (!isset($GLOBALS['TSFE']->additionalHeaderData[$lib])) {
+                       $GLOBALS['TSFE']->additionalHeaderData[$lib] = '<script type="text/javascript" src="' . $this->backPath . $lib . '"></script>';
+               }
+       }
+
+       /**
+        * Insert additional style sheet link
+        *
+        * @param       string          $key: some key identifying the style sheet
+        * @param       string          $href: uri to the style sheet file
+        * @param       string          $title: value for the title attribute of the link element
+        * @return      string          $relation: value for the rel attribute of the link element
+        * @return      void
+        */
+       public function addStyleSheet($key, $href, $title='', $relation='stylesheet') {
+               if (!isset($GLOBALS['TSFE']->additionalHeaderData[$key])) {
+                       $GLOBALS['TSFE']->additionalHeaderData[$key] = '<link rel="' . $relation . '" type="text/css" href="' . $href . '"' . ($title ? (' title="' . $title . '"') : '') . ' />';
+               }
+        }
 }
 
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tceforms.php']) {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tceforms.php']);
 }
+
 ?>