Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions administrator/language/en-GB/plg_editors_tinymce.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ PLG_TINY_FIELD_CSS_LABEL="Template CSS Classes"
PLG_TINY_FIELD_CUSTOM_CSS_DESC="Optional CSS file that will override the standard editor.css file. Enter a file name to point to a file in the CSS folder of the default template (for example, templates/cassiopeia/css/). Or enter a full URL path to the custom CSS file. If you enter a value in this field, this file will be used instead of the editor.css file."
PLG_TINY_FIELD_CUSTOM_CSS_LABEL="Custom CSS Classes"
PLG_TINY_FIELD_CUSTOM_PATH_LABEL="Images Directory"
PLG_TINY_FIELD_CUSTOM_CONTENT_TEMPLATE_PATH_DESC="The directory that TinyMCE will look in for any custom templates or snippets."
PLG_TINY_FIELD_CUSTOM_CONTENT_TEMPLATE_PATH_LABEL="Content Template Directory"
PLG_TINY_FIELD_CUSTOMBUTTON_LABEL="Custom Button"
PLG_TINY_FIELD_CUSTOMPLUGIN_LABEL="Custom Plugin"
PLG_TINY_FIELD_DIRECTION_LABEL="Text Direction"
Expand Down
13 changes: 13 additions & 0 deletions plugins/editors/tinymce/forms/setoptions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@
showon="drag_drop:1"
/>

<field
name="content_template_path"
type="folderlist"
label="PLG_TINY_FIELD_CUSTOM_CONTENT_TEMPLATE_PATH_LABEL"
description="PLG_TINY_FIELD_CUSTOM_CONTENT_TEMPLATE_PATH_DESC"
directory="/templates"
hide_default="true"
recursive="true"
exclude="system"
default=""
folderFilter="^html"
/>

<field
name="entity_encoding"
type="list"
Expand Down
69 changes: 52 additions & 17 deletions plugins/editors/tinymce/tinymce.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,31 +470,66 @@ public function onDisplay(

if (!empty($allButtons['template']))
{
foreach (glob(JPATH_ROOT . '/media/vendor/tinymce/templates/*.html') as $filename)
// Do we have a custom content_template_path
if (!empty($levelParams->get('content_template_path')))
{
$filename = basename($filename, '.html');

if ($filename !== 'index')
$content_template = '/templates/' . $levelParams->get('content_template_path') . '/';
foreach (glob(JPATH_ROOT . $content_template . '*.txt') as $filename)
{
$lang = Factory::getLanguage();
$title = $filename;
$description = ' ';
$filename = basename($filename, '.txt');

if ($lang->hasKey('PLG_TINY_TEMPLATE_' . strtoupper($filename) . '_TITLE'))
if ($filename !== 'index')
{
$title = Text::_('PLG_TINY_TEMPLATE_' . strtoupper($filename) . '_TITLE');
$lang = Factory::getLanguage();
$title = $filename;
$description = ' ';

if ($lang->hasKey('PLG_TINY_TEMPLATE_' . strtoupper($filename) . '_TITLE'))
{
$title = Text::_('PLG_TINY_TEMPLATE_' . strtoupper($filename) . '_TITLE');
}

if ($lang->hasKey('PLG_TINY_TEMPLATE_' . strtoupper($filename) . '_DESC'))
{
$description = Text::_('PLG_TINY_TEMPLATE_' . strtoupper($filename) . '_DESC');
}

$templates[] = array(
'title' => $title,
'description' => $description,
'url' => Uri::root(true) . $content_template . $filename . '.txt',
);
}
}
}
else
{
foreach (glob(JPATH_ROOT . '/media/vendor/tinymce/templates/*.html') as $filename)
{
$filename = basename($filename, '.html');

if ($lang->hasKey('PLG_TINY_TEMPLATE_' . strtoupper($filename) . '_DESC'))
if ($filename !== 'index')
{
$description = Text::_('PLG_TINY_TEMPLATE_' . strtoupper($filename) . '_DESC');
$lang = Factory::getLanguage();
$title = $filename;
$description = ' ';

if ($lang->hasKey('PLG_TINY_TEMPLATE_' . strtoupper($filename) . '_TITLE'))
{
$title = Text::_('PLG_TINY_TEMPLATE_' . strtoupper($filename) . '_TITLE');
}

if ($lang->hasKey('PLG_TINY_TEMPLATE_' . strtoupper($filename) . '_DESC'))
{
$description = Text::_('PLG_TINY_TEMPLATE_' . strtoupper($filename) . '_DESC');
}

$templates[] = array(
'title' => $title,
'description' => $description,
'url' => Uri::root(true) . '/media/vendor/tinymce/templates/' . $filename . '.html',
);
}

$templates[] = array(
'title' => $title,
'description' => $description,
'url' => Uri::root(true) . '/media/vendor/tinymce/templates/' . $filename . '.html',
);
}
}
}
Expand Down