Skip to content

Commit

Permalink
MDL-55597 tool_templatelibrary: Re-inforce logic to skip theme templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Frédéric Massart committed Oct 7, 2016
1 parent 049d208 commit 490afb5
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions admin/tool/templatelibrary/classes/api.php
Expand Up @@ -117,17 +117,21 @@ public static function load_canonical_template($component, $template) {
// Get the list of possible template directories.
$dirs = mustache_template_finder::get_template_directories_for_component($component);
$filename = false;
$themedir = core_component::get_plugin_types()['theme'];

foreach ($dirs as $dir) {
// Skip theme dirs - we only want the original plugin/core template.
if (strpos($dir, "/theme/") === false) {
$candidate = $dir . $template . '.mustache';
if (file_exists($candidate)) {
$filename = $candidate;
break;
}
if (strpos($dir, $themedir) === 0) {
continue;
}

$candidate = $dir . $template . '.mustache';
if (file_exists($candidate)) {
$filename = $candidate;
break;
}
}

if ($filename === false) {
throw new moodle_exception('filenotfound', 'error');
}
Expand Down

0 comments on commit 490afb5

Please sign in to comment.