MDL-86498 badges: Empty string for empty links

This commit is contained in:
Jun Pataleta
2025-09-09 18:16:46 +08:00
parent ebc1084cdc
commit f27faa1305
+32 -10
View File
@@ -187,10 +187,22 @@ class core_badges_renderer extends plugin_renderer_base {
$dl[get_string('createdon', 'search')] = userdate($badge->timecreated);
$dl[get_string('badgeimage', 'badges')] = print_badge_image($badge, $context, 'large');
$dl[get_string('imageauthorname', 'badges')] = $badge->imageauthorname;
$dl[get_string('imageauthoremail', 'badges')] =
html_writer::tag('a', $badge->imageauthoremail, array('href' => 'mailto:' . $badge->imageauthoremail));
$dl[get_string('imageauthorurl', 'badges')] =
html_writer::link($badge->imageauthorurl, $badge->imageauthorurl, array('target' => '_blank'));
$dl[get_string('imageauthoremail', 'badges')] = '';
if (trim($badge->imageauthoremail)) {
$dl[get_string('imageauthoremail', 'badges')] = html_writer::tag(
'a',
$badge->imageauthoremail,
['href' => 'mailto:' . $badge->imageauthoremail],
);
}
$dl[get_string('imageauthorurl', 'badges')] = '';
if (trim($badge->imageauthorurl)) {
$dl[get_string('imageauthorurl', 'badges')] = html_writer::link(
$badge->imageauthorurl,
$badge->imageauthorurl,
['target' => '_blank'],
);
}
$dl[get_string('imagecaption', 'badges')] = $badge->imagecaption;
$tags = \core_tag_tag::get_item_tags('core_badges', 'badge', $badge->id);
$dl[get_string('tags', 'badges')] = $this->output->tag_list($tags, '');
@@ -200,12 +212,22 @@ class core_badges_renderer extends plugin_renderer_base {
$display .= $this->heading(get_string('issuerdetails', 'badges'), 3);
$dl = array();
$dl[get_string('issuername', 'badges')] = $badge->issuername;
$dl[get_string('contact', 'badges')] = html_writer::tag('a', $badge->issuercontact, array('href' => 'mailto:' . $badge->issuercontact));
$dl[get_string('issuerurl', 'badges')] = html_writer::tag(
'a',
$badge->issuerurl,
['href' => $badge->issuerurl, 'target' => '_blank'],
);
$dl[get_string('contact', 'badges')] = '';
if (trim($badge->issuercontact)) {
$dl[get_string('contact', 'badges')] = html_writer::tag(
'a',
$badge->issuercontact,
['href' => 'mailto:' . $badge->issuercontact],
);
}
$dl[get_string('issuerurl', 'badges')] = '';
if (trim($badge->issuerurl)) {
$dl[get_string('issuerurl', 'badges')] = html_writer::tag(
'a',
$badge->issuerurl,
['href' => $badge->issuerurl, 'target' => '_blank'],
);
}
$display .= $this->definition_list($dl);
// Issuance details if any.