diff --git a/lib/classes/output/icon_system.php b/lib/classes/output/icon_system.php index 9615e9d63f3..e8b1211e02c 100644 --- a/lib/classes/output/icon_system.php +++ b/lib/classes/output/icon_system.php @@ -109,7 +109,7 @@ abstract class icon_system { if ($this->map === null) { $this->map = $this->get_icon_name_map(); } - if ($component == null) { + if ($component == null || $component == 'moodle') { $component = 'core'; } else if ($component != 'theme') { $component = \core_component::normalize_componentname($component); diff --git a/lib/classes/output/mustache_pix_helper.php b/lib/classes/output/mustache_pix_helper.php index 3b0d261a96a..cc07f33c23d 100644 --- a/lib/classes/output/mustache_pix_helper.php +++ b/lib/classes/output/mustache_pix_helper.php @@ -63,11 +63,13 @@ class mustache_pix_helper { // Split the text into an array of variables. $key = strtok($text, ","); $key = trim($key); + $key = $helper->render($key); $component = strtok(","); $component = trim($component); if (!$component) { $component = ''; } + $component = $helper->render($component); $text = strtok(""); // Allow mustache tags in the last argument. $text = $helper->render($text); diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php index 2ef36e4d3e1..6f93fa52fb9 100644 --- a/lib/outputcomponents.php +++ b/lib/outputcomponents.php @@ -626,11 +626,6 @@ class pix_icon implements renderable, templatable { */ var $attributes = array(); - /** - * @var bool True if this is a font-awesome icon. - */ - protected $fontawesome; - /** * Constructor * @@ -703,6 +698,24 @@ class pix_icon implements renderable, templatable { return $data; } + + /** + * Much simpler version of export that will produce the data required to render this pix with the + * pix helper in a mustache tag. + * + * @return array + */ + public function export_for_pix() { + $title = isset($this->attributes['title']) ? $this->attributes['title'] : ''; + if (empty($title)) { + $title = isset($this->attributes['alt']) ? $this->attributes['alt'] : ''; + } + return [ + 'key' => $this->pix, + 'component' => $this->component, + 'title' => $title + ]; + } } /** @@ -1509,7 +1522,7 @@ class action_link implements renderable { $data->text = $this->text instanceof renderable ? $output->render($this->text) : (string) $this->text; $data->url = $this->url ? $this->url->out(false) : ''; - $data->icon = $this->icon ? $this->icon->export_for_template($output) : null; + $data->icon = $this->icon ? $this->icon->export_for_pix() : null; $data->classes = isset($attributes['class']) ? $attributes['class'] : ''; unset($attributes['class']); @@ -4295,7 +4308,7 @@ class action_menu implements renderable, templatable { } if ($actionicon instanceof pix_icon) { - $primary->icon = $actionicon->export_for_template($output); + $primary->icon = $actionicon->export_for_pix(); $primary->title = !empty($actionicon->attributes['alt']) ? $this->actionicon->attributes['alt'] : ''; } else { $primary->iconraw = $actionicon ? $output->render($actionicon) : ''; @@ -4451,7 +4464,7 @@ class action_menu_link extends action_link implements renderable { unset($icon->attributes['title']); } } - $data->icon = $icon ? $icon->export_for_template($output) : null; + $data->icon = $icon ? $icon->export_for_pix() : null; } $data->disabled = !empty($attributes['disabled']); diff --git a/lib/templates/action_link.mustache b/lib/templates/action_link.mustache index 11617bc1761..0616c6345cb 100644 --- a/lib/templates/action_link.mustache +++ b/lib/templates/action_link.mustache @@ -52,11 +52,11 @@ } }} {{^disabled}} - {{#icon}}{{>core/pix_icon}}{{/icon}}{{{text}}} + {{#icon}}{{#pix}}{{key}}, {{component}}, {{title}}{{/pix}}{{/icon}}{{{text}}} {{#hasactions}} {{> core/actions }} {{/hasactions}} {{/disabled}} {{#disabled}} - {{#icon}}{{>core/pix_icon}}{{/icon}}{{{text}}} + {{#icon}}{{#pix}}{{key}}, {{component}}, {{title}}{{/pix}}{{/icon}}{{{text}}} {{/disabled}} diff --git a/lib/templates/action_menu_item.mustache b/lib/templates/action_menu_item.mustache index bbbf864c791..a2d00daf8ef 100644 --- a/lib/templates/action_menu_item.mustache +++ b/lib/templates/action_menu_item.mustache @@ -27,5 +27,5 @@ {{#actionmenulink}}{{> core/action_menu_link }}{{/actionmenulink}} {{#actionmenufiller}} {{/actionmenufiller}} {{#actionlink}}{{> core/action_link }}{{/actionlink}} -{{#pixicon}}{{> core/pix_icon }}{{/pixicon}} -{{#rawhtml}}{{{.}}}{{/rawhtml}} \ No newline at end of file +{{#pixicon}}{{#pix}}{{key}}, {{component}}, {{title}}{{/pix}}{{/pixicon}} +{{#rawhtml}}{{{.}}}{{/rawhtml}} diff --git a/lib/templates/action_menu_link.mustache b/lib/templates/action_menu_link.mustache index d8d34627e54..ade499f89a2 100644 --- a/lib/templates/action_menu_link.mustache +++ b/lib/templates/action_menu_link.mustache @@ -29,8 +29,8 @@ } }} {{^disabled}} - {{#icon}}{{>core/pix_icon}}{{/icon}}{{#showtext}} + {{/showtext}}{{#icon}}{{#pix}}{{key}}, {{component}}, {{title}}{{/pix}}{{/icon}}{{#showtext}} {{/disabled}} {{#disabled}} - {{/showtext}}{{#icon}}{{>core/pix_icon}}{{/icon}}{{{text}}} + {{#icon}}{{#pix}}{{key}}, {{component}}, {{title}}{{/pix}}{{/icon}}{{{text}}} {{/disabled}} diff --git a/lib/templates/action_menu_trigger.mustache b/lib/templates/action_menu_trigger.mustache index 20683739e26..93285103816 100644 --- a/lib/templates/action_menu_trigger.mustache +++ b/lib/templates/action_menu_trigger.mustache @@ -26,4 +26,4 @@ "menutrigger": true } }} -{{{actiontext}}}{{{menutrigger}}}{{#icon}}{{> core/pix_icon}}{{/icon}}{{#rawicon}}{{{.}}}{{/rawicon}}{{#menutrigger}}{{/menutrigger}} \ No newline at end of file +{{{actiontext}}}{{{menutrigger}}}{{#icon}}{{#pix}}{{key}}, {{component}}, {{title}}{{/pix}}{{/icon}}{{#rawicon}}{{{.}}}{{/rawicon}}{{#menutrigger}}{{/menutrigger}} diff --git a/theme/boost/classes/output/core_renderer.php b/theme/boost/classes/output/core_renderer.php index ada3c09f3fb..4e5835ef78d 100644 --- a/theme/boost/classes/output/core_renderer.php +++ b/theme/boost/classes/output/core_renderer.php @@ -406,20 +406,6 @@ class core_renderer extends \core_renderer { } $context = $menu->export_for_template($this); - // We do not want the icon with the caret, the caret is added by Bootstrap. - if (empty($context->primary->menutrigger)) { - $newurl = $this->pix_url('t/edit', 'moodle'); - $context->primary->icon['attributes'] = array_reduce($context->primary->icon['attributes'], - function($carry, $item) use ($newurl) { - if ($item['name'] === 'src') { - $item['value'] = $newurl->out(false); - } - $carry[] = $item; - return $carry; - }, [] - ); - } - return $this->render_from_template('core/action_menu', $context); } diff --git a/theme/boost/templates/core/action_menu_item.mustache b/theme/boost/templates/core/action_menu_item.mustache index bbbf864c791..a2d00daf8ef 100644 --- a/theme/boost/templates/core/action_menu_item.mustache +++ b/theme/boost/templates/core/action_menu_item.mustache @@ -27,5 +27,5 @@ {{#actionmenulink}}{{> core/action_menu_link }}{{/actionmenulink}} {{#actionmenufiller}} {{/actionmenufiller}} {{#actionlink}}{{> core/action_link }}{{/actionlink}} -{{#pixicon}}{{> core/pix_icon }}{{/pixicon}} -{{#rawhtml}}{{{.}}}{{/rawhtml}} \ No newline at end of file +{{#pixicon}}{{#pix}}{{key}}, {{component}}, {{title}}{{/pix}}{{/pixicon}} +{{#rawhtml}}{{{.}}}{{/rawhtml}} diff --git a/theme/boost/templates/core/action_menu_link.mustache b/theme/boost/templates/core/action_menu_link.mustache index 34108f77f88..4a96ccdad6a 100644 --- a/theme/boost/templates/core/action_menu_link.mustache +++ b/theme/boost/templates/core/action_menu_link.mustache @@ -27,8 +27,8 @@ } }} {{^disabled}} - {{#icon}}{{>core/pix_icon}}{{/icon}}{{#showtext}} + {{/showtext}}{{#icon}}{{#pix}}{{key}}, {{component}}, {{title}}{{/pix}}{{/icon}}{{#showtext}} {{/disabled}} {{#disabled}} - {{/showtext}}{{#icon}}{{>core/pix_icon}}{{/icon}}{{{text}}} + {{#icon}}{{#pix}}{{key}},{{component}},{{title}}{{/pix}}{{/icon}}{{{text}}} {{/disabled}} diff --git a/theme/boost/templates/core/action_menu_trigger.mustache b/theme/boost/templates/core/action_menu_trigger.mustache index f785cb51252..e6de51a6e0a 100644 --- a/theme/boost/templates/core/action_menu_trigger.mustache +++ b/theme/boost/templates/core/action_menu_trigger.mustache @@ -17,12 +17,12 @@ {{! Action menu trigger. }} -