[TASK] Show copy and cut buttons in filelist options 21/52521/3
authorGianluigi Martino <gmartino27@gmail.com>
Thu, 20 Apr 2017 16:15:24 +0000 (18:15 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Tue, 2 May 2017 18:35:44 +0000 (20:35 +0200)
At the moment it is only possible to copy or cut files / folder over the
clickmenu. With this patch the copy and cut functions are also listed as
buttons in option list.

Resolves: #80920
Releases: master, 8.7, 7.6
Change-Id: I75d4b8666858b78c4ed01514d43af4471cef5c2e
Reviewed-on: https://review.typo3.org/52521
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Henrik Elsner <helsner@dfau.de>
Tested-by: Henrik Elsner <helsner@dfau.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/filelist/Classes/FileList.php

index 7232e15..d6a3fc3 100644 (file)
@@ -922,6 +922,8 @@ class FileList extends AbstractRecordList
     {
         $cells = [];
         $fullIdentifier = $fileOrFolderObject->getCombinedIdentifier();
+        $md5 = GeneralUtility::shortMD5($fullIdentifier);
+        $isSel = $this->clipObj->isSelected('_FILE', $md5);
 
         // Edit file content (if editable)
         if ($fileOrFolderObject instanceof File && $fileOrFolderObject->checkActionPermission('write') && GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], $fileOrFolderObject->getExtension())) {
@@ -990,6 +992,30 @@ class FileList extends AbstractRecordList
             $cells['info'] = $this->spaceIcon;
         }
 
+        // copy the file
+        if ($fileOrFolderObject->checkActionPermission('copy') && $this->clipObj->current === 'normal') {
+            $copyTitle = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.copy'));
+            $copyIcon = $this->iconFactory->getIcon('actions-edit-copy', Icon::SIZE_SMALL)->render();
+
+            if ($isSel === 'copy') {
+                $copyIcon = $this->iconFactory->getIcon('actions-edit-copy-release', Icon::SIZE_SMALL)->render();
+            }
+
+            $cells['copy'] = '<a class="btn btn-default"" href="' . htmlspecialchars($this->clipObj->selUrlFile($fullIdentifier, 1, ($isSel === 'copy'))) . '" title="' . $copyTitle . '">' . $copyIcon . '</a>';
+        }
+
+        // cut the file
+        if ($fileOrFolderObject->checkActionPermission('move') && $this->clipObj->current === 'normal') {
+            $cutTitle = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.cut'));
+            $cutIcon = $this->iconFactory->getIcon('actions-edit-cut', Icon::SIZE_SMALL)->render();
+
+            if ($isSel === 'cut') {
+                $cutIcon = $this->iconFactory->getIcon('actions-edit-cut-release', Icon::SIZE_SMALL)->render();
+            }
+
+            $cells['cut'] = '<a class="btn btn-default" href="' . htmlspecialchars($this->clipObj->selUrlFile($fullIdentifier, 0, ($isSel === 'cut'))) . '" title="' . $cutTitle . '">' . $cutIcon . '</a>';
+        }
+
         // delete the file
         if ($fileOrFolderObject->checkActionPermission('delete')) {
             $identifier = $fileOrFolderObject->getIdentifier();