diff options
| author | 2022-07-04 09:53:26 +0200 | |
|---|---|---|
| committer | 2022-07-04 09:53:26 +0200 | |
| commit | 509c8cae6381ec46af7c8303eb92fda6ce496a4a (patch) | |
| tree | 653f7f44df842f9d7135decd89467879a0098c50 /app/Models/Themes.php | |
| parent | 57d571230eeb2d3ede57e640b640f17c7a2298a2 (diff) | |
Dynamic OPML (#4407)
* Dynamic OPML draft
#fix https://github.com/FreshRSS/FreshRSS/issues/4191
* Export dynamic OPML
http://opml.org/spec2.opml#1629043127000
* Restart with simpler approach
* Minor revert
* Export dynamic OPML also for single feeds
* Special category type for importing dynamic OPML
* Parameter for excludeMutedFeeds
* Details
* More draft
* i18n
* Fix update
* Draft manual import working
* Working manual refresh
* Draft automatic update
* Working Web refresh + fixes
* Import/export dynamic OPML settings
* Annoying numerous lines in SQL logs
* Fix minor JavaScript error
* Fix auto adding new columns
* Add require
* Add missing đ˛
* Missing space
* Disable adding new feeds to dynamic categories
* Link from import
* i18n typo
* Improve theme icon function
* Fix pink-dark
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>'; + } } } |
