From 509c8cae6381ec46af7c8303eb92fda6ce496a4a Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 4 Jul 2022 09:53:26 +0200 Subject: Dynamic OPML (#4407) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- app/Models/Themes.php | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) (limited to 'app/Models/Themes.php') 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 '' . $alt . ''; + 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 '' . $alt . ''; + switch ($type) { + case self::ICON_URL: + return Minz_Url::display($url); + case self::ICON_IMG: + return '' . $alt . ''; + case self::ICON_EMOJI: + default: + return '' . $alt . ''; + } } } -- cgit v1.2.3