diff options
Diffstat (limited to 'app/Models/Themes.php')
| -rw-r--r-- | app/Models/Themes.php | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/app/Models/Themes.php b/app/Models/Themes.php index ceaa49266..a59f4b663 100644 --- a/app/Models/Themes.php +++ b/app/Models/Themes.php @@ -68,6 +68,13 @@ class FreshRSS_Themes extends Minz_Model { return $infos; } + public static function title($name) { + static $titles = [ + 'opml-dyn' => 'sub.category.dynamic_opml', + ]; + return $titles[$name] ?? ''; + } + public static function alt($name) { static $alts = array( 'add' => '➕', //✚ @@ -94,6 +101,7 @@ class FreshRSS_Themes extends Minz_Model { 'next' => '⏩', 'non-starred' => '☆', 'notice' => 'ℹ️', //ⓘ + 'opml-dyn' => '🗲', 'prev' => '⏪', 'read' => '☑️', //☑ 'rss' => '📣', //☄ @@ -115,7 +123,13 @@ class FreshRSS_Themes extends Minz_Model { return isset($name) ? $alts[$name] : ''; } - public static function icon($name, $urlOnly = false) { + // TODO: Change for enum in PHP 8.1+ + const ICON_DEFAULT = 0; + const ICON_IMG = 1; + const ICON_URL = 2; + const ICON_EMOJI = 3; + + public static function icon(string $name, int $type = self::ICON_DEFAULT): string { $alt = self::alt($name); if ($alt == '') { return ''; @@ -124,14 +138,29 @@ class FreshRSS_Themes extends Minz_Model { $url = $name . '.svg'; $url = isset(self::$themeIcons[$url]) ? (self::$themeIconsUrl . $url) : (self::$defaultIconsUrl . $url); - if ($urlOnly) { - return Minz_Url::display($url); + $title = self::title($name); + if ($title != '') { + $title = ' title="' . _t($title) . '"'; } - if (FreshRSS_Context::$user_conf && FreshRSS_Context::$user_conf->icons_as_emojis) { - return '<span class="icon">' . $alt . '</span>'; + if ($type == self::ICON_DEFAULT) { + if ((FreshRSS_Context::$user_conf && FreshRSS_Context::$user_conf->icons_as_emojis) || + // default to emoji alternate for some icons + in_array($name, [ 'opml-dyn' ])) { + $type = self::ICON_EMOJI; + } else { + $type = self::ICON_IMG; + } } - return '<img class="icon" src="' . Minz_Url::display($url) . '" loading="lazy" alt="' . $alt . '" />'; + switch ($type) { + case self::ICON_URL: + return Minz_Url::display($url); + case self::ICON_IMG: + return '<img class="icon" src="' . Minz_Url::display($url) . '" loading="lazy" alt="' . $alt . '"' . $title . ' />'; + case self::ICON_EMOJI: + default: + return '<span class="icon"' . $title . '>' . $alt . '</span>'; + } } } |
