From 897e4a3f4a273d50c28157edb67612b2d7fa2e6f Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 27 Dec 2024 12:03:59 +0100 Subject: Search in all feeds (#7144) * Search in all feeds Search in PRIORITY_ARCHIVED with `&get=A` fix https://github.com/FreshRSS/FreshRSS/discussions/7143 * Fix type * Search in PRIORITY_ARCHIVED with `&get=Z` * More * Fixes * One more fix * Extra features in user queries * Move i18n key * Fix overview * Enlarge query boxes * Revert i18n spelling * i18n: it Thanks @UserRoot-Luca Co-authored-by: UserRoot-Luca <55756898+UserRoot-Luca@users.noreply.github.com> --------- Co-authored-by: UserRoot-Luca <55756898+UserRoot-Luca@users.noreply.github.com> --- app/Models/Context.php | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'app/Models/Context.php') diff --git a/app/Models/Context.php b/app/Models/Context.php index eeb16f414..6cdda909c 100644 --- a/app/Models/Context.php +++ b/app/Models/Context.php @@ -20,7 +20,7 @@ final class FreshRSS_Context { public static int $total_unread = 0; public static int $total_important_unread = 0; - /** @var array{'all':int,'read':int,'unread':int} */ + /** @var array{all:int,read:int,unread:int} */ public static array $total_starred = [ 'all' => 0, 'read' => 0, @@ -29,15 +29,17 @@ final class FreshRSS_Context { public static int $get_unread = 0; - /** @var array{'all':bool,'starred':bool,'important':bool,'feed':int|false,'category':int|false,'tag':int|false,'tags':bool} */ + /** @var array{all:bool,A:bool,starred:bool,important:bool,feed:int|false,category:int|false,tag:int|false,tags:bool,Z:bool} */ public static array $current_get = [ 'all' => false, + 'A' => false, 'starred' => false, 'important' => false, 'feed' => false, 'category' => false, 'tag' => false, 'tags' => false, + 'Z' => false, ]; public static string $next_get = 'a'; @@ -271,12 +273,14 @@ final class FreshRSS_Context { * Return the current get as a string or an array. * * If $array is true, the first item of the returned value is 'f' or 'c' or 't' and the second is the id. - * @phpstan-return ($asArray is true ? array{'a'|'c'|'f'|'i'|'s'|'t'|'T',bool|int} : string) + * @phpstan-return ($asArray is true ? array{'a'|'A'|'c'|'f'|'i'|'s'|'t'|'T'|'Z',bool|int} : string) * @return string|array{string,bool|int} */ public static function currentGet(bool $asArray = false): string|array { if (self::$current_get['all']) { return $asArray ? ['a', true] : 'a'; + } elseif (self::$current_get['A']) { + return $asArray ? ['A', true] : 'A'; } elseif (self::$current_get['important']) { return $asArray ? ['i', true] : 'i'; } elseif (self::$current_get['starred']) { @@ -301,6 +305,8 @@ final class FreshRSS_Context { } } elseif (self::$current_get['tags']) { return $asArray ? ['T', true] : 'T'; + } elseif (self::$current_get['Z']) { + return $asArray ? ['Z', true] : 'Z'; } return ''; } @@ -312,6 +318,14 @@ final class FreshRSS_Context { return self::$current_get['all'] != false; } + public static function isAllAndCategories(): bool { + return self::$current_get['A'] != false; + } + + public static function isAllAndArchived(): bool { + return self::$current_get['Z'] != false; + } + /** * @return bool true if the current request targets important feeds, false otherwise. */ @@ -349,12 +363,14 @@ final class FreshRSS_Context { return match ($type) { 'a' => self::$current_get['all'], + 'A' => self::$current_get['A'], 'i' => self::$current_get['important'], 's' => self::$current_get['starred'], 'f' => self::$current_get['feed'] == $id, 'c' => self::$current_get['category'] == $id, 't' => self::$current_get['tag'] == $id, 'T' => self::$current_get['tags'] || self::$current_get['tag'], + 'Z' => self::$current_get['Z'], default => false, }; } @@ -386,13 +402,23 @@ final class FreshRSS_Context { } switch ($type) { - case 'a': + case 'a': // All PRIORITY_MAIN_STREAM self::$current_get['all'] = true; + self::$description = FreshRSS_Context::systemConf()->meta_description; + self::$get_unread = self::$total_unread; + break; + case 'A': // All except PRIORITY_ARCHIVED + self::$current_get['A'] = true; + self::$description = FreshRSS_Context::systemConf()->meta_description; + self::$get_unread = self::$total_unread; + break; + case 'Z': // All including PRIORITY_ARCHIVED + self::$current_get['Z'] = true; self::$name = _t('index.feed.title'); self::$description = FreshRSS_Context::systemConf()->meta_description; self::$get_unread = self::$total_unread; break; - case 'i': + case 'i': // Priority important feeds self::$current_get['important'] = true; self::$name = _t('index.menu.important'); self::$description = FreshRSS_Context::systemConf()->meta_description; -- cgit v1.2.3