2017-08-03 23:28:32 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class pluginTinymce extends Plugin {
|
|
|
|
|
2017-08-06 00:52:00 +02:00
|
|
|
private $loadOnController = array(
|
2017-10-02 22:42:18 +02:00
|
|
|
'new-content',
|
|
|
|
'edit-content'
|
2017-08-03 23:28:32 +02:00
|
|
|
);
|
|
|
|
|
2018-07-30 23:43:12 +02:00
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
$this->dbFields = array(
|
2018-09-23 13:38:14 +02:00
|
|
|
'toolbar1'=>'formatselect bold italic bullist numlist blockquote alignleft aligncenter alignright link unlink pagebreak image removeformat code',
|
2018-07-30 23:43:12 +02:00
|
|
|
'toolbar2'=>'',
|
2018-08-19 17:45:49 +02:00
|
|
|
'mobileToolbar'=>'bold italic bullist formatselect',
|
2018-07-30 23:43:12 +02:00
|
|
|
'plugins'=>'code autolink image link pagebreak advlist lists textcolor colorpicker textpattern'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function form()
|
|
|
|
{
|
2018-08-05 17:54:20 +02:00
|
|
|
global $L;
|
2018-07-30 23:43:12 +02:00
|
|
|
|
|
|
|
$html = '<div>';
|
2018-08-05 17:54:20 +02:00
|
|
|
$html .= '<label>'.$L->get('Toolbar top').'</label>';
|
2018-08-02 22:33:53 +02:00
|
|
|
$html .= '<input name="toolbar1" id="jstoolbar1" type="text" value="'.$this->getValue('toolbar1').'">';
|
2018-07-30 23:43:12 +02:00
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
$html .= '<div>';
|
2018-08-05 17:54:20 +02:00
|
|
|
$html .= '<label>'.$L->get('Toolbar bottom').'</label>';
|
2018-08-02 22:33:53 +02:00
|
|
|
$html .= '<input name="toolbar2" id="jstoolbar2" type="text" value="'.$this->getValue('toolbar2').'">';
|
2018-07-30 23:43:12 +02:00
|
|
|
$html .= '</div>';
|
|
|
|
|
2018-08-19 17:45:49 +02:00
|
|
|
$html .= '<div>';
|
|
|
|
$html .= '<label>'.$L->get('Mobile toolbar').'</label>';
|
|
|
|
$html .= '<input name="mobileToolbar" id="jsmobileToolbar" type="text" value="'.$this->getValue('mobileToolbar').'">';
|
|
|
|
$html .= '</div>';
|
|
|
|
|
2018-07-30 23:43:12 +02:00
|
|
|
$html .= '<div>';
|
2018-08-05 17:54:20 +02:00
|
|
|
$html .= '<label>'.$L->get('Plugins').'</label>';
|
2018-08-02 22:33:53 +02:00
|
|
|
$html .= '<input name="plugins" id="jsplugins" type="text" value="'.$this->getValue('plugins').'">';
|
2018-07-30 23:43:12 +02:00
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
2017-08-03 23:28:32 +02:00
|
|
|
public function adminHead()
|
|
|
|
{
|
2018-07-07 12:04:34 +02:00
|
|
|
if (!in_array($GLOBALS['ADMIN_CONTROLLER'], $this->loadOnController)) {
|
|
|
|
return false;
|
2017-08-03 23:28:32 +02:00
|
|
|
}
|
2018-07-07 12:04:34 +02:00
|
|
|
|
|
|
|
return '<script src="'.$this->htmlPath().'tinymce/tinymce.min.js"></script>';
|
2017-08-03 23:28:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function adminBodyEnd()
|
|
|
|
{
|
2018-08-19 17:45:49 +02:00
|
|
|
global $L;
|
|
|
|
|
2018-07-07 12:04:34 +02:00
|
|
|
if (!in_array($GLOBALS['ADMIN_CONTROLLER'], $this->loadOnController)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-08-19 17:45:49 +02:00
|
|
|
// Detect if the user is browsing in a mobile
|
|
|
|
if ($this->isMobile()) {
|
|
|
|
$toolbar1 = $this->getValue('mobileToolbar');
|
|
|
|
$toolbar2 = '';
|
|
|
|
$min_height = '320';
|
2018-10-01 21:11:09 +02:00
|
|
|
$content_css = $this->htmlPath().'css/bludit.css';
|
2018-08-19 17:45:49 +02:00
|
|
|
} else {
|
|
|
|
$toolbar1 = $this->getValue('toolbar1');
|
|
|
|
$toolbar2 = $this->getValue('toolbar2');
|
|
|
|
$min_height = '500';
|
2018-10-01 21:11:09 +02:00
|
|
|
$content_css = $this->htmlPath().'css/bludit.css';
|
2018-08-19 17:45:49 +02:00
|
|
|
}
|
2017-08-03 23:28:32 +02:00
|
|
|
|
2018-08-02 22:33:53 +02:00
|
|
|
$plugins = $this->getValue('plugins');
|
2018-07-30 23:43:12 +02:00
|
|
|
|
|
|
|
$lang = 'en';
|
2018-08-05 17:54:20 +02:00
|
|
|
if (file_exists($this->phpPath().'tinymce'.DS.'langs'.DS.$L->currentLanguage().'.js')) {
|
|
|
|
$lang = $L->currentLanguage();
|
|
|
|
} elseif (file_exists($this->phpPath().'tinymce'.DS.'langs'.DS.$L->currentLanguageShortVersion().'.js')) {
|
|
|
|
$lang = $L->currentLanguageShortVersion();
|
2018-07-30 23:43:12 +02:00
|
|
|
}
|
|
|
|
|
2018-10-07 15:54:28 +02:00
|
|
|
if (IMAGE_RELATIVE_TO_ABSOLUTE) {
|
|
|
|
$document_base_url = 'document_base_url: "'.DOMAIN_UPLOADS.'",';
|
|
|
|
} else {
|
|
|
|
$document_base_url = '';
|
|
|
|
}
|
|
|
|
|
2018-07-07 12:04:34 +02:00
|
|
|
$script = <<<EOF
|
|
|
|
<script>
|
|
|
|
|
|
|
|
// Function required for Media Manager
|
|
|
|
// Insert an image on the editor in the cursor position
|
|
|
|
function editorInsertMedia(filename) {
|
|
|
|
tinymce.activeEditor.insertContent("<img src=\""+filename+"\" alt=\"\">");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Function required for Autosave function
|
|
|
|
// Returns the content of the editor
|
|
|
|
function editorGetContent() {
|
|
|
|
return tinymce.get('jseditor').getContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#jseditor").show();
|
|
|
|
|
|
|
|
tinymce.init({
|
|
|
|
selector: "#jseditor",
|
|
|
|
theme: "modern",
|
|
|
|
skin: "bludit",
|
2018-08-19 17:45:49 +02:00
|
|
|
min_height: $min_height,
|
2018-09-19 19:01:56 +02:00
|
|
|
autoresize_min_height: $min_height,
|
|
|
|
autoresize_bottom_margin: 10,
|
2018-07-07 12:04:34 +02:00
|
|
|
max_height: 1000,
|
|
|
|
element_format : "html",
|
|
|
|
entity_encoding : "raw",
|
|
|
|
schema: "html5",
|
|
|
|
statusbar: false,
|
|
|
|
menubar:false,
|
|
|
|
remove_script_host: false,
|
|
|
|
branding: false,
|
|
|
|
browser_spellcheck: true,
|
|
|
|
pagebreak_separator: PAGE_BREAK,
|
|
|
|
paste_as_text: true,
|
|
|
|
relative_urls: true,
|
|
|
|
remove_script_host: false,
|
2018-10-07 15:54:28 +02:00
|
|
|
$document_base_url
|
2018-07-30 23:43:12 +02:00
|
|
|
plugins: ["$plugins"],
|
|
|
|
toolbar1: "$toolbar1",
|
|
|
|
toolbar2: "$toolbar2",
|
2018-10-01 21:11:09 +02:00
|
|
|
language: "$lang",
|
|
|
|
content_css : "$content_css"
|
2018-07-07 12:04:34 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
|
|
EOF;
|
|
|
|
return $script;
|
2017-08-03 23:28:32 +02:00
|
|
|
}
|
2018-08-19 17:45:49 +02:00
|
|
|
|
|
|
|
private function isMobile() {
|
|
|
|
return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
|
|
|
|
}
|
2017-08-03 23:28:32 +02:00
|
|
|
}
|