aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers/configureController.php
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <aledeg@users.noreply.github.com> 2021-01-14 18:14:53 -0500
committerGravatar GitHub <noreply@github.com> 2021-01-15 00:14:53 +0100
commitc5da4e56a690d9e9caf8ca4bad4349684b4d39c5 (patch)
treeb3a46ff845feab6016aa19d55b4885c4a949d9dc /app/Controllers/configureController.php
parent29fe125b4a18f7107b50e54c69184c4f1777bbf6 (diff)
Add a query configuration page (#3366)
* Add a query configuration page Before, there was no way to modify a user query. Thus you need to create a new one and delete the old one afterward. Now, every user query can be modified if needed. They have their own configuration page on which it can be modified or deleted. * Change drag and drop action on queries Before, the drag and drop action needed to be validated by submitting the form to be persisted. Now, it's done automatically after the query is dropped to its final location.
Diffstat (limited to 'app/Controllers/configureController.php')
-rwxr-xr-xapp/Controllers/configureController.php84
1 files changed, 84 insertions, 0 deletions
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php
index 917879810..b37d2cefa 100755
--- a/app/Controllers/configureController.php
+++ b/app/Controllers/configureController.php
@@ -280,6 +280,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
$category_dao = FreshRSS_Factory::createCategoryDao();
$feed_dao = FreshRSS_Factory::createFeedDao();
$tag_dao = FreshRSS_Factory::createTagDao();
+
if (Minz_Request::isPost()) {
$params = Minz_Request::param('queries', array());
@@ -304,10 +305,93 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
}
}
+ $this->view->categories = $category_dao->listCategories(false);
+ $this->view->feeds = $feed_dao->listFeeds();
+ $this->view->tags = $tag_dao->listTags();
+
+ $id = Minz_Request::param('id');
+ $this->view->displaySlider = false;
+ if (false !== $id) {
+ $this->view->displaySlider = true;
+ $this->view->query = $this->view->queries[$id];
+ $this->view->queryId = $id;
+ }
+
Minz_View::prependTitle(_t('conf.query.title') . ' · ');
}
/**
+ * Handles query configuration.
+ * It displays the query configuration page and handles modifications
+ * applied to the selected query.
+ */
+ public function queryAction() {
+ $this->view->_layout(false);
+
+ $id = Minz_Request::param('id');
+ if (false === $id || !isset(FreshRSS_Context::$user_conf->queries[$id])) {
+ Minz_Error::error(404);
+ return;
+ }
+
+ $category_dao = FreshRSS_Factory::createCategoryDao();
+ $feed_dao = FreshRSS_Factory::createFeedDao();
+ $tag_dao = FreshRSS_Factory::createTagDao();
+
+ $query = new FreshRSS_UserQuery(FreshRSS_Context::$user_conf->queries[$id], $feed_dao, $category_dao, $tag_dao);
+ $this->view->query = $query;
+ $this->view->queryId = $id;
+ $this->view->categories = $category_dao->listCategories(false);
+ $this->view->feeds = $feed_dao->listFeeds();
+ $this->view->tags = $tag_dao->listTags();
+
+ if (Minz_Request::isPost()) {
+ $params = array_filter(Minz_Request::param('query', []));
+ if (!empty($params['search'])) {
+ $params['search'] = urldecode($params['search']);
+ }
+ if (!empty($params['state'])) {
+ $params['state'] = array_sum($params['state']);
+ }
+ $params['url'] = Minz_Url::display(['params' => $params]);
+ $name = Minz_Request::param('name', _t('conf.query.number', $id + 1));
+ if ('' === $name) {
+ $name = _t('conf.query.number', $id + 1);
+ }
+ $params['name'] = $name;
+
+ $queries = FreshRSS_Context::$user_conf->queries;
+ $queries[$id] = new FreshRSS_UserQuery($params, $feed_dao, $category_dao, $tag_dao);
+ FreshRSS_Context::$user_conf->queries = $queries;
+ FreshRSS_Context::$user_conf->save();
+
+ Minz_Request::good(_t('feedback.conf.updated'),
+ array('c' => 'configure', 'a' => 'queries', 'params' => ['id' => $id]));
+ }
+
+ Minz_View::prependTitle(_t('conf.query.title') . ' · ' . $query->getName() . ' · ');
+ }
+
+ /**
+ * Handles query deletion
+ */
+ public function deleteQueryAction() {
+ $id = Minz_Request::param('id');
+ if (false === $id || !isset(FreshRSS_Context::$user_conf->queries[$id])) {
+ Minz_Error::error(404);
+ return;
+ }
+
+ $queries = FreshRSS_Context::$user_conf->queries;
+ unset($queries[$id]);
+ FreshRSS_Context::$user_conf->queries = $queries;
+ FreshRSS_Context::$user_conf->save();
+
+ Minz_Request::good(_t('feedback.conf.updated'),
+ array('c' => 'configure', 'a' => 'queries'));
+ }
+
+ /**
* This action handles the creation of a user query.
*
* It gets the GET parameters and stores them in the configuration query