2 namespace TYPO3\CMS\T3editor;
65 protected $codemirrorPath =
'sysext/t3editor/Resources/Public/JavaScript/Contrib/codemirror/js/';
123 $mode = self::MODE_HTML;
126 $mode = self::MODE_JAVASCRIPT;
130 $mode = self::MODE_XML;
133 $mode = self::MODE_CSS;
136 $mode = self::MODE_TYPOSCRIPT;
139 $mode = self::MODE_SPARQL;
144 $mode = self::MODE_PHP;
147 $mode = self::MODE_MIXED;
177 $GLOBALS[
'LANG']->includeLLFile(
'EXT:t3editor/Resources/Private/Language/locallang.xlf');
179 $GLOBALS[
'BE_USER']->uc[
'disablePMKTextarea'] = 1;
181 $this->relExtPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath(
't3editor');
189 public function getJavascriptCode()
193 $pageRenderer->addCssFile($this->relExtPath .
'Resources/Public/Css/t3editor.css');
195 $pageRenderer->addJsLibrary(
'codemirror', $this->codemirrorPath .
'codemirror.js');
196 if ($this->mode === self::MODE_TYPOSCRIPT) {
197 foreach ($this->codeCompletionComponents as $codeCompletionComponent) {
198 $pageRenderer->loadRequireJsModule(
'TYPO3/CMS/T3editor/Plugins/CodeCompletion/' . $codeCompletionComponent);
201 $pageRenderer->loadRequireJsModule(
'TYPO3/CMS/T3editor/T3editor');
215 return str_replace(array(CR, LF),
'', $T3editor_template);
227 case self::MODE_TYPOSCRIPT:
228 $relPath =
'../../../parse_typoscript/';
229 $parserfile = array($relPath .
'tokenizetyposcript.js', $relPath .
'parsetyposcript.js');
231 case self::MODE_JAVASCRIPT:
232 $parserfile = array(
'tokenizetyposcript.js',
'parsejavascript.js');
235 $parserfile = array(
'parsecss.js');
238 $parserfile = array(
'parsexml.js');
240 case self::MODE_SPARQL:
241 $parserfile = array(
'parsesparql.js');
243 case self::MODE_HTML:
244 $parserfile = array(
'tokenizejavascript.js',
'parsejavascript.js',
'parsecss.js',
'parsexml.js',
'parsehtmlmixed.js');
247 case self::MODE_MIXED:
248 $parserfile = array(
'tokenizejavascript.js',
'parsejavascript.js',
'parsecss.js',
'parsexml.js',
'../contrib/php/js/tokenizephp.js',
'../contrib/php/js/parsephp.js',
'../contrib/php/js/parsephphtmlmixed.js');
251 return json_encode($parserfile);
263 case self::MODE_TYPOSCRIPT:
264 $stylesheet = array($this->relExtPath .
'Resources/Public/Css/typoscriptcolors.css');
266 case self::MODE_JAVASCRIPT:
267 $stylesheet = array($this->codemirrorPath .
'../css/jscolors.css');
270 $stylesheet = array($this->codemirrorPath .
'../css/csscolors.css');
273 $stylesheet = array($this->codemirrorPath .
'../css/xmlcolors.css');
275 case self::MODE_HTML:
276 $stylesheet = array($this->codemirrorPath .
'../css/xmlcolors.css', $this->codemirrorPath .
'../css/jscolors.css', $this->codemirrorPath .
'../css/csscolors.css');
278 case self::MODE_SPARQL:
279 $stylesheet = array($this->codemirrorPath .
'../css/sparqlcolors.css');
282 $stylesheet = array($this->codemirrorPath .
'../contrib/php/css/phpcolors.css');
284 case self::MODE_MIXED:
285 $stylesheet = array($this->codemirrorPath .
'../css/xmlcolors.css', $this->codemirrorPath .
'../css/jscolors.css', $this->codemirrorPath .
'../css/csscolors.css', $this->codemirrorPath .
'../contrib/php/css/phpcolors.css');
288 $stylesheet = array();
290 $stylesheet[] = $this->relExtPath .
'Resources/Public/Css/t3editor_inner.css';
291 return json_encode($stylesheet);
305 public function getCodeEditor($name, $class =
'', $content =
'', $additionalParams =
'', $alt =
'', array $hiddenfields = array())
308 $class .=
' t3editor';
309 $alt = htmlspecialchars($alt);
311 $alt =
' alt="' . $alt .
'"';
314 '<div class="t3editor">'
315 .
'<div class="t3e_wrap">'
319 .
'id="t3editor_' . $this->editorCounter .
'" '
320 .
'name="' . $name .
'" '
321 .
'class="' . $class .
'" '
322 . $additionalParams .
' '
324 .
' data-labels="' . htmlspecialchars(json_encode(
$GLOBALS[
'LANG']->getLabelsWithPrefix(
'js.',
'label_'))) .
'"'
325 .
' data-instance-number="' . $this->editorCounter .
'"'
326 .
' data-editor-path="' . htmlspecialchars($this->relExtPath) .
'"'
327 .
' data-codemirror-path="' . htmlspecialchars($this->codemirrorPath) .
'"'
328 .
' data-ajaxsavetype="' . htmlspecialchars($this->ajaxSaveType) .
'"'
331 .
'>' . htmlspecialchars($content)
334 if (!empty($hiddenfields)) {
335 foreach ($hiddenfields as $name => $value) {
336 $code .=
'<input type="hidden" ' .
'name="' . $name .
'" ' .
'value="' . $value .
'" />';
339 $this->editorCounter++;
353 if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX) {
355 $savingsuccess =
false;
357 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'ext/t3editor/classes/class.tx_t3editor.php'][
'ajaxSaveCode'])) {
361 'request' => $request,
362 'response' => $response
364 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'ext/t3editor/classes/class.tx_t3editor.php'][
'ajaxSaveCode'] as $key => $_funcRef) {
368 $responseContent = array(
'result' => $savingsuccess);
369 }
catch (\Exception $e) {
370 $responseContent = array(
372 'exceptionMessage' => htmlspecialchars($e->getMessage()),
373 'exceptionCode' => $e->getCode()
378 $response->
getBody()->write(json_encode($responseContent));
395 $plugins = &
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
't3editor'][
'plugins'];
396 if (is_array($plugins)) {
397 $result = array_values($plugins);
399 $request->
getBody()->write(json_encode($result));