Пример #1
0
    /**
     * For TYPO3 Element Browser: Expand folder of files.
     *
     * @param Folder $folder The folder path to expand
     * @param array $extensionList List of fileextensions to show
     * @param bool $noThumbs Whether to show thumbnails or not. If set, no thumbnails are shown.
     * @return string HTML output
     */
    public function renderFilesInFolder(Folder $folder, array $extensionList = [], $noThumbs = false)
    {
        if (!$folder->checkActionPermission('read')) {
            return '';
        }
        $lang = $this->getLanguageService();
        $titleLen = (int) $this->getBackendUser()->uc['titleLen'];
        if ($this->searchWord !== '') {
            $files = $this->fileRepository->searchByName($folder, $this->searchWord);
        } else {
            $extensionList = !empty($extensionList) && $extensionList[0] === '*' ? [] : $extensionList;
            $files = $this->getFilesInFolder($folder, $extensionList);
        }
        $filesCount = count($files);
        $lines = array();
        // Create the header of current folder:
        $folderIcon = $this->iconFactory->getIconForResource($folder, Icon::SIZE_SMALL);
        $lines[] = '
			<tr>
				<th class="col-title" nowrap="nowrap">' . $folderIcon . ' ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($folder->getIdentifier(), $titleLen)) . '</th>
				<th class="col-control" nowrap="nowrap"></th>
				<th class="col-clipboard" nowrap="nowrap">
					<a href="#" class="btn btn-default" id="t3js-importSelection" title="' . $lang->getLL('importSelection', true) . '">' . $this->iconFactory->getIcon('actions-document-import-t3d', Icon::SIZE_SMALL) . '</a>
					<a href="#" class="btn btn-default" id="t3js-toggleSelection" title="' . $lang->getLL('toggleSelection', true) . '">' . $this->iconFactory->getIcon('actions-document-select', Icon::SIZE_SMALL) . '</a>
				</th>
				<th nowrap="nowrap">&nbsp;</th>
			</tr>';
        if ($filesCount === 0) {
            $lines[] = '
				<tr>
					<td colspan="4">No files found.</td>
				</tr>';
        }
        foreach ($files as $fileObject) {
            $fileExtension = $fileObject->getExtension();
            // Thumbnail/size generation:
            $imgInfo = array();
            if (!$noThumbs && GeneralUtility::inList(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] . ',' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['mediafile_ext']), strtolower($fileExtension))) {
                $processedFile = $fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => 64, 'height' => 64));
                $imageUrl = $processedFile->getPublicUrl(true);
                $imgInfo = array($fileObject->getProperty('width'), $fileObject->getProperty('height'));
                $pDim = $imgInfo[0] . 'x' . $imgInfo[1] . ' pixels';
                $clickIcon = '<img src="' . $imageUrl . '"' . ' width="' . $processedFile->getProperty('width') . '"' . ' height="' . $processedFile->getProperty('height') . '"' . ' hspace="5" vspace="5" border="1" />';
            } else {
                $clickIcon = '';
                $pDim = '';
            }
            // Create file icon:
            $size = ' (' . GeneralUtility::formatSize($fileObject->getSize()) . 'bytes' . ($pDim ? ', ' . $pDim : '') . ')';
            $icon = '<span title="' . htmlspecialchars($fileObject->getName() . $size) . '">' . $this->iconFactory->getIconForResource($fileObject, Icon::SIZE_SMALL) . '</span>';
            // Create links for adding the file:
            $filesIndex = count($this->elements);
            $this->elements['file_' . $filesIndex] = array('type' => 'file', 'table' => 'sys_file', 'uid' => $fileObject->getUid(), 'fileName' => $fileObject->getName(), 'filePath' => $fileObject->getUid(), 'fileExt' => $fileExtension, 'fileIcon' => $icon);
            if ($this->fileIsSelectableInFileList($fileObject, $imgInfo)) {
                $ATag = '<a href="#" class="btn btn-default" title="' . htmlspecialchars($fileObject->getName()) . '" data-file-index="' . htmlspecialchars($filesIndex) . '" data-close="0">';
                $ATag_alt = '<a href="#" title="' . htmlspecialchars($fileObject->getName()) . '" data-file-index="' . htmlspecialchars($filesIndex) . '" data-close="1">';
                $ATag_e = '</a>';
                $bulkCheckBox = '<label class="btn btn-default btn-checkbox"><input type="checkbox" class="typo3-bulk-item" name="file_' . $filesIndex . '" value="0" /><span class="t3-icon fa"></span></label>';
            } else {
                $ATag = '';
                $ATag_alt = '';
                $ATag_e = '';
                $bulkCheckBox = '';
            }
            // Create link to showing details about the file in a window:
            $Ahref = BackendUtility::getModuleUrl('show_item', array('type' => 'file', 'table' => '_FILE', 'uid' => $fileObject->getCombinedIdentifier(), 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')));
            // Combine the stuff:
            $filenameAndIcon = $ATag_alt . $icon . htmlspecialchars(GeneralUtility::fixed_lgd_cs($fileObject->getName(), $titleLen)) . $ATag_e;
            // Show element:
            $lines[] = '
					<tr class="file_list_normal">
						<td class="col-title" nowrap="nowrap">' . $filenameAndIcon . '&nbsp;</td>
						<td class="col-control">
							<div class="btn-group">' . $ATag . '<span title="' . $lang->getLL('addToList', true) . '">' . $this->iconFactory->getIcon('actions-edit-add', Icon::SIZE_SMALL)->render() . '</span>' . $ATag_e . '
							<a href="' . htmlspecialchars($Ahref) . '" class="btn btn-default" title="' . $lang->getLL('info', true) . '">' . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL) . '</a>
						</td>
						<td class="col-clipboard" valign="top">' . $bulkCheckBox . '</td>
						<td nowrap="nowrap">&nbsp;' . $pDim . '</td>
					</tr>';
            if ($pDim) {
                $lines[] = '
					<tr>
						<td class="filelistThumbnail" colspan="4">' . $ATag_alt . $clickIcon . $ATag_e . '</td>
					</tr>';
            }
        }
        $out = '<h3>' . $lang->getLL('files', true) . ' ' . $filesCount . ':</h3>';
        $out .= GeneralUtility::makeInstance(FolderUtilityRenderer::class, $this)->getFileSearchField($this->searchWord);
        $out .= '<div id="filelist">';
        $out .= $this->getBulkSelector($filesCount);
        // Wrap all the rows in table tags:
        $out .= '

	<!--
		Filelisting
	-->
			<table class="table table-striped table-hover" id="typo3-filelist">
				' . implode('', $lines) . '
			</table>';
        // Return accumulated content for filelisting:
        $out .= '</div>';
        return $out;
    }
Пример #2
0
 /**
  * Search for files by name and pass them with a facade to fluid
  *
  * @param string $searchWord
  */
 public function searchAction($searchWord = '')
 {
     if (empty($searchWord)) {
         $this->forward('index');
     }
     $fileFacades = [];
     $files = $this->fileRepository->searchByName($this->folderObject, $searchWord);
     if (empty($files)) {
         $this->controllerContext->getFlashMessageQueue('core.template.flashMessages')->addMessage(new FlashMessage(LocalizationUtility::translate('flashmessage.no_results', 'filelist'), '', FlashMessage::INFO));
     } else {
         foreach ($files as $file) {
             $fileFacades[] = new \TYPO3\CMS\Filelist\FileFacade($file);
         }
     }
     $this->view->assign('searchWord', $searchWord);
     $this->view->assign('files', $fileFacades);
     $this->view->assign('settings', ['jsConfirmationDelete' => $this->getBackendUser()->jsConfirmation(JsConfirmation::DELETE)]);
 }
Пример #3
0
 /**
  * Search for files by name and pass them with a facade to fluid
  *
  * @param string $searchWord
  */
 public function searchAction($searchWord = '')
 {
     if (empty($searchWord)) {
         $this->forward('index');
     }
     $fileFacades = [];
     $files = $this->fileRepository->searchByName($this->folderObject, $searchWord);
     if (empty($files)) {
         $this->controllerContext->getFlashMessageQueue('core.template.flashMessages')->addMessage(new FlashMessage(LocalizationUtility::translate('flashmessage.no_results', 'filelist'), '', FlashMessage::INFO));
     } else {
         foreach ($files as $file) {
             $fileFacades[] = new \TYPO3\CMS\Filelist\FileFacade($file);
         }
     }
     $pageRenderer = $this->view->getModuleTemplate()->getPageRenderer();
     $pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileList');
     $this->view->assign('searchWord', $searchWord);
     $this->view->assign('files', $fileFacades);
     $this->view->assign('veriCode', $this->getBackendUser()->veriCode());
     $this->view->assign('deleteUrl', BackendUtility::getModuleUrl('tce_file'));
     $this->view->assign('settings', ['jsConfirmationDelete' => $this->getBackendUser()->jsConfirmation(JsConfirmation::DELETE)]);
     $pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileDelete');
     $pageRenderer->addInlineLanguageLabelFile('EXT:lang/Resources/Private/Language/locallang_alt_doc.xlf', 'buttons');
 }
Пример #4
0
 /**
  * For TYPO3 Element Browser: Expand folder of files.
  *
  * @param Folder $folder The folder path to expand
  * @param string $extensionList List of fileextensions to show
  * @param bool $noThumbs Whether to show thumbnails or not. If set, no thumbnails are shown.
  * @return string HTML output
  */
 public function TBE_expandFolder(Folder $folder, $extensionList = '', $noThumbs = false)
 {
     if (!$folder->checkActionPermission('read')) {
         return '';
     }
     $extensionList = $extensionList == '*' ? '' : $extensionList;
     if ($this->searchWord !== '') {
         $files = $this->fileRepository->searchByName($folder, $this->searchWord);
     } else {
         $files = $this->getFilesInFolder($folder, $extensionList);
     }
     return $this->fileList($files, $folder, $noThumbs);
 }