From 4369677af2b2c25f4e8e60b88f91f38510725c09 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Thu, 18 Jan 2018 15:15:11 +0800 Subject: [PATCH] MDL-60646 user_portfolio: Fix action icons in Show / hide column * Refactor the code to make it look cleaner and easier to read. * Fixed incorrect alt-text for the configure icon. * Fixed missing alt-text for show/hide icon. --- user/portfolio.php | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/user/portfolio.php b/user/portfolio.php index 788bffc35ab..4cd41825a42 100644 --- a/user/portfolio.php +++ b/user/portfolio.php @@ -113,14 +113,24 @@ if ($display) { $table->data = array(); foreach ($instances as $i) { + // Contents of the actions (Show / hide) column. + $actions = ''; + + // Configure icon. + if ($i->has_user_config()) { + $configurl = new moodle_url($baseurl); + $configurl->param('config', $i->get('id')); + $actions .= html_writer::link($configurl, $OUTPUT->pix_icon('t/edit', get_string('configure', 'portfolio'))); + } + + // Hide/show icon. $visible = $i->get_user_config('visible', $USER->id); - $table->data[] = array($i->get('name'), $i->get('plugin'), - ($i->has_user_config() - ? '' . - $OUTPUT->pix_icon('t/edit', get_string('configure')) . '' : '') . - ' ' . - $OUTPUT->pix_icon('t/' . (($visible) ? 'hide' : 'show')), get_string($visible ? 'hide' : 'show') . '
' - ); + $visibilityaction = $visible ? 'hide' : 'show'; + $showhideurl = new moodle_url($baseurl); + $showhideurl->param('hide', $i->get('id')); + $actions .= html_writer::link($showhideurl, $OUTPUT->pix_icon('t/' . $visibilityaction, get_string($visibilityaction))); + + $table->data[] = array($i->get('name'), $i->get('plugin'), $actions); } echo html_writer::table($table); -- 2.11.4.GIT