From 8ee8a573f1f7e9cc45f9b3c46627d15670f14f3a Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 29 Sep 2018 20:47:17 +0200 Subject: Custom labels (#2027) * First draft of custom tags https://github.com/FreshRSS/FreshRSS/issues/928 https://github.com/FreshRSS/FreshRSS/issues/1367 * SMALLINT to BIGINT for id_entry And uppercase SQL types * Fix layout for unreads * Start UI menu * Change menu order * Clean database helpers https://github.com/FreshRSS/FreshRSS/pull/2027#discussion_r217971535 * Travis rules do not understand PostgreSQL constants Grrr * Tag controller + UI * Add column attributes to tags * Use only favicon for now, for label * Fix styling for different themes * Constant for maximum InnoDB index length in Unicode https://github.com/FreshRSS/FreshRSS/pull/2027#discussion_r219052200 (I would have personnally prefered keeping the readability of a real value instead of a constant, in this case of many SQL fields) * Use FreshRSS_Factory::createCategoryDao * Add view of all articles containing any tag * Fix search in tags * Mark as read tags * Partial auto-update unread tags * More auto update tag unreads * Add tag deletion * Do not purge tagged articles * Minor comment * Fix SQLite and UI bug * Google Reader API support for user tags Add SQL check that tag names must be distinct from category names * whitespace * Add missing API for EasyRSS * Compatibility SQLite Problematic parentheses * Add SQL DISTINCT for cases with multiple tags * Fix for PostgreSQL PostgreSQL needs some additional type hint to avoid "could not determine data type of parameter $1" http://www.postgresql-archive.org/Could-not-determine-data-type-of-parameter-1-tp2171092p2171094.html --- app/Models/UserQuery.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'app/Models/UserQuery.php') diff --git a/app/Models/UserQuery.php b/app/Models/UserQuery.php index ef94fdaf6..f607084f8 100644 --- a/app/Models/UserQuery.php +++ b/app/Models/UserQuery.php @@ -19,15 +19,17 @@ class FreshRSS_UserQuery { private $url; private $feed_dao; private $category_dao; + private $tag_dao; /** * @param array $query * @param FreshRSS_Searchable $feed_dao * @param FreshRSS_Searchable $category_dao */ - public function __construct($query, FreshRSS_Searchable $feed_dao = null, FreshRSS_Searchable $category_dao = null) { + public function __construct($query, FreshRSS_Searchable $feed_dao = null, FreshRSS_Searchable $category_dao = null, FreshRSS_Searchable $tag_dao = null) { $this->category_dao = $category_dao; $this->feed_dao = $feed_dao; + $this->tag_dao = $tag_dao; if (isset($query['get'])) { $this->parseGet($query['get']); } @@ -88,6 +90,9 @@ class FreshRSS_UserQuery { case 's': $this->parseFavorite(); break; + case 't': + $this->parseTag($matches['id']); + break; } } } @@ -138,6 +143,25 @@ class FreshRSS_UserQuery { $this->get_type = 'feed'; } + /** + * Parse the query string when it is a "tag" query + * + * @param integer $id + * @throws FreshRSS_DAO_Exception + */ + private function parseTag($id) { + if ($this->tag_dao == null) { + throw new FreshRSS_DAO_Exception('Tag DAO is not loaded in UserQuery'); + } + $category = $this->category_dao->searchById($id); + if ($tag) { + $this->get_name = $tag->name(); + } else { + $this->deprecated = true; + } + $this->get_type = 'tag'; + } + /** * Parse the query string when it is a "favorite" query */ -- cgit v1.2.3