Skip to content
Merged
6 changes: 1 addition & 5 deletions administrator/modules/mod_login/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,7 @@ class="btn btn-secondary btn-block mt-4 <?php echo $button['class'] ?? '' ?>"
<?php if (!empty($button['icon'])): ?>
<span class="<?php echo $button['icon'] ?>"></span>
<?php elseif (!empty($button['image'])): ?>
<?php echo HTMLHelper::_('image', $button['image'], Text::_($button['tooltip'] ?? ''), [
'class' => 'icon',
], true) ?>
<?php elseif (!empty($button['svg'])): ?>
<?php echo $button['svg']; ?>
<?php echo $button['image']; ?>
<?php endif; ?>
<?php echo Text::_($button['label']) ?>
</button>
Expand Down
2 changes: 1 addition & 1 deletion build/media_source/plg_system_webauthn/images/webauthn.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 0 additions & 38 deletions libraries/src/HTML/Helpers/Icons.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,42 +90,4 @@ public static function button($button)

return $layout->render($button);
}

/**
* Writes an inline '<svg>' element
*
* @param string $file The relative or absolute PATH to use for the src attribute.
* @param boolean $relative Flag if the path to the file is relative to the /media folder (and searches in template).
*
* @return string|null
*
* @since 4.0
*/
public static function svg(string $file, bool $relative = true): ?string
{
// Check extension for .svg
$extension = strtolower(substr($file, -4));

if ($extension !== '.svg')
{
return null;
}

// Get path to icon
$file = HTMLHelper::_('image', $file, '', '', $relative, true);

// Make sure path is local to Joomla
$file = Path::check(JPATH_ROOT . '/' . substr($file, \strlen(Uri::root(true))));

// If you can't find the icon or if it's unsafe then skip it
if (!$file)
{
return null;
}

// Get contents to display inline
$file = file_get_contents($file);

return $file;
}
}
1 change: 0 additions & 1 deletion libraries/src/Helper/AuthenticationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ public static function getLoginButtons(string $formId): array
'tooltip' => '',
'icon' => '',
'image' => '',
'svg' => '',
'class' => '',
'id' => '',
'onclick' => '',
Expand Down
6 changes: 1 addition & 5 deletions modules/mod_login/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,7 @@ class="btn btn-secondary btn-block mt-4 <?php echo $button['class'] ?? '' ?>"
<?php if (!empty($button['icon'])): ?>
<span class="<?php echo $button['icon'] ?>"></span>
<?php elseif (!empty($button['image'])): ?>
<?php echo HTMLHelper::_('image', $button['image'], Text::_($button['tooltip'] ?? ''), [
'class' => 'icon',
], true) ?>
<?php elseif (!empty($button['svg'])): ?>
<?php echo $button['svg']; ?>
<?php echo $button['image']; ?>
<?php endif; ?>
<?php echo Text::_($button['label']) ?>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,23 @@ public function onUserLoginButtons(string $form): array
// Set up the JavaScript callback
$url = $uri->toString();

// Get local path to image
$image = HTMLHelper::_('image', 'plg_system_webauthn/webauthn.svg', '', '', true, true);

// If you can't find the image then skip it
$image = $image ? JPATH_ROOT . substr($image, strlen(Uri::root(true))) : '';

// Extract image if it exists
$image = file_exists($image) ? file_get_contents($image) : '';

return [
[
'label' => 'PLG_SYSTEM_WEBAUTHN_LOGIN_LABEL',
'tooltip' => 'PLG_SYSTEM_WEBAUTHN_LOGIN_DESC',
'id' => $randomId,
'data-webauthn-form' => $form,
'data-webauthn-url' => $url,
'svg' => HTMLHelper::_('icons.svg', 'plg_system_webauthn/webauthn.svg', true),
'image' => $image,
'class' => 'plg_system_webauthn_login_button',
],
];
Expand Down