Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Add missing copy and cut button in file list search result
It is now possible to copy or cut the file in file list search result. Resolves: #86414 Releases: master Change-Id: I60ca052d36efaa45cc348f712b05cac3127cc120 Reviewed-on: https://review.typo3.org/58426 Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de> Tested-by: Daniel Goerz <daniel.goerz@posteo.de> Tested-by: TYPO3com <no-reply@typo3.com> Tested-by: Felix Althaus <felix.althaus@undkonsorten.com> Reviewed-by: Benni Mack <benni@typo3.org> Tested-by: Benni Mack <benni@typo3.org>
- Loading branch information
1 parent
4c9699a
commit 0430307
Showing
4 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
typo3/sysext/filelist/Classes/ViewHelpers/Uri/CopyCutFileViewHelper.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
namespace TYPO3\CMS\Filelist\ViewHelpers\Uri; | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
use Closure; | ||
use TYPO3\CMS\Backend\Clipboard\Clipboard; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; | ||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; | ||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; | ||
|
||
/** | ||
* Class EditFileContentViewHelper | ||
*/ | ||
class CopyCutFileViewHelper extends AbstractViewHelper | ||
{ | ||
use CompileWithRenderStatic; | ||
|
||
/** | ||
* Initialize arguments | ||
*/ | ||
public function initializeArguments() | ||
{ | ||
$this->registerArgument('file', \TYPO3\CMS\Core\Resource\AbstractFile::class, '', true); | ||
$this->registerArgument('copyOrCut', 'string', '', false, 'copy'); | ||
} | ||
|
||
/** | ||
* Renders a link to copy a file | ||
* | ||
* @param array $arguments | ||
* @param Closure $renderChildrenClosure | ||
* @param RenderingContextInterface $renderingContext | ||
* | ||
* @return string | ||
* @throws \InvalidArgumentException | ||
*/ | ||
public static function renderStatic(array $arguments, Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) | ||
{ | ||
if ($arguments['copyOrCut'] !== 'cut' && $arguments['copyOrCut'] !== 'copy') { | ||
throw new \InvalidArgumentException('Argument "copyOrCut" must be either "copy" or "cut"', 1540548015); | ||
} | ||
|
||
/** @var \TYPO3\CMS\Core\Resource\AbstractFile $file */ | ||
$file = $arguments['file']; | ||
|
||
/** @var Clipboard $clipboard */ | ||
$clipboard = GeneralUtility::makeInstance(Clipboard::class); | ||
$clipboard->initializeClipboard(); | ||
|
||
$fullIdentifier = $file->getCombinedIdentifier(); | ||
$md5 = GeneralUtility::shortMD5($fullIdentifier); | ||
$isSel = $clipboard->isSelected('_FILE', $md5); | ||
|
||
if ($arguments['copyOrCut'] === 'copy') { | ||
return $clipboard->selUrlFile($fullIdentifier, true, $isSel === 'copy'); | ||
} | ||
return $clipboard->selUrlFile($fullIdentifier, false, $isSel === 'cut'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters