예제 #1
0
 /**
  * Get main headline based on active folder or storage for backend module
  *
  * Folder names are resolved to their special names like done in the tree view.
  *
  * @return string
  */
 protected function getModuleHeadline()
 {
     $name = $this->folderObject->getName();
     if ($name === '') {
         // Show storage name on storage root
         if ($this->folderObject->getIdentifier() === '/') {
             $name = $this->folderObject->getStorage()->getName();
         }
     } else {
         $name = key(\TYPO3\CMS\Core\Resource\Utility\ListUtility::resolveSpecialFolderNames(array($name => $this->folderObject)));
     }
     return $name;
 }
예제 #2
0
 /**
  * Get main headline based on active folder or storage for backend module
  * Folder names are resolved to their special names like done in the tree view.
  *
  * @return string
  */
 protected function getModuleHeadline()
 {
     $name = $this->folderObject->getName();
     if ($name === '') {
         // Show storage name on storage root
         if ($this->folderObject->getIdentifier() === '/') {
             $name = $this->folderObject->getStorage()->getName();
         }
     } else {
         $name = key(ListUtility::resolveSpecialFolderNames([$name => $this->folderObject]));
     }
     return $name;
 }
예제 #3
0
 /**
  * Get main headline based on active folder or storage for backend module
  *
  * Folder names are resolved to their special names like done in the tree view.
  *
  * @param Folder $folder
  * @return string
  */
 protected function getFolderName(Folder $folder)
 {
     $name = $folder->getName();
     if ($name === '') {
         // Show storage name on storage root
         if ($folder->getIdentifier() === '/') {
             $name = $folder->getStorage()->getName();
         }
     } else {
         $name = key(ListUtility::resolveSpecialFolderNames(array($name => $folder)));
     }
     return $name;
 }
예제 #4
0
    /**
     * Main function, rendering the content of the rename form
     *
     * @return void
     */
    public function main()
    {
        if ($this->fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
            $fileIdentifier = $this->fileOrFolderObject->getCombinedIdentifier();
        } else {
            $fileIdentifier = $this->fileOrFolderObject->getUid();
        }
        $pageContent = '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('tce_file')) . '" method="post" name="editform" role="form">';
        // Making the formfields for renaming:
        $pageContent .= '

			<div class="form-group">
				<input class="form-control" type="text" name="file[rename][0][target]" value="' . htmlspecialchars($this->fileOrFolderObject->getName()) . '" ' . $this->getDocumentTemplate()->formWidth(40) . ' />
				<input type="hidden" name="file[rename][0][data]" value="' . htmlspecialchars($fileIdentifier) . '" />
			</div>
		';
        // Making submit button:
        $pageContent .= '
			<div class="form-group">
				<input class="btn btn-primary" type="submit" value="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_rename.php.submit', true) . '" />
				<input class="btn btn-danger" type="submit" value="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.cancel', true) . '" onclick="backToList(); return false;" />
				<input type="hidden" name="redirect" value="' . htmlspecialchars($this->returnUrl) . '" />
			</div>
		';
        $pageContent .= '</form>';
        // Create buttons
        $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
        // csh button
        $cshButton = $buttonBar->makeHelpButton()->setModuleName('xMOD_csh_corebe')->setFieldName('file_rename');
        $buttonBar->addButton($cshButton);
        // back button
        if ($this->returnUrl) {
            $backButton = $buttonBar->makeLinkButton()->sethref(GeneralUtility::linkThisUrl($this->returnUrl))->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.goBack', true))->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-view-go-back', Icon::SIZE_SMALL));
            $buttonBar->addButton($backButton);
        }
        // set header
        $this->content = '<h1>' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_rename.php.pagetitle') . '</h1>';
        // add section
        $this->content .= $this->moduleTemplate->section('', $pageContent);
        $this->moduleTemplate->setContent($this->content);
    }
예제 #5
0
    /**
     * Main function, rendering the content of the rename form
     *
     * @return void
     */
    public function main()
    {
        // Make page header:
        $this->content = $this->doc->startPage($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_rename.php.pagetitle'));
        $pageContent = $this->doc->header($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_rename.php.pagetitle'));
        if ($this->fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
            $fileIdentifier = $this->fileOrFolderObject->getCombinedIdentifier();
        } else {
            $fileIdentifier = $this->fileOrFolderObject->getUid();
        }
        $pageContent .= '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('tce_file')) . '" method="post" name="editform" role="form">';
        // Making the formfields for renaming:
        $pageContent .= '

			<div class="form-group">
				<input class="form-control" type="text" name="file[rename][0][target]" value="' . htmlspecialchars($this->fileOrFolderObject->getName()) . '" ' . $this->getDocumentTemplate()->formWidth(40) . ' />
				<input type="hidden" name="file[rename][0][data]" value="' . htmlspecialchars($fileIdentifier) . '" />
			</div>
		';
        // Making submit button:
        $pageContent .= '
			<div class="form-group">
				<input class="btn btn-primary" type="submit" value="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_rename.php.submit', TRUE) . '" />
				<input class="btn btn-danger" type="submit" value="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.cancel', TRUE) . '" onclick="backToList(); return false;" />
				<input type="hidden" name="redirect" value="' . htmlspecialchars($this->returnUrl) . '" />
				' . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction') . '
			</div>
		';
        $pageContent .= '</form>';
        $docHeaderButtons = array('back' => '');
        $docHeaderButtons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'file_rename');
        // Back
        if ($this->returnUrl) {
            $docHeaderButtons['back'] = '<a href="' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::linkThisUrl($this->returnUrl)) . '" class="typo3-goBack" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.goBack', TRUE) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-view-go-back') . '</a>';
        }
        // Add the HTML as a section:
        $markerArray = array('CSH' => $docHeaderButtons['csh'], 'FUNC_MENU' => '', 'CONTENT' => $pageContent, 'PATH' => $this->title);
        $this->content .= $this->doc->moduleBody(array(), $docHeaderButtons, $markerArray);
        $this->content .= $this->doc->endPage();
        $this->content = $this->doc->insertStylesAndJS($this->content);
    }
예제 #6
0
 /**
  * Creates the edit control section
  *
  * @param File|Folder $fileOrFolderObject Array with information about the file/directory for which to make the edit control section for the listing.
  * @return string HTML-table
  */
 public function makeEdit($fileOrFolderObject)
 {
     $cells = array();
     $fullIdentifier = $fileOrFolderObject->getCombinedIdentifier();
     // Edit file content (if editable)
     if ($fileOrFolderObject instanceof File && $fileOrFolderObject->checkActionPermission('write') && GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], $fileOrFolderObject->getExtension())) {
         $url = BackendUtility::getModuleUrl('file_edit', array('target' => $fullIdentifier));
         $editOnClick = 'top.content.list_frame.location.href=' . GeneralUtility::quoteJSvalue($url) . '+\'&returnUrl=\'+top.rawurlencode(top.content.list_frame.document.location.pathname+top.content.list_frame.document.location.search);return false;';
         $cells['edit'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($editOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.editcontent') . '">' . IconUtility::getSpriteIcon('actions-page-open') . '</a>';
     } else {
         $cells['edit'] = $this->spaceIcon;
     }
     if ($fileOrFolderObject instanceof File) {
         $fileUrl = $fileOrFolderObject->getPublicUrl(TRUE);
         if ($fileUrl) {
             $aOnClick = 'return top.openUrlInWindow(' . GeneralUtility::quoteJSvalue($fileUrl) . ', \'WebFile\');';
             $cells['view'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($aOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.view') . '">' . IconUtility::getSpriteIcon('actions-document-view') . '</a>';
         } else {
             $cells['view'] = $this->spaceIcon;
         }
     } else {
         $cells['view'] = $this->spaceIcon;
     }
     // rename the file
     if ($fileOrFolderObject->checkActionPermission('rename')) {
         $url = BackendUtility::getModuleUrl('file_rename', array('target' => $fullIdentifier));
         $renameOnClick = 'top.content.list_frame.location.href = ' . GeneralUtility::quoteJSvalue($url) . '+\'&returnUrl=\'+top.rawurlencode(top.content.list_frame.document.location.pathname+top.content.list_frame.document.location.search);return false;';
         $cells['rename'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($renameOnClick) . '"  title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.rename') . '">' . IconUtility::getSpriteIcon('actions-edit-rename') . '</a>';
     } else {
         $cells['rename'] = $this->spaceIcon;
     }
     if ($fileOrFolderObject->checkActionPermission('read')) {
         $infoOnClick = '';
         if ($fileOrFolderObject instanceof Folder) {
             $infoOnClick = 'top.launchView( \'_FOLDER\', ' . GeneralUtility::quoteJSvalue($fullIdentifier) . ');return false;';
         } elseif ($fileOrFolderObject instanceof File) {
             $infoOnClick = 'top.launchView( \'_FILE\', ' . GeneralUtility::quoteJSvalue($fullIdentifier) . ');return false;';
         }
         $cells['info'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($infoOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.info') . '">' . IconUtility::getSpriteIcon('status-dialog-information') . '</a>';
     } else {
         $cells['info'] = $this->spaceIcon;
     }
     // delete the file
     if ($fileOrFolderObject->checkActionPermission('delete')) {
         $identifier = $fileOrFolderObject->getIdentifier();
         if ($fileOrFolderObject instanceof Folder) {
             $referenceCountText = BackendUtility::referenceCount('_FILE', $identifier, ' (There are %s reference(s) to this folder!)');
         } else {
             $referenceCountText = BackendUtility::referenceCount('sys_file', $fileOrFolderObject->getUid(), ' (There are %s reference(s) to this file!)');
         }
         if ($this->getBackendUser()->jsConfirmation(JsConfirmation::DELETE)) {
             $confirmationCheck = 'confirm(' . GeneralUtility::quoteJSvalue(sprintf($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:mess.delete'), $fileOrFolderObject->getName()) . $referenceCountText) . ')';
         } else {
             $confirmationCheck = '1 == 1';
         }
         $removeOnClick = 'if (' . $confirmationCheck . ') { top.content.list_frame.location.href=' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('tce_file') . '&file[delete][0][data]=' . rawurlencode($fileOrFolderObject->getCombinedIdentifier()) . '&vC=' . $this->getBackendUser()->veriCode() . BackendUtility::getUrlToken('tceAction') . '&redirect=') . '+top.rawurlencode(top.content.list_frame.document.location.pathname+top.content.list_frame.document.location.search);};';
         $cells['delete'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($removeOnClick) . '"  title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.delete') . '">' . IconUtility::getSpriteIcon('actions-edit-delete') . '</a>';
     } else {
         $cells['delete'] = $this->spaceIcon;
     }
     // Hook for manipulating edit icons.
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fileList']['editIconsHook'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fileList']['editIconsHook'] as $classData) {
             $hookObject = GeneralUtility::getUserObj($classData);
             if (!$hookObject instanceof FileListEditIconHookInterface) {
                 throw new \UnexpectedValueException('$hookObject must implement interface \\TYPO3\\CMS\\Filelist\\FileListEditIconHookInterface', 1235225797);
             }
             $hookObject->manipulateEditIcons($cells, $this);
         }
     }
     // Compile items into a DIV-element:
     return '<div class="btn-group">' . implode('', $cells) . '</div>';
 }
예제 #7
0
 /**
  * Copy folder
  *
  * @param \TYPO3\CMS\Core\Resource\Folder $folderToCopy The folder to copy
  * @param \TYPO3\CMS\Core\Resource\Folder $targetParentFolder The target folder
  * @param string $newFolderName
  * @param string $conflictMode  "overrideExistingFolder", "renameNewFolder", "cancel
  * @return \TYPO3\CMS\Core\Resource\Folder The new (copied) folder object
  */
 public function copyFolder(\TYPO3\CMS\Core\Resource\Folder $folderToCopy, \TYPO3\CMS\Core\Resource\Folder $targetParentFolder, $newFolderName = NULL, $conflictMode = 'renameNewFolder')
 {
     // TODO implement the $conflictMode handling
     // TODO permission checks
     $returnObject = NULL;
     $newFolderName = $newFolderName ? $newFolderName : $folderToCopy->getName();
     $this->emitPreFolderCopySignal($folderToCopy, $targetParentFolder, $newFolderName);
     $sourceStorage = $folderToCopy->getStorage();
     // call driver method to move the file
     // that also updates the file object properties
     try {
         if ($sourceStorage == $this) {
             $this->driver->copyFolderWithinStorage($folderToCopy, $targetParentFolder, $newFolderName);
             $returnObject = $this->getFolder($targetParentFolder->getSubfolder($newFolderName)->getIdentifier());
         } else {
             $this->copyFolderBetweenStorages($folderToCopy, $targetParentFolder, $newFolderName);
         }
     } catch (\TYPO3\CMS\Core\Exception $e) {
         echo $e->getMessage();
     }
     $this->emitPostFolderCopySignal($folderToCopy, $targetParentFolder, $newFolderName);
     return $returnObject;
 }
예제 #8
0
 /**
  * Returns the value for the image "title" attribute
  *
  * @param \TYPO3\CMS\Core\Resource\Folder $folderObject The folder to be used
  * @return 	string The attribute value (is htmlspecialchared() already)
  */
 public function getTitleAttrib(\TYPO3\CMS\Core\Resource\Folder $folderObject)
 {
     return htmlspecialchars($folderObject->getName());
 }
예제 #9
0
 /**
  * Returns the value for the image "title" attribute
  *
  * @param \TYPO3\CMS\Core\Resource\Folder $folderObject The folder to be used
  * @return 	string The attribute value (is htmlspecialchared() already)
  */
 public function getTitleAttrib($folderObject)
 {
     return htmlspecialchars($folderObject->getName());
 }
예제 #10
0
    /**
     * @param Folder $parentFolder
     * @return string HTML code
     */
    protected function renderFolders(Folder $parentFolder)
    {
        if (!$parentFolder->checkActionPermission('read')) {
            return '';
        }
        $content = '';
        $lang = $this->getLanguageService();
        $folders = $parentFolder->getSubfolders();
        $folderIdentifier = $parentFolder->getCombinedIdentifier();
        // Create headline (showing number of folders):
        $content .= '<h3>' . sprintf($lang->getLL('folders', true) . ' (%s):', count($folders)) . '</h3>';
        $titleLength = (int) $this->getBackendUser()->uc['titleLen'];
        // Create the header of current folder:
        $folderIcon = '<a href="#" data-folder-id="' . htmlspecialchars($folderIdentifier) . '" data-close="1">';
        $folderIcon .= $this->iconFactory->getIcon('apps-filetree-folder-default', Icon::SIZE_SMALL);
        $folderIcon .= htmlspecialchars(GeneralUtility::fixed_lgd_cs($parentFolder->getName(), $titleLength));
        $folderIcon .= '</a>';
        $content .= $folderIcon . '<br />';
        $lines = array();
        // Traverse the folder list:
        foreach ($folders as $subFolder) {
            $subFolderIdentifier = $subFolder->getCombinedIdentifier();
            // Create folder icon:
            $icon = '<span style="width: 16px; height: 16px; display: inline-block;"></span>';
            $icon .= '<span title="' . htmlspecialchars($subFolder->getName()) . '">' . $this->iconFactory->getIcon('apps-filetree-folder-default', Icon::SIZE_SMALL) . '</span>';
            // Create links for adding the folder:
            $aTag = '<a href="#" data-folder-id="' . htmlspecialchars($folderIdentifier) . '" data-close="0">';
            $aTag_alt = '<a href="#" data-folder-id="' . htmlspecialchars($folderIdentifier) . '" data-close="1">';
            if (strstr($subFolderIdentifier, ',') || strstr($subFolderIdentifier, '|')) {
                // In case an invalid character is in the filepath, display error message:
                $errorMessage = sprintf($lang->getLL('invalidChar', true), ', |');
                $aTag = '<a href="#" class="t3-js-folderIdError" data-message="' . $errorMessage . '">';
            }
            $aTag_e = '</a>';
            // Combine icon and folderpath:
            $foldernameAndIcon = $aTag_alt . $icon . htmlspecialchars(GeneralUtility::fixed_lgd_cs($subFolder->getName(), $titleLength)) . $aTag_e;
            $lines[] = '
				<tr class="bgColor4">
					<td nowrap="nowrap">' . $foldernameAndIcon . '&nbsp;</td>
					<td>' . $aTag . '<span title="' . $lang->getLL('addToList', true) . '">' . $this->iconFactory->getIcon('actions-edit-add', Icon::SIZE_SMALL)->render() . '</span>' . $aTag_e . '</td>
					<td>&nbsp;</td>
				</tr>';
            $lines[] = '
					<tr>
						<td colspan="3"><span style="width: 1px; height: 3px; display: inline-block;"></span></td>
					</tr>';
        }
        // Wrap all the rows in table tags:
        $content .= '

	<!--
		Folder listing
	-->
			<table border="0" cellpadding="0" cellspacing="1" id="typo3-folderList">
				' . implode('', $lines) . '
			</table>';
        return $content;
    }
예제 #11
0
 /**
  * Returns some data specific for the directories...
  *
  * @param \TYPO3\CMS\Core\Resource\Folder $folderObject File information array
  * @return array (title, icon, path)
  * @deprecated since 6.2 - will be removed two versions later without replacement
  */
 public function dirData(\TYPO3\CMS\Core\Resource\Folder $folderObject)
 {
     GeneralUtility::logDeprecatedFunction();
     $title = htmlspecialchars($folderObject->getName());
     $icon = 'apps-filetree-folder-default';
     $role = $folderObject->getRole();
     if ($role === FolderInterface::ROLE_TEMPORARY) {
         $title = '<strong>' . $GLOBALS['LANG']->getLL('temp', TRUE) . '</strong>';
         $icon = 'apps-filetree-folder-temp';
     } elseif ($role === FolderInterface::ROLE_RECYCLER) {
         $icon = 'apps-filetree-folder-recycler';
         $title = '<strong>' . $GLOBALS['LANG']->getLL('recycler', TRUE) . '</strong>';
     }
     return array($title, $icon, $folderObject->getIdentifier());
 }
예제 #12
0
    /**
     * Render list of folders.
     *
     * @param Folder $baseFolder
     * @return string HTML output
     */
    public function folderList(Folder $baseFolder)
    {
        $content = '';
        $lang = $this->getLanguageService();
        $folders = $baseFolder->getSubfolders();
        $folderIdentifier = $baseFolder->getCombinedIdentifier();
        // Create headline (showing number of folders):
        $content .= $this->barheader(sprintf($lang->getLL('folders') . ' (%s):', count($folders)));
        $titleLength = (int) $this->getBackendUserAuthentication()->uc['titleLen'];
        // Create the header of current folder:
        $aTag = '<a href="#" onclick="return insertElement(\'\',' . GeneralUtility::quoteJSvalue($folderIdentifier) . ', \'folder\', ' . GeneralUtility::quoteJSvalue($folderIdentifier) . ', ' . GeneralUtility::quoteJSvalue($folderIdentifier) . ', \'\', \'\',\'\',1);">';
        // Add the foder icon
        $folderIcon = $aTag;
        $folderIcon .= IconUtility::getSpriteIcon('apps-filetree-folder-default');
        $folderIcon .= htmlspecialchars(GeneralUtility::fixed_lgd_cs($baseFolder->getName(), $titleLength));
        $folderIcon .= '</a>';
        $content .= $folderIcon . '<br />';
        $lines = array();
        // Traverse the folder list:
        foreach ($folders as $subFolder) {
            $subFolderIdentifier = $subFolder->getCombinedIdentifier();
            // Create folder icon:
            $icon = '<img src="clear.gif" width="16" height="16" alt="" />';
            $icon .= IconUtility::getSpriteIcon('apps-filetree-folder-default', array('title' => htmlspecialchars($subFolder->getName())));
            // Create links for adding the folder:
            if ($this->P['itemName'] != '' && $this->P['formName'] != '') {
                $aTag = '<a href="#" onclick="return set_folderpath(' . GeneralUtility::quoteJSvalue($subFolderIdentifier) . ');">';
            } else {
                $aTag = '<a href="#" onclick="return insertElement(\'\',' . GeneralUtility::quoteJSvalue($subFolderIdentifier) . ', \'folder\', ' . GeneralUtility::quoteJSvalue($subFolderIdentifier) . ', ' . GeneralUtility::quoteJSvalue($subFolderIdentifier) . ', \'\', \'\');">';
            }
            if (strstr($subFolderIdentifier, ',') || strstr($subFolderIdentifier, '|')) {
                // In case an invalid character is in the filepath, display error message:
                $errorMessage = GeneralUtility::quoteJSvalue(sprintf($lang->getLL('invalidChar'), ', |'));
                $aTag = $aTag_alt = '<a href="#" onclick="alert(' . $errorMessage . ');return false;">';
            } else {
                // If foldername is OK, just add it:
                $aTag_alt = substr($aTag, 0, -4) . ',\'\',1);">';
            }
            $aTag_e = '</a>';
            // Combine icon and folderpath:
            $foldernameAndIcon = $aTag_alt . $icon . htmlspecialchars(GeneralUtility::fixed_lgd_cs($subFolder->getName(), $titleLength)) . $aTag_e;
            if ($this->P['itemName'] != '') {
                $lines[] = '
					<tr class="bgColor4">
						<td nowrap="nowrap">' . $foldernameAndIcon . '&nbsp;</td>
						<td>&nbsp;</td>
					</tr>';
            } else {
                $lines[] = '
					<tr class="bgColor4">
						<td nowrap="nowrap">' . $foldernameAndIcon . '&nbsp;</td>
						<td>' . $aTag . IconUtility::getSpriteIcon('actions-edit-add', array('title' => $lang->getLL('addToList', TRUE))) . $aTag_e . ' </td>
						<td>&nbsp;</td>
					</tr>';
            }
            $lines[] = '
					<tr>
						<td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
					</tr>';
        }
        // Wrap all the rows in table tags:
        $content .= '

	<!--
		Folder listing
	-->
			<table border="0" cellpadding="0" cellspacing="1" id="typo3-folderList">
				' . implode('', $lines) . '
			</table>';
        // Return accumulated content for folderlisting:
        return $content;
    }
예제 #13
0
    /**
     * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images.
     * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE
     *
     * @param \TYPO3\CMS\Core\Resource\Folder $folder The folder path to expand
     * @param string $extensionList List of fileextensions to show
     * @return string HTML output
     * @todo Define visibility
     */
    public function TBE_dragNDrop(\TYPO3\CMS\Core\Resource\Folder $folder, $extensionList = '')
    {
        $extensionList = $extensionList == '*' ? '' : $extensionList;
        $out = '';
        if ($folder) {
            if ($folder->getStorage()->isPublic()) {
                // Read files from directory:
                $files = $folder->getFiles($extensionList);
                if (is_array($files)) {
                    $out .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('files') . ' (%s):', count($files)));
                    $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
                    $picon = '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_webfolders.gif', 'width="18" height="16"') . ' alt="" />';
                    $picon .= htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs(basename($folder->getName()), $titleLen));
                    $out .= $picon . '<br />';
                    // Init row-array:
                    $lines = array();
                    // Add "drag-n-drop" message:
                    $lines[] = '
						<tr>
							<td colspan="2">' . $this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')) . '</td>
						</tr>';
                    // Traverse files:
                    foreach ($files as $fileObject) {
                        $fileInfo = $fileObject->getStorage()->getFileInfo($fileObject);
                        // URL of image:
                        $iUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::rawurlencodeFP($fileObject->getPublicUrl(TRUE));
                        // Show only web-images
                        $fileExtension = strtolower($fileObject->getExtension());
                        if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList('gif,jpeg,jpg,png', $fileExtension)) {
                            $imgInfo = @getimagesize($fileObject->getForLocalProcessing(FALSE));
                            $pDim = $imgInfo[0] . 'x' . $imgInfo[1] . ' pixels';
                            $size = ' (' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($fileObject->getSize()) . 'bytes' . ($pDim ? ', ' . $pDim : '') . ')';
                            $filenameAndIcon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForFile($fileExtension, array('title' => $fileObject->getName() . $size));
                            if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('noLimit')) {
                                $maxW = 10000;
                                $maxH = 10000;
                            } else {
                                $maxW = 380;
                                $maxH = 500;
                            }
                            $IW = $imgInfo[0];
                            $IH = $imgInfo[1];
                            if ($IW > $maxW) {
                                $IH = ceil($IH / $IW * $maxW);
                                $IW = $maxW;
                            }
                            if ($IH > $maxH) {
                                $IW = ceil($IW / $IH * $maxH);
                                $IH = $maxH;
                            }
                            // Make row:
                            $lines[] = '
								<tr class="bgColor4">
									<td nowrap="nowrap">' . $filenameAndIcon . '&nbsp;</td>
									<td nowrap="nowrap">' . ($imgInfo[0] != $IW ? '<a href="' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::linkThisScript(array('noLimit' => '1'))) . '">' . '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/icon_warning2.gif', 'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('clickToRedrawFullSize', 1) . '" alt="" />' . '</a>' : '') . $pDim . '&nbsp;</td>
								</tr>';
                            $lines[] = '
								<tr>
									<td colspan="2"><img src="' . $iUrl . '" data-htmlarea-file-uid="' . $fileObject->getUid() . '" width="' . $IW . '" height="' . $IH . '" border="1" alt="" /></td>
								</tr>';
                            $lines[] = '
								<tr>
									<td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
								</tr>';
                        }
                    }
                    // Finally, wrap all rows in a table tag:
                    $out .= '


			<!--
				File listing / Drag-n-drop
			-->
						<table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
							' . implode('', $lines) . '
						</table>';
                }
            } else {
                // Print this warning if the folder is NOT a web folder:
                $out .= $this->barheader($GLOBALS['LANG']->getLL('files'));
                $out .= $this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'), 'icon_warning2');
            }
        }
        return $out;
    }
예제 #14
0
 /**
  * Returns some data specific for the directories...
  *
  * @param \TYPO3\CMS\Core\Resource\Folder $folderObject File information array
  * @return array (title, icon, path)
  * @todo Define visibility
  */
 public function dirData(\TYPO3\CMS\Core\Resource\Folder $folderObject)
 {
     $title = htmlspecialchars($folderObject->getName());
     $icon = 'apps-filetree-folder-default';
     if ($title == '_temp_') {
         $icon = 'apps-filetree-folder-temp';
         $title = '<strong>' . $GLOBALS['LANG']->getLL('temp', TRUE) . '</strong>';
     }
     if ($title == '_recycler_') {
         $icon = 'apps-filetree-folder-recycler';
         $title = '<strong>' . $GLOBALS['LANG']->getLL('recycler', TRUE) . '</strong>';
     }
     // Mark the icon as read-only icon if the folder is not writable
     if ($folderObject->checkActionPermission('write') === FALSE) {
         $icon = 'apps-filetree-folder-locked';
     }
     return array($title, $icon, $folderObject->getIdentifier());
 }
예제 #15
0
 /**
  * Creates the edit control section
  *
  * @param File|Folder $fileOrFolderObject Array with information about the file/directory for which to make the edit control section for the listing.
  * @return string HTML-table
  */
 public function makeEdit($fileOrFolderObject)
 {
     $cells = [];
     $fullIdentifier = $fileOrFolderObject->getCombinedIdentifier();
     // Edit file content (if editable)
     if ($fileOrFolderObject instanceof File && $fileOrFolderObject->checkActionPermission('write') && GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], $fileOrFolderObject->getExtension())) {
         $url = BackendUtility::getModuleUrl('file_edit', ['target' => $fullIdentifier]);
         $editOnClick = 'top.list_frame.location.href=' . GeneralUtility::quoteJSvalue($url) . '+\'&returnUrl=\'+top.rawurlencode(top.list_frame.document.location.pathname+top.list_frame.document.location.search);return false;';
         $cells['edit'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($editOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.editcontent') . '">' . $this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL)->render() . '</a>';
     } else {
         $cells['edit'] = $this->spaceIcon;
     }
     if ($fileOrFolderObject instanceof File) {
         $fileUrl = $fileOrFolderObject->getPublicUrl(true);
         if ($fileUrl) {
             $aOnClick = 'return top.openUrlInWindow(' . GeneralUtility::quoteJSvalue($fileUrl) . ', \'WebFile\');';
             $cells['view'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($aOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.view') . '">' . $this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL)->render() . '</a>';
         } else {
             $cells['view'] = $this->spaceIcon;
         }
     } else {
         $cells['view'] = $this->spaceIcon;
     }
     // replace file
     if ($fileOrFolderObject instanceof File && $fileOrFolderObject->checkActionPermission('replace')) {
         $url = BackendUtility::getModuleUrl('file_replace', ['target' => $fullIdentifier, 'uid' => $fileOrFolderObject->getUid()]);
         $replaceOnClick = 'top.list_frame.location.href = ' . GeneralUtility::quoteJSvalue($url) . '+\'&returnUrl=\'+top.rawurlencode(top.list_frame.document.location.pathname+top.list_frame.document.location.search);return false;';
         $cells['replace'] = '<a href="#" class="btn btn-default" onclick="' . $replaceOnClick . '"  title="' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.replace') . '">' . $this->iconFactory->getIcon('actions-edit-replace', Icon::SIZE_SMALL)->render() . '</a>';
     }
     // rename the file
     if ($fileOrFolderObject->checkActionPermission('rename')) {
         $url = BackendUtility::getModuleUrl('file_rename', ['target' => $fullIdentifier]);
         $renameOnClick = 'top.list_frame.location.href = ' . GeneralUtility::quoteJSvalue($url) . '+\'&returnUrl=\'+top.rawurlencode(top.list_frame.document.location.pathname+top.list_frame.document.location.search);return false;';
         $cells['rename'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($renameOnClick) . '"  title="' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.rename') . '">' . $this->iconFactory->getIcon('actions-edit-rename', Icon::SIZE_SMALL)->render() . '</a>';
     } else {
         $cells['rename'] = $this->spaceIcon;
     }
     if ($fileOrFolderObject->checkActionPermission('read')) {
         $infoOnClick = '';
         if ($fileOrFolderObject instanceof Folder) {
             $infoOnClick = 'top.launchView( \'_FOLDER\', ' . GeneralUtility::quoteJSvalue($fullIdentifier) . ');return false;';
         } elseif ($fileOrFolderObject instanceof File) {
             $infoOnClick = 'top.launchView( \'_FILE\', ' . GeneralUtility::quoteJSvalue($fullIdentifier) . ');return false;';
         }
         $cells['info'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($infoOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.info') . '">' . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL)->render() . '</a>';
     } else {
         $cells['info'] = $this->spaceIcon;
     }
     // delete the file
     if ($fileOrFolderObject->checkActionPermission('delete')) {
         $identifier = $fileOrFolderObject->getIdentifier();
         if ($fileOrFolderObject instanceof Folder) {
             $referenceCountText = BackendUtility::referenceCount('_FILE', $identifier, ' ' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.referencesToFolder'));
             $deleteType = 'delete_folder';
         } else {
             $referenceCountText = BackendUtility::referenceCount('sys_file', $fileOrFolderObject->getUid(), ' ' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.referencesToFile'));
             $deleteType = 'delete_file';
         }
         if ($this->getBackendUser()->jsConfirmation(JsConfirmation::DELETE)) {
             $confirmationCheck = '1';
         } else {
             $confirmationCheck = '0';
         }
         $deleteUrl = BackendUtility::getModuleUrl('tce_file');
         $confirmationMessage = sprintf($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.delete'), $fileOrFolderObject->getName()) . $referenceCountText;
         $title = $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.delete');
         $cells['delete'] = '<a href="#" class="btn btn-default t3js-filelist-delete" data-content="' . htmlspecialchars($confirmationMessage) . '" data-check="' . $confirmationCheck . '" data-delete-url="' . htmlspecialchars($deleteUrl) . '" data-title="' . htmlspecialchars($title) . '" data-identifier="' . htmlspecialchars($fileOrFolderObject->getCombinedIdentifier()) . '" data-veri-code="' . $this->getBackendUser()->veriCode() . '" data-delete-type="' . $deleteType . '" title="' . htmlspecialchars($title) . '">' . $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render() . '</a>';
     } else {
         $cells['delete'] = $this->spaceIcon;
     }
     // Hook for manipulating edit icons.
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fileList']['editIconsHook'])) {
         $cells['__fileOrFolderObject'] = $fileOrFolderObject;
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fileList']['editIconsHook'] as $classData) {
             $hookObject = GeneralUtility::getUserObj($classData);
             if (!$hookObject instanceof FileListEditIconHookInterface) {
                 throw new \UnexpectedValueException($classData . ' must implement interface ' . FileListEditIconHookInterface::class, 1235225797);
             }
             $hookObject->manipulateEditIcons($cells, $this);
         }
         unset($cells['__fileOrFolderObject']);
     }
     // Compile items into a DIV-element:
     return '<div class="btn-group">' . implode('', $cells) . '</div>';
 }