From 2decc82c3eaeaf205295667e836087f309156822 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Fri, 21 Jun 2019 08:42:06 +0200 Subject: Change category configuration (#2410) * Change category configuration Before, we had a drop-down list to interract on categories. It was not working the same way as feeds. Now, categories and feeds behave in a similar manner. At the moment, there is no change in features but it will allow to expand them. See #2369 * Minor whitespace --- app/Controllers/subscriptionController.php | 46 ++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'app/Controllers/subscriptionController.php') diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php index 9cf41ed0b..79da39751 100644 --- a/app/Controllers/subscriptionController.php +++ b/app/Controllers/subscriptionController.php @@ -35,9 +35,20 @@ class FreshRSS_subscription_Controller extends Minz_ActionController { $this->view->onlyFeedsWithError = Minz_Request::paramTernary('error'); $id = Minz_Request::param('id'); - if ($id !== false) { - $feedDAO = FreshRSS_Factory::createFeedDao(); - $this->view->feed = $feedDAO->searchById($id); + $this->view->displaySlider = false; + if (false !== $id) { + $type = Minz_Request::param('type'); + $this->view->displaySlider = true; + switch ($type) { + case 'category': + $categoryDAO = FreshRSS_Factory::createCategoryDao(); + $this->view->category = $categoryDAO->searchById($id); + break; + default: + $feedDAO = FreshRSS_Factory::createFeedDao(); + $this->view->feed = $feedDAO->searchById($id); + break; + } } } @@ -140,6 +151,35 @@ class FreshRSS_subscription_Controller extends Minz_ActionController { } } + public function categoryAction() { + $this->view->_useLayout(false); + + $categoryDAO = FreshRSS_Factory::createCategoryDao(); + + $id = Minz_Request::param('id'); + $category = $categoryDAO->searchById($id); + if ($id === false || null === $category) { + Minz_Error::error(404); + return; + } + $this->view->category = $category; + + if (Minz_Request::isPost()) { + $values = array( + 'name' => Minz_Request::param('name', ''), + ); + + invalidateHttpCache(); + + $url_redirect = array('c' => 'subscription', 'params' => array('id' => $id, 'type' => 'category')); + if (false !== $categoryDAO->updateCategory($id, $values)) { + Minz_Request::good(_t('feedback.sub.category.updated'), $url_redirect); + } else { + Minz_Request::bad(_t('feedback.sub.category.error'), $url_redirect); + } + } + } + /** * This action displays the bookmarklet page. */ -- cgit v1.2.3