2 namespace TYPO3\CMS\T3editor\Form\Element;
45 self::MODE_JAVASCRIPT,
49 self::MODE_TYPOSCRIPT,
80 protected $codemirrorPath =
'sysext/t3editor/Resources/Public/JavaScript/Contrib/codemirror/js/';
96 $this->
getLanguageService()->includeLLFile(
'EXT:t3editor/Resources/Private/Language/locallang.xlf');
101 $parameterArray = $this->data[
'parameterArray'];
104 $this->
setMode(isset($parameterArray[
'fieldConf'][
'config'][
'format']) ? $parameterArray[
'fieldConf'][
'config'][
'format'] :
T3editor::MODE_MIXED);
106 $attributes = array();
107 $attributes[
'rows'] = $rows;
108 $attributes[
'wrap'] =
'off';
109 $attributes[
'style'] =
'width:100%;';
112 $attributeString =
'';
113 foreach ($attributes as $param => $value) {
114 $attributeString .= $param .
'="' . htmlspecialchars($value) .
'" ';
118 $parameterArray[
'itemFormElName'],
119 'text-monospace enable-tab',
120 $parameterArray[
'itemFormElValue'],
122 $this->data[
'tableName'] .
' > ' . $this->data[
'fieldName'],
138 if (!in_array(
$mode, $this->allowedModes,
true)) {
139 throw new \InvalidArgumentException(
$mode .
'is not allowed', 1438352574);
159 $this->resultArray[
'stylesheetFiles'][] = $this->relExtPath .
'Resources/Public/Css/t3editor.css';
160 $this->resultArray[
'requireJsModules'][] =
'TYPO3/CMS/T3editor/T3editor';
161 if ($this->mode === self::MODE_TYPOSCRIPT) {
162 foreach ($this->codeCompletionComponents as $codeCompletionComponent) {
163 $this->resultArray[
'requireJsModules'][] =
'TYPO3/CMS/T3editor/Plugins/CodeCompletion/' . $codeCompletionComponent;
179 protected function getHTMLCodeForEditor($name, $class =
'', $content =
'', $additionalParams =
'', $alt =
'', array $hiddenfields = array())
182 $attributes = array();
183 $attributes[
'class'] = $class .
' t3editor';
184 $attributes[
'alt'] = $alt;
186 $attributes[
'name'] = $name;
187 $attributes[
'data-labels'] = json_encode($this->
getLanguageService()->getLabelsWithPrefix(
'js.',
'label_'));
191 $attributes[
'data-ajaxsavetype'] =
'';
195 $attributesString =
'';
196 foreach ($attributes as $attribute => $value) {
197 $attributesString .= $attribute .
'="' . htmlspecialchars($value) .
'" ';
199 $attributesString .= $additionalParams;
201 $code[] =
'<div class="t3editor">';
202 $code[] =
' <div class="t3e_wrap">';
205 $code[] =
' <textarea ' . $attributesString .
'>' . htmlspecialchars($content) .
'</textarea>';
208 if (!empty($hiddenfields)) {
209 foreach ($hiddenfields as $name => $value) {
210 $code[] =
'<input type="hidden" name="' . htmlspecialchars($name) .
'" value="' . htmlspecialchars($value) .
'" />';
213 $this->editorCounter++;
214 return implode(LF, $code);
225 $parserfile = array();
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);