Skip to content

Commit 62c5078

Browse files
committed
Use X-Requested-With header for XHR detection
1 parent ded74dc commit 62c5078

6 files changed

Lines changed: 14 additions & 23 deletions

File tree

controllers/Index.php

Lines changed: 8 additions & 13 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 root
79
*
@@ -14,21 +16,14 @@ class Index extends BaseController {
1416
* home site
1517
* html
1618
*
19+
* @param Base $f3 fatfree base instance
20+
*
1721
* @return void
1822
*/
19-
public function home() {
20-
// parse params
21-
$options = [];
22-
if (\F3::get('homepage') != '') {
23-
$options = ['type' => \F3::get('homepage')];
24-
}
25-
26-
// use ajax given params?
27-
if (count($_GET) > 0) {
28-
$options = $_GET;
29-
}
23+
public function home(Base $f3) {
24+
$options = $_GET;
3025

31-
if (!isset($options['ajax'])) {
26+
if (!$f3->ajax()) {
3227
// show as full html page
3328
$this->view->publicMode = \F3::get('public') == 1;
3429
$this->view->authEnabled = \F3::get('auth')->enabled() === true;
@@ -81,7 +76,7 @@ public function home() {
8176
}
8277

8378
// ajax call = only send entries and statistics not full template
84-
if (isset($options['ajax'])) {
79+
if ($f3->ajax()) {
8580
$this->view->jsonSuccess([
8681
'lastUpdate' => \helpers\ViewHelper::date_iso8601($itemsDao->lastUpdate()),
8782
'hasMore' => $items['hasMore'],

controllers/Sources.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,11 @@ public function write(Base $f3, array $params) {
161161
$tags = array_map('htmlspecialchars', $data['tags']);
162162
$spout = $data['spout'];
163163
$filter = $data['filter'];
164-
$isAjax = isset($data['ajax']);
165164

166165
unset($data['title']);
167166
unset($data['spout']);
168167
unset($data['filter']);
169168
unset($data['tags']);
170-
unset($data['ajax']);
171169

172170
// check if source already exists
173171
$id = $params['id'];
@@ -218,7 +216,7 @@ public function write(Base $f3, array $params) {
218216
];
219217

220218
// only for selfoss ui (update stats in navigation)
221-
if ($isAjax) {
219+
if ($f3->ajax()) {
222220
// get new tag list with updated count values
223221
$tagController = new \controllers\Tags();
224222
$return['tags'] = $tagController->tagsListAsString();

public/js/selfoss-base.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ var selfoss = {
2121
tag: '',
2222
source: '',
2323
sourcesNav: false,
24-
extraIds: [],
25-
ajax: true
24+
extraIds: []
2625
},
2726

2827
/**

public/js/selfoss-events-entries.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ selfoss.events.entries = function() {
189189
url: $('base').attr('href') + 'source/' + selfoss.filter.source + '/update',
190190
type: 'POST',
191191
dataType: 'text',
192-
data: { ajax: true },
192+
data: {},
193193
success: function() {
194194
// hide nav on smartphone
195195
if (selfoss.isSmartphone()) {

public/js/selfoss-events-entriestoolbar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ selfoss.events.entriesToolbar = function(parent) {
9696

9797
$.ajax({
9898
url: $('base').attr('href') + (starr ? 'starr/' : 'unstarr/') + id,
99-
data: { ajax: true },
99+
data: {},
100100
type: 'POST',
101101
success: function() {
102102
selfoss.db.setOnline();
@@ -151,7 +151,7 @@ selfoss.events.entriesToolbar = function(parent) {
151151

152152
$.ajax({
153153
url: $('base').attr('href') + (unread ? 'mark/' : 'unmark/') + id,
154-
data: { ajax: true },
154+
data: {},
155155
type: 'POST',
156156
success: function() {
157157
selfoss.db.setOnline();

public/js/selfoss-events-sources.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ selfoss.events.sources = function() {
5757
// get values and params
5858
var values = selfoss.getValues(parent);
5959
values['tags'] = values['tags'].split(',');
60-
values['ajax'] = true;
6160

6261
$.ajax({
6362
url: url,
@@ -124,7 +123,7 @@ selfoss.events.sources = function() {
124123
// delete on server
125124
$.ajax({
126125
url: $('base').attr('href') + 'source/delete/' + id,
127-
data: { ajax: true },
126+
data: {},
128127
type: 'POST',
129128
success: function() {
130129
parent.fadeOut('fast', function() {

0 commit comments

Comments
 (0)