mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-50346 core: Allow sub-directories in template names
This commit is contained in:
parent
414eca8923
commit
0261d1effa
15 changed files with 209 additions and 64 deletions
|
@ -51,7 +51,7 @@ class external extends external_api {
|
|||
public static function load_template_parameters() {
|
||||
return new external_function_parameters(
|
||||
array('component' => new external_value(PARAM_COMPONENT, 'component containing the template'),
|
||||
'template' => new external_value(PARAM_ALPHANUMEXT, 'name of the template'),
|
||||
'template' => new external_value(PARAM_SAFEPATH, 'name of the template'),
|
||||
'themename' => new external_value(PARAM_ALPHANUMEXT, 'The current theme.'),
|
||||
'includecomments' => new external_value(PARAM_BOOL, 'Include comments or not', VALUE_DEFAULT, false)
|
||||
)
|
||||
|
@ -102,7 +102,7 @@ class external extends external_api {
|
|||
public static function load_template_with_dependencies_parameters() {
|
||||
return new external_function_parameters([
|
||||
'component' => new external_value(PARAM_COMPONENT, 'component containing the template'),
|
||||
'template' => new external_value(PARAM_ALPHANUMEXT, 'name of the template'),
|
||||
'template' => new external_value(PARAM_SAFEPATH, 'name of the template'),
|
||||
'themename' => new external_value(PARAM_ALPHANUMEXT, 'The current theme.'),
|
||||
'includecomments' => new external_value(PARAM_BOOL, 'Include comments or not', VALUE_DEFAULT, false),
|
||||
'lang' => new external_value(PARAM_LANG, 'lang', VALUE_DEFAULT, null),
|
||||
|
|
|
@ -107,11 +107,9 @@ class mustache_template_finder {
|
|||
throw new coding_exception('Templates names must be specified as "componentname/templatename"' .
|
||||
' (' . s($name) . ' requested) ');
|
||||
}
|
||||
|
||||
list($component, $templatename) = explode('/', $name, 2);
|
||||
$component = clean_param($component, PARAM_COMPONENT);
|
||||
if (strpos($templatename, '/') !== false) {
|
||||
throw new coding_exception('Templates cannot be placed in sub directories (' . s($name) . ' requested)');
|
||||
}
|
||||
|
||||
$dirs = self::get_template_directories_for_component($component, $themename);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue