A free, self-hostable news aggregator…
Cat updating system works
Marien Fressinauddc714d394937
diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.phpindex be8524749..65fe631cc 100644--- a/app/Controllers/categoryController.php+++ b/app/Controllers/categoryController.php@@ -62,6 +62,45 @@ class FreshRSS_category_Controller extends Minz_ActionController {Minz_Request::forward($url_redirect, true);}+ /**+ * This action updates the given category.+ *+ * Request parameters are:+ * - id+ * - name+ */+ public function updateAction() {+ $catDAO = new FreshRSS_CategoryDAO();+ $url_redirect = array('c' => 'configure', 'a' => 'categorize');++ if (Minz_Request::isPost()) {+ invalidateHttpCache();++ $id = Minz_Request::param('id');+ $name = Minz_Request::param('name', '');+ if (strlen($name) <= 0) {+ Minz_Request::bad(_t('category_no_name'), $url_redirect);+ }++ if ($catDAO->searchById($id) == null) {+ Minz_Request::bad(_t('category_not_exist'), $url_redirect);+ }++ $cat = new FreshRSS_Category($name);+ $values = array(+ 'name' => $cat->name(),+ );++ if ($catDAO->updateCategory($id, $values)) {+ Minz_Request::good(_t('category_updated'), $url_redirect);+ } else {+ Minz_Request::bad(_t('error_occurred'), $url_redirect);+ }+ }++ Minz_Request::forward($url_redirect, true);+ }+/*** This action deletes a category.* Feeds in the given category are moved in the default category.diff --git a/app/views/configure/categorize.phtml b/app/views/configure/categorize.phtmlindex 781c4bb14..b9d04ddb8 100644--- a/app/views/configure/categorize.phtml+++ b/app/views/configure/categorize.phtml@@ -28,32 +28,38 @@?><div class="box"><div class="box-title stick">- <input type="text" value="<?php echo $cat->name(); ?>" />- <div class="dropdown">- <div id="dropdown-cat-<?php echo $cat->id(); ?>" class="dropdown-target"></div>+ <form action="<?php echo _url('category', 'update', 'id', $cat->id()); ?>" method="post">+ <input type="text" name="name" value="<?php echo $cat->name(); ?>" />+ <button class="btn" type="submit">✓</button>- <a class="dropdown-toggle btn" href="#dropdown-cat-<?php echo $cat->id(); ?>"><?php echo _i('down'); ?></a>- <ul class="dropdown-menu">- <li class="dropdown-close"><a href="#close">❌</a></li>+ <div class="dropdown">+ <div id="dropdown-cat-<?php echo $cat->id(); ?>" class="dropdown-target"></div>- <li class="item">- <button class="as-link confirm"- data-str-confirm="<?php echo _t('confirm_action_feed_cat'); ?>"- type="submit"- form="controller-category"- formaction="<?php echo _url('category', 'empty', 'id', $cat->id()); ?>">- <?php echo _t('ask_empty'); ?></button>- </li>- <li class="item">- <button class="as-link confirm"- data-str-confirm="<?php echo _t('confirm_action_feed_cat'); ?>"- type="submit"- form="controller-category"- formaction="<?php echo _url('category', 'delete', 'id', $cat->id()); ?>">- <?php echo _t('delete'); ?></button>- </li>- </ul>- </div>+ <a class="dropdown-toggle btn" href="#dropdown-cat-<?php echo $cat->id(); ?>"><?php echo _i('down'); ?></a>+ <ul class="dropdown-menu">+ <li class="dropdown-close"><a href="#close">❌</a></li>++ <?php if (!empty($feeds)) { ?>+ <li class="item">+ <button class="as-link confirm"+ data-str-confirm="<?php echo _t('confirm_action_feed_cat'); ?>"+ type="submit"+ form="controller-category"+ formaction="<?php echo _url('category', 'empty', 'id', $cat->id()); ?>">+ <?php echo _t('ask_empty'); ?></button>+ </li>+ <?php } ?>+ <li class="item">+ <button class="as-link confirm"+ data-str-confirm="<?php echo _t('confirm_action_feed_cat'); ?>"+ type="submit"+ form="controller-category"+ formaction="<?php echo _url('category', 'delete', 'id', $cat->id()); ?>">+ <?php echo _t('delete'); ?></button>+ </li>+ </ul>+ </div>+ </form></div><ul class="box-content">