2 namespace TYPO3\CMS\Filelist
;
4 /***************************************************************
7 * (c) 1999-2013 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 use TYPO3\CMS\Backend\Utility\BackendUtility
;
31 use TYPO3\CMS\Backend\Utility\IconUtility
;
32 use TYPO3\CMS\Core\Utility\GeneralUtility
;
33 use TYPO3\CMS\Core\
Resource\FolderInterface
;
36 * Class for rendering of File>Filelist
38 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
40 class FileList
extends \TYPO3\CMS\Backend\RecordList\AbstractRecordList
{
43 * Default Max items shown
45 * @todo Define visibility
50 * Boolean. Thumbnails on records containing files (pictures)
52 * @todo Define visibility
57 * @todo Define visibility
59 public $widthGif = '<img src="clear.gif" width="1" height="1" hspace="165" alt="" />';
62 * Max length of strings
64 * @todo Define visibility
69 * @todo Define visibility
74 * If TRUE click menus are generated on files and folders
76 * @todo Define visibility
78 public $clickMenus = 1;
81 * The field to sort by
83 * @todo Define visibility
88 * Reverse sorting flag
90 * @todo Define visibility
95 * @todo Define visibility
97 public $firstElementNumber = 0;
100 * @todo Define visibility
102 public $clipBoard = 0;
105 * @todo Define visibility
107 public $bigControlPanel = 0;
110 * @todo Define visibility
115 * @todo Define visibility
117 public $HTMLcode = '';
120 * @todo Define visibility
122 public $totalbytes = 0;
125 * @todo Define visibility
127 public $dirs = array();
130 * @todo Define visibility
132 public $files = array();
135 * @todo Define visibility
140 * @var \TYPO3\CMS\Core\Resource\Folder
142 protected $folderObject;
145 * Counting the elements no matter what
147 * @todo Define visibility
149 public $eCounter = 0;
152 * @todo Define visibility
154 public $dirCounter = 0;
157 * @todo Define visibility
159 public $totalItems = '';
162 * @todo Define visibility
164 public $CBnames = array();
167 * Initialization of class
169 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject The folder to work on
170 * @param integer $pointer Pointer
171 * @param boolean $sort Sorting column
172 * @param boolean $sortRev Sorting direction
173 * @param boolean $bigControlPanel Show clipboard flag
175 * @todo Define visibility
177 public function start(\TYPO3\CMS\Core\
Resource\Folder
$folderObject, $pointer, $sort, $sortRev, $clipBoard = FALSE, $bigControlPanel = FALSE) {
178 $this->script
= BackendUtility
::getModuleUrl('file_list');
179 $this->folderObject
= $folderObject;
181 $this->totalbytes
= 0;
183 $this->HTMLcode
= '';
184 $this->path
= $folderObject->getIdentifier();
186 $this->sortRev
= $sortRev;
187 $this->firstElementNumber
= $pointer;
188 $this->clipBoard
= $clipBoard;
189 $this->bigControlPanel
= $bigControlPanel;
190 // Setting the maximum length of the filenames to the user's settings or minimum 30 (= $this->fixedL)
191 $this->fixedL
= max($this->fixedL
, $GLOBALS['BE_USER']->uc
['titleLen']);
192 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_common.xlf');
196 * Reading files and directories, counting elements and generating the list in ->HTMLcode
199 * @todo Define visibility
201 public function generateList() {
202 $this->HTMLcode
.= $this->getTable('fileext,tstamp,size,rw,_REF_');
206 * Return the buttons used by the file list to include in the top header
208 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject
211 public function getButtonsAndOtherMarkers(\TYPO3\CMS\Core\
Resource\Folder
$folderObject) {
212 $otherMarkers = array(
222 // Makes the code for the foldericon in the top
224 list($_, $icon, $path) = $this->dirData($folderObject);
225 $title = htmlspecialchars($folderObject->getIdentifier());
226 // Start compiling the HTML
227 // @todo: how to fix this? $title = $GLOBALS['SOBE']->basicFF->blindPath($title);
228 // If this is some subpage under the mount root....
229 if ($folderObject->getStorage()->isWithinFileMountBoundaries($folderObject)) {
230 // The icon with link
231 $otherMarkers['PAGE_ICON'] = IconUtility
::getSpriteIcon($icon, array('title' => $title));
232 // No HTML specialchars here - HTML like <strong> </strong> is allowed
233 $otherMarkers['TITLE'] .= GeneralUtility
::removeXSS(GeneralUtility
::fixed_lgd_cs($title, -($this->fixedL +
20)));
235 // This is the root page
236 $otherMarkers['PAGE_ICON'] = IconUtility
::getSpriteIcon('apps-filetree-root');
237 $otherMarkers['TITLE'] .= htmlspecialchars(GeneralUtility
::fixed_lgd_cs($title, -($this->fixedL +
20)));
239 if ($this->clickMenus
) {
240 $otherMarkers['PAGE_ICON'] = $GLOBALS['SOBE']->doc
->wrapClickMenuOnIcon($otherMarkers['PAGE_ICON'], $folderObject->getCombinedIdentifier());
242 // Add paste button if clipboard is initialized
243 if ($this->clipObj
instanceof \TYPO3\CMS\Backend\Clipboard\Clipboard
) {
244 $elFromTable = $this->clipObj
->elFromTable('_FILE');
245 if (count($elFromTable)) {
246 $buttons['PASTE'] = '<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', TRUE) . '">' . IconUtility
::getSpriteIcon('actions-document-paste-after') . '</a>';
251 $buttons['refresh'] = '<a href="' . htmlspecialchars($this->listURL()) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.reload', TRUE) . '">' . IconUtility
::getSpriteIcon('actions-system-refresh') . '</a>';
252 return array($buttons, $otherMarkers);
256 * Wrapping input string in a link with clipboard command.
258 * @param string $string String to be linked - must be htmlspecialchar'ed / prepared before.
259 * @param string $table table - NOT USED
260 * @param string $cmd "cmd" value
261 * @param string $warning Warning for JS confirm message
262 * @return string Linked string
263 * @todo Define visibility
265 public function linkClipboardHeaderIcon($string, $table, $cmd, $warning = '') {
266 $onClickEvent = 'document.dblistForm.cmd.value=\'' . $cmd . '\';document.dblistForm.submit();';
268 $onClickEvent = 'if (confirm(' . $GLOBALS['LANG']->JScharCode($warning) . ')){' . $onClickEvent . '}';
270 return '<a href="#" onclick="' . htmlspecialchars($onClickEvent) . 'return false;">' . $string . '</a>';
274 * Returns a table with directories and files listed.
276 * @param array $rowlist Array of files from path
277 * @return string HTML-table
278 * @todo Define visibility
280 public function getTable($rowlist) {
281 // TODO use folder methods directly when they support filters
282 $storage = $this->folderObject
->getStorage();
283 $storage->resetFileAndFolderNameFiltersToDefault();
284 $folders = $storage->getFolderList($this->folderObject
->getIdentifier());
285 $files = $storage->getFileList($this->folderObject
->getIdentifier());
286 // Only render the contents of a browsable storage
287 if ($this->folderObject
->getStorage()->isBrowsable()) {
288 $this->sort
= trim($this->sort
);
289 if ($this->sort
!== '') {
290 $filesToSort = array();
291 foreach ($files as $file) {
292 $fileObject = $storage->getFile($file['identifier']);
293 switch ($this->sort
) {
295 $sortingKey = $fileObject->getSize();
298 $sortingKey = ($fileObject->checkActionPermission('read') ?
'R' : '' . $fileObject->checkActionPermission('write')) ?
'W' : '';
301 $sortingKey = $fileObject->getExtension();
304 $sortingKey = $fileObject->getModificationTime();
307 if ($fileObject->hasProperty($this->sort
)) {
308 $sortingKey = $fileObject->getProperty($this->sort
);
310 $sortingKey = $fileObject->getName();
314 while (isset($filesToSort[$sortingKey . $i])) {
317 $filesToSort[$sortingKey . $i] = $fileObject;
319 uksort($filesToSort, 'strnatcasecmp');
320 if (intval($this->sortRev
) === 1) {
321 $filesToSort = array_reverse($filesToSort);
323 $files = $filesToSort;
325 $this->totalItems
= count($folders) +
count($files);
326 // Adds the code of files/dirs
329 // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
330 $rowlist = GeneralUtility
::rmFromList($titleCol, $rowlist);
331 $rowlist = GeneralUtility
::uniqueList($rowlist);
332 $rowlist = $rowlist ?
$titleCol . ',' . $rowlist : $titleCol;
333 if ($this->bigControlPanel ||
$this->clipBoard
) {
334 $rowlist = str_replace('file,', 'file,_CLIPBOARD_,', $rowlist);
336 $this->fieldArray
= explode(',', $rowlist);
337 $folderObjects = array();
338 foreach ($folders as $folder) {
339 $folderObjects[] = $storage->getFolder($folder['identifier']);
342 $folderObjects = \TYPO3\CMS\Core\
Resource\Utility\ListUtility
::resolveSpecialFolderNames($folderObjects);
343 uksort($folderObjects, 'strnatcasecmp');
345 // Directories are added
346 $iOut = $this->formatDirList($folderObjects);
348 // Half line is drawn
354 $iOut .= $this->formatFileList($files, $titleCol);
355 // Header line is drawn
357 foreach ($this->fieldArray
as $v) {
358 if ($v == '_CLIPBOARD_' && $this->clipBoard
) {
361 $elFromTable = $this->clipObj
->elFromTable($table);
362 if (count($elFromTable)) {
363 $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) . '">' . IconUtility
::getSpriteIcon('actions-document-paste-after') . '</a>';
365 if ($this->clipObj
->current
!= 'normal' && $iOut) {
366 $cells[] = $this->linkClipboardHeaderIcon(IconUtility
::getSpriteIcon('actions-edit-copy', array('title' => $GLOBALS['LANG']->getLL('clip_selectMarked', TRUE))), $table, 'setCB');
367 $cells[] = $this->linkClipboardHeaderIcon(IconUtility
::getSpriteIcon('actions-edit-delete', array('title' => $GLOBALS['LANG']->getLL('clip_deleteMarked'))), $table, 'delete', $GLOBALS['LANG']->getLL('clip_deleteMarkedWarning'));
368 $onClick = 'checkOffCB(\'' . implode(',', $this->CBnames
) . '\', this); return false;';
369 $cells[] = '<a class="cbcCheckAll" rel="" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $GLOBALS['LANG']->getLL('clip_markRecords', TRUE) . '">' . IconUtility
::getSpriteIcon('actions-document-select') . '</a>';
371 $theData[$v] = implode('', $cells);
374 $theT = $this->linkWrapSort($GLOBALS['LANG']->getLL('c_' . $v, TRUE), $this->folderObject
->getCombinedIdentifier(), $v);
375 $theData[$v] = $theT;
380 $out .= '<thead>' . $this->addelement(1, $levelUp, $theData, ' class="t3-row-header"', '') . '</thead>';
381 $out .= '<tbody>' . $iOut . '</tbody>';
382 // half line is drawn
388 <table cellpadding="0" cellspacing="0" id="typo3-filelist">
393 /** @var $flashMessage \TYPO3\CMS\Core\Messaging\FlashMessage */
394 $flashMessage = GeneralUtility
::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->getLL('storageNotBrowsableMessage'), $GLOBALS['LANG']->getLL('storageNotBrowsableTitle'), \TYPO3\CMS\Core\Messaging\FlashMessage
::INFO
);
395 $out = $flashMessage->render();
401 * Gets the number of files and total size of a folder
404 * @todo Define visibility
406 public function getFolderInfo() {
407 if ($this->counter
== 1) {
408 $fileLabel = $GLOBALS['LANG']->getLL('file', TRUE);
410 $fileLabel = $GLOBALS['LANG']->getLL('files', TRUE);
412 return $this->counter
. ' ' . $fileLabel . ', ' . GeneralUtility
::formatSize($this->totalbytes
, $GLOBALS['LANG']->getLL('byteSizeUnits', TRUE));
416 * This returns tablerows for the directories in the array $items['sorting'].
418 * @param \TYPO3\CMS\Core\Resource\Folder[] $folders Folders of \TYPO3\CMS\Core\Resource\Folder
419 * @return string HTML table rows.
420 * @todo Define visibility
422 public function formatDirList(array $folders) {
424 foreach ($folders as $folderName => $folderObject) {
425 $role = $folderObject->getRole();
426 if ($role === FolderInterface
::ROLE_PROCESSING
) {
427 // don't show processing-folder
430 if ($role !== FolderInterface
::ROLE_DEFAULT
) {
431 $displayName = '<strong>' . htmlspecialchars($folderName) . '</strong>';
433 $displayName = htmlspecialchars($folderName);
436 list($flag, $code) = $this->fwd_rwd_nav();
441 list($_, $icon, $path) = $this->dirData($folderObject);
442 // The icon with link
443 $theIcon = IconUtility
::getSpriteIcon($icon, array('title' => $folderName));
444 if ($this->clickMenus
) {
445 $theIcon = $GLOBALS['SOBE']->doc
->wrapClickMenuOnIcon($theIcon, $folderObject->getCombinedIdentifier());
447 // Preparing and getting the data-array
449 foreach ($this->fieldArray
as $field) {
452 $numFiles = $folderObject->getFileCount();
453 $theData[$field] = $numFiles . ' ' . $GLOBALS['LANG']->getLL(($numFiles === 1 ?
'file' : 'files'), TRUE);
456 $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>');
459 $theData[$field] = $GLOBALS['LANG']->getLL('folder', TRUE);
462 // @todo: FAL: how to get the mtime info -- $theData[$field] = \TYPO3\CMS\Backend\Utility\BackendUtility::date($theFile['tstamp']);
463 $theData[$field] = '-';
466 $theData[$field] = $this->linkWrapDir($displayName, $folderObject);
470 if ($this->bigControlPanel
) {
471 $temp .= $this->makeEdit($folderObject);
473 $temp .= $this->makeClip($folderObject);
474 $theData[$field] = $temp;
477 $theData[$field] = $this->makeRef($folderObject);
480 $theData[$field] = GeneralUtility
::fixed_lgd_cs($theFile[$field], $this->fixedL
);
483 $out .= $this->addelement(1, $theIcon, $theData, ' class="file_list_normal"');
486 $this->dirCounter
= $this->eCounter
;
492 * Wraps the directory-titles
494 * @param string $title String to be wrapped in links
495 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject Folder to work on
496 * @return string HTML
497 * @todo Define visibility
499 public function linkWrapDir($title, \TYPO3\CMS\Core\
Resource\Folder
$folderObject) {
500 $href = $this->backPath
. $this->script
. '&id=' . rawurlencode($folderObject->getCombinedIdentifier());
501 $onclick = ' onclick="' . htmlspecialchars(('top.content.nav_frame.hilight_row("file","folder' . GeneralUtility
::md5int($folderObject->getCombinedIdentifier()) . '_"+top.fsMod.currentBank)')) . '"';
502 // Sometimes $code contains plain HTML tags. In such a case the string should not be modified!
503 if (!strcmp($title, strip_tags($title))) {
504 return '<a href="' . htmlspecialchars($href) . '"' . $onclick . ' title="' . htmlspecialchars($title) . '">' . GeneralUtility
::fixed_lgd_cs($title, $this->fixedL
) . '</a>';
506 return '<a href="' . htmlspecialchars($href) . '"' . $onclick . '>' . $title . '</a>';
511 * Wraps filenames in links which opens them in a window IF they are in web-path.
513 * @param string $code String to be wrapped in links
514 * @param \TYPO3\CMS\Core\Resource\File $fileObject File to be linked
515 * @return string HTML
516 * @todo Define visibility
518 public function linkWrapFile($code, \TYPO3\CMS\Core\
Resource\File
$fileObject) {
519 $fileUrl = $fileObject->getPublicUrl(TRUE);
521 $aOnClick = 'return top.openUrlInWindow(\'' . $fileUrl . '\', \'WebFile\');';
522 $code = '<a href="#" title="' . htmlspecialchars($code) . '" onclick="' . htmlspecialchars($aOnClick) . '">' . GeneralUtility
::fixed_lgd_cs($code, $this->fixedL
) . '</a>';
528 * Returns list URL; This is the URL of the current script with id and imagemode parameters, thats all.
529 * The URL however is not relative (with the backpath), otherwise GeneralUtility::sanitizeLocalUrl() would say that
530 * the URL would be invalid
533 * @todo Define visibility
535 public function listURL() {
536 return GeneralUtility
::linkThisScript(array(
537 'target' => rawurlencode($this->folderObject
->getCombinedIdentifier()),
538 'imagemode' => $this->thumbs
543 * Returns some data specific for the directories...
545 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject File information array
546 * @return array (title, icon, path)
547 * @todo Define visibility
549 public function dirData(\TYPO3\CMS\Core\
Resource\Folder
$folderObject) {
550 $title = htmlspecialchars($folderObject->getName());
551 $icon = 'apps-filetree-folder-default';
552 $role = $folderObject->getRole();
553 if ($role === FolderInterface
::ROLE_TEMPORARY
) {
554 $title = '<strong>' . $GLOBALS['LANG']->getLL('temp', TRUE) . '</strong>';
555 $icon = 'apps-filetree-folder-temp';
556 } elseif ($role === FolderInterface
::ROLE_RECYCLER
) {
557 $icon = 'apps-filetree-folder-recycler';
558 $title = '<strong>' . $GLOBALS['LANG']->getLL('recycler', TRUE) . '</strong>';
560 // Mark the icon as read-only icon if the folder is not writable
561 if ($folderObject->checkActionPermission('write') === FALSE) {
562 $icon = 'apps-filetree-folder-locked';
564 return array($title, $icon, $folderObject->getIdentifier());
568 * This returns tablerows for the files in the array $items['sorting'].
570 * @param \TYPO3\CMS\Core\Resource\File[] $files File items
571 * @return string HTML table rows.
572 * @todo Define visibility
574 public function formatFileList(array $files) {
576 // first two keys are "0" (default) and "-1" (multiple), after that comes the "other languages"
577 $systemLanguages = GeneralUtility
::makeInstance('TYPO3\\CMS\\Backend\\Configuration\\TranslationConfigurationProvider')->getSystemLanguages();
578 foreach ($files as $fileObject) {
579 list($flag, $code) = $this->fwd_rwd_nav();
584 $this->totalbytes +
= $fileObject->getSize();
585 $ext = $fileObject->getExtension();
586 $fileName = trim($fileObject->getName());
587 // The icon with link
588 $theIcon = IconUtility
::getSpriteIconForFile($ext, array('title' => $fileName));
589 if ($this->clickMenus
) {
590 $theIcon = $GLOBALS['SOBE']->doc
->wrapClickMenuOnIcon($theIcon, $fileObject->getCombinedIdentifier());
592 // Preparing and getting the data-array
594 foreach ($this->fieldArray
as $field) {
597 $theData[$field] = GeneralUtility
::formatSize($fileObject->getSize(), $GLOBALS['LANG']->getLL('byteSizeUnits', TRUE));
600 $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>');
603 $theData[$field] = strtoupper($ext);
606 $theData[$field] = BackendUtility
::date($fileObject->getProperty('modification_date'));
610 if ($this->bigControlPanel
) {
611 $temp .= $this->makeEdit($fileObject);
613 $temp .= $this->makeClip($fileObject);
614 if (count($systemLanguages) > 2) {
615 $temp .= '<a class="filelist-translationToggler" data-fileid="' . $fileObject->getUid() . '">' .
616 IconUtility
::getSpriteIcon('mimetypes-x-content-page-language-overlay') . '</a>';
618 $theData[$field] = $temp;
621 $theData[$field] = $this->makeRef($fileObject);
624 $theData[$field] = $this->linkWrapFile(htmlspecialchars($fileName), $fileObject);
626 if ($fileObject->isMissing()) {
627 $flashMessage = \TYPO3\CMS\Core\
Resource\Utility\BackendUtility
::getFlashMessageForMissingFile($fileObject);
628 $theData[$field] .= $flashMessage->render();
630 } elseif ($this->thumbs
&& $this->isImage($ext)) {
631 $processedFile = $fileObject->process(\TYPO3\CMS\Core\
Resource\ProcessedFile
::CONTEXT_IMAGEPREVIEW
, array());
632 if ($processedFile) {
633 $thumbUrl = $processedFile->getPublicUrl(TRUE);
634 $theData[$field] .= '<br /><img src="' . $thumbUrl . '" hspace="2" data-file-name="' . htmlspecialchars($fileName) . '" title="' . htmlspecialchars($fileName) . '" alt="" />';
639 $theData[$field] = '';
640 if ($fileObject->hasProperty($field)) {
641 $theData[$field] = htmlspecialchars(GeneralUtility
::fixed_lgd_cs($fileObject->getProperty($field), $this->fixedL
));
645 $out .= $this->addelement(1, $theIcon, $theData, ' class="file_list_normal"');
647 $metaDataRecord = $fileObject->_getMetaData();
648 $translations = $this->getTranslationsForMetaData($metaDataRecord);
649 if (count($systemLanguages) > 2) {
650 $code = IconUtility
::getSpriteIcon('empty-empty');
651 foreach ($systemLanguages as $language) {
652 $languageId = $language['uid'];
653 if ($languageId == -1 ||
$languageId == 0) {
656 $flagIcon = $language['flagIcon'];
657 if (array_key_exists($languageId, $translations)) {
659 $theIcon = IconUtility
::getSpriteIcon(
660 'actions-document-open',
661 array('title' => $fileName),
662 array($flagIcon . '-overlay' => array()));
664 'sys_file_metadata' => array($translations[$languageId]['uid'] => 'edit')
666 $editOnClick = BackendUtility
::editOnClick(GeneralUtility
::implodeArrayForUrl('edit', $data), $GLOBALS['BACK_PATH'], $this->listUrl());
667 $code .= sprintf('<a href="#" onclick="%s">%s</a>', htmlspecialchars($editOnClick), $theIcon);
670 $href = $GLOBALS['SOBE']->doc
->issueCommand(
671 '&cmd[sys_file_metadata][' . $metaDataRecord['uid'] . '][localize]=' . $languageId,
672 $this->backPath
. 'alt_doc.php?justLocalized=' . rawurlencode(('sys_file_metadata:' . $metaDataRecord['uid'] . ':' . $languageId)) .
673 '&returnUrl=' . rawurlencode($this->listURL()) . BackendUtility
::getUrlToken('editRecord')
675 $theIcon = IconUtility
::getSpriteIcon($flagIcon);
677 $code .= sprintf('<a href="%s">%s</a>', htmlspecialchars($href), $theIcon);
680 $out .= '<tr class="file_list_normal localisationData" data-fileid="' . $fileObject->getUid() . '"><td></td><td colspan="' . count($this->fieldArray
) . '">' . $code . '</td></tr>';
689 * Fetch the translations for a sys_file_metadata record
691 * @param $metaDataRecord
692 * @return array keys are the sys_language uids, values are the $rows
694 protected function getTranslationsForMetaData($metaDataRecord) {
695 $where = $GLOBALS['TCA']['sys_file_metadata']['ctrl']['transOrigPointerField'] . '=' . intval($metaDataRecord['uid']) .
696 ' AND ' . $GLOBALS['TCA']['sys_file_metadata']['ctrl']['languageField'] . '>0';
697 $translationRecords = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_file_metadata', $where);
698 $translations = array();
699 foreach ($translationRecords as $record) {
700 $translations[$record[$GLOBALS['TCA']['sys_file_metadata']['ctrl']['languageField']]] = $record;
702 return $translations;
706 * Returns TRUE if $ext is an image-extension according to $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
708 * @param string $ext File extension
710 * @todo Define visibility
712 public function isImage($ext) {
713 return GeneralUtility
::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], strtolower($ext));
717 * Wraps the directory-titles ($code) in a link to filelist/mod1/index.php (id=$path) and sorting commands...
719 * @param string $code String to be wrapped
720 * @param string $folderIdentifier ID (path)
721 * @param string $col Sorting column
722 * @return string HTML
723 * @todo Define visibility
725 public function linkWrapSort($code, $folderIdentifier, $col) {
726 if ($this->sort
=== $col) {
727 // Check reverse sorting
728 $params = '&SET[sort]=' . $col . '&SET[reverse]=' . ($this->sortRev ?
'0' : '1');
729 $sortArrow = IconUtility
::getSpriteIcon('status-status-sorting-light-' . ($this->sortRev ?
'desc' : 'asc'));
731 $params = '&SET[sort]=' . $col . '&SET[reverse]=0';
734 $href = GeneralUtility
::resolveBackPath(($GLOBALS['BACK_PATH'] . $this->script
)) . '&id=' . rawurlencode($folderIdentifier) . $params;
735 return '<a href="' . htmlspecialchars($href) . '">' . $code . $sortArrow . '</a>';
739 * Creates the clipboard control pad
741 * @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.
742 * @return string HTML-table
743 * @todo Define visibility
745 public function makeClip($fileOrFolderObject) {
747 $fullIdentifier = $fileOrFolderObject->getCombinedIdentifier();
748 $md5 = GeneralUtility
::shortmd5($fullIdentifier);
749 // For normal clipboard, add copy/cut buttons:
750 if ($this->clipObj
->current
== 'normal') {
751 $isSel = $this->clipObj
->isSelected('_FILE', $md5);
752 $cells[] = '<a href="' . htmlspecialchars($this->clipObj
->selUrlFile($fullIdentifier, 1, ($isSel == 'copy'))) . '">' . IconUtility
::getSpriteIcon(('actions-edit-copy' . ($isSel == 'copy' ?
'-release' : '')), array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.copy', TRUE))) . '</a>';
753 $cells[] = '<a href="' . htmlspecialchars($this->clipObj
->selUrlFile($fullIdentifier, 0, ($isSel == 'cut'))) . '">' . IconUtility
::getSpriteIcon(('actions-edit-cut' . ($isSel == 'cut' ?
'-release' : '')), array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.cut', TRUE))) . '</a>';
755 // For numeric pads, add select checkboxes:
756 $n = '_FILE|' . $md5;
757 $this->CBnames
[] = $n;
758 $checked = $this->clipObj
->isSelected('_FILE', $md5) ?
' checked="checked"' : '';
759 $cells[] = '<input type="hidden" name="CBH[' . $n . ']" value="0" />' . '<input type="checkbox" name="CBC[' . $n . ']" value="' . htmlspecialchars($fullIdentifier) . '" class="smallCheckboxes"' . $checked . ' />';
761 // Display PASTE button, if directory:
762 $elFromTable = $this->clipObj
->elFromTable('_FILE');
763 if (is_a($fileOrFolderObject, 'TYPO3\\CMS\\Core\\Resource\\Folder') && count($elFromTable)) {
764 $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) . '">' . IconUtility
::getSpriteIcon('actions-document-paste-into') . '</a>';
766 // Compile items into a DIV-element:
767 return ' <!-- CLIPBOARD PANEL: -->
768 <div class="typo3-clipCtrl">
775 * Creates the edit control section
777 * @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.
778 * @return string HTML-table
779 * @todo Define visibility
781 public function makeEdit($fileOrFolderObject) {
783 $fullIdentifier = $fileOrFolderObject->getCombinedIdentifier();
784 // Edit metadata of file
786 if (is_a($fileOrFolderObject, 'TYPO3\\CMS\\Core\\Resource\\File') && $fileOrFolderObject->isIndexed() && $fileOrFolderObject->checkActionPermission('write')) {
787 $metaData = $fileOrFolderObject->_getMetaData();
789 'sys_file_metadata' => array($metaData['uid'] => 'edit')
791 $editOnClick = BackendUtility
::editOnClick(GeneralUtility
::implodeArrayForUrl('edit', $data), $GLOBALS['BACK_PATH'], $this->listUrl());
792 $cells['editmetadata'] = '<a href="#" onclick="' . $editOnClick . '" title="Edit Metadata of this file">' . IconUtility
::getSpriteIcon('actions-document-open') . '</a>';
794 $cells['editmetadata'] = IconUtility
::getSpriteIcon('empty-empty');
796 } catch (\Exception
$e) {
797 $cells['editmetadata'] = IconUtility
::getSpriteIcon('empty-empty');
799 // Edit file content (if editable)
800 if (is_a($fileOrFolderObject, 'TYPO3\\CMS\\Core\\Resource\\File') && $fileOrFolderObject->checkActionPermission('write') && GeneralUtility
::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], $fileOrFolderObject->getExtension())) {
801 $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;';
802 $cells['edit'] = '<a href="#" onclick="' . $editOnClick . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.edit') . '">' . IconUtility
::getSpriteIcon('actions-page-open') . '</a>';
804 $cells['edit'] = IconUtility
::getSpriteIcon('empty-empty');
807 if ($fileOrFolderObject->checkActionPermission('rename')) {
808 $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;';
809 $cells['rename'] = '<a href="#" onclick="' . $renameOnClick . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.rename') . '">' . IconUtility
::getSpriteIcon('actions-edit-rename') . '</a>';
811 $cells['rename'] = IconUtility
::getSpriteIcon('empty-empty');
813 if ($fileOrFolderObject->checkActionPermission('read')) {
814 if (is_a($fileOrFolderObject, 'TYPO3\\CMS\\Core\\Resource\\Folder')) {
815 $infoOnClick = 'top.launchView( \'_FOLDER\', \'' . $fullIdentifier . '\');return false;';
816 } elseif (is_a($fileOrFolderObject, 'TYPO3\\CMS\\Core\\Resource\\File')) {
817 $infoOnClick = 'top.launchView( \'_FILE\', \'' . $fullIdentifier . '\');return false;';
819 $cells['info'] = '<a href="#" onclick="' . $infoOnClick . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.info') . '">' . IconUtility
::getSpriteIcon('status-dialog-information') . '</a>';
821 $cells['info'] = IconUtility
::getSpriteIcon('empty-empty');
825 if ($fileOrFolderObject->checkActionPermission('delete')) {
826 $identifier = $fileOrFolderObject->getIdentifier();
827 if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\
Resource\Folder
) {
828 $referenceCountText = BackendUtility
::referenceCount('_FILE', $identifier, ' (There are %s reference(s) to this folder!)');
830 $referenceCountText = BackendUtility
::referenceCount('sys_file', $identifier, ' (There are %s reference(s) to this file!)');
833 if ($GLOBALS['BE_USER']->jsConfirmation(4)) {
834 $confirmationCheck = 'confirm(' . $GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:mess.delete'), basename($identifier)) . $referenceCountText) . ')';
836 $confirmationCheck = '1 == 1';
839 $removeOnClick = 'if (' . $confirmationCheck . ') { top.content.list_frame.location.href=top.TS.PATH_typo3+\'tce_file.php?file[delete][0][data]=' . rawurlencode($fileOrFolderObject->getCombinedIdentifier()) . '&vC=' . $GLOBALS['BE_USER']->veriCode() . '&redirect=\'+top.rawurlencode(top.content.list_frame.document.location.pathname+top.content.list_frame.document.location.search);};';
841 $cells['delete'] = '<a href="#" onclick="' . htmlspecialchars($removeOnClick) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.delete') . '">' . IconUtility
::getSpriteIcon('actions-edit-delete') . '</a>';
843 $cells['delete'] = IconUtility
::getSpriteIcon('empty-empty');
846 // Hook for manipulating edit icons.
847 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fileList']['editIconsHook'])) {
848 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fileList']['editIconsHook'] as $classData) {
849 $hookObject = GeneralUtility
::getUserObj($classData);
850 if (!$hookObject instanceof \TYPO3\CMS\Filelist\FileListEditIconHookInterface
) {
851 throw new \
UnexpectedValueException(
852 '$hookObject must implement interface \\TYPO3\\CMS\\Filelist\\FileListEditIconHookInterface',
856 $hookObject->manipulateEditIcons($cells, $this);
859 // Compile items into a DIV-element:
860 return ' <!-- EDIT CONTROLS: -->
861 <div class="typo3-editCtrl">
868 * Make reference count
870 * @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.
871 * @return string HTML
872 * @todo Define visibility
874 public function makeRef($fileOrFolderObject) {
875 if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\
Resource\FolderInterface
) {
879 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table=\'sys_file\' AND ref_uid = ' . (integer)$fileOrFolderObject->getUid() . ' AND deleted=0');
880 return $this->generateReferenceToolTip($rows, '\'_FILE\', ' . GeneralUtility
::quoteJSvalue($fileOrFolderObject->getCombinedIdentifier()));