diff options
| author | 2025-10-14 15:43:43 +0200 | |
|---|---|---|
| committer | 2025-10-14 15:43:43 +0200 | |
| commit | b7bd18148e65bbdd6be442036a295eb43ca1501e (patch) | |
| tree | 4fba0694a3c45f015f2ed83ebd2356d169241f79 /app/Models | |
| parent | faaa770bc0b396d6e842fe816012661f07eac395 (diff) | |
Option to show user labels instead of tags in RSS share (#8112)
* Option to show user labels instead of tags in RSS share
fix https://github.com/FreshRSS/FreshRSS/discussions/8108#discussioncomment-14668813
<img width="711" height="182" alt="image" src="https://github.com/user-attachments/assets/8effb2cd-fffb-4f00-b628-54e963e8b2dc" />
Diffstat (limited to 'app/Models')
| -rw-r--r-- | app/Models/UserQuery.php | 20 | ||||
| -rw-r--r-- | app/Models/View.php | 3 |
2 files changed, 20 insertions, 3 deletions
diff --git a/app/Models/UserQuery.php b/app/Models/UserQuery.php index 077ae0b90..26264fa24 100644 --- a/app/Models/UserQuery.php +++ b/app/Models/UserQuery.php @@ -21,6 +21,7 @@ class FreshRSS_UserQuery { private string $token = ''; private bool $shareRss = false; private bool $shareOpml = false; + private bool $publishLabelsInsteadOfTags = false; /** @var array<int,FreshRSS_Category> $categories where the key is the category ID */ private array $categories; /** @var array<int,FreshRSS_Tag> $labels where the key is the label ID */ @@ -43,7 +44,7 @@ class FreshRSS_UserQuery { /** * @param array{get?:string,name?:string,order?:string,search?:string,state?:int,url?:string,token?:string, - * shareRss?:bool,shareOpml?:bool,description?:string,imageUrl?:string} $query + * shareRss?:bool,shareOpml?:bool,publishLabelsInsteadOfTags?:bool,description?:string,imageUrl?:string} $query * @param array<FreshRSS_Category> $categories * @param array<FreshRSS_Tag> $labels */ @@ -75,6 +76,7 @@ class FreshRSS_UserQuery { unset($link['name']); unset($link['shareOpml']); unset($link['shareRss']); + unset($link['publishLabelsInsteadOfTags']); $this->url = Minz_Url::display(['params' => $link]); } } else { @@ -92,6 +94,9 @@ class FreshRSS_UserQuery { if (isset($query['shareOpml'])) { $this->shareOpml = $query['shareOpml']; } + if (isset($query['publishLabelsInsteadOfTags'])) { + $this->publishLabelsInsteadOfTags = (bool)$query['publishLabelsInsteadOfTags']; + } if (isset($query['description'])) { $this->description = $query['description']; } @@ -109,7 +114,9 @@ class FreshRSS_UserQuery { /** * Convert the current object to an array. * - * @return array{'get'?:string,'name'?:string,'order'?:string,'search'?:string,'state'?:int,'url'?:string,'token'?:string} + * @return array{get?:string,name?:string,order?:string,search?:string, + * state?:int,url?:string,token?:string,shareRss?:bool,shareOpml?:bool, + * publishLabelsInsteadOfTags?:bool,description?:string,imageUrl?:string} */ public function toArray(): array { return array_filter([ @@ -122,6 +129,7 @@ class FreshRSS_UserQuery { 'token' => $this->token, 'shareRss' => $this->shareRss, 'shareOpml' => $this->shareOpml, + 'publishLabelsInsteadOfTags' => $this->publishLabelsInsteadOfTags, 'description' => $this->description, 'imageUrl' => $this->imageUrl, ], fn($v): bool => $v !== '' && $v !== 0 && $v !== false); @@ -279,6 +287,14 @@ class FreshRSS_UserQuery { return $this->shareOpml; } + public function setPublishLabelsInsteadOfTags(bool $publishLabelsInsteadOfTags): void { + $this->publishLabelsInsteadOfTags = $publishLabelsInsteadOfTags; + } + + public function publishLabelsInsteadOfTags(): bool { + return $this->publishLabelsInsteadOfTags; + } + protected function sharedUrl(bool $xmlEscaped = true): string { $currentUser = Minz_User::name() ?? ''; return Minz_Url::display("/api/query.php?user={$currentUser}&t={$this->token}", $xmlEscaped ? 'html' : '', true); diff --git a/app/Models/View.php b/app/Models/View.php index 11ca3a105..104afb3c0 100644 --- a/app/Models/View.php +++ b/app/Models/View.php @@ -78,7 +78,7 @@ class FreshRSS_View extends Minz_View { // Export / Import public string $content; /** @var array<string,array<string>> */ - public array $entryIdsTagNames; + public array $entryIdsTagNames = []; public string $list_title; public int $queryId; public string $type; @@ -111,6 +111,7 @@ class FreshRSS_View extends Minz_View { public bool $internal_rendering = false; public string $description = ''; public string $image_url = ''; + public bool $publishLabelsInsteadOfTags = false; // Content preview public string $fatalError; |
