diff options
| author | 2020-07-23 11:31:38 +0200 | |
|---|---|---|
| committer | 2020-07-23 11:31:38 +0200 | |
| commit | 909fdaca3172c0e825c7e6268950e16bc5d3e4f3 (patch) | |
| tree | 1d71aaf56ec7d4e39b46ed669d0fb57df60eecd3 /app/Controllers | |
| parent | 12d2baf64d3d6a1b95376460c7128a079dd1bac6 (diff) | |
Add tag management page (#3121)
The new page allows to create, delete and rename tags.
See #3058
Diffstat (limited to 'app/Controllers')
| -rw-r--r-- | app/Controllers/tagController.php | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/app/Controllers/tagController.php b/app/Controllers/tagController.php index ba9efe2fc..c49a3fcc4 100644 --- a/app/Controllers/tagController.php +++ b/app/Controllers/tagController.php @@ -63,7 +63,7 @@ class FreshRSS_tag_Controller extends Minz_ActionController { } if (!$this->ajax) { Minz_Request::forward(array( - 'c' => 'index', + 'c' => 'tag', 'a' => 'index', ), true); } @@ -77,4 +77,42 @@ class FreshRSS_tag_Controller extends Minz_ActionController { $tagDAO = FreshRSS_Factory::createTagDao(); $this->view->tags = $tagDAO->getTagsForEntry($id_entry); } + + public function addAction() { + if (!Minz_Request::isPost()) { + Minz_Error::error(405); + } + + $name = Minz_Request::param('name'); + $tagDAO = FreshRSS_Factory::createTagDao(); + if (null === $tagDAO->searchByName($name)) { + $tagDAO->addTag(['name' => $name]); + Minz_Request::good('feedback.tag.created', ['c' => 'tag', 'a' => 'index'], true); + } + + Minz_Request::bad('feedback.tag.name_exists', ['c' => 'tag', 'a' => 'index'], true); + } + + public function renameAction() { + if (!Minz_Request::isPost()) { + Minz_Error::error(405); + } + + $name = Minz_Request::param('name'); + $tagDAO = FreshRSS_Factory::createTagDao(); + $newTag = $tagDAO->searchByName($name); + if (null === $newTag) { + $tagDAO->updateTag(Minz_Request::param('id_tag'), ['name' => $name]); + } else { + $tagDAO->updateEntryTag(Minz_Request::param('id_tag'), $newTag->id()); + $tagDAO->deleteTag(Minz_Request::param('id_tag')); + } + + Minz_Request::good('feedback.tag.renamed', ['c' => 'tag', 'a' => 'index'], true); + } + + public function indexAction() { + $tagDAO = FreshRSS_Factory::createTagDao(); + $this->view->tags = $tagDAO->listTags(); + } } |
