From 917a92cf34849c1db9e3c0d733bfec2877984111 Mon Sep 17 00:00:00 2001 From: SharkyKZ Date: Fri, 2 Oct 2020 20:27:46 +0300 Subject: [PATCH] [4.0] Fall back to system template when template file not found (#30857) * Fall back to system template * Load parent language file only when needed * Correct template file --- libraries/src/Document/HtmlDocument.php | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/libraries/src/Document/HtmlDocument.php b/libraries/src/Document/HtmlDocument.php index 1cc28b52d6c5c..3e5bf5f538222 100644 --- a/libraries/src/Document/HtmlDocument.php +++ b/libraries/src/Document/HtmlDocument.php @@ -827,22 +827,22 @@ protected function _fetchTemplate($params = array()) $inherits = $params['templateInherits'] ?? ''; $baseDir = $directory . '/' . $template; - if (!empty($inherits) - && !is_file($directory . '/' . $template . '/' . $file) - && is_file($directory . '/' . $inherits . '/' . $file) - ) + if (!is_file($directory . '/' . $template . '/' . $file)) { - $baseDir = $directory . '/' . $inherits; - } - - if (!is_file($baseDir . '/' . $file)) - { - $template = 'system'; - } + if ($inherits !== '' && is_file($directory . '/' . $inherits . '/' . $file)) + { + $baseDir = $directory . '/' . $inherits; + } + else + { + $baseDir = $directory . '/system'; + $template = 'system'; - if (!is_file($baseDir . '/' . $file)) - { - $file = 'index.php'; + if ($file !== 'index.php' && !is_file($baseDir . '/' . $file)) + { + $file = 'index.php'; + } + } } // Load the language file for the template @@ -850,7 +850,7 @@ protected function _fetchTemplate($params = array()) // 1.5 or core then 1.6 $lang->load('tpl_' . $template, JPATH_BASE) - || $lang->load('tpl_' . $inherits, $directory . '/' . $inherits) + || ($inherits !== '' && $lang->load('tpl_' . $inherits, $directory . '/' . $inherits)) || $lang->load('tpl_' . $template, $directory . '/' . $template); // Assign the variables