2020-07-27 09:35:34 +00:00
|
|
|
<?php
|
2020-08-04 11:25:22 +00:00
|
|
|
|
2020-07-27 09:35:34 +00:00
|
|
|
/**
|
|
|
|
* @copyright 2020 Podlibre
|
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the inline svg icon
|
|
|
|
*
|
|
|
|
* @param string $name name of the icon file without the .svg extension
|
|
|
|
* @param string $class to be added to the svg string
|
|
|
|
* @return string svg contents
|
|
|
|
*/
|
2020-10-02 15:38:16 +00:00
|
|
|
function icon(string $name, string $class = '')
|
2020-07-27 09:35:34 +00:00
|
|
|
{
|
|
|
|
$svg_contents = file_get_contents('assets/icons/' . $name . '.svg');
|
2020-10-02 15:38:16 +00:00
|
|
|
if ($class !== '') {
|
2020-07-27 09:35:34 +00:00
|
|
|
$svg_contents = str_replace(
|
|
|
|
'<svg',
|
|
|
|
'<svg class="' . $class . '"',
|
2021-04-02 17:20:02 +00:00
|
|
|
$svg_contents,
|
2020-07-27 09:35:34 +00:00
|
|
|
);
|
|
|
|
}
|
2020-10-02 15:38:16 +00:00
|
|
|
|
2020-07-27 09:35:34 +00:00
|
|
|
return $svg_contents;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the inline svg image
|
|
|
|
*
|
|
|
|
* @param string $name name of the image file without the .svg extension
|
|
|
|
* @param string $class to be added to the svg string
|
|
|
|
* @return string svg contents
|
|
|
|
*/
|
|
|
|
function svg($name, $class = null)
|
|
|
|
{
|
|
|
|
$svg_contents = file_get_contents('assets/images/' . $name . '.svg');
|
|
|
|
if ($class) {
|
|
|
|
$svg_contents = str_replace(
|
|
|
|
'<svg',
|
|
|
|
'<svg class="' . $class . '"',
|
2021-04-02 17:20:02 +00:00
|
|
|
$svg_contents,
|
2020-08-27 10:05:44 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return $svg_contents;
|
|
|
|
}
|