Skip to content

Commit

Permalink
Merge branch 'MDL-70476' of https://github.com/timhunt/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Jan 6, 2021
2 parents fd1d9fe + fbc010a commit c59c8e7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
5 changes: 5 additions & 0 deletions lib/classes/output/mustache_pix_helper.php
Expand Up @@ -72,6 +72,11 @@ public function pix($text, Mustache_LambdaHelper $helper) {
$text = strtok("");
// Allow mustache tags in the last argument.
$text = trim($helper->render($text));
// The $text has come from a template, so HTML special
// chars have been escaped. However, render_pix_icon
// assumes the alt arrives with no escaping. So we need
// ot un-escape here.
$text = htmlspecialchars_decode($text);

return trim($this->renderer->pix_icon($key, $text, $component));
}
Expand Down
23 changes: 14 additions & 9 deletions lib/templates/permissionmanager_role.mustache
Expand Up @@ -30,24 +30,29 @@
* rolename Name of the role rendered - must have been prepared for output with format_string,
or more likely one of the role API functions like role_fix_names.
* roleid Id of the role
* action WEhich action is done on click
* action Which action is done on click
* spanclass class attribute of span
* linkclass class attribute of link
* adminurl moodle admin url
* imageurl moodle url for delete(x) image
* icon moodle icon for delete(x)
* iconalt alt text for the icon. Must have been HTML escaped.
Example context (json):
{"rolename" : "Manager",
"roleid" : 1,
"action": "prevent",
"spanclass": "allowed",
"linkclass": "preventlink",
"adminurl" : "http://localhost/moodle/admin/"}
{
"rolename": "Manager",
"roleid": 1,
"action": "prevent",
"spanclass": "allowed",
"linkclass": "preventlink",
"adminurl": "http://localhost/moodle/admin/",
"icon": "t/delete",
"iconalt": "Delete Student role"
}
}}
<span style="display:inline-block;" class="{{spanclass}}">&nbsp;{{{rolename}}}&nbsp;
<a href="{{adminurl}}roles/permissions.php" class="{{linkclass}}" data-role-id="{{roleid}}" data-action="{{action}}">
{{#icon}}
{{#pix}}{{icon}}, core, {{iconalt}}{{/pix}}
{{#pix}}{{icon}}, core, {{{iconalt}}}{{/pix}}
{{/icon}}
</a>
</span>

0 comments on commit c59c8e7

Please sign in to comment.