mirror of
https://github.com/e107inc/e107.git
synced 2025-08-03 05:07:27 +02:00
Fixes #825 = TinyMce config now allows for json markup. Example html template added.
This commit is contained in:
16
e107_plugins/tinymce4/snippets/bootstrap_table.htm
Normal file
16
e107_plugins/tinymce4/snippets/bootstrap_table.htm
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<!-- This will not be inserted -->
|
||||||
|
<div class="mceTmpl">
|
||||||
|
<table class="table table-striped table-bordered">
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Heading 1</th>
|
||||||
|
<th scope="col">Heading 2</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Example 1 </td>
|
||||||
|
<td>Example 2 </td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Example 3</td>
|
||||||
|
<td>Example 4</td>
|
||||||
|
</tr>
|
||||||
|
</table></div>
|
@@ -3,8 +3,21 @@
|
|||||||
<plugins>advlist autolink lists link image charmap print preview hr anchor pagebreak searchreplace wordcount visualblocks visualchars code fullscreen
|
<plugins>advlist autolink lists link image charmap print preview hr anchor pagebreak searchreplace wordcount visualblocks visualchars code fullscreen
|
||||||
insertdatetime media nonbreaking save table contextmenu directionality emoticons template paste textcolor</plugins>
|
insertdatetime media nonbreaking save table contextmenu directionality emoticons template paste textcolor</plugins>
|
||||||
<menubar>edit view format insert table tools</menubar>
|
<menubar>edit view format insert table tools</menubar>
|
||||||
<toolbar1>undo redo | styleselect | bold italic forecolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | e107-image e107-video e107-glyph | preview</toolbar1>
|
<toolbar1>undo redo | styleselect | bold italic forecolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image template | e107-image e107-video e107-glyph | preview</toolbar1>
|
||||||
<external_plugins>e107 example</external_plugins>
|
<external_plugins>e107 example</external_plugins>
|
||||||
<image_advtab>true</image_advtab>
|
<image_advtab>true</image_advtab>
|
||||||
<extended_valid_elements>i[*], object[*],embed[*],bbcode[*]</extended_valid_elements>
|
<extended_valid_elements>i[*], object[*],embed[*],bbcode[*]</extended_valid_elements>
|
||||||
|
<templates>[
|
||||||
|
{
|
||||||
|
title: "Bootstrap table",
|
||||||
|
url: "{e_PLUGIN}tinymce4/snippets/bootstrap_table.htm",
|
||||||
|
description: "Adds a Bootstrap 3 table"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Example",
|
||||||
|
content: "Example Content",
|
||||||
|
description: "Adds an example."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
</templates>
|
||||||
</tinymce>
|
</tinymce>
|
||||||
|
@@ -10,6 +10,66 @@
|
|||||||
$_E107['no_online'] = true;
|
$_E107['no_online'] = true;
|
||||||
require_once("../../class2.php");
|
require_once("../../class2.php");
|
||||||
|
|
||||||
|
/*
|
||||||
|
echo '
|
||||||
|
|
||||||
|
|
||||||
|
tinymce.init({
|
||||||
|
"selector": ".e-wysiwyg",
|
||||||
|
"theme": "modern",
|
||||||
|
"plugins": "advlist autolink lists link image charmap print preview hr anchor pagebreak searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking save table contextmenu directionality emoticons template paste textcolor",
|
||||||
|
"language": "en",
|
||||||
|
"menubar": "edit view format insert table tools",
|
||||||
|
"toolbar1": "undo redo | styleselect | bold italic forecolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | e107-image e107-video e107-glyph | preview",
|
||||||
|
"external_plugins": {"e107":"/e107_plugins/tinymce4/plugins/e107/plugin.js","example":"/e107_plugins/tinymce4/plugins/example/plugin.js"},
|
||||||
|
"image_advtab": true,
|
||||||
|
"extended_valid_elements": "i[*], object[*],embed[*],bbcode[*]",
|
||||||
|
"convert_fonts_to_spans": false,
|
||||||
|
"content_css": "http://netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css",
|
||||||
|
"relative_urls": false,
|
||||||
|
"preformatted": true,
|
||||||
|
// "document_base_url": "http://eternal.technology/"
|
||||||
|
});
|
||||||
|
';
|
||||||
|
exit;
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
echo 'tinymce.init({
|
||||||
|
selector: ".e-wysiwyg",
|
||||||
|
theme: "modern",
|
||||||
|
plugins: "template",
|
||||||
|
toolbar: "template",
|
||||||
|
// template_cdate_classes: "cdate creationdate",
|
||||||
|
// template_mdate_classes: "mdate modifieddate",
|
||||||
|
// template_selected_content_classes: "selcontent",
|
||||||
|
// template_cdate_format: "%m/%d/%Y : %H:%M:%S",
|
||||||
|
// template_mdate_format: "%m/%d/%Y : %H:%M:%S",
|
||||||
|
// template_replace_values: {
|
||||||
|
// username : "Jack Black",
|
||||||
|
// staffid : "991234"
|
||||||
|
// },
|
||||||
|
templates : [
|
||||||
|
{
|
||||||
|
title: "Editor Details",
|
||||||
|
url: "editor_details.htm",
|
||||||
|
description: "Adds Editor Name and Staff ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Timestamp",
|
||||||
|
content: "Some Content goes here. ",
|
||||||
|
description: "Adds an editing timestamp."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});';
|
||||||
|
*/
|
||||||
|
|
||||||
|
// exit;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$text = <<<TMPL
|
$text = <<<TMPL
|
||||||
|
|
||||||
@@ -55,6 +115,7 @@ $gen = $wy->renderConfig();
|
|||||||
|
|
||||||
if(ADMIN && e_QUERY == 'debug')
|
if(ADMIN && e_QUERY == 'debug')
|
||||||
{
|
{
|
||||||
|
define('e_IFRAME', true);
|
||||||
require_once(HEADERF);
|
require_once(HEADERF);
|
||||||
|
|
||||||
echo "<table class='table'><tr><td>";
|
echo "<table class='table'><tr><td>";
|
||||||
@@ -98,9 +159,9 @@ class wysiwyg
|
|||||||
{
|
{
|
||||||
$this->getConfig($config);
|
$this->getConfig($config);
|
||||||
$text .= "\n /* TinyMce Config: ".$this->configName." */\n\n";
|
$text .= "\n /* TinyMce Config: ".$this->configName." */\n\n";
|
||||||
$text .= "tinymce.init(";
|
$text .= "tinymce.init({\n";
|
||||||
$text .= json_encode($this->config); // Moc: temporary fix for BC with PHP 5.3: https://github.com/e107inc/e107/issues/614
|
$text .= $this->config; // Moc: temporary fix for BC with PHP 5.3: https://github.com/e107inc/e107/issues/614
|
||||||
$text .= ");";
|
$text .= "\n});";
|
||||||
|
|
||||||
return stripslashes($text);
|
return stripslashes($text);
|
||||||
}
|
}
|
||||||
@@ -165,28 +226,38 @@ class wysiwyg
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $ext;
|
return json_encode($ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function convertBoolean($string)
|
function convertBoolean($string)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(is_string($string))
|
||||||
|
{
|
||||||
|
$string = trim($string);
|
||||||
$string = str_replace("\n","",$string);
|
$string = str_replace("\n","",$string);
|
||||||
|
|
||||||
if($string === 'true')
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($string === 'false')
|
if($string === true)
|
||||||
{
|
{
|
||||||
return false;
|
return 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($string === false)
|
||||||
|
{
|
||||||
|
return 'false';
|
||||||
|
}
|
||||||
|
|
||||||
|
if($string === 'true' || $string === 'false' || $string[0] == '[')
|
||||||
|
{
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return '"'.$string.'"';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function getConfig($config=FALSE)
|
function getConfig($config=FALSE)
|
||||||
@@ -220,7 +291,7 @@ class wysiwyg
|
|||||||
|
|
||||||
unset($config['@attributes']);
|
unset($config['@attributes']);
|
||||||
|
|
||||||
$this->config = array(
|
$ret = array(
|
||||||
'selector' => '.e-wysiwyg',
|
'selector' => '.e-wysiwyg',
|
||||||
'theme' => 'modern',
|
'theme' => 'modern',
|
||||||
'plugins' => $this->filter_plugins($config['tinymce_plugins']),
|
'plugins' => $this->filter_plugins($config['tinymce_plugins']),
|
||||||
@@ -231,24 +302,36 @@ class wysiwyg
|
|||||||
|
|
||||||
// Loop thru XML parms.
|
// Loop thru XML parms.
|
||||||
foreach($config as $k=>$xml)
|
foreach($config as $k=>$xml)
|
||||||
|
{
|
||||||
|
$ret[$k] = $xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ret['convert_fonts_to_spans'] = false;
|
||||||
|
$ret['content_css'] = e_PLUGIN_ABS.'tinymce4/editor.css,https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css,http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css';
|
||||||
|
|
||||||
|
$ret['relative_urls'] = false; //Media Manager prefers it like this.
|
||||||
|
$ret['preformatted'] = true;
|
||||||
|
$ret['document_base_url'] = SITEURL;
|
||||||
|
|
||||||
|
if(!empty($ret['templates']))
|
||||||
|
{
|
||||||
|
$ret['templates'] = $tp->replaceConstants($ret['templates'],'abs'); // $this->getTemplates();
|
||||||
|
}
|
||||||
|
// $this->config['verify_css_classes'] = 'false';
|
||||||
|
|
||||||
|
$text = array();
|
||||||
|
foreach($ret as $k=>$v)
|
||||||
{
|
{
|
||||||
if($k == 'external_plugins')
|
if($k == 'external_plugins')
|
||||||
{
|
{
|
||||||
$this->config['external_plugins'] = $this->getExternalPlugins($xml);
|
$text[] = 'external_plugins: '. $this->getExternalPlugins($v);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
$text[] = $k.': '.$this->convertBoolean($v);
|
||||||
$this->config[$k] = $this->convertBoolean($xml);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->config['convert_fonts_to_spans'] = false;
|
|
||||||
$this->config['content_css'] = 'http://netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css';
|
|
||||||
|
|
||||||
$this->config['relative_urls'] = false; //Media Manager prefers it like this.
|
$this->config = implode(",\n",$text);
|
||||||
$this->config['preformatted'] = true;
|
|
||||||
$this->config['document_base_url'] = SITEURL;
|
|
||||||
|
|
||||||
// $this->config['verify_css_classes'] = 'false';
|
|
||||||
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -389,6 +472,16 @@ class wysiwyg
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getTemplates()
|
||||||
|
{
|
||||||
|
$templatePath = (is_readable(THEME."templates/tinymce/".$template)) ? THEME."templates/tinymce/".$template : e_PLUGIN."tinymce4/templates/".$template;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function filter_plugins($plugs)
|
function filter_plugins($plugs)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user