aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers/configureController.php
diff options
context:
space:
mode:
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