Skip to content

Commit 5015998

Browse files
committed
Merge branch 'master' into moodle_500_create_section_method_mdl-80187
2 parents e3afb04 + 27a155a commit 5015998

2 files changed

Lines changed: 9 additions & 45 deletions

File tree

classes/output/renderer.php

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,31 +87,24 @@ public function __construct(\moodle_page $page, string $target) {
8787
public function render(\renderable $widget) {
8888
global $CFG;
8989
$fullpath = str_replace('\\', '/', get_class($widget));
90-
$classparts = explode('/', $fullpath);
91-
// Strip namespaces.
92-
$classname = array_pop($classparts);
93-
// Remove _renderable suffixes.
94-
$classname = preg_replace('/_renderable$/', '', $classname);
95-
96-
$rendermethod = 'render_' . $classname;
97-
if (method_exists($this, $rendermethod)) {
98-
return $this->$rendermethod($widget);
99-
}
90+
10091
// Check for special course format templatables.
10192
if ($widget instanceof \templatable) {
102-
// Templatables from both core_courseformat\output\xxx_format\* and format_xxx\output\xxx_format\*
103-
// use core_crouseformat/local/xxx_format templates by default.
93+
// Templatables from both core_courseformat\output\local\* and format_xxx\output\courseformat\*
94+
// use format_multitopic/courseformat templates, if they exist.
10495
$corepath = 'core_courseformat\/output\/local';
105-
$pluginpath = 'format_.+\/output\/courseformat';
106-
$specialrenderers = '/^(?<componentpath>' /*. $corepath . '|'*/ . $pluginpath . ')\/(?<template>.+)$/'; // CHANGED.
96+
$pluginpath = 'format_\w+\/output\/courseformat';
97+
$specialrenderers = '/^(?<componentpath>' . $corepath . '|' . $pluginpath . ')\/(?<template>.+)$/';
10798
$matches = null;
10899

109-
if (preg_match($specialrenderers, $fullpath, $matches)) {
100+
if (preg_match($specialrenderers, $fullpath, $matches)
101+
&& file_exists($CFG->dirroot . '/course/format/multitopic/templates/courseformat/' . $matches['template'])) {
110102
$data = $widget->export_for_template($this);
111103
return $this->render_from_template('format_multitopic/courseformat/' . $matches['template'], $data); // CHANGED.
112104
}
113105
}
114-
// If nothing works, let the parent class decide.
106+
107+
// If it doesn't work, let the parent class decide.
115108
return parent::render($widget);
116109
}
117110

templates/courseformat/content/section/controlmenu.mustache

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)