Fixed bug #65: Thumbnails in Element Browser are only displayed if fileSuffix is...
[Packages/TYPO3.CMS.git] / typo3 / class.browse_links.php
index fee5406..c81752c 100755 (executable)
@@ -218,7 +218,7 @@ class TBE_browser_recordList extends localRecordList {
                        $code = htmlspecialchars(t3lib_div::fixed_lgd_cs($code,$this->fixedL));
                }
 
-               $title = t3lib_BEfunc::getRecordTitle($table,$row);
+               $title = t3lib_BEfunc::getRecordTitle($table,$row,FALSE,TRUE);
                $ficon = t3lib_iconWorks::getIcon($table,$row);
                $aOnClick = "return insertElement('".$table."', '".$row['uid']."', 'db', ".t3lib_div::quoteJSvalue($title).", '', '', '".$ficon."');";
                $ATag = '<a href="#" onclick="'.$aOnClick.'">';
@@ -234,14 +234,14 @@ class TBE_browser_recordList extends localRecordList {
        }
 
        /**
-        * Returns the title (based on $code) of a table ($table) without a link
+        * Local version that sets allFields to true to support userFieldSelect
         *
-        * @param       string          Table name
-        * @param       string          Table label
-        * @return      string          The linked table label
+        * @return      void
+        * @see fieldSelectBox
         */
-       function linkWrapTable($table,$code)    {
-               return $code;
+       function generateList() {
+               $this->allFields = true;
+               parent::generateList();
        }
 }
 
@@ -706,10 +706,14 @@ class browse_links {
         * Example value: "data[pages][39][bodytext]|||tt_content|" or "data[tt_content][NEW3fba56fde763d][image]|||gif,jpg,jpeg,tif,bmp,pcx,tga,png,pdf,ai|"
         *
         * Values:
-        * 0: form field name reference
+        * 0: form field name reference, eg. "data[tt_content][123][image]"
         * 1: old/unused?
         * 2: old/unused?
         * 3: allowed types. Eg. "tt_content" or "gif,jpg,jpeg,tif,bmp,pcx,tga,png,pdf,ai"
+        * 4: IRRE uniqueness: target level object-id to perform actions/checks on, eg. "data[79][tt_address][1][<field>][<foreign_table>]"
+        * 5: IRRE uniqueness: name of function in opener window that checks if element is already used, eg. "inline.checkUniqueElement"
+        * 6: IRRE uniqueness: name of function in opener window that performs some additional(!) action, eg. "inline.setUniqueElement"
+        * 7: IRRE uniqueness: name of function in opener window that performs action instead of using addElement/insertElement, eg. "inline.importElement"
         *
         * $pArr = explode('|',$this->bparams);
         * $formFieldName = $pArr[0];
@@ -946,9 +950,70 @@ class browse_links {
                ';
 
 
-                       // This is JavaScript especially for the TBE Element Browser!
+               /**
+                * Splits parts of $this->bparams
+                * @see $bparams
+                */
                $pArr = explode('|',$this->bparams);
+
+                       // This is JavaScript especially for the TBE Element Browser!
                $formFieldName = 'data['.$pArr[0].']['.$pArr[1].']['.$pArr[2].']';
+
+                       // insertElement - Call check function (e.g. for uniqueness handling):
+               if ($pArr[4] && $pArr[5]) {
+                       $JScodeCheck = '
+                                       // Call a check function in the opener window (e.g. for uniqueness handling):
+                               if (parent.window.opener) {
+                                       var res = parent.window.opener.'.$pArr[5].'("'.addslashes($pArr[4]).'",table,uid,type);
+                                       if (!res.passed) {
+                                               if (res.message) alert(res.message);
+                                               performAction = false;
+                                       }
+                               } else {
+                                       alert("Error - reference to main window is not set properly!");
+                                       parent.close();
+                               }
+                       ';
+               }
+                       // insertElement - Call helper function:
+               if ($pArr[4] && $pArr[6]) {
+                       $JScodeHelper = '
+                                               // Call helper function to manage data in the opener window:
+                                       if (parent.window.opener) {
+                                               parent.window.opener.'.$pArr[6].'("'.addslashes($pArr[4]).'",table,uid,type,"'.addslashes($pArr[0]).'");
+                                       } else {
+                                               alert("Error - reference to main window is not set properly!");
+                                               parent.close();
+                                       }
+                       ';
+               }
+                       // insertElement - perform action commands:
+               if ($pArr[4] && $pArr[7]) {
+                               // Call user defined action function:
+                       $JScodeAction = '
+                                       if (parent.window.opener) {
+                                               parent.window.opener.'.$pArr[7].'("'.addslashes($pArr[4]).'",table,uid,type);
+                                               focusOpenerAndClose(close);
+                                       } else {
+                                               alert("Error - reference to main window is not set properly!");
+                                               parent.close();
+                                       }
+                       ';
+               } else if ($pArr[0] && !$pArr[1] && !$pArr[2]) {
+                       $JScodeAction = '
+                                       addElement(filename,table+"_"+uid,fp,close);
+                       ';
+               } else {
+                       $JScodeAction = '
+                                       if (setReferences()) {
+                                               parent.window.opener.group_change("add","'.$pArr[0].'","'.$pArr[1].'","'.$pArr[2].'",elRef,targetDoc);
+                                       } else {
+                                               alert("Error - reference to main window is not set properly!");
+                                       }
+                                       focusOpenerAndClose(close);
+                       ';
+               }
+
                $JScode.='
                        var elRef="";
                        var targetDoc="";
@@ -974,33 +1039,29 @@ class browse_links {
                                }
                        }
                        function insertElement(table, uid, type, filename,fp,filetype,imagefile,action, close)  {       //
-                               if (1=='.($pArr[0]&&!$pArr[1]&&!$pArr[2] ? 1 : 0).')    {
-                                       addElement(filename,table+"_"+uid,fp,close);
-                               } else {
-                                       if (setReferences())    {
-                                               parent.window.opener.group_change("add","'.$pArr[0].'","'.$pArr[1].'","'.$pArr[2].'",elRef,targetDoc);
-                                       } else {
-                                               alert("Error - reference to main window is not set properly!");
-                                       }
-                                       if (close)      {
-                                               parent.window.opener.focus();
-                                               parent.close();
-                                       }
+                               var performAction = true;
+                               '.$JScodeCheck.'
+                                       // Call performing function and finish this action:
+                               if (performAction) {
+                                               '.$JScodeHelper.$JScodeAction.'
                                }
                                return false;
                        }
                        function addElement(elName,elValue,altElValue,close)    {       //
                                if (parent.window.opener && parent.window.opener.setFormValueFromBrowseWin)     {
                                        parent.window.opener.setFormValueFromBrowseWin("'.$pArr[0].'",altElValue?altElValue:elValue,elName);
-                                       if (close)      {
-                                               parent.window.opener.focus();
-                                               parent.close();
-                                       }
+                                       focusOpenerAndClose(close);
                                } else {
                                        alert("Error - reference to main window is not set properly!");
                                        parent.close();
                                }
                        }
+                       function focusOpenerAndClose(close)     {       //
+                               if (close)      {
+                                       parent.window.opener.focus();
+                                       parent.close();
+                               }
+                       }
                ';
 
                        // Finally, add the accumulated JavaScript to the template object:
@@ -1378,7 +1439,7 @@ class browse_links {
        function main_db()      {
 
                        // Starting content:
-               $content=$this->doc->startPage('TBE file selector');
+               $content=$this->doc->startPage('TBE record selector');
 
                        // Init variable:
                $pArr = explode('|',$this->bparams);
@@ -1387,6 +1448,8 @@ class browse_links {
                $pagetree = t3lib_div::makeInstance('TBE_PageTree');
                $pagetree->thisScript=$this->thisScript;
                $pagetree->ext_pArrPages = !strcmp($pArr[3],'pages')?1:0;
+               $pagetree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
+               $pagetree->addField('nav_title');
                $tree=$pagetree->getBrowsableTree();
 
                        // Making the list of elements, if applicable:
@@ -1454,11 +1517,11 @@ class browse_links {
                        $_MCONF['name']='file_list';
                        $_MOD_SETTINGS = t3lib_BEfunc::getModuleData($_MOD_MENU, t3lib_div::_GP('SET'), $_MCONF['name']);
                        $addParams = '&act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
-                       $thumbNailCheck = t3lib_BEfunc::getFuncCheck('','SET[displayThumbs]',$_MOD_SETTINGS['displayThumbs'],$this->thisScript,$addParams).' '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.php:displayThumbs',1);
+                       $thumbNailCheck = t3lib_BEfunc::getFuncCheck('','SET[displayThumbs]',$_MOD_SETTINGS['displayThumbs'],$this->thisScript,$addParams,'id="checkDisplayThumbs"').' <label for="checkDisplayThumbs">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.php:displayThumbs',1).'</label>';
                } else {
                        $thumbNailCheck='';
                }
-               $noThumbs = $noThumbs?$noThumbs:!$_MOD_SETTINGS['displayThumbs'];
+               $noThumbs = $noThumbs ? $noThumbs : !$_MOD_SETTINGS['displayThumbs'];
 
                        // Create folder tree:
                $foldertree = t3lib_div::makeInstance('TBE_FolderTree');
@@ -1487,7 +1550,7 @@ class browse_links {
                                </tr>
                        </table>
                        ';
-               $content.=$thumbNailCheck;
+               $content.= $thumbNailCheck;
 
                        // Adding create folder + upload forms if applicable:
                if (!$BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) $content.=$uploadForm;
@@ -1674,6 +1737,12 @@ class browse_links {
 
                                //      Add the HTML for the record list to output variable:
                        $out.=$dblist->HTMLcode;
+
+                               // Add support for fieldselectbox in singleTableMode
+                       if ($dblist->table) {
+                               $out.= $dblist->fieldSelectBox($dblist->table);
+                       }
+
                        $out.=$dblist->getSearchBox();
                }
 
@@ -1829,7 +1898,7 @@ class browse_links {
                                $fI=pathinfo($filepath);
 
                                        // Thumbnail/size generation:
-                               if (t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],$fI['extension']) && !$noThumbs)      {
+                               if (t3lib_div::inList(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']),strtolower($fI['extension'])) && !$noThumbs)      {
                                        $imgInfo = $imgObj->getImageDimensions($filepath);
                                        $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
                                        $clickIcon = t3lib_BEfunc::getThumbNail($BACK_PATH.'thumbs.php',$filepath,'hspace="5" vspace="5" border="1"');
@@ -2223,7 +2292,7 @@ class browse_links {
 
                $code.='
                        <div id="c-override">
-                               <input type="checkbox" name="overwriteExistingFiles" value="1" /> '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:overwriteExistingFiles',1).'
+                               <input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> <label for="overwriteExistingFiles">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:overwriteExistingFiles',1).'</label>
                        </div>
                ';