2015-07-29 04:30:41 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class pluginTrumbowyg extends Plugin {
|
|
|
|
|
|
|
|
private $loadWhenController = array(
|
|
|
|
'new-post',
|
|
|
|
'new-page',
|
|
|
|
'edit-post',
|
|
|
|
'edit-page'
|
|
|
|
);
|
|
|
|
|
|
|
|
public function onAdminHead()
|
|
|
|
{
|
|
|
|
global $Language;
|
|
|
|
global $Site;
|
|
|
|
global $layout;
|
|
|
|
|
|
|
|
$html = '';
|
|
|
|
|
2015-08-01 18:28:47 +02:00
|
|
|
// Load CSS and JS only on Controllers in array.
|
2015-07-29 04:30:41 +02:00
|
|
|
if(in_array($layout['controller'], $this->loadWhenController))
|
|
|
|
{
|
|
|
|
$language = $Site->shortLanguage();
|
|
|
|
|
|
|
|
$html = '<script src="'.HTML_PATH_PLUGINS.'trumbowyg/trumbowyg/trumbowyg.min.js"></script>';
|
|
|
|
$html .= '<script src="'.HTML_PATH_PLUGINS.'trumbowyg/trumbowyg/langs/'.$language.'.min.js"></script>';
|
|
|
|
$html .= '<link rel="stylesheet" href="'.HTML_PATH_PLUGINS.'trumbowyg/trumbowyg/ui/trumbowyg.min.css">';
|
|
|
|
|
|
|
|
// CSS fix for Bludit
|
2015-08-01 18:28:47 +02:00
|
|
|
$html .= '<style>';
|
|
|
|
$html .= '.trumbowyg-box {width: 80%; margin: 0;}';
|
|
|
|
$html .= '.trumbowyg-fullscreen {width: 100% !important;}';
|
|
|
|
$html .= '</style>';
|
2015-07-29 04:30:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function onAdminBodyEnd()
|
|
|
|
{
|
|
|
|
global $Language;
|
|
|
|
global $Site;
|
|
|
|
global $layout;
|
|
|
|
|
|
|
|
$html = '';
|
|
|
|
|
2015-08-01 18:28:47 +02:00
|
|
|
// Load CSS and JS only on Controllers in array.
|
2015-07-29 04:30:41 +02:00
|
|
|
if(in_array($layout['controller'], $this->loadWhenController))
|
|
|
|
{
|
|
|
|
$language = $Site->shortLanguage();
|
|
|
|
|
|
|
|
$html = '<script>$(document).ready(function() { ';
|
|
|
|
$html .= '$("#jscontent").trumbowyg({lang: "'.$language.'", resetCss: true, removeformatPasted: true, autogrow: true});';
|
|
|
|
$html .= '}); </script>';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
}
|