/**
     * Injects the request object for the current request or subrequest
     * As this controller goes only through the main() method, it is rather simple for now
     *
     * @param ServerRequestInterface $request the current request
     * @param ResponseInterface $response the prepared response object
     * @return ResponseInterface the response with the content
     */
    public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
    {
        $this->determineScriptUrl($request);
        $this->initVariables($request);
        $this->loadLinkHandlers();
        $this->initCurrentUrl();
        $menuData = $this->buildMenuArray();
        $renderLinkAttributeFields = $this->renderLinkAttributeFields();
        $browserContent = $this->displayedLinkHandler->render($request);
        $this->initDocumentTemplate();
        $content = $this->doc->startPage('Link Browser');
        $content .= $this->doc->getFlashMessages();
        if ($this->currentLink) {
            $content .= '<!-- Print current URL -->
				<table border="0" cellpadding="0" cellspacing="0" id="typo3-curUrl">
					<tr>
						<td>' . $this->getLanguageService()->getLL('currentLink', true) . ': ' . htmlspecialchars($this->currentLinkHandler->formatCurrentUrl()) . '</td>
					</tr>
				</table>';
        }
        $content .= $this->doc->getTabMenuRaw($menuData);
        $content .= $renderLinkAttributeFields;
        $content .= '<div class="linkBrowser-tabContent">' . $browserContent . '</div>';
        $content .= $this->doc->endPage();
        $response->getBody()->write($this->doc->insertStylesAndJS($content));
        return $response;
    }
    /**
     * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for folders.
     *
     * @return string HTML content for the module
     * @todo Define visibility
     */
    public function main_folder()
    {
        // include JS files
        $this->doc->getDragDropCode('folders');
        // Setting prefs for foldertree
        $this->doc->JScode .= $this->doc->wrapScriptTags('
			Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
		');
        // Starting content:
        $content = $this->doc->startPage('TBE folder selector');
        // Add the FlashMessages if any
        $content .= $this->doc->getFlashMessages();
        // Init variable:
        $parameters = explode('|', $this->bparams);
        if ($this->expandFolder) {
            $this->selectedFolder = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFolderObjectFromCombinedIdentifier($this->expandFolder);
        }
        if ($this->selectedFolder) {
            $createFolder = $this->createFolder($this->selectedFolder);
        } else {
            $createFolder = '';
        }
        // Create folder tree:
        $folderTree = GeneralUtility::makeInstance('TBE_FolderTree');
        $folderTree->thisScript = $this->thisScript;
        $folderTree->ext_noTempRecyclerDirs = $this->mode == 'filedrag';
        $tree = $folderTree->getBrowsableTree(FALSE);
        list(, , $specUid) = explode('_', $this->PM);
        if ($this->selectedFolder) {
            if ($this->mode == 'filedrag') {
                $folders = $this->TBE_dragNDrop($this->selectedFolder, $parameters[3]);
            } else {
                $folders = $this->TBE_expandSubFolders($this->selectedFolder);
            }
        }
        // Putting the parts together, side by side:
        $content .= '

			<!--
				Wrapper table for folder tree / folder list:
			-->
			<table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
				<tr>
					<td class="c-wCell" valign="top">' . $this->barheader($GLOBALS['LANG']->getLL('folderTree') . ':') . $tree . '</td>
					<td class="c-wCell" valign="top">' . $folders . '</td>
				</tr>
			</table>
			';
        // Adding create folder if applicable:
        $content .= $createFolder;
        // Add some space
        $content .= '<br /><br />';
        // Ending page, returning content:
        $content .= $this->doc->endPage();
        $content = $this->doc->insertStylesAndJS($content);
        return $content;
    }
示例#3
0
 /**
  * Injects the request object for the current request or subrequest
  * As this controller goes only through the main() method, it is rather simple for now
  *
  * @param ServerRequestInterface $request the current request
  * @param ResponseInterface $response the prepared response object
  * @return ResponseInterface the response with the content
  */
 public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
 {
     $this->determineScriptUrl($request);
     $this->initVariables($request);
     $this->loadLinkHandlers();
     $this->initCurrentUrl();
     $menuData = $this->buildMenuArray();
     $renderLinkAttributeFields = $this->renderLinkAttributeFields();
     $browserContent = $this->displayedLinkHandler->render($request);
     $this->initDocumentTemplate();
     $content = $this->doc->startPage('Link Browser');
     $content .= $this->doc->getFlashMessages();
     if (!empty($this->currentLinkParts)) {
         $content .= $this->renderCurrentUrl();
     }
     $content .= '<div class="link-browser-section link-browser-tabs">' . $this->doc->getTabMenuRaw($menuData) . '</div>';
     $content .= $renderLinkAttributeFields;
     $content .= $browserContent;
     $content .= $this->doc->endPage();
     $response->getBody()->write($this->doc->insertStylesAndJS($content));
     return $response;
 }
示例#4
0
    /**
     * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for files.
     *
     * @return string HTML content for the module
     * @todo Define visibility
     */
    public function main_file()
    {
        // include JS files and set prefs for foldertree
        $this->doc->getDragDropCode('folders');
        $this->doc->JScode .= $this->doc->wrapScriptTags('
			Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
		');
        // Starting content:
        $content = $this->doc->startPage('TBE file selector');
        // Init variable:
        $pArr = explode('|', $this->bparams);
        // The key number 3 of the pArr contains the "allowed" string. Disallowed is not passed to
        // the element browser at all but only filtered out in TCEMain afterwards
        $allowed = $pArr[3];
        if ($allowed !== 'sys_file') {
            $allowedFileExtensions = $allowed;
        }
        $this->storages = $GLOBALS['BE_USER']->getFileStorages();
        if (isset($allowedFileExtensions)) {
            // Create new filter object
            $filterObject = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\Filter\\FileExtensionFilter');
            $filterObject->setAllowedFileExtensions($allowedFileExtensions);
            // Set file extension filters on all storages
            /** @var $storage \TYPO3\CMS\Core\Resource\ResourceStorage */
            foreach ($this->storages as $storage) {
                $storage->addFileAndFolderNameFilter(array($filterObject, 'filterFileList'));
            }
        }
        // Create upload/create folder forms, if a path is given
        $this->selectedFolder = FALSE;
        if ($this->expandFolder) {
            $fileOrFolderObject = NULL;
            // Try to fetch the folder the user had open the last time he browsed files
            // Fallback to the default folder in case the last used folder is not existing
            try {
                $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
            } catch (\TYPO3\CMS\Core\Resource\Exception $accessException) {
                // We're just catching the exception here, nothing to be done if folder does not exist or is not accessible.
            }
            if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
                // It's a folder
                $this->selectedFolder = $fileOrFolderObject;
            } elseif ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\FileInterface) {
                // It's a file
                $this->selectedFolder = $fileOrFolderObject->getParentFolder();
            }
        }
        // Or get the user's default upload folder
        if (!$this->selectedFolder) {
            try {
                $this->selectedFolder = $GLOBALS['BE_USER']->getDefaultUploadFolder();
            } catch (\Exception $e) {
                // The configured default user folder does not exist
            }
        }
        // Build the file upload and folder creation form
        $uploadForm = '';
        $createFolder = '';
        if ($this->selectedFolder) {
            $uploadForm = $this->uploadForm($this->selectedFolder);
            $createFolder = $this->createFolder($this->selectedFolder);
        }
        // Insert the upload form on top, if so configured
        if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
            $content .= $uploadForm;
        }
        // Getting flag for showing/not showing thumbnails:
        $noThumbs = $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInEB');
        $_MOD_SETTINGS = array();
        if (!$noThumbs) {
            // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
            $_MOD_MENU = array('displayThumbs' => '');
            $_MCONF['name'] = 'file_list';
            $_MOD_SETTINGS = BackendUtility::getModuleData($_MOD_MENU, GeneralUtility::_GP('SET'), $_MCONF['name']);
        }
        $noThumbs = $noThumbs ?: !$_MOD_SETTINGS['displayThumbs'];
        // Create folder tree:
        $folderTree = GeneralUtility::makeInstance('TBE_FolderTree');
        $folderTree->thisScript = $this->thisScript;
        $folderTree->ext_noTempRecyclerDirs = $this->mode == 'filedrag';
        $tree = $folderTree->getBrowsableTree();
        list(, , $specUid) = explode('_', $this->PM);
        if ($this->selectedFolder) {
            if ($this->mode == 'filedrag') {
                $files = $this->TBE_dragNDrop($this->selectedFolder, $pArr[3]);
            } else {
                $files = $this->TBE_expandFolder($this->selectedFolder, $pArr[3], $noThumbs);
            }
        } else {
            $files = '';
        }
        // Add the FlashMessages if any
        $content .= $this->doc->getFlashMessages();
        // Putting the parts together, side by side:
        $content .= '

			<!--
				Wrapper table for folder tree / file list:
			-->
			<table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
				<tr>
					<td class="c-wCell" valign="top">' . $this->barheader($GLOBALS['LANG']->getLL('folderTree') . ':') . $tree . '</td>
					<td class="c-wCell" valign="top">' . $files . '</td>
				</tr>
			</table>
			';
        // Adding create folder + upload forms if applicable:
        if (!$GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
            $content .= $uploadForm;
        }
        $content .= $createFolder;
        // Add some space
        $content .= '<br /><br />';
        // Setup indexed elements:
        $this->doc->JScode .= $this->doc->wrapScriptTags('BrowseLinks.addElements(' . json_encode($this->elements) . ');');
        // Ending page, returning content:
        $content .= $this->doc->endPage();
        $content = $this->doc->insertStylesAndJS($content);
        return $content;
    }
示例#5
0
    /**
     * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for folders.
     *
     * @return string HTML content for the module
     */
    protected function main_folder()
    {
        // include JS files
        // Setting prefs for foldertree
        $this->doc->getDragDropCode('folders', 'Tree.ajaxID = "sc_alt_file_navframe_expandtoggle";');
        // Starting content:
        $content = $this->doc->startPage('TBE folder selector');
        // Add the FlashMessages if any
        $content .= $this->doc->getFlashMessages();
        // Init variable:
        $parameters = explode('|', $this->bparams);
        if ($this->expandFolder) {
            $this->selectedFolder = ResourceFactory::getInstance()->getFolderObjectFromCombinedIdentifier($this->expandFolder);
        }
        if ($this->selectedFolder) {
            $createFolder = $this->createFolder($this->selectedFolder);
        } else {
            $createFolder = '';
        }
        // Create folder tree:
        /** @var ElementBrowserFolderTreeView $folderTree */
        $folderTree = GeneralUtility::makeInstance(ElementBrowserFolderTreeView::class);
        $folderTree->setLinkParameterProvider($this);
        $folderTree->thisScript = $this->thisScript;
        $folderTree->ext_noTempRecyclerDirs = $this->mode === 'filedrag';
        $tree = $folderTree->getBrowsableTree();
        $folders = '';
        if ($this->selectedFolder) {
            if ($this->mode === 'filedrag') {
                $folders = $this->TBE_dragNDrop($this->selectedFolder, $parameters[3]);
            } else {
                $folders = $this->TBE_expandSubFolders($this->selectedFolder);
            }
        }
        // Putting the parts together, side by side:
        $content .= '

			<!--
				Wrapper table for folder tree / folder list:
			-->
			<table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
				<tr>
					<td class="c-wCell" valign="top">' . $this->barheader($this->getLanguageService()->getLL('folderTree') . ':') . $tree . '</td>
					<td class="c-wCell" valign="top">' . $folders . '</td>
				</tr>
			</table>
			';
        // Adding create folder if applicable:
        $content .= $createFolder;
        // Add some space
        $content .= '<br /><br />';
        // Ending page, returning content:
        $content .= $this->doc->endPage();
        $content = $this->doc->insertStylesAndJS($content);
        return $content;
    }