Skip to content

Commit 0ec02ab

Browse files
committed
Access query string params through argument
1 parent d537f50 commit 0ec02ab

3 files changed

Lines changed: 49 additions & 20 deletions

File tree

controllers/Items.php

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace controllers;
44

5+
use Base;
6+
57
/**
68
* Controller for item handling
79
*
@@ -14,13 +16,16 @@ class Items extends BaseController {
1416
* mark items as read. Allows one id or an array of ids
1517
* json
1618
*
19+
* @param Base $f3 fatfree base instance
20+
* @param array $params query string parameters
21+
*
1722
* @return void
1823
*/
19-
public function mark() {
24+
public function mark(Base $f3, array $params) {
2025
$this->needsLoggedIn();
2126

22-
if (\F3::get('PARAMS["item"]') !== null) {
23-
$lastid = \F3::get('PARAMS["item"]');
27+
if (isset($params['item'])) {
28+
$lastid = $params['item'];
2429
} elseif (isset($_POST['ids'])) {
2530
$lastid = $_POST['ids'];
2631
}
@@ -45,12 +50,15 @@ public function mark() {
4550
* mark item as unread
4651
* json
4752
*
53+
* @param Base $f3 fatfree base instance
54+
* @param array $params query string parameters
55+
*
4856
* @return void
4957
*/
50-
public function unmark() {
58+
public function unmark(Base $f3, array $params) {
5159
$this->needsLoggedIn();
5260

53-
$lastid = \F3::get('PARAMS["item"]');
61+
$lastid = $params['item'];
5462

5563
$itemDao = new \daos\Items();
5664

@@ -69,12 +77,15 @@ public function unmark() {
6977
* starr item
7078
* json
7179
*
80+
* @param Base $f3 fatfree base instance
81+
* @param array $params query string parameters
82+
*
7283
* @return void
7384
*/
74-
public function starr() {
85+
public function starr(Base $f3, array $params) {
7586
$this->needsLoggedIn();
7687

77-
$id = \F3::get('PARAMS["item"]');
88+
$id = $params['item'];
7889

7990
$itemDao = new \daos\Items();
8091

@@ -92,12 +103,15 @@ public function starr() {
92103
* unstarr item
93104
* json
94105
*
106+
* @param Base $f3 fatfree base instance
107+
* @param array $params query string parameters
108+
*
95109
* @return void
96110
*/
97-
public function unstarr() {
111+
public function unstarr(Base $f3, array $params) {
98112
$this->needsLoggedIn();
99113

100-
$id = \F3::get('PARAMS["item"]');
114+
$id = $params['item'];
101115

102116
$itemDao = new \daos\Items();
103117

controllers/Rss.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace controllers;
44

5+
use Base;
56
use FeedWriter\RSS2;
67

78
/**
@@ -15,9 +16,12 @@ class Rss extends BaseController {
1516
/**
1617
* rss feed
1718
*
19+
* @param Base $f3 fatfree base instance
20+
* @param array $params query string parameters
21+
*
1822
* @return void
1923
*/
20-
public function rss() {
24+
public function rss(Base $f3, array $params) {
2125
$this->needsLoggedInOrPublicMode();
2226

2327
$feedWriter = new RSS2();
@@ -38,11 +42,11 @@ public function rss() {
3842
$options = $_GET;
3943
}
4044
$options['items'] = \F3::get('rss_max_items');
41-
if (\F3::get('PARAMS["tag"]') !== null) {
42-
$options['tag'] = \F3::get('PARAMS["tag"]');
45+
if (isset($params['tag'])) {
46+
$options['tag'] = $params['tag'];
4347
}
44-
if (\F3::get('PARAMS["type"]') !== null) {
45-
$options['type'] = \F3::get('PARAMS["type"]');
48+
if (isset($params['type'])) {
49+
$options['type'] = $params['type'];
4650
}
4751

4852
// get items

controllers/Sources.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace controllers;
44

5+
use Base;
6+
57
/**
68
* Controller for sources handling
79
*
@@ -120,9 +122,12 @@ public function sourcesListAsString() {
120122
* render spouts params
121123
* json
122124
*
125+
* @param Base $f3 fatfree base instance
126+
* @param array $params query string parameters
127+
*
123128
* @return void
124129
*/
125-
public function write() {
130+
public function write(Base $f3, array $params) {
126131
$this->needsLoggedIn();
127132

128133
$sourcesDao = new \daos\Sources();
@@ -167,7 +172,7 @@ public function write() {
167172
unset($data['ajax']);
168173

169174
// check if source already exists
170-
$id = \F3::get('PARAMS["id"]');
175+
$id = $params['id'];
171176
$sourceExists = $sourcesDao->isValid('id', $id);
172177

173178
// load password value if not changed for spouts containing passwords
@@ -248,12 +253,15 @@ public function sourcesStats() {
248253
* delete source
249254
* json
250255
*
256+
* @param Base $f3 fatfree base instance
257+
* @param array $params query string parameters
258+
*
251259
* @return void
252260
*/
253-
public function remove() {
261+
public function remove(Base $f3, array $params) {
254262
$this->needsLoggedIn();
255263

256-
$id = \F3::get('PARAMS["id"]');
264+
$id = $params['id'];
257265

258266
$sourceDao = new \daos\Sources();
259267

@@ -277,10 +285,13 @@ public function remove() {
277285
* update source
278286
* text
279287
*
288+
* @param Base $f3 fatfree base instance
289+
* @param array $params query string parameters
290+
*
280291
* @return void
281292
*/
282-
public function update() {
283-
$id = \F3::get('PARAMS["id"]');
293+
public function update(Base $f3, array $params) {
294+
$id = $params['id'];
284295

285296
// only allow access for localhost and authenticated users
286297
if (!$this->allowedToUpdate()) {

0 commit comments

Comments
 (0)