aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/app/Controllers/configureController.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Controllers/configureController.php')
-rw-r--r--app/Controllers/configureController.php56
1 files changed, 28 insertions, 28 deletions
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php
index 8db36a899..e7f877428 100644
--- a/app/Controllers/configureController.php
+++ b/app/Controllers/configureController.php
@@ -301,12 +301,8 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
public function queriesAction(): void {
FreshRSS_View::appendScript(Minz_Url::display('/scripts/draggable.js?' . @filemtime(PUBLIC_PATH . '/scripts/draggable.js')));
- $category_dao = FreshRSS_Factory::createCategoryDao();
- $feed_dao = FreshRSS_Factory::createFeedDao();
- $tag_dao = FreshRSS_Factory::createTagDao();
-
if (Minz_Request::isPost()) {
- /** @var array<int,array{'get'?:string,'name'?:string,'order'?:string,'search'?:string,'state'?:int,'url'?:string}> $params */
+ /** @var array<int,array{'get'?:string,'name'?:string,'order'?:string,'search'?:string,'state'?:int,'url'?:string,'token'?:string}> $params */
$params = Minz_Request::paramArray('queries');
$queries = [];
@@ -318,7 +314,7 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
if (!empty($query['search'])) {
$query['search'] = urldecode($query['search']);
}
- $queries[$key] = (new FreshRSS_UserQuery($query, $feed_dao, $category_dao, $tag_dao))->toArray();
+ $queries[$key] = (new FreshRSS_UserQuery($query, FreshRSS_Context::categories(), FreshRSS_Context::labels()))->toArray();
}
FreshRSS_Context::userConf()->queries = $queries;
FreshRSS_Context::userConf()->save();
@@ -327,13 +323,13 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
} else {
$this->view->queries = [];
foreach (FreshRSS_Context::userConf()->queries as $key => $query) {
- $this->view->queries[intval($key)] = new FreshRSS_UserQuery($query, $feed_dao, $category_dao, $tag_dao);
+ $this->view->queries[intval($key)] = new FreshRSS_UserQuery($query, FreshRSS_Context::categories(), FreshRSS_Context::labels());
}
}
- $this->view->categories = $category_dao->listCategories(false) ?: [];
- $this->view->feeds = $feed_dao->listFeeds();
- $this->view->tags = $tag_dao->listTags() ?: [];
+ $this->view->categories = FreshRSS_Context::categories();
+ $this->view->feeds = FreshRSS_Context::feeds();
+ $this->view->tags = FreshRSS_Context::labels();
if (Minz_Request::paramTernary('id') !== null) {
$id = Minz_Request::paramInt('id');
@@ -363,20 +359,21 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
return;
}
- $category_dao = FreshRSS_Factory::createCategoryDao();
- $feed_dao = FreshRSS_Factory::createFeedDao();
- $tag_dao = FreshRSS_Factory::createTagDao();
-
- $query = new FreshRSS_UserQuery(FreshRSS_Context::userConf()->queries[$id], $feed_dao, $category_dao, $tag_dao);
+ $query = new FreshRSS_UserQuery(FreshRSS_Context::userConf()->queries[$id], FreshRSS_Context::categories(), FreshRSS_Context::labels());
$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() ?: [];
+ $this->view->categories = FreshRSS_Context::categories();
+ $this->view->feeds = FreshRSS_Context::feeds();
+ $this->view->tags = FreshRSS_Context::labels();
if (Minz_Request::isPost()) {
$params = array_filter(Minz_Request::paramArray('query'));
$queryParams = [];
+ $name = Minz_Request::paramString('name') ?: _t('conf.query.number', $id + 1);
+ if ('' === $name) {
+ $name = _t('conf.query.number', $id + 1);
+ }
+ $queryParams['name'] = $name;
if (!empty($params['get']) && is_string($params['get'])) {
$queryParams['get'] = htmlspecialchars_decode($params['get'], ENT_QUOTES);
}
@@ -389,15 +386,21 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
if (!empty($params['state']) && is_array($params['state'])) {
$queryParams['state'] = (int)(array_sum($params['state']));
}
- $name = Minz_Request::paramString('name') ?: _t('conf.query.number', $id + 1);
- if ('' === $name) {
- $name = _t('conf.query.number', $id + 1);
+ if (empty($params['token']) || !is_string($params['token'])) {
+ $queryParams['token'] = FreshRSS_UserQuery::generateToken($name);
+ } else {
+ $queryParams['token'] = $params['token'];
+ }
+ if (!empty($params['shareRss']) && ctype_digit($params['shareRss'])) {
+ $queryParams['shareRss'] = (bool)$params['shareRss'];
+ }
+ if (!empty($params['shareOpml']) && ctype_digit($params['shareOpml'])) {
+ $queryParams['shareOpml'] = (bool)$params['shareOpml'];
}
- $queryParams['name'] = $name;
$queryParams['url'] = Minz_Url::display(['params' => $queryParams]);
$queries = FreshRSS_Context::userConf()->queries;
- $queries[$id] = (new FreshRSS_UserQuery($queryParams, $feed_dao, $category_dao, $tag_dao))->toArray();
+ $queries[$id] = (new FreshRSS_UserQuery($queryParams, FreshRSS_Context::categories(), FreshRSS_Context::labels()))->toArray();
FreshRSS_Context::userConf()->queries = $queries;
FreshRSS_Context::userConf()->save();
@@ -433,18 +436,15 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
* lean data.
*/
public function bookmarkQueryAction(): void {
- $category_dao = FreshRSS_Factory::createCategoryDao();
- $feed_dao = FreshRSS_Factory::createFeedDao();
- $tag_dao = FreshRSS_Factory::createTagDao();
$queries = [];
foreach (FreshRSS_Context::userConf()->queries as $key => $query) {
- $queries[$key] = (new FreshRSS_UserQuery($query, $feed_dao, $category_dao, $tag_dao))->toArray();
+ $queries[$key] = (new FreshRSS_UserQuery($query, FreshRSS_Context::categories(), FreshRSS_Context::labels()))->toArray();
}
$params = $_GET;
unset($params['rid']);
$params['url'] = Minz_Url::display(['params' => $params]);
$params['name'] = _t('conf.query.number', count($queries) + 1);
- $queries[] = (new FreshRSS_UserQuery($params, $feed_dao, $category_dao, $tag_dao))->toArray();
+ $queries[] = (new FreshRSS_UserQuery($params, FreshRSS_Context::categories(), FreshRSS_Context::labels()))->toArray();
FreshRSS_Context::userConf()->queries = $queries;
FreshRSS_Context::userConf()->save();