TYPO3 CMS  TYPO3_6-2
FileEditHook.php
Go to the documentation of this file.
1 <?php
3 
22 class FileEditHook {
23 
27  protected $t3editor = NULL;
28 
32  protected $ajaxSaveType = 'TypoScriptTemplateInformationModuleFunctionController';
33 
37  protected function getT3editor() {
38  if ($this->t3editor == NULL) {
39  $this->t3editor = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\T3editor\\T3editor')->setAjaxSaveType($this->ajaxSaveType);
40  }
41  return $this->t3editor;
42  }
43 
51  public function preOutputProcessingHook($parameters, $pObj) {
52  $t3editor = $this->getT3editor();
53  $t3editor->setModeByFile($parameters['target']);
54  if (!$t3editor->isEnabled() || !$t3editor->getMode()) {
55  return;
56  }
57  $parameters['content'] = str_replace('<!--###POSTJSMARKER###-->', '<!--###POSTJSMARKER###-->' . $t3editor->getModeSpecificJavascriptCode(), $parameters['content']);
58  }
59 
68  public function preStartPageHook($parameters, $pObj) {
69  if (preg_match('/typo3\\/file_edit\\.php/', $_SERVER['SCRIPT_NAME'])) {
70  $t3editor = $this->getT3editor();
71  if (!$t3editor->isEnabled()) {
72  return;
73  }
74  $pObj->JScode .= $t3editor->getJavascriptCode($pObj);
75  $pObj->loadJavascriptLib(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('t3editor') . 'res/jslib/fileedit.js');
76  }
77  }
78 
86  public function postOutputProcessingHook($parameters, $pObj) {
87  $t3editor = $this->getT3editor();
88  if (!$t3editor->isEnabled() || !$t3editor->getMode()) {
89  return;
90  }
91  $attributes = 'rows="30" ' . 'wrap="off" ' . $pObj->doc->formWidth(48, TRUE, 'width:98%;height:60%');
92  $title = $GLOBALS['LANG']->getLL('file') . ' ' . htmlspecialchars($pObj->target);
93  $outCode = $t3editor->getCodeEditor('file[editfile][0][data]', 'fixed-font enable-tab', '$1', $attributes, $title, array(
94  'target' => (int)$pObj->target
95  ));
96  $parameters['pageContent'] = preg_replace('/\\<textarea .*name="file\\[editfile\\]\\[0\\]\\[data\\]".*\\>([^\\<]*)\\<\\/textarea\\>/mi', $outCode, $parameters['pageContent']);
97  }
98 
105  public function save($parameters, $pObj) {
106  $savingsuccess = FALSE;
107  if ($parameters['type'] == $this->ajaxSaveType) {
108  $tceFile = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Controller\\File\\FileController');
109  $tceFile->processAjaxRequest(array(), $parameters['ajaxObj']);
110  $result = $parameters['ajaxObj']->getContent('result');
111  $savingsuccess = is_array($result) && $result['editfile'][0];
112  }
113  return $savingsuccess;
114  }
115 
116 }
$parameters
Definition: FileDumpEID.php:15
preStartPageHook($parameters, $pObj)
preOutputProcessingHook($parameters, $pObj)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
postOutputProcessingHook($parameters, $pObj)