From 0114db359b81ca16bdeffc52d9c7565b7a494149 Mon Sep 17 00:00:00 2001 From: djarrancotleanu Date: Thu, 30 Jan 2025 10:50:43 +1000 Subject: [PATCH] Issue #358: Use pix_icon to render icons --- classes/output/manage/base_table.php | 36 ++++------------------------ views/warningbar/warningbar.php | 21 +++++++--------- 2 files changed, 14 insertions(+), 43 deletions(-) diff --git a/classes/output/manage/base_table.php b/classes/output/manage/base_table.php index c64eef0..3f2fd31 100644 --- a/classes/output/manage/base_table.php +++ b/classes/output/manage/base_table.php @@ -77,12 +77,7 @@ protected function create_data_buttons(outage $outage, $editdelete) { // View button. $buttons .= html_writer::link( new moodle_url('/auth/outage/info.php', ['id' => $outage->id]), - html_writer::empty_tag('img', [ - 'src' => $OUTPUT->image_url('t/preview'), - 'alt' => get_string('view'), - 'class' => 'iconsmall', - 'style' => 'width: 1.5rem; height: 1.5rem;', - ]), + $OUTPUT->pix_icon('t/preview', get_string('view'), 'moodle', array('class' => 'iconsmall')), [ 'title' => get_string('view'), 'target' => '_blank', @@ -93,12 +88,7 @@ protected function create_data_buttons(outage $outage, $editdelete) { if ($editdelete) { $buttons .= html_writer::link( new moodle_url('/auth/outage/edit.php', ['edit' => $outage->id]), - html_writer::empty_tag('img', [ - 'src' => $OUTPUT->image_url('t/edit'), - 'alt' => get_string('edit'), - 'class' => 'iconsmall', - 'style' => 'width: 1.5rem; height: 1.5rem;', - ]), + $OUTPUT->pix_icon('t/edit', get_string('edit'), 'moodle', array('class' => 'iconsmall')), ['title' => get_string('edit')] ); } @@ -106,13 +96,7 @@ protected function create_data_buttons(outage $outage, $editdelete) { // Clone button. $buttons .= html_writer::link( new moodle_url('/auth/outage/edit.php', ['clone' => $outage->id]), - html_writer::empty_tag('img', [ - 'src' => $OUTPUT->image_url('t/copy'), - 'alt' => get_string('clone', 'auth_outage'), - 'class' => 'iconsmall', - 'style' => 'width: 1.5rem; height: 1.5rem;', - - ]), + $OUTPUT->pix_icon('t/copy', get_string('clone', 'auth_outage'), 'moodle', array('class' => 'iconsmall')), ['title' => get_string('clone', 'auth_outage')] ); @@ -120,12 +104,7 @@ protected function create_data_buttons(outage $outage, $editdelete) { if ($outage->is_ongoing()) { $buttons .= html_writer::link( new moodle_url('/auth/outage/finish.php', ['id' => $outage->id]), - html_writer::empty_tag('img', [ - 'src' => $OUTPUT->image_url('t/check'), - 'alt' => get_string('finish', 'auth_outage'), - 'class' => 'iconsmall', - 'style' => 'width: 1.5rem; height: 1.5rem;', - ]), + $OUTPUT->pix_icon('t/check', get_string('finish', 'auth_outage'), 'moodle', array('class' => 'iconsmall')), ['title' => get_string('finish', 'auth_outage')] ); } @@ -134,12 +113,7 @@ protected function create_data_buttons(outage $outage, $editdelete) { if ($editdelete) { $buttons .= html_writer::link( new moodle_url('/auth/outage/delete.php', ['id' => $outage->id]), - html_writer::empty_tag('img', [ - 'src' => $OUTPUT->image_url('t/delete'), - 'alt' => get_string('delete'), - 'class' => 'iconsmall', - 'style' => 'width: 1.5rem; height: 1.5rem;', - ]), + $OUTPUT->pix_icon('t/delete', get_string('delete'), 'moodle', array('class' => 'iconsmall')), ['title' => get_string('delete')] ); } diff --git a/views/warningbar/warningbar.php b/views/warningbar/warningbar.php index 382fd8f..43047a6 100644 --- a/views/warningbar/warningbar.php +++ b/views/warningbar/warningbar.php @@ -47,18 +47,15 @@ ['target' => '_blank', 'class' => 'auth_outage_warningbar_box_title'] ); if (is_siteadmin()) { - $url = new moodle_url('/auth/outage/finish.php', ['id' => $viewbag['outage']->id]); - $text = html_writer::empty_tag('img', [ - 'src' => $OUTPUT->image_url('t/check'), - 'alt' => get_string('finish', 'auth_outage'), - 'class' => 'iconsmall', - 'style' => 'width: 1rem; height: 1rem;', - ]).' '.get_string('finish', 'auth_outage'); - $attr = [ - 'title' => get_string('finish', 'auth_outage'), - 'class' => 'auth_outage_warningbar_box_finish', - ]; - $title .= ' '.html_writer::span(html_writer::link($url, $text, $attr), '', ['id' => 'auth_outage_warningbar_button']); + $link = html_writer::link( + new moodle_url('/auth/outage/finish.php', ['id' => $viewbag['outage']->id]), + $OUTPUT->pix_icon('t/check', get_string('finish', 'auth_outage'), 'moodle', array('class' => 'iconsmall')) . get_string('finish', 'auth_outage'), + [ + 'title' => get_string('finish', 'auth_outage'), + 'class' => 'auth_outage_warningbar_box_finish', + ] + ); + $title .= ' '.html_writer::span($link, '', ['id' => 'auth_outage_warningbar_button']); } } ?>