2 namespace TYPO3\CMS\Filelist
;
4 /***************************************************************
7 * (c) 1999-2009 Kasper Skårhøj (kasperYYYY@typo3.com)
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
30 * Class for rendering of File>Filelist
32 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
34 class FileList
extends \TYPO3\CMS\Backend\RecordList\AbstractRecordList
{
36 // default Max items shown
38 * @todo Define visibility
42 // Boolean. Thumbnails on records containing files (pictures)
44 * @todo Define visibility
49 * @todo Define visibility
51 public $widthGif = '<img src="clear.gif" width="1" height="1" hspace="165" alt="" />';
53 // Max length of strings
55 * @todo Define visibility
60 * @todo Define visibility
64 // If TRUE click menus are generated on files and folders
66 * @todo Define visibility
68 public $clickMenus = 1;
70 // The field to sort by...
72 * @todo Define visibility
76 // Reverse sorting flag
78 * @todo Define visibility
83 * @todo Define visibility
85 public $firstElementNumber = 0;
88 * @todo Define visibility
90 public $clipBoard = 0;
93 * @todo Define visibility
95 public $bigControlPanel = 0;
99 * @todo Define visibility
104 * @todo Define visibility
106 public $HTMLcode = '';
109 * @todo Define visibility
111 public $totalbytes = 0;
114 * @todo Define visibility
116 public $dirs = array();
119 * @todo Define visibility
121 public $files = array();
124 * @todo Define visibility
129 * @var \TYPO3\CMS\Core\Resource\Folder
131 protected $folderObject;
133 // Counting the elements no matter what...
135 * @todo Define visibility
137 public $eCounter = 0;
140 * @todo Define visibility
142 public $dirCounter = 0;
145 * @todo Define visibility
147 public $totalItems = '';
150 * @todo Define visibility
152 public $CBnames = array();
155 * Initialization of class
157 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject The folder to work on
158 * @param integer $pointer Pointer
159 * @param boolean $sort Sorting column
160 * @param boolean $sortRev Sorting direction
161 * @param boolean $bigControlPanel Show clipboard flag
163 * @todo Define visibility
165 public function start(\TYPO3\CMS\Core\
Resource\Folder
$folderObject, $pointer, $sort, $sortRev, $clipBoard = FALSE, $bigControlPanel = FALSE) {
166 $this->script
= \TYPO3\CMS\Backend\Utility\BackendUtility
::getModuleUrl('file_list');
167 $this->folderObject
= $folderObject;
169 $this->totalbytes
= 0;
171 $this->HTMLcode
= '';
172 $this->path
= $folderObject->getIdentifier();
174 $this->sortRev
= $sortRev;
175 $this->firstElementNumber
= $pointer;
176 $this->clipBoard
= $clipBoard;
177 $this->bigControlPanel
= $bigControlPanel;
178 // Setting the maximum length of the filenames to the user's settings or minimum 30 (= $this->fixedL)
179 $this->fixedL
= max($this->fixedL
, $GLOBALS['BE_USER']->uc
['titleLen']);
180 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_common.xml');
184 * Reading files and directories, counting elements and generating the list in ->HTMLcode
187 * @todo Define visibility
189 public function generateList() {
190 $this->HTMLcode
.= $this->getTable('fileext,tstamp,size,rw,_REF_');
194 * Return the buttons used by the file list to include in the top header
196 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject
199 public function getButtonsAndOtherMarkers(\TYPO3\CMS\Core\
Resource\Folder
$folderObject) {
200 $otherMarkers = array(
210 // Makes the code for the foldericon in the top
212 list($title, $icon, $path) = $this->dirData($folderObject);
213 $title = htmlspecialchars($folderObject->getIdentifier());
214 // Start compiling the HTML
215 // @todo: how to fix this? $title = $GLOBALS['SOBE']->basicFF->blindPath($title);
216 // If this is some subpage under the mount root....
217 if ($folderObject->getStorage()->isWithinFileMountBoundaries($folderObject)) {
218 // The icon with link
219 $otherMarkers['PAGE_ICON'] = \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon($icon, array('title' => $title));
220 $buttons['level_up'] = $this->linkWrapDir(\TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('actions-view-go-up', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.upOneLevel', 1))), $folderObject);
221 // No HTML specialchars here - HTML like <strong> </strong> is allowed
222 $otherMarkers['TITLE'] .= \TYPO3\CMS\Core\Utility\GeneralUtility
::removeXSS(\TYPO3\CMS\Core\Utility\GeneralUtility
::fixed_lgd_cs($title, -($this->fixedL +
20)));
224 // This is the root page
225 $otherMarkers['PAGE_ICON'] = \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('apps-filetree-root');
226 $otherMarkers['TITLE'] .= htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility
::fixed_lgd_cs($title, -($this->fixedL +
20)));
228 if ($this->clickMenus
) {
229 $otherMarkers['PAGE_ICON'] = $GLOBALS['SOBE']->doc
->wrapClickMenuOnIcon($otherMarkers['PAGE_ICON'], $folderObject->getCombinedIdentifier());
232 $buttons['refresh'] = '<a href="' . htmlspecialchars($this->listURL()) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.reload', 1) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('actions-system-refresh') . '</a>';
233 return array($buttons, $otherMarkers);
237 * Wrapping input string in a link with clipboard command.
239 * @param string $string String to be linked - must be htmlspecialchar'ed / prepared before.
240 * @param string $table table - NOT USED
241 * @param string $cmd "cmd" value
242 * @param string $warning Warning for JS confirm message
243 * @return string Linked string
244 * @todo Define visibility
246 public function linkClipboardHeaderIcon($string, $table, $cmd, $warning = '') {
247 $onClickEvent = 'document.dblistForm.cmd.value=\'' . $cmd . '\';document.dblistForm.submit();';
249 $onClickEvent = 'if (confirm(' . $GLOBALS['LANG']->JScharCode($warning) . ')){' . $onClickEvent . '}';
251 return '<a href="#" onclick="' . htmlspecialchars($onClickEvent) . 'return false;">' . $string . '</a>';
255 * Returns a table with directories and files listed.
257 * @param array $rowlist Array of files from path
258 * @return string HTML-table
259 * @todo Define visibility
261 public function getTable($rowlist) {
262 // TODO use folder methods directly when they support filters
263 $storage = $this->folderObject
->getStorage();
264 $storage->resetFileAndFolderNameFiltersToDefault();
265 $folders = $storage->getFolderList($this->folderObject
->getIdentifier());
266 $files = $storage->getFileList($this->folderObject
->getIdentifier());
267 // Only render the contents of a browsable storage
268 if ($this->folderObject
->getStorage()->isBrowsable()) {
269 $this->sort
= trim($this->sort
);
270 if ($this->sort
!== '') {
271 $filesToSort = array();
272 foreach ($files as $file) {
273 $fileObject = $storage->getFile($file['identifier']);
274 switch ($this->sort
) {
276 $sortingKey = $fileObject->getSize();
279 $sortingKey = ($fileObject->checkActionPermission('read') ?
'R' : '' . $fileObject->checkActionPermission('write')) ?
'W' : '';
282 $sortingKey = $fileObject->getExtension();
285 $sortingKey = $fileObject->getModificationTime();
288 if ($fileObject->hasProperty($this->sort
)) {
289 $sortingKey = $fileObject->getProperty($this->sort
);
291 $sortingKey = $fileObject->getName();
295 while (isset($filesToSort[$sortingKey . $i])) {
298 $filesToSort[$sortingKey . $i] = $fileObject;
300 if (intval($this->sortRev
) === 1) {
301 krsort($filesToSort);
305 $files = $filesToSort;
307 $this->totalItems
= count($folders) +
count($files);
308 // Adds the code of files/dirs
311 // @todo: fix this: go up one level with FAL
312 // $upLevelDir = dirname(substr($files['files'][0]['path'], 0, -1)) . '/';
313 // $levelUp = $GLOBALS['SOBE']->basicFF->checkPathAgainstMounts($upLevelDir) ? $this->linkWrapDir(t3lib_iconWorks::getSpriteIcon('actions-view-go-up', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.upOneLevel', TRUE))), $upLevelDir) : '';
314 // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
315 $rowlist = \TYPO3\CMS\Core\Utility\GeneralUtility
::rmFromList($titleCol, $rowlist);
316 $rowlist = \TYPO3\CMS\Core\Utility\GeneralUtility
::uniqueList($rowlist);
317 $rowlist = $rowlist ?
$titleCol . ',' . $rowlist : $titleCol;
318 if ($this->bigControlPanel ||
$this->clipBoard
) {
319 $rowlist = str_replace('file,', 'file,_CLIPBOARD_,', $rowlist);
321 $this->fieldArray
= explode(',', $rowlist);
322 $folderObjects = array();
323 foreach ($folders as $folder) {
324 $folderObjects[] = $storage->getFolder($folder['identifier']);
326 // Directories are added
327 $iOut = $this->formatDirList($folderObjects);
329 // Half line is drawn
335 $iOut .= $this->formatFileList($files, $titleCol);
336 // Header line is drawn
338 foreach ($this->fieldArray
as $v) {
339 if ($v == '_CLIPBOARD_' && $this->clipBoard
) {
342 $elFromTable = $this->clipObj
->elFromTable($table);
343 if (count($elFromTable)) {
344 $cells[] = '<a href="' . htmlspecialchars($this->clipObj
->pasteUrl('_FILE', $this->folderObject
->getCombinedIdentifier())) . '" onclick="return ' . htmlspecialchars($this->clipObj
->confirmMsg('_FILE', $this->path
, 'into', $elFromTable)) . '" title="' . $GLOBALS['LANG']->getLL('clip_paste', 1) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('actions-document-paste-after') . '</a>';
346 if ($this->clipObj
->current
!= 'normal' && $iOut) {
347 $cells[] = $this->linkClipboardHeaderIcon(\TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('actions-edit-copy', array('title' => $GLOBALS['LANG']->getLL('clip_selectMarked', 1))), $table, 'setCB');
348 $cells[] = $this->linkClipboardHeaderIcon(\TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('actions-edit-delete', array('title' => $GLOBALS['LANG']->getLL('clip_deleteMarked'))), $table, 'delete', $GLOBALS['LANG']->getLL('clip_deleteMarkedWarning'));
349 $onClick = 'checkOffCB(\'' . implode(',', $this->CBnames
) . '\', this); return false;';
350 $cells[] = '<a class="cbcCheckAll" rel="" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $GLOBALS['LANG']->getLL('clip_markRecords', TRUE) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('actions-document-select') . '</a>';
352 $theData[$v] = implode('', $cells);
355 $theT = $this->linkWrapSort($GLOBALS['LANG']->getLL('c_' . $v, 1), $this->folderObject
->getCombinedIdentifier(), $v);
356 $theData[$v] = $theT;
361 $out .= '<thead>' . $this->addelement(1, $levelUp, $theData, ' class="t3-row-header"', '') . '</thead>';
362 $out .= '<tbody>' . $iOut . '</tbody>';
363 // half line is drawn
369 <table cellpadding="0" cellspacing="0" id="typo3-filelist">
374 /** @var $flashMessage \TYPO3\CMS\Core\Messaging\FlashMessage */
375 $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->getLL('storageNotBrowsableMessage'), $GLOBALS['LANG']->getLL('storageNotBrowsableTitle'), \TYPO3\CMS\Core\Messaging\FlashMessage
::INFO
);
376 $out = $flashMessage->render();
382 * Gets the number of files and total size of a folder
385 * @todo Define visibility
387 public function getFolderInfo() {
388 if ($this->counter
== 1) {
389 $fileLabel = $GLOBALS['LANG']->getLL('file', TRUE);
391 $fileLabel = $GLOBALS['LANG']->getLL('files', TRUE);
393 return $this->counter
. ' ' . $fileLabel . ', ' . \TYPO3\CMS\Core\Utility\GeneralUtility
::formatSize($this->totalbytes
, $GLOBALS['LANG']->getLL('byteSizeUnits', TRUE));
397 * This returns tablerows for the directories in the array $items['sorting'].
399 * @param \TYPO3\CMS\Core\Resource\Folder[] $folders Folders of \TYPO3\CMS\Core\Resource\Folder
400 * @return string HTML table rows.
401 * @todo Define visibility
403 public function formatDirList(array $folders) {
405 foreach ($folders as $folderObject) {
406 list($flag, $code) = $this->fwd_rwd_nav();
411 list($title, $icon, $path) = $this->dirData($folderObject);
412 // The icon with link
413 $theIcon = \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIconForFile('folder', array('title' => $title));
414 if ($this->clickMenus
) {
415 $theIcon = $GLOBALS['SOBE']->doc
->wrapClickMenuOnIcon($theIcon, $folderObject->getCombinedIdentifier());
417 // Preparing and getting the data-array
419 foreach ($this->fieldArray
as $field) {
422 $numFiles = $folderObject->getFileCount();
423 $theData[$field] = $numFiles . ' ' . $GLOBALS['LANG']->getLL(($numFiles === 1 ?
'file' : 'files'), TRUE);
426 $theData[$field] = (!$folderObject->checkActionPermission('read') ?
' ' : '<span class="typo3-red"><strong>' . $GLOBALS['LANG']->getLL('read', TRUE) . '</strong></span>') . (!$folderObject->checkActionPermission('write') ?
'' : '<span class="typo3-red"><strong>' . $GLOBALS['LANG']->getLL('write', TRUE) . '</strong></span>');
429 $theData[$field] = $GLOBALS['LANG']->getLL('folder', TRUE);
432 // @todo: FAL: how to get the mtime info -- $theData[$field] = \TYPO3\CMS\Backend\Utility\BackendUtility::date($theFile['tstamp']);
433 $theData[$field] = '-';
436 $theData[$field] = $this->linkWrapDir($title, $folderObject);
440 if ($this->bigControlPanel
) {
441 $temp .= $this->makeEdit($folderObject);
443 $temp .= $this->makeClip($folderObject);
444 $theData[$field] = $temp;
447 $theData[$field] = $this->makeRef($folderObject);
450 $theData[$field] = \TYPO3\CMS\Core\Utility\GeneralUtility
::fixed_lgd_cs($theFile[$field], $this->fixedL
);
454 $out .= $this->addelement(1, $theIcon, $theData, ' class="file_list_normal"');
457 $this->dirCounter
= $this->eCounter
;
463 * Wraps the directory-titles
465 * @param string $title String to be wrapped in links
466 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject Folder to work on
467 * @return string HTML
468 * @todo Define visibility
470 public function linkWrapDir($title, \TYPO3\CMS\Core\
Resource\Folder
$folderObject) {
471 $href = $this->backPath
. $this->script
. '&id=' . rawurlencode($folderObject->getCombinedIdentifier());
472 $onclick = ' onclick="' . htmlspecialchars(('top.content.nav_frame.hilight_row("file","folder' . \TYPO3\CMS\Core\Utility\GeneralUtility
::md5int($folderObject->getCombinedIdentifier()) . '_"+top.fsMod.currentBank)')) . '"';
473 // Sometimes $code contains plain HTML tags. In such a case the string should not be modified!
474 if (!strcmp($title, strip_tags($title))) {
475 return '<a href="' . htmlspecialchars($href) . '"' . $onclick . ' title="' . htmlspecialchars($title) . '">' . \TYPO3\CMS\Core\Utility\GeneralUtility
::fixed_lgd_cs($title, $this->fixedL
) . '</a>';
477 return '<a href="' . htmlspecialchars($href) . '"' . $onclick . '>' . $title . '</a>';
482 * Wraps filenames in links which opens them in a window IF they are in web-path.
484 * @param string $code String to be wrapped in links
485 * @param \TYPO3\CMS\Core\Resource\File $fileObject File to be linked
486 * @return string HTML
487 * @todo Define visibility
489 public function linkWrapFile($code, \TYPO3\CMS\Core\
Resource\File
$fileObject) {
490 $fileUrl = $fileObject->getPublicUrl(TRUE);
492 $aOnClick = 'return top.openUrlInWindow(\'' . $fileUrl . '\', \'WebFile\');';
493 $code = '<a href="#" title="' . htmlspecialchars($code) . '" onclick="' . htmlspecialchars($aOnClick) . '">' . \TYPO3\CMS\Core\Utility\GeneralUtility
::fixed_lgd_cs($code, $this->fixedL
) . '</a>';
499 * Returns list URL; This is the URL of the current script with id and imagemode parameters, thats all.
500 * The URL however is not relative (with the backpath), otherwise \TYPO3\CMS\Core\Utility\GeneralUtility::sanitizeLocalUrl() would say that
501 * the URL would be invalid
504 * @todo Define visibility
506 public function listURL() {
507 return \TYPO3\CMS\Core\Utility\GeneralUtility
::linkThisScript(array(
508 'target' => rawurlencode($this->folderObject
->getCombinedIdentifier()),
509 'imagemode' => $this->thumbs
514 * Returns some data specific for the directories...
516 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject File information array
517 * @return array (title, icon, path)
518 * @todo Define visibility
520 public function dirData(\TYPO3\CMS\Core\
Resource\Folder
$folderObject) {
521 $title = htmlspecialchars($folderObject->getName());
522 $icon = 'apps-filetree-folder-default';
523 if ($title == '_temp_') {
524 $icon = 'apps-filetree-folder-temp';
525 $title = '<strong>' . $GLOBALS['LANG']->getLL('temp', TRUE) . '</strong>';
527 if ($title == '_recycler_') {
528 $icon = 'apps-filetree-folder-recycler';
529 $title = '<strong>' . $GLOBALS['LANG']->getLL('recycler', TRUE) . '</strong>';
531 // Mark the icon as read-only icon if the folder is not writable
532 if ($folderObject->checkActionPermission('write') === FALSE) {
533 $icon = 'apps-filetree-folder-locked';
535 return array($title, $icon, $folderObject->getIdentifier());
539 * This returns tablerows for the files in the array $items['sorting'].
541 * @param \TYPO3\CMS\Core\Resource\File[] $files File items
542 * @return string HTML table rows.
543 * @todo Define visibility
545 public function formatFileList(array $files) {
547 foreach ($files as $fileObject) {
548 list($flag, $code) = $this->fwd_rwd_nav();
553 $fileInfo = $fileObject->getStorage()->getFileInfo($fileObject);
554 $this->totalbytes +
= $fileObject->getSize();
555 $ext = $fileObject->getExtension();
556 $fileName = trim($fileObject->getName());
557 // The icon with link
558 $theIcon = \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIconForFile($ext, array('title' => $fileName));
559 if ($this->clickMenus
) {
560 $theIcon = $GLOBALS['SOBE']->doc
->wrapClickMenuOnIcon($theIcon, $fileObject->getCombinedIdentifier());
562 // Preparing and getting the data-array
564 foreach ($this->fieldArray
as $field) {
567 $theData[$field] = \TYPO3\CMS\Core\Utility\GeneralUtility
::formatSize($fileObject->getSize(), $GLOBALS['LANG']->getLL('byteSizeUnits', TRUE));
570 $theData[$field] = '' . (!$fileObject->checkActionPermission('read') ?
' ' : '<span class="typo3-red"><strong>' . $GLOBALS['LANG']->getLL('read', TRUE) . '</strong></span>') . (!$fileObject->checkActionPermission('write') ?
'' : '<span class="typo3-red"><strong>' . $GLOBALS['LANG']->getLL('write', TRUE) . '</strong></span>');
573 $theData[$field] = strtoupper($ext);
576 $theData[$field] = \TYPO3\CMS\Backend\Utility\BackendUtility
::date($fileInfo['mtime']);
580 if ($this->bigControlPanel
) {
581 $temp .= $this->makeEdit($fileObject);
583 $temp .= $this->makeClip($fileObject);
584 $theData[$field] = $temp;
587 $theData[$field] = $this->makeRef($fileObject);
590 $theData[$field] = $this->linkWrapFile(htmlspecialchars($fileName), $fileObject);
592 if ($this->thumbs
&& $this->isImage($ext)) {
593 $processedFile = $fileObject->process(\TYPO3\CMS\Core\
Resource\ProcessedFile
::CONTEXT_IMAGEPREVIEW
, array());
594 if ($processedFile) {
595 $thumbUrl = $processedFile->getPublicUrl(TRUE);
596 $theData[$field] .= '<br /><img src="' . $thumbUrl . '" hspace="2" title="' . htmlspecialchars($fileName) . '" alt="" />';
601 // @todo: fix the access on the array
602 $theData[$field] = htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility
::fixed_lgd_cs($theFile[$field], $this->fixedL
));
606 $out .= $this->addelement(1, $theIcon, $theData, ' class="file_list_normal"');
614 * Returns TRUE if $ext is an image-extension according to $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
616 * @param string $ext File extension
618 * @todo Define visibility
620 public function isImage($ext) {
621 return \TYPO3\CMS\Core\Utility\GeneralUtility
::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], strtolower($ext));
625 * Wraps the directory-titles ($code) in a link to filelist/mod1/index.php (id=$path) and sorting commands...
627 * @param string $code String to be wrapped
628 * @param string $folderIdentifier ID (path)
629 * @param string $col Sorting column
630 * @return string HTML
631 * @todo Define visibility
633 public function linkWrapSort($code, $folderIdentifier, $col) {
634 if ($this->sort
=== $col) {
635 // Check reverse sorting
636 $params = '&SET[sort]=' . $col . '&SET[reverse]=' . ($this->sortRev ?
'0' : '1');
637 $sortArrow = \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('status-status-sorting-light-' . ($this->sortRev ?
'desc' : 'asc'));
639 $params = '&SET[sort]=' . $col . '&SET[reverse]=0';
642 $href = \TYPO3\CMS\Core\Utility\GeneralUtility
::resolveBackPath(($GLOBALS['BACK_PATH'] . $this->script
)) . '&id=' . rawurlencode($folderIdentifier) . $params;
643 return '<a href="' . htmlspecialchars($href) . '">' . $code . $sortArrow . '</a>';
647 * Creates the clipboard control pad
649 * @param \TYPO3\CMS\Core\Resource\File|\TYPO3\CMS\Core\Resource\Folder $fileOrFolderObject Array with information about the file/directory for which to make the clipboard panel for the listing.
650 * @return string HTML-table
651 * @todo Define visibility
653 public function makeClip($fileOrFolderObject) {
655 $fullIdentifier = $fileOrFolderObject->getCombinedIdentifier();
656 $md5 = \TYPO3\CMS\Core\Utility\GeneralUtility
::shortmd5($fullIdentifier);
657 // For normal clipboard, add copy/cut buttons:
658 if ($this->clipObj
->current
== 'normal') {
659 $isSel = $this->clipObj
->isSelected('_FILE', $md5);
660 $cells[] = '<a href="' . htmlspecialchars($this->clipObj
->selUrlFile($fullIdentifier, 1, ($isSel == 'copy'))) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon(('actions-edit-copy' . ($isSel == 'copy' ?
'-release' : '')), array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:cm.copy', 1))) . '</a>';
661 $cells[] = '<a href="' . htmlspecialchars($this->clipObj
->selUrlFile($fullIdentifier, 0, ($isSel == 'cut'))) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon(('actions-edit-cut' . ($isSel == 'cut' ?
'-release' : '')), array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:cm.cut', 1))) . '</a>';
663 // For numeric pads, add select checkboxes:
664 $n = '_FILE|' . $md5;
665 $this->CBnames
[] = $n;
666 $checked = $this->clipObj
->isSelected('_FILE', $md5) ?
' checked="checked"' : '';
667 $cells[] = '<input type="hidden" name="CBH[' . $n . ']" value="0" />' . '<input type="checkbox" name="CBC[' . $n . ']" value="' . htmlspecialchars($fullIdentifier) . '" class="smallCheckboxes"' . $checked . ' />';
669 // Display PASTE button, if directory:
670 $elFromTable = $this->clipObj
->elFromTable('_FILE');
671 if (is_a($fileOrFolderObject, 'TYPO3\\CMS\\Core\\Resource\\Folder') && count($elFromTable)) {
672 $cells[] = '<a href="' . htmlspecialchars($this->clipObj
->pasteUrl('_FILE', $fullIdentifier)) . '" onclick="return ' . htmlspecialchars($this->clipObj
->confirmMsg('_FILE', $fullIdentifier, 'into', $elFromTable)) . '" title="' . $GLOBALS['LANG']->getLL('clip_pasteInto', TRUE) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('actions-document-paste-into') . '</a>';
674 // Compile items into a DIV-element:
675 return ' <!-- CLIPBOARD PANEL: -->
676 <div class="typo3-clipCtrl">
683 * Creates the edit control section
685 * @param \TYPO3\CMS\Core\Resource\File|\TYPO3\CMS\Core\Resource\Folder $fileOrFolderObject Array with information about the file/directory for which to make the edit control section for the listing.
686 * @return string HTML-table
687 * @todo Define visibility
689 public function makeEdit($fileOrFolderObject) {
691 $fullIdentifier = $fileOrFolderObject->getCombinedIdentifier();
692 // Edit metadata of file
694 if (is_a($fileOrFolderObject, 'TYPO3\\CMS\\Core\\Resource\\File') && $fileOrFolderObject->isIndexed() && $fileOrFolderObject->checkActionPermission('edit')) {
696 'sys_file' => array($fileOrFolderObject->getUid() => 'edit')
698 $editOnClick = \TYPO3\CMS\Backend\Utility\BackendUtility
::editOnClick(\TYPO3\CMS\Core\Utility\GeneralUtility
::implodeArrayForUrl('edit', $data), $GLOBALS['BACK_PATH'], $this->listUrl());
699 $cells['editmetadata'] = '<a href="#" onclick="' . $editOnClick . '" title="Edit Metadata of this file">' . \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('actions-document-open') . '</a>';
701 $cells['editmetadata'] = \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('empty-empty');
703 } catch (\Exception
$e) {
704 $cells['editmetadata'] = \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('empty-empty');
706 // Edit file content (if editable)
707 if (is_a($fileOrFolderObject, 'TYPO3\\CMS\\Core\\Resource\\File') && $fileOrFolderObject->checkActionPermission('edit') && \TYPO3\CMS\Core\Utility\GeneralUtility
::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], $fileOrFolderObject->getExtension())) {
708 $editOnClick = 'top.content.list_frame.location.href=top.TS.PATH_typo3+\'file_edit.php?target=' . rawurlencode($fullIdentifier) . '&returnUrl=\'+top.rawurlencode(top.content.list_frame.document.location.pathname+top.content.list_frame.document.location.search);return false;';
709 $cells['edit'] = '<a href="#" onclick="' . $editOnClick . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.edit') . '">' . \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('actions-page-open') . '</a>';
711 $cells['edit'] = \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('empty-empty');
714 if ($fileOrFolderObject->checkActionPermission('rename')) {
715 $renameOnClick = 'top.content.list_frame.location.href = top.TS.PATH_typo3+\'file_rename.php?target=' . rawurlencode($fullIdentifier) . '&returnUrl=\'+top.rawurlencode(top.content.list_frame.document.location.pathname+top.content.list_frame.document.location.search);return false;';
716 $cells['rename'] = '<a href="#" onclick="' . $renameOnClick . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.rename') . '">' . \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('actions-edit-rename') . '</a>';
718 $cells['rename'] = \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('empty-empty');
720 if (is_a($fileOrFolderObject, 'TYPO3\\CMS\\Core\\Resource\\Folder')) {
721 $infoOnClick = 'top.launchView( \'_FOLDER\', \'' . $fullIdentifier . '\');return false;';
722 } elseif (is_a($fileOrFolderObject, 'TYPO3\\CMS\\Core\\Resource\\File')) {
723 $infoOnClick = 'top.launchView( \'_FILE\', \'' . $fullIdentifier . '\');return false;';
725 $cells['info'] = '<a href="#" onclick="' . $infoOnClick . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.info') . '">' . \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('status-dialog-information') . '</a>';
726 // Hook for manipulating edit icons.
727 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fileList']['editIconsHook'])) {
728 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fileList']['editIconsHook'] as $classData) {
729 $hookObject = \TYPO3\CMS\Core\Utility\GeneralUtility
::getUserObj($classData);
730 if (!$hookObject instanceof \TYPO3\CMS\Filelist\FileListEditIconHookInterface
) {
731 throw new \
UnexpectedValueException('$hookObject must implement interface fileList_editIconHook', 1235225797);
733 $hookObject->manipulateEditIcons($cells, $this);
736 // Compile items into a DIV-element:
737 return ' <!-- EDIT CONTROLS: -->
738 <div class="typo3-editCtrl">
745 * Make reference count
747 * @param \TYPO3\CMS\Core\Resource\File|\TYPO3\CMS\Core\Resource\Folder $fileOrFolderObject Array with information about the file/directory for which to make the clipboard panel for the listing.
748 * @return string HTML
749 * @todo Define visibility
751 public function makeRef($fileOrFolderObject) {
752 if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\
Resource\FolderInterface
) {
756 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table=\'sys_file\' AND ref_uid = ' . (integer)$fileOrFolderObject->getUid() . ' AND deleted=0');
757 return $this->generateReferenceToolTip($rows, '\'_FILE\', ' . \TYPO3\CMS\Core\Utility\GeneralUtility
::quoteJSvalue($fileOrFolderObject->getCombinedIdentifier()));