2 namespace TYPO3\CMS\T3editor\Hook;
30 protected $ajaxSaveType =
'TypoScriptTemplateInformationModuleFunctionController';
37 if ($this->t3editor == null) {
38 $this->t3editor = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\
T3editor\T3editor::class)->setMode(\TYPO3\CMS\
T3editor\
T3editor::MODE_TYPOSCRIPT)->setAjaxSaveType($this->ajaxSaveType);
72 foreach (array(
'constants',
'config') as $type) {
73 if ($parameters[
'e'][$type]) {
74 $attributes =
'rows="' . $parameters[
'numberOfRows'] .
'" ' .
'wrap="off" ' . $pObj->pObj->doc->formWidth(48,
true,
'width:98%;height:60%');
75 $title =
$GLOBALS[
'LANG']->getLL(
'template') .
' ' . htmlspecialchars($parameters[
'tplRow'][
'title']) .
$GLOBALS[
'LANG']->getLL(
'delimiter') .
' ' .
$GLOBALS[
'LANG']->getLL($type);
76 $outCode =
$t3editor->getCodeEditor(
'data[' . $type .
']',
'text-monospace enable-tab',
'$1', $attributes, $title, array(
77 'pageId' => (
int)$pObj->pObj->id
79 $parameters[
'theOutput'] = preg_replace(
'/\\<textarea name="data\\[' . $type .
'\\]".*\\>([^\\<]*)\\<\\/textarea\\>/mi', $outCode, $parameters[
'theOutput']);
89 public function save($parameters, $pObj)
91 $savingsuccess =
false;
92 if ($parameters[
'type'] == $this->ajaxSaveType) {
93 $pageId = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP(
'pageId');
94 if (!is_numeric($pageId) || $pageId < 1) {
99 $set = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP(
'SET');
100 $template_uid = $set[
'templatesOnPage'] ?: 0;
102 $tmpl = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\ExtendedTemplateService::class);
107 $tplRow = $tmpl->ext_getFirstTemplate($pageId, $template_uid);
108 $existTemplate = is_array($tplRow);
109 if ($existTemplate) {
110 $saveId = $tplRow[
'_ORIG_uid'] ?: $tplRow[
'uid'];
112 $POST = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST();
113 if ($POST[
'submit']) {
116 if (is_array($POST[
'data'])) {
117 foreach ($POST[
'data'] as $field => $val) {
122 $val = str_replace([CRLF, CR], LF, $val);
123 $recData[
'sys_template'][$saveId][$field] = $val;
128 if (!empty($recData)) {
130 $tstemplateinfo = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController::class);
133 $tstemplateinfo->pObj = $pObj;
134 $tstemplateinfo->pObj->MOD_SETTINGS = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleData(array(
'includeTypoScriptFileContent' =>
true), array(),
'web_ts');
135 $recData[
'sys_template'][$saveId] = $tstemplateinfo->processTemplateRowBeforeSaving($recData[
'sys_template'][$saveId]);
137 $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class);
138 $tce->stripslashes_values = 0;
140 $tce->start($recData, array());
142 $tce->process_datamap();
145 $tce->clear_cacheCmd(
'all');
146 $savingsuccess =
true;
151 return $savingsuccess;