Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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: 1 addition & 1 deletion libraries/src/Application/AdministratorApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public function getTemplate($params = false)
$db = Factory::getDbo();

$query = $db->getQuery(true)
->select($db->quoteName(['s.template', 's.params', 's.inheritable', 's.parent']))
->select($db->quoteName(['s.template', 's.client_id', 's.params', 's.inheritable', 's.parent']))
->from($db->quoteName('#__template_styles', 's'))
->join(
'LEFT',
Expand Down
1 change: 1 addition & 0 deletions libraries/src/Application/ApiApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ public function getTemplate($params = false)
$template->params = new Registry;
$template->inheritable = 0;
$template->parent = '';
$template->client_id = 0;

return $template;
}
Expand Down
1 change: 1 addition & 0 deletions libraries/src/Application/CMSApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ public function getTemplate($params = false)
$template->params = new Registry;
$template->inheritable = 0;
$template->parent = '';
$template->client_id = 0;

return $template;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Application/SiteApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ public function getTemplate($params = false)
$db = Factory::getDbo();

$query = $db->getQuery(true)
->select($db->quoteName(['id', 'home', 'template', 's.params', 'inheritable', 'parent']))
->select($db->quoteName(['id', 'home', 'template', 's.client_id', 's.params', 'inheritable', 'parent']))
->from($db->quoteName('#__template_styles', 's'))
->where(
[
Expand Down
22 changes: 14 additions & 8 deletions libraries/src/HTML/HTMLHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,14 @@ public static function iframe($url, $name, $attribs = null, $noFrames = '')
* @param boolean $relative Flag if the path to the file is relative to the /media folder (and searches in template).
* @param boolean $detectBrowser Flag if the browser should be detected to include specific browser files.
* @param boolean $detectDebug Flag if debug mode is enabled to include uncompressed files if debug is on.
* @param object $template The template object.
*
* @return array files to be included.
*
* @see Browser
* @since 1.6
*/
protected static function includeRelativeFiles($folder, $file, $relative, $detectBrowser, $detectDebug)
protected static function includeRelativeFiles($folder, $file, $relative, $detectBrowser, $detectDebug, $template)
{
// Set debug flag
$debugMode = false;
Expand Down Expand Up @@ -412,13 +413,16 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec
// If relative search in template directory or media directory
if ($relative)
{
$app = Factory::getApplication();
$template = $app->getTemplate(true);
$templaPath = JPATH_THEMES;
if (!(array) $template)
{
$template = Factory::getApplication()->getTemplate(true);
}

$templaPath = isset($template->realPath) ? $template->realPath : JPATH_THEMES;

if ($template->inheritable || !empty($template->parent))
{
$client = $app->isClient('administrator') === true ? 'administrator' : 'site';
$client = $template->client_id === 1 ? 'administrator' : 'site';
$templaPath = JPATH_ROOT . "/media/templates/$client";
}

Expand Down Expand Up @@ -730,7 +734,7 @@ public static function image($file, $alt, $attribs = null, $relative = false, $r

if ($returnPath !== -1)
{
$includes = static::includeRelativeFiles('images', $file, $relative, false, false);
$includes = static::includeRelativeFiles('images', $file, $relative, false, false, new \stdClass);
$file = \count($includes) ? $includes[0] : null;
}

Expand Down Expand Up @@ -761,8 +765,9 @@ public static function stylesheet($file, $options = array(), $attribs = array())
$options['pathOnly'] = $options['pathOnly'] ?? false;
$options['detectBrowser'] = $options['detectBrowser'] ?? false;
$options['detectDebug'] = $options['detectDebug'] ?? true;
$options['template'] = $options['template'] ?? new \stdClass;

$includes = static::includeRelativeFiles('css', $file, $options['relative'], $options['detectBrowser'], $options['detectDebug']);
$includes = static::includeRelativeFiles('css', $file, $options['relative'], $options['detectBrowser'], $options['detectDebug'], $options['template']);

// If only path is required
if ($options['pathOnly'])
Expand Down Expand Up @@ -813,8 +818,9 @@ public static function script($file, $options = array(), $attribs = array())
$options['pathOnly'] = $options['pathOnly'] ?? false;
$options['detectBrowser'] = $options['detectBrowser'] ?? false;
$options['detectDebug'] = $options['detectDebug'] ?? true;
$options['template'] = $options['template'] ?? new \stdClass;

$includes = static::includeRelativeFiles('js', $file, $options['relative'], $options['detectBrowser'], $options['detectDebug']);
$includes = static::includeRelativeFiles('js', $file, $options['relative'], $options['detectBrowser'], $options['detectDebug'], $options['template']);

// If only path is required
if ($options['pathOnly'])
Expand Down
38 changes: 7 additions & 31 deletions plugins/editors/tinymce/tinymce.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,9 @@ public function onDisplay(
/*
* Lets get the default template for the site application
*/
$db = Factory::getDbo();
$db = Factory::getContainer()->get('db');
$query = $db->getQuery(true)
->select($db->quoteName('template'))
->select('*')
->from($db->quoteName('#__template_styles'))
->where(
[
Expand All @@ -281,7 +281,8 @@ public function onDisplay(

try
{
$template = $db->loadResult();
$template = $db->loadObject();
$template->realPath = JPATH_ROOT . '/templates';
}
catch (RuntimeException $e)
{
Expand All @@ -290,8 +291,7 @@ public function onDisplay(
return '';
}

$content_css = null;
$templates_path = JPATH_SITE . '/templates';
$content_css = null;

// Loading of css file for 'styles' dropdown
if ($content_css_custom)
Expand All @@ -305,39 +305,15 @@ public function onDisplay(
// If it is not a URL, assume it is a file name in the current template folder
else
{
$content_css = Uri::root(true) . '/templates/' . $template . '/css/' . $content_css_custom;

// Issue warning notice if the file is not found (but pass name to $content_css anyway to avoid TinyMCE error
if (!file_exists($templates_path . '/' . $template . '/css/' . $content_css_custom))
{
$msg = sprintf(Text::_('PLG_TINY_ERR_CUSTOMCSSFILENOTPRESENT'), $content_css_custom);
Log::add($msg, Log::WARNING, 'jerror');
}
$content_css = HTMLHelper::stylesheet($content_css_custom, ['pathOnly' => true, 'relative' => true, 'template' => $template]);
}
}
else
{
// Process when use_content_css is Yes and no custom file given
if ($use_content_css)
{
// First check templates folder for default template
// if no editor.css file in templates folder, check system template folder
if (!file_exists($templates_path . '/' . $template . '/css/editor.css'))
{
// If no editor.css file in system folder, show alert
if (!file_exists($templates_path . '/system/css/editor.css'))
{
Log::add(Text::_('PLG_TINY_ERR_EDITORCSSFILENOTPRESENT'), Log::WARNING, 'jerror');
}
else
{
$content_css = Uri::root(true) . '/templates/system/css/editor.css';
}
}
else
{
$content_css = Uri::root(true) . '/templates/' . $template . '/css/editor.css';
}
$content_css = HTMLHelper::stylesheet('editor.css', ['pathOnly' => true, 'relative' => true, 'template' => $template]);
}
}

Expand Down