Merge pull request #1290 from MrReSc/master

Codesample plugin setting and translations
This commit is contained in:
Diego Najar 2020-12-21 09:52:29 +01:00 committed by GitHub
commit 5abddff1aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 14 deletions

View file

@ -4,7 +4,8 @@
"name": "TinyMCE", "name": "TinyMCE",
"description": "WYSIWYG HTML Editor, mit dem Inhalte einfach formatiert werden können." "description": "WYSIWYG HTML Editor, mit dem Inhalte einfach formatiert werden können."
}, },
"Toolbar top": "Obere Werkzeugleiste", "toolbar-top": "Obere Werkzeugleiste",
"Toolbar bottom": "Untere Werkzeugleiste", "toolbar-bottom": "Untere Werkzeugleiste",
"Mobile toolbar": "Werkzeugleiste auf Mobiles" "codesample-languages": "Codesample Programmiersprachen",
} "codesample-supported-laguages": "Pragrammiersprachen die von Prism unterstützt werden."
}

View file

@ -4,7 +4,8 @@
"name": "TinyMCE", "name": "TinyMCE",
"description": "WYSIWYG HTML Editor, mit dem Inhalte einfach formatiert werden können." "description": "WYSIWYG HTML Editor, mit dem Inhalte einfach formatiert werden können."
}, },
"Toolbar top": "Obere Werkzeugleiste", "toolbar-top": "Obere Werkzeugleiste",
"Toolbar bottom": "Untere Werkzeugleiste", "toolbar-bottom": "Untere Werkzeugleiste",
"Mobile toolbar": "Werkzeugleiste auf Mobiles" "codesample-languages": "Codesample Programmiersprachen",
} "codesample-supported-laguages": "Pragrammiersprachen die von Prism unterstützt werden."
}

View file

@ -3,5 +3,9 @@
{ {
"name": "TinyMCE", "name": "TinyMCE",
"description": "HTML Editor for formatting content. Recommended for the users who don't want to work with Markdown code." "description": "HTML Editor for formatting content. Recommended for the users who don't want to work with Markdown code."
} },
"toolbar-top": "Toolbar top",
"toolbar-bottom": "Toolbar bottom",
"codesample-languages": "Codesample languages",
"codesample-supported-laguages": "Programming languages supported by Prism."
} }

View file

@ -12,7 +12,8 @@ class pluginTinymce extends Plugin {
$this->dbFields = array( $this->dbFields = array(
'toolbar1'=>'formatselect bold italic forecolor backcolor removeformat | bullist numlist table | blockquote alignleft aligncenter alignright | link unlink pagebreak image code', 'toolbar1'=>'formatselect bold italic forecolor backcolor removeformat | bullist numlist table | blockquote alignleft aligncenter alignright | link unlink pagebreak image code',
'toolbar2'=>'', 'toolbar2'=>'',
'plugins'=>'code autolink image link pagebreak advlist lists textpattern table' 'plugins'=>'code autolink image link pagebreak advlist lists textpattern table',
'codesampleLanguages'=>'HTML/XML markup|JavaScript javascript|CSS css|PHP php|Ruby ruby|Python python|Java java|C c|C# sharp|C++ cpp'
); );
} }
@ -20,13 +21,17 @@ class pluginTinymce extends Plugin {
{ {
global $L; global $L;
$html = '<div>'; $html = '<div class="alert alert-primary" role="alert">';
$html .= '<label>'.$L->get('Toolbar top').'</label>'; $html .= $this->description();
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$L->get('toolbar-top').'</label>';
$html .= '<input name="toolbar1" id="jstoolbar1" type="text" value="'.$this->getValue('toolbar1').'">'; $html .= '<input name="toolbar1" id="jstoolbar1" type="text" value="'.$this->getValue('toolbar1').'">';
$html .= '</div>'; $html .= '</div>';
$html .= '<div>'; $html .= '<div>';
$html .= '<label>'.$L->get('Toolbar bottom').'</label>'; $html .= '<label>'.$L->get('toolbar-bottom').'</label>';
$html .= '<input name="toolbar2" id="jstoolbar2" type="text" value="'.$this->getValue('toolbar2').'">'; $html .= '<input name="toolbar2" id="jstoolbar2" type="text" value="'.$this->getValue('toolbar2').'">';
$html .= '</div>'; $html .= '</div>';
@ -35,6 +40,14 @@ class pluginTinymce extends Plugin {
$html .= '<input name="plugins" id="jsplugins" type="text" value="'.$this->getValue('plugins').'">'; $html .= '<input name="plugins" id="jsplugins" type="text" value="'.$this->getValue('plugins').'">';
$html .= '</div>'; $html .= '</div>';
if (strpos($this->getValue('plugins'), 'codesample') !== false) {
$html .= '<div>';
$html .= '<label>'.$L->get('codesample-languages').'</label>';
$html .= '<input name="codesampleLanguages" id="jsCodesampleLanguages" type="text" value="'.$this->getValue('codesampleLanguages').'">';
$html .= '<span class="tip">'.$L->get('codesample-supported-laguages').'</span>';
$html .= '</div>';
}
return $html; return $html;
} }
@ -64,6 +77,14 @@ class pluginTinymce extends Plugin {
$plugins = $this->getValue('plugins'); $plugins = $this->getValue('plugins');
$version = $this->version(); $version = $this->version();
if (strpos($this->getValue('plugins'), 'codesample') !== false) {
$codesampleLanguages = explode("|", $this->getValue('codesampleLanguages'));
foreach($codesampleLanguages AS $codesampleLang) {
$values = explode(" ", $codesampleLang);
$codesampleConfig .= "{ text: '" . $values[0] . "', value: '" . $values[1] . "' },";
}
}
$lang = 'en'; $lang = 'en';
if (file_exists($this->phpPath().'tinymce'.DS.'langs'.DS.$L->currentLanguage().'.js')) { if (file_exists($this->phpPath().'tinymce'.DS.'langs'.DS.$L->currentLanguage().'.js')) {
$lang = $L->currentLanguage(); $lang = $L->currentLanguage();
@ -121,7 +142,8 @@ $html = <<<EOF
toolbar1: "$toolbar1", toolbar1: "$toolbar1",
toolbar2: "$toolbar2", toolbar2: "$toolbar2",
language: "$lang", language: "$lang",
content_css: "$content_css" content_css: "$content_css",
codesample_languages: [$codesampleConfig],
}); });
</script> </script>