/** * Create a flash message for a file that is marked as missing * * @param AbstractFile $file * @return FlashMessage */ public static function getFlashMessageForMissingFile(AbstractFile $file) { /** @var LanguageService $lang */ $lang = $GLOBALS['LANG']; /** @var FlashMessage $flashMessage */ $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $lang->sL('LLL:EXT:lang/locallang_core.xlf:warning.file_missing_text') . ' <abbr title="' . htmlspecialchars($file->getStorage()->getName() . ' :: ' . $file->getIdentifier()) . '">' . htmlspecialchars($file->getName()) . '</abbr>', $lang->sL('LLL:EXT:lang/locallang_core.xlf:warning.file_missing'), FlashMessage::ERROR); return $flashMessage; }
/** * Main function, redering the actual content of the editing page * * @return void */ public function main() { $this->getButtons(); // Hook before compiling the output if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook'])) { $preOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook']; if (is_array($preOutputProcessingHook)) { $hookParameters = array('content' => &$this->content, 'target' => &$this->target); foreach ($preOutputProcessingHook as $hookFunction) { GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this); } } } $pageContent = '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('tce_file')) . '" method="post" id="EditFileController" name="editform">'; $pageContent .= '<h1>' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_edit.php.pagetitle') . ' ' . htmlspecialchars($this->fileObject->getName()) . '</h1>'; $code = ''; $extList = $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext']; try { if (!$extList || !GeneralUtility::inList($extList, $this->fileObject->getExtension())) { throw new \Exception('Files with that extension are not editable.'); } // Read file content to edit: $fileContent = $this->fileObject->getContents(); // Making the formfields $hValue = BackendUtility::getModuleUrl('file_edit', array('target' => $this->origTarget, 'returnUrl' => $this->returnUrl)); $code .= ' <div id="c-edit"> <textarea rows="30" name="file[editfile][0][data]" wrap="off" class="form-control text-monospace t3js-enable-tab">' . htmlspecialchars($fileContent) . '</textarea> <input type="hidden" name="file[editfile][0][target]" value="' . $this->fileObject->getUid() . '" /> <input type="hidden" name="redirect" value="' . htmlspecialchars($hValue) . '" /> </div> <br />'; } catch (\Exception $e) { $code .= sprintf($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_edit.php.coundNot'), $extList); } // Ending of section and outputting editing form: $pageContent .= $code; // Hook after compiling the output if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['postOutputProcessingHook'])) { $postOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['postOutputProcessingHook']; if (is_array($postOutputProcessingHook)) { $hookParameters = array('pageContent' => &$pageContent, 'target' => &$this->target); foreach ($postOutputProcessingHook as $hookFunction) { GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this); } } } $pageContent .= '</form>'; $this->content = $pageContent; $this->moduleTemplate->setContent($this->content); }
/** * Main function, redering the actual content of the editing page * * @return void */ public function main() { $docHeaderButtons = $this->getButtons(); $this->content = $this->doc->startPage($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_edit.php.pagetitle')); // Hook before compiling the output if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook'])) { $preOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook']; if (is_array($preOutputProcessingHook)) { $hookParameters = array('content' => &$this->content, 'target' => &$this->target); foreach ($preOutputProcessingHook as $hookFunction) { GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this); } } } $pageContent = $this->doc->header($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_edit.php.pagetitle') . ' ' . htmlspecialchars($this->fileObject->getName())); $pageContent .= $this->doc->spacer(2); $code = ''; $extList = $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext']; try { if (!$extList || !GeneralUtility::inList($extList, $this->fileObject->getExtension())) { throw new \Exception('Files with that extension are not editable.'); } // Read file content to edit: $fileContent = $this->fileObject->getContents(); // Making the formfields $hValue = BackendUtility::getModuleUrl('file_edit', array('target' => $this->origTarget, 'returnUrl' => $this->returnUrl)); // Edit textarea: $code .= ' <div id="c-edit"> <textarea rows="30" name="file[editfile][0][data]" wrap="off" ' . $this->doc->formWidth(48, TRUE, 'width:98%;height:80%') . ' class="text-monospace t3js-enable-tab">' . GeneralUtility::formatForTextarea($fileContent) . '</textarea> <input type="hidden" name="file[editfile][0][target]" value="' . $this->fileObject->getUid() . '" /> <input type="hidden" name="redirect" value="' . htmlspecialchars($hValue) . '" /> ' . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction') . ' </div> <br />'; // Make shortcut: if ($this->getBackendUser()->mayMakeShortcut()) { $docHeaderButtons['shortcut'] = $this->doc->makeShortcutIcon('target', '', 'file_edit', 1); } else { $docHeaderButtons['shortcut'] = ''; } } catch (\Exception $e) { $code .= sprintf($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_edit.php.coundNot'), $extList); } // Ending of section and outputting editing form: $pageContent .= $this->doc->sectionEnd(); $pageContent .= $code; // Hook after compiling the output if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['postOutputProcessingHook'])) { $postOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['postOutputProcessingHook']; if (is_array($postOutputProcessingHook)) { $hookParameters = array('pageContent' => &$pageContent, 'target' => &$this->target); foreach ($postOutputProcessingHook as $hookFunction) { GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this); } } } // Add the HTML as a section: $markerArray = array('CSH' => $docHeaderButtons['csh'], 'FUNC_MENU' => '', 'BUTTONS' => $docHeaderButtons, 'PATH' => $this->title, 'CONTENT' => $pageContent); $this->content .= $this->doc->moduleBody(array(), $docHeaderButtons, $markerArray); $this->content .= $this->doc->endPage(); $this->content = $this->doc->insertStylesAndJS($this->content); }
/** * Create a flash message for a file that is marked as missing * * @param \TYPO3\CMS\Core\Resource\AbstractFile $file * @return \TYPO3\CMS\Core\Messaging\FlashMessage */ public static function getFlashMessageForMissingFile(\TYPO3\CMS\Core\Resource\AbstractFile $file) { /** @var \TYPO3\CMS\Core\Messaging\FlashMessage $flashMessage */ $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessage::class, $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.file_missing_text') . ' <abbr title="' . htmlspecialchars($file->getStorage()->getName() . ' :: ' . $file->getIdentifier()) . '">' . htmlspecialchars($file->getName()) . '</abbr>', $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.file_missing'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); return $flashMessage; }
/** * Main function, redering the actual content of the editing page * * @return void * @todo Define visibility */ public function main() { //TODO: change locallang*.php to locallang*.xml $docHeaderButtons = $this->getButtons(); $this->content = $this->doc->startPage($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.pagetitle')); // Hook before compiling the output if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook'])) { $preOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook']; if (is_array($preOutputProcessingHook)) { $hookParameters = array('content' => &$this->content, 'target' => &$this->target); foreach ($preOutputProcessingHook as $hookFunction) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this); } } } $pageContent = $this->doc->header($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.pagetitle') . ' ' . htmlspecialchars($this->fileObject->getName())); $pageContent .= $this->doc->spacer(2); $code = ''; $extList = $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext']; if ($extList && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($extList, $this->fileObject->getExtension())) { // Read file content to edit: $fileContent = $this->fileObject->getContents(); // Making the formfields $hValue = 'file_edit.php?target=' . rawurlencode($this->origTarget) . '&returnUrl=' . rawurlencode($this->returnUrl); // Edit textarea: $code .= ' <div id="c-edit"> <textarea rows="30" name="file[editfile][0][data]" wrap="off"' . $this->doc->formWidthText(48, 'width:98%;height:80%', 'off') . ' class="fixed-font enable-tab">' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatForTextarea($fileContent) . '</textarea> <input type="hidden" name="file[editfile][0][target]" value="' . $this->fileObject->getUid() . '" /> <input type="hidden" name="redirect" value="' . htmlspecialchars($hValue) . '" /> </div> <br />'; // Make shortcut: if ($GLOBALS['BE_USER']->mayMakeShortcut()) { $this->MCONF['name'] = 'xMOD_file_edit.php'; $docHeaderButtons['shortcut'] = $this->doc->makeShortcutIcon('target', '', $this->MCONF['name'], 1); } else { $docHeaderButtons['shortcut'] = ''; } } else { $code .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.coundNot'), $extList); } // Ending of section and outputting editing form: $pageContent .= $this->doc->sectionEnd(); $pageContent .= $code; // Hook after compiling the output if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['postOutputProcessingHook'])) { $postOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['postOutputProcessingHook']; if (is_array($postOutputProcessingHook)) { $hookParameters = array('pageContent' => &$pageContent, 'target' => &$this->target); foreach ($postOutputProcessingHook as $hookFunction) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this); } } } // Add the HTML as a section: $markerArray = array('CSH' => $docHeaderButtons['csh'], 'FUNC_MENU' => \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']), 'BUTTONS' => $docHeaderButtons, 'PATH' => $this->title, 'CONTENT' => $pageContent); $this->content .= $this->doc->moduleBody(array(), $docHeaderButtons, $markerArray); $this->content .= $this->doc->endPage(); $this->content = $this->doc->insertStylesAndJS($this->content); }