Fixed bug #10515: extend Filelist with icon block according to list view
authorSteffen Kamper <info@sk-typo3.de>
Fri, 12 Jun 2009 11:43:10 +0000 (11:43 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Fri, 12 Jun 2009 11:43:10 +0000 (11:43 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@5584 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/class.file_list.inc
typo3/file_list.php
typo3/interfaces/interface.filelist_editiconshook.php [new file with mode: 0644]
typo3/stylesheet.css
typo3/sysext/lang/locallang_mod_file_list.xml
typo3/sysext/t3skin/stylesheets/typo3-file-list.css

index 536ae3d..87d77d4 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-06-12  Steffen Kamper  <info@sk-typo3.de>
+
+       * Fixed bug #10515: extend Filelist with icon block according to list view
+
 2009-06-12  Oliver Hader  <oliver@typo3.org>
 
        * Fixed bug #11272: Autoloader floads sysLog with XCLASS failures
index be60adb..73148c4 100644 (file)
@@ -84,6 +84,7 @@ class fileList extends t3lib_recordList {
        var $sortRev = 1;                                       // Reverse sorting flag
        var $firstElementNumber=0;
        var $clipBoard = 0;
+       var $bigControlPanel = 0;
 
                // internal
        var $JScode = '';
@@ -110,7 +111,7 @@ class fileList extends t3lib_recordList {
         * @param       boolean         Show clipboard flag
         * @return      void
         */
-       function start($path,$pointer,$sort,$sortRev,$clipBoard=0)      {
+       function start($path, $pointer, $sort, $sortRev, $clipBoard=0, $bigControlPanel=0) {
                $this->counter=0;
                $this->totalbytes=0;
                $this->JScode='';
@@ -120,6 +121,7 @@ class fileList extends t3lib_recordList {
                $this->sortRev=$sortRev;
                $this->firstElementNumber=$pointer;
                $this->clipBoard = $clipBoard;
+               $this->bigControlPanel = $bigControlPanel;
                        // setting the maximum length of the filenames to the user's settings or minimum 30 (= $this->fixedL)
                $this->fixedL = max($this->fixedL, $GLOBALS['BE_USER']->uc['titleLen']);
 
@@ -222,12 +224,16 @@ class fileList extends t3lib_recordList {
                        // Adds the code of files/dirs
                $out='';
                $titleCol = 'file';
+               $upLevelDir = dirname(substr($files['files'][0]['path'], 0, -1)) . '/';
+               $levelUp = $GLOBALS['SOBE']->basicFF->checkPathAgainstMounts($upLevelDir) ? $this->linkWrapDir('<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/i/folder_up.gif', 'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.upOneLevel',1) . '" alt="" />', $upLevelDir) : '';
 
                        // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
                $rowlist = t3lib_div::rmFromList($titleCol,$rowlist);
                $rowlist = t3lib_div::uniqueList($rowlist);
                $rowlist = $rowlist ? $titleCol.','.$rowlist : $titleCol;
-               if ($this->clipBoard)   $rowlist.=',_CLIPBOARD_';
+               if ($this->bigControlPanel || $this->clipBoard) {
+                       $rowlist = str_replace('file,', 'file,_CLIPBOARD_,', $rowlist);
+               }
                $this->fieldArray = explode(',',$rowlist);
 
                        // Directories are added
@@ -247,9 +253,9 @@ class fileList extends t3lib_recordList {
 
                        // Header line is drawn
                $theData = Array();
-               reset($this->fieldArray);
-               while(list(,$v)=each($this->fieldArray))        {
-                       if ($v=='_CLIPBOARD_')  {
+               
+               foreach ($this->fieldArray as $v)       {
+                       if ($v == '_CLIPBOARD_' && $this->clipBoard) {
                                $cells=array();
                                $table='_FILE';
                                $elFromTable = $this->clipObj->elFromTable($table);
@@ -265,14 +271,13 @@ class fileList extends t3lib_recordList {
                                                        '<img'.t3lib_iconWorks::skinImg('','gfx/clip_select.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->getLL('clip_markRecords',1).'" alt="'.$GLOBALS['LANG']->getLL('clip_markRecords',1).'" />'.
                                                        '</a>';
                                }
-
                                $theData[$v] = implode('',$cells);
                        } else {        // Normal row:
                                $theT = $this->linkWrapSort($GLOBALS['LANG']->getLL('c_'.$v,1), $this->path,$v);
                                $theData[$v] = $theT;
                        }
                }
-               $out.=$this->addelement(1,'',$theData,' class="c-headLine"','');
+               $out.=$this->addelement(1, $levelUp, $theData, ' class="c-headLine"', '');
                $out.=$iOut;
 
                        // half line is drawn
@@ -350,7 +355,12 @@ class fileList extends t3lib_recordList {
                                                                $theData[$field]= $this->linkWrapDir($title,$path);
                                                        break;
                                                        case '_CLIPBOARD_':
-                                                               $theData[$field]=$this->makeClip($theFile);
+                                                               $temp = '';
+                                                               if ($this->bigControlPanel) {
+                                                                       $temp .= $this->makeEdit($theFile);
+                                                               }
+                                                               $temp .= $this->makeClip($theFile);
+                                                               $theData[$field] = $temp;
                                                        break;
                                                        case '_REF_':
                                                                $theData[$field]=$this->makeRef($theFile);
@@ -487,7 +497,12 @@ class fileList extends t3lib_recordList {
                                                                $theData[$field]=Date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $theFile[$field]);
                                                        break;
                                                        case '_CLIPBOARD_':
-                                                               $theData[$field]=$this->makeClip($theFile);
+                                                               $temp = '';
+                                                               if ($this->bigControlPanel) {
+                                                                       $temp .= $this->makeEdit($theFile);
+                                                               }
+                                                               $temp .= $this->makeClip($theFile);
+                                                               $theData[$field] = $temp;
                                                        break;
                                                        case '_REF_':
                                                                $theData[$field]=$this->makeRef($theFile);
@@ -660,6 +675,63 @@ class fileList extends t3lib_recordList {
        }
 
        /**
+       * Creates the edit control section
+       * 
+       * @param        array           Array with information about the file/directory for which to make the edit control section for the listing.
+       * @return       string          HTML-table
+       */
+       function makeEdit($theData) {
+               $cells = array();
+               $fullIdent = $theData['path'].$theData['file'];
+               $canEdit = t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], $theData['realFileext']);
+               
+                       // prepare space icon
+               $iconWidth  = $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['iconSizeWidth']  ? $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['iconSizeWidth']  : 12;
+               $iconHeight = $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['iconSizeHeight'] ? $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['iconSizeHeight'] : 12;
+               $spaceIcon = '<img src="' . $this->backPath . 'clear.gif" width="' . $iconWidth . '" height="' . $iconHeight . '" title="" alt="" />';
+
+               
+                       //edit
+               if ($theData['type'] == 'dir' || !$canEdit) {
+                       $cells['edit'] = $spaceIcon;
+               } else {
+                       $editOnClick = 'top.content.list_frame.location.href=top.TS.PATH_typo3+\'file_edit.php?target=' .
+                               rawurlencode($fullIdent) . 
+                               '&returnUrl=\'+top.rawurlencode(top.content.list_frame.document.location);return false;';
+                       $cells['edit'] = '<a href="#" onclick="' . $editOnClick . '"><img' . t3lib_iconWorks::skinImg('', 'gfx/edit_file.gif', 'width="' . $iconWidth . '" height="' . $iconHeight . '"') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.edit') . '" alt="" /></a>';
+               }
+                       //rename
+               $renameOnClick = 'top.content.list_frame.location.href=top.TS.PATH_typo3+\'file_rename.php?target=' .
+                       rawurlencode($fullIdent) . 
+                       '&returnUrl=\'+top.rawurlencode(top.content.list_frame.document.location);return false;';
+               $cells['rename'] = '<a href="#" onclick="' . $renameOnClick . '"><img' . t3lib_iconWorks::skinImg('', 'gfx/rename.gif', 'width="' . $iconWidth . '" height="' . $iconHeight . '"') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.rename') . '" alt="" /></a>';
+
+                       //info
+               $infoOnClick = 'top.launchView(\'' . $fullIdent . '\', \'\');return false;';
+               $cells['info'] = '<a href="#" onclick="' . $infoOnClick . '"><img' . t3lib_iconWorks::skinImg('', 'gfx/zoom2.gif', 'width="' . $iconWidth . '" height="' . $iconHeight . '"') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.info') . '" alt="" /></a>';
+
+                       // Hook for manipulating edit icons.
+               if(is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fileList']['editIconsHook'])) {
+                       foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fileList']['editIconsHook'] as $classData) {
+                               $hookObject = &t3lib_div::getUserObj($classData);
+
+                               if(!($hookObject instanceof fileList_editIconHook)) {
+                                       throw new UnexpectedValueException('$hookObject must implement interface fileList_editIconHook', 1235225797);
+                               }
+
+                               $hookObject->manipulateEditIcons($cells, $this);
+                       }
+               }
+               
+                       // Compile items into a DIV-element:
+               return '                                                        <!-- EDIT CONTROLS: -->
+                                                                                       <div class="typo3-editCtrl">
+                                                                                               ' . implode('
+                                                                                               ', $cells).'
+                                                                                       </div>';
+       }
+       
+       /**
         * Make reference count
         *
         * @param       array           Array with information about the file/directory for which to make the clipboard panel for the listing.
index bb4d936..5175842 100644 (file)
@@ -145,7 +145,8 @@ class SC_file_list {
                        'sort' => '',
                        'reverse' => '',
                        'displayThumbs' => '',
-                       'clipBoard' => ''
+                       'clipBoard' => '',
+                       'bigControlPanel' => ''
                );
 
                        // CLEANSE SETTINGS
@@ -281,7 +282,7 @@ class SC_file_list {
 
                                // Start up filelisting object, include settings.
                        $this->pointer = t3lib_div::intInRange($this->pointer,0,100000);
-                       $this->filelist->start($this->id,$this->pointer,$this->MOD_SETTINGS['sort'],$this->MOD_SETTINGS['reverse'],$this->MOD_SETTINGS['clipBoard']);
+                       $this->filelist->start($this->id, $this->pointer, $this->MOD_SETTINGS['sort'], $this->MOD_SETTINGS['reverse'], $this->MOD_SETTINGS['clipBoard'], $this->MOD_SETTINGS['bigControlPanel']);
 
                                // Generate the list
                        $this->filelist->generateList();
@@ -331,6 +332,9 @@ class SC_file_list {
                                        <div id="typo3-listOptions">
                                ';
 
+                                       // Add "display bigControlPanel" checkbox:      
+                               $pageContent.=t3lib_BEfunc::getFuncCheck($this->id, 'SET[bigControlPanel]', $this->MOD_SETTINGS['bigControlPanel'], 'file_list.php', '', 'id="bigControlPanel"') . '<label for="bigControlPanel"> ' .$LANG->getLL('bigControlPanel', 1) . '</label><br />';
+
                                        // Add "display thumbnails" checkbox:
                                $pageContent.=t3lib_BEfunc::getFuncCheck($this->id,'SET[displayThumbs]',$this->MOD_SETTINGS['displayThumbs'],'file_list.php','','id="checkDisplayThumbs"').' <label for="checkDisplayThumbs">'.$LANG->getLL('displayThumbs',1).'</label><br />';
 
diff --git a/typo3/interfaces/interface.filelist_editiconshook.php b/typo3/interfaces/interface.filelist_editiconshook.php
new file mode 100644 (file)
index 0000000..f61da37
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2008 Steffen Kamper <info@sk-typo3.de>
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*  A copy is found in the textfile GPL.txt and important notices to the license
+*  from the author is found in LICENSE.txt distributed with these scripts.
+*
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+
+/**
+ * interface for classes which hook into file list module and manipulateds edit icon array
+ *
+ * @author     Steffen Kamper <info@sk-typo3.de>
+ * @package TYPO3
+ * @subpackage cms
+ */
+interface fileList_editIconHook {
+
+       /**
+        * modifies edit icon array
+        *
+        * @param       array                                   array of edit icons
+        * @param       fileList        parent object
+        * @return      void
+        */
+       public function manipulateEditIcons(&$cells, &$parentObject);
+
+}
+
+?>
\ No newline at end of file
index 692b868..aae4050 100644 (file)
@@ -2044,6 +2044,14 @@ table#typo3-filelist tr.c-headLine td {
 table#typo3-filelist tr td div.typo3-clipCtrl {
        background-color: #abbbb4;
        text-align: center;
+       float: left;
+}
+
+table#typo3-filelist tr td div.typo3-editCtrl {
+       background-color: #abbbb4;
+       text-align: center;
+       float: left;
+       padding-right: 10px;
 }
 
 
index c30f4d4..d880bb4 100755 (executable)
@@ -6,6 +6,7 @@
        </meta>
        <data type="array">
                <languageKey index="default" type="array">
+                       <label index="bigControlPanel">Extended view</label>
                        <label index="clipBoard">Show clipboard</label>
                        <label index="clip_paste">Paste in clipboard content</label>
                        <label index="clip_pasteInto">Paste into: Clipboard content is inserted into this folder</label>
index 37e8013..714bb26 100644 (file)
@@ -41,6 +41,7 @@ table#typo3-filelist tr td img {
        text-align: center;
 }
 
-table#typo3-filelist tr td div.typo3-clipCtrl {
+table#typo3-filelist tr td div.typo3-clipCtrl,
+table#typo3-filelist tr td div.typo3-editCtrl {
        background-color:transparent;
 }