23 use TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException;
86 parent::__construct();
105 if ($fileIdentifier) {
107 ->retrieveFileOrFolderObject($fileIdentifier);
110 if (!$this->fileObject) {
112 $message = $this->
getLanguageService()->sL(
'LLL:EXT:lang/locallang_mod_file_list.xlf:targetNoDir',
true);
113 throw new \RuntimeException(
$title .
': ' . $message, 1294586841);
115 if ($this->fileObject->getStorage()->getUid() === 0) {
117 'You are not allowed to access files outside your storages',
123 $icon = $this->iconFactory->getIcon(
'apps-filetree-root',
Icon::SIZE_SMALL)->render();
126 $this->fileObject->getStorage()->getName()
127 ) .
': ' . htmlspecialchars(
128 $this->fileObject->getIdentifier()
133 $this->moduleTemplate->addJavaScriptCode(
134 'FileEditBackToList',
135 'function backToList() {
136 top.goToModule("file_FilelistList");
150 if (isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'typo3/file_edit.php'][
'preOutputProcessingHook'])) {
151 $preOutputProcessingHook = &
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'typo3/file_edit.php'][
'preOutputProcessingHook'];
152 if (is_array($preOutputProcessingHook)) {
153 $hookParameters = array(
154 'content' => &$this->content,
155 'target' => &$this->target
157 foreach ($preOutputProcessingHook as $hookFunction) {
163 $pageContent =
'<form action="' . htmlspecialchars(BackendUtility::getModuleUrl(
'tce_file')) .
'" method="post" id="EditFileController" name="editform">';
164 $pageContent .=
'<h1>'
165 . $this->
getLanguageService()->sL(
'LLL:EXT:lang/locallang_core.xlf:file_edit.php.pagetitle')
166 .
' ' . htmlspecialchars($this->fileObject->getName()) .
'</h1>';
169 $extList =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'textfile_ext'];
172 throw new \Exception(
'Files with that extension are not editable.');
176 $fileContent = $this->fileObject->getContents();
179 $hValue = BackendUtility::getModuleUrl(
'file_edit', array(
180 'target' => $this->origTarget,
181 'returnUrl' => $this->returnUrl
185 <textarea rows="30" name="file[editfile][0][data]" wrap="off" class="text-monospace t3js-enable-tab">' . htmlspecialchars($fileContent) .
'</textarea>
186 <input type="hidden" name="file[editfile][0][target]" value="' . $this->fileObject->getUid() .
'" />
187 <input type="hidden" name="redirect" value="' . htmlspecialchars($hValue) .
'" />
193 $this->
getLanguageService()->sL(
'LLL:EXT:lang/locallang_core.xlf:file_edit.php.coundNot'),
199 $pageContent .= $code;
202 if (isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'typo3/file_edit.php'][
'postOutputProcessingHook'])) {
203 $postOutputProcessingHook = &
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'typo3/file_edit.php'][
'postOutputProcessingHook'];
204 if (is_array($postOutputProcessingHook)) {
205 $hookParameters = array(
206 'pageContent' => &$pageContent,
207 'target' => &$this->target
209 foreach ($postOutputProcessingHook as $hookFunction) {
214 $pageContent .=
'</form>';
215 $this->content = $pageContent;
217 $this->moduleTemplate->setContent($this->content);
231 $response->
getBody()->write($this->moduleTemplate->renderContent());
242 $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
246 $helpButton = $buttonBar->makeHelpButton()
247 ->setFieldName(
'file_edit')
248 ->setModuleName(
'xMOD_csh_corebe');
249 $buttonBar->addButton($helpButton);
252 $saveButton = $buttonBar->makeInputButton()
255 ->setOnClick(
'document.editform.submit();')
256 ->setTitle(
$lang->makeEntities(
$lang->sL(
'LLL:EXT:lang/locallang_core.xlf:file_edit.php.submit',
true)))
257 ->setIcon($this->moduleTemplate->getIconFactory()->getIcon(
'actions-document-save',
Icon::SIZE_SMALL));
260 $saveAndCloseButton = $buttonBar->makeInputButton()
261 ->setName(
'_saveandclose')
264 'document.editform.redirect.value='
266 .
'; document.editform.submit();'
268 ->setTitle(
$lang->sL(
'LLL:EXT:lang/locallang_core.xlf:file_edit.php.saveAndClose',
true))
269 ->setIcon($this->moduleTemplate->getIconFactory()->getIcon(
270 'actions-document-save-close',
274 $splitButton = $buttonBar->makeSplitButton()
275 ->addItem($saveButton)
276 ->addItem($saveAndCloseButton);
280 $closeButton = $buttonBar->makeLinkButton()
282 ->setOnClick(
'backToList(); return false;')
283 ->setTitle(
$lang->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.cancel',
true))
284 ->setIcon($this->moduleTemplate->getIconFactory()->getIcon(
'actions-document-close',
Icon::SIZE_SMALL));
288 $shortButton = $buttonBar->makeShortcutButton()
289 ->setModuleName(
'file_edit')
290 ->setGetVariables([
'target']);
291 $buttonBar->addButton($shortButton);