1
0
mirror of https://github.com/e107inc/e107.git synced 2025-06-21 00:17:14 +02:00

Auto-read new TinyMce snippet files.

This commit is contained in:
Cameron
2016-03-08 19:59:36 -08:00
parent cf90582418
commit 00f8dcdb16
3 changed files with 50 additions and 4 deletions

View File

@ -0,0 +1,8 @@
<!--
Title: Bootstrap Row 2 Column - 4:8
Info: Adds a Bootstrap 3 table at cursor
-->
<div class="mceTmpl">
<div class='col-md-4'>col-md-4</div>
<div class='col-md-8'>col-md-8</div>
</div>

View File

@ -1,4 +1,7 @@
<!-- This will not be inserted -->
<!--
Title: Bootstrap table
Info: Adds a Bootstrap 3 table at cursor
-->
<div class="mceTmpl">
<table class="table table-striped table-bordered">
<tr>

View File

@ -600,12 +600,15 @@ class wysiwyg
$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['content_css'] = e_PLUGIN_ABS.'tinymce4/editor.css,https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css,http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css';
// $ret['content_css'] = e_WEB_ABS."js/bootstrap/css/bootstrap.min.css";
$ret['relative_urls'] = false; //Media Manager prefers it like this.
$ret['preformatted'] = true;
$ret['document_base_url'] = SITEURL;
$ret['schema'] = "html5";
$ret['element_format'] = "html";
// $ret['table_default_attributes'] = json_encode(array('class'=>'table table-striped' ));
@ -614,6 +617,16 @@ class wysiwyg
{
$ret['templates'] = $tp->replaceConstants($ret['templates'],'abs'); // $this->getTemplates();
}
if(ADMIN)
{
$ret['templates'] = $this->getSnippets();
}
// $this->config['verify_css_classes'] = 'false';
$text = array();
@ -780,6 +793,28 @@ class wysiwyg
}
private function getSnippets()
{
$files = e107::getFile()->get_files(e_PLUGIN."tinymce4/snippets");
$ret = array();
foreach($files as $f)
{
$content = file_get_contents($f['path'].$f['fname'], null, null, null, 140);
preg_match('/<!--[^\w]*Title:[\s]([^\r\n]*)[\s]*Info: ?([^\r\n]*)/is', $content, $m);
if(!empty($m[1]))
{
$url = e_PLUGIN_ABS."tinymce4/snippets/".$f['fname'];
$ret[] = array('title'=>trim($m[1]), 'url'=>$url, 'description'=>trim($m[2]));
}
}
return json_encode($ret);
}
function filter_plugins($plugs)
{