1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 20:30:39 +02:00

Fixes #825 = TinyMce config now allows for json markup. Example html template added.

This commit is contained in:
Cameron
2015-01-29 19:48:31 -08:00
parent 868c586529
commit 968e9d8ee3
3 changed files with 149 additions and 27 deletions

View 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>

View File

@@ -3,8 +3,21 @@
<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>
<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>
<image_advtab>true</image_advtab>
<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>

View File

@@ -10,6 +10,66 @@
$_E107['no_online'] = true;
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
@@ -55,6 +115,7 @@ $gen = $wy->renderConfig();
if(ADMIN && e_QUERY == 'debug')
{
define('e_IFRAME', true);
require_once(HEADERF);
echo "<table class='table'><tr><td>";
@@ -98,9 +159,9 @@ class wysiwyg
{
$this->getConfig($config);
$text .= "\n /* TinyMce Config: ".$this->configName." */\n\n";
$text .= "tinymce.init(";
$text .= json_encode($this->config); // Moc: temporary fix for BC with PHP 5.3: https://github.com/e107inc/e107/issues/614
$text .= ");";
$text .= "tinymce.init({\n";
$text .= $this->config; // Moc: temporary fix for BC with PHP 5.3: https://github.com/e107inc/e107/issues/614
$text .= "\n});";
return stripslashes($text);
}
@@ -165,26 +226,36 @@ class wysiwyg
}
return $ext;
return json_encode($ext);
}
function convertBoolean($string)
{
$string = str_replace("\n","",$string);
if($string === 'true')
if(is_string($string))
{
return true;
$string = trim($string);
$string = str_replace("\n","",$string);
}
if($string === 'false')
if($string === true)
{
return false;
return 'true';
}
return $string;
if($string === false)
{
return 'false';
}
if($string === 'true' || $string === 'false' || $string[0] == '[')
{
return $string;
}
return '"'.$string.'"';
}
@@ -220,8 +291,8 @@ class wysiwyg
unset($config['@attributes']);
$this->config = array(
'selector' => '.e-wysiwyg',
$ret = array(
'selector' => '.e-wysiwyg',
'theme' => 'modern',
'plugins' => $this->filter_plugins($config['tinymce_plugins']),
'language' => $this->tinymce_lang()
@@ -232,24 +303,36 @@ class wysiwyg
// Loop thru XML parms.
foreach($config as $k=>$xml)
{
if($k == 'external_plugins')
{
$this->config['external_plugins'] = $this->getExternalPlugins($xml);
continue;
}
$this->config[$k] = $this->convertBoolean($xml);
$ret[$k] = $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';
$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';
$this->config['relative_urls'] = false; //Media Manager prefers it like this.
$this->config['preformatted'] = true;
$this->config['document_base_url'] = SITEURL;
$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')
{
$text[] = 'external_plugins: '. $this->getExternalPlugins($v);
continue;
}
$text[] = $k.': '.$this->convertBoolean($v);
}
$this->config = implode(",\n",$text);
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)
{