Exemplo n.º 1
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);
    }
Exemplo n.º 2
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);
    }
Exemplo n.º 3
0
 /**
  * Make reference count
  *
  * @param File|Folder $fileOrFolderObject Array with information about the file/directory for which to make the clipboard panel for the listing.
  * @return string HTML
  */
 public function makeRef($fileOrFolderObject)
 {
     if ($fileOrFolderObject instanceof FolderInterface) {
         return '-';
     }
     // Look up the file in the sys_refindex.
     // Exclude sys_file_metadata records as these are no use references
     $databaseConnection = $this->getDatabaseConnection();
     $table = 'sys_refindex';
     $referenceCount = $databaseConnection->exec_SELECTcountRows('*', $table, 'ref_table=' . $databaseConnection->fullQuoteStr('sys_file', $table) . ' AND ref_uid=' . (int) $fileOrFolderObject->getUid() . ' AND deleted=0' . ' AND tablename != ' . $databaseConnection->fullQuoteStr('sys_file_metadata', $table));
     return $this->generateReferenceToolTip($referenceCount, '\'_FILE\', ' . GeneralUtility::quoteJSvalue($fileOrFolderObject->getCombinedIdentifier()));
 }
Exemplo n.º 4
0
 /**
  * Make reference count
  *
  * @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.
  * @return string HTML
  * @todo Define visibility
  */
 public function makeRef($fileOrFolderObject)
 {
     if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\FolderInterface) {
         return '-';
     }
     // Look up the file in the sys_refindex.
     // Exclude sys_file_metadata records as these are no use references
     $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table=\'sys_file\' AND ref_uid = ' . (int) $fileOrFolderObject->getUid() . ' AND deleted=0 AND tablename != "sys_file_metadata"');
     return $this->generateReferenceToolTip($rows, '\'_FILE\', ' . GeneralUtility::quoteJSvalue($fileOrFolderObject->getCombinedIdentifier()));
 }
Exemplo n.º 5
0
 /**
  * Make reference count
  *
  * @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.
  * @return string HTML
  * @todo Define visibility
  */
 public function makeRef($fileOrFolderObject)
 {
     if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\FolderInterface) {
         return '-';
     }
     // Look up the path:
     $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr('sys_file', 'sys_refindex') . ' AND ref_uid = ' . $fileOrFolderObject->getUid() . ' AND deleted=0');
     return $this->generateReferenceToolTip($rows, '\'_FILE\', \'' . $fileOrFolderObject->getCombinedIdentifier() . '\'');
 }
 /**
  * Creates the edit control section
  *
  * @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.
  * @return string HTML-table
  * @todo Define visibility
  */
 protected function makeEdit7($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);
         }
     }
     $cells = array_merge($cells, $this->addAdditionalCells($fileOrFolderObject));
     // Compile items into a DIV-element:
     return '<div class="btn-group">' . implode('', $cells) . '</div>';
 }
Exemplo n.º 7
0
 /**
  * Make reference count
  *
  * @param File|Folder $fileOrFolderObject Array with information about the file/directory for which to make the clipboard panel for the listing.
  * @return string HTML
  */
 public function makeRef($fileOrFolderObject)
 {
     if ($fileOrFolderObject instanceof FolderInterface) {
         return '-';
     }
     // Look up the file in the sys_refindex.
     // Exclude sys_file_metadata records as these are no use references
     $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_refindex');
     $referenceCount = $queryBuilder->count('*')->from('sys_refindex')->where($queryBuilder->expr()->eq('ref_table', $queryBuilder->quote('sys_file')))->andWhere($queryBuilder->expr()->eq('ref_uid', (int) $fileOrFolderObject->getUid()))->andWhere($queryBuilder->expr()->neq('tablename', $queryBuilder->quote('sys_file_metadata')))->execute()->fetchColumn();
     return $this->generateReferenceToolTip($referenceCount, '\'_FILE\', ' . GeneralUtility::quoteJSvalue($fileOrFolderObject->getCombinedIdentifier()));
 }