]>
Commit | Line | Data |
---|---|---|
afcfe6ca | 1 | <?php |
369dbc19 | 2 | class Pref_Feeds extends Handler_Protected { |
8484ce22 AD |
3 | |
4 | function csrf_ignore($method) { | |
f6cd767b | 5 | $csrf_ignored = array("index", "getfeedtree", "add", "editcats", "editfeed", |
bc6fa236 | 6 | "savefeedorder", "uploadicon", "feedswitherrors", "inactivefeeds"); |
8484ce22 AD |
7 | |
8 | return array_search($method, $csrf_ignored) !== false; | |
9 | } | |
10 | ||
afcfe6ca AD |
11 | function batch_edit_cbox($elem, $label = false) { |
12 | print "<input type=\"checkbox\" title=\"".__("Check to enable field")."\" | |
13 | onchange=\"dijit.byId('feedEditDlg').toggleField(this, '$elem', '$label')\">"; | |
14 | } | |
15 | ||
16 | function renamecat() { | |
17 | $title = db_escape_string($_REQUEST['title']); | |
18 | $id = db_escape_string($_REQUEST['id']); | |
19 | ||
20 | if ($title) { | |
21 | db_query($this->link, "UPDATE ttrss_feed_categories SET | |
22 | title = '$title' WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
23 | } | |
24 | return; | |
25 | } | |
26 | ||
2a060a94 | 27 | private function get_category_items($cat_id) { |
6e0ee833 AD |
28 | |
29 | if ($_REQUEST['mode'] != 2) | |
30 | $search = $_SESSION["prefs_feed_search"]; | |
31 | else | |
32 | $search = ""; | |
17c755f0 AD |
33 | |
34 | if ($search) $search_qpart = " AND LOWER(title) LIKE LOWER('%$search%')"; | |
35 | ||
f393dc6f | 36 | $show_empty_cats = $_REQUEST['mode'] != 2 && !$search && |
fbf85cf6 | 37 | get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS'); |
2a060a94 AD |
38 | |
39 | $items = array(); | |
40 | ||
2ecd2df5 | 41 | $result = db_query($this->link, "SELECT id, title, collapsed FROM ttrss_feed_categories |
2a060a94 AD |
42 | WHERE owner_uid = " . $_SESSION["uid"] . " AND parent_cat = '$cat_id' ORDER BY order_id, title"); |
43 | ||
44 | while ($line = db_fetch_assoc($result)) { | |
45 | ||
46 | $cat = array(); | |
47 | $cat['id'] = 'CAT:' . $line['id']; | |
2ecd2df5 | 48 | $cat['bare_id'] = (int)$line['id']; |
2a060a94 AD |
49 | $cat['name'] = $line['title']; |
50 | $cat['items'] = array(); | |
51 | $cat['checkbox'] = false; | |
2ecd2df5 | 52 | $cat['hidden'] = sql_bool_to_bool($line['collapsed']); |
2a060a94 | 53 | $cat['type'] = 'category'; |
2ecd2df5 | 54 | $cat['unread'] = 0; |
2c5f231e | 55 | $cat['child_unread'] = 0; |
2a060a94 AD |
56 | |
57 | $cat['items'] = $this->get_category_items($line['id']); | |
58 | ||
59 | $cat['param'] = T_sprintf('(%d feeds)', count($cat['items'])); | |
60 | ||
61 | if (count($cat['items']) > 0 || $show_empty_cats) | |
62 | array_push($items, $cat); | |
63 | ||
64 | } | |
65 | ||
66 | $feed_result = db_query($this->link, "SELECT id, title, last_error, | |
67 | ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated | |
68 | FROM ttrss_feeds | |
69 | WHERE cat_id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]. | |
70 | "$search_qpart ORDER BY order_id, title"); | |
71 | ||
72 | while ($feed_line = db_fetch_assoc($feed_result)) { | |
73 | $feed = array(); | |
74 | $feed['id'] = 'FEED:' . $feed_line['id']; | |
2ecd2df5 | 75 | $feed['bare_id'] = (int)$feed_line['id']; |
2a060a94 AD |
76 | $feed['name'] = $feed_line['title']; |
77 | $feed['checkbox'] = false; | |
2ecd2df5 | 78 | $feed['unread'] = 0; |
2a060a94 AD |
79 | $feed['error'] = $feed_line['last_error']; |
80 | $feed['icon'] = getFeedIcon($feed_line['id']); | |
81 | $feed['param'] = make_local_datetime($this->link, | |
82 | $feed_line['last_updated'], true); | |
83 | ||
84 | array_push($items, $feed); | |
85 | } | |
86 | ||
87 | return $items; | |
88 | } | |
89 | ||
afcfe6ca AD |
90 | function getfeedtree() { |
91 | ||
6e0ee833 AD |
92 | if ($_REQUEST['mode'] != 2) |
93 | $search = $_SESSION["prefs_feed_search"]; | |
94 | else | |
95 | $search = ""; | |
afcfe6ca AD |
96 | |
97 | if ($search) $search_qpart = " AND LOWER(title) LIKE LOWER('%$search%')"; | |
98 | ||
99 | $root = array(); | |
100 | $root['id'] = 'root'; | |
101 | $root['name'] = __('Feeds'); | |
102 | $root['items'] = array(); | |
103 | $root['type'] = 'category'; | |
104 | ||
2ecd2df5 AD |
105 | $enable_cats = get_pref($this->link, 'ENABLE_FEED_CATS'); |
106 | ||
107 | if ($_REQUEST['mode'] == 2) { | |
108 | ||
109 | if ($enable_cats) { | |
110 | $cat_hidden = get_pref($this->link, "_COLLAPSED_SPECIAL"); | |
111 | $cat = $this->feedlist_init_cat(-1, $cat_hidden); | |
112 | } else { | |
113 | $cat['items'] = array(); | |
114 | } | |
115 | ||
5417fbd7 | 116 | foreach (array(-4, -3, -1, -2, 0, -6) as $i) { |
2ecd2df5 AD |
117 | array_push($cat['items'], $this->feedlist_init_feed($i)); |
118 | } | |
119 | ||
120 | if ($enable_cats) { | |
121 | array_push($root['items'], $cat); | |
122 | } else { | |
123 | $root['items'] = array_merge($root['items'], $cat['items']); | |
124 | } | |
afcfe6ca | 125 | |
2ecd2df5 AD |
126 | $result = db_query($this->link, "SELECT * FROM |
127 | ttrss_labels2 WHERE owner_uid = ".$_SESSION['uid']." ORDER by caption"); | |
128 | ||
129 | if (db_num_rows($result) > 0) { | |
130 | ||
131 | if (get_pref($this->link, 'ENABLE_FEED_CATS')) { | |
132 | $cat_hidden = get_pref($this->link, "_COLLAPSED_LABELS"); | |
133 | $cat = $this->feedlist_init_cat(-2, $cat_hidden); | |
134 | } else { | |
135 | $cat['items'] = array(); | |
136 | } | |
137 | ||
138 | while ($line = db_fetch_assoc($result)) { | |
139 | ||
140 | $label_id = -$line['id'] - 11; | |
141 | $count = getFeedUnread($this->link, $label_id); | |
142 | ||
143 | $feed = $this->feedlist_init_feed($label_id, false, $count); | |
144 | ||
145 | $feed['fg_color'] = $line['fg_color']; | |
146 | $feed['bg_color'] = $line['bg_color']; | |
147 | ||
148 | array_push($cat['items'], $feed); | |
149 | } | |
150 | ||
151 | if ($enable_cats) { | |
152 | array_push($root['items'], $cat); | |
153 | } else { | |
154 | $root['items'] = array_merge($root['items'], $cat['items']); | |
155 | } | |
156 | } | |
157 | } | |
158 | ||
159 | if ($enable_cats) { | |
f393dc6f | 160 | $show_empty_cats = $_REQUEST['mode'] != 2 && !$search && |
2ecd2df5 AD |
161 | get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS'); |
162 | ||
163 | $result = db_query($this->link, "SELECT id, title, collapsed FROM ttrss_feed_categories | |
2a060a94 | 164 | WHERE owner_uid = " . $_SESSION["uid"] . " AND parent_cat IS NULL ORDER BY order_id, title"); |
afcfe6ca AD |
165 | |
166 | while ($line = db_fetch_assoc($result)) { | |
167 | $cat = array(); | |
168 | $cat['id'] = 'CAT:' . $line['id']; | |
2ecd2df5 | 169 | $cat['bare_id'] = (int)$line['id']; |
afcfe6ca AD |
170 | $cat['name'] = $line['title']; |
171 | $cat['items'] = array(); | |
172 | $cat['checkbox'] = false; | |
2ecd2df5 | 173 | $cat['hidden'] = sql_bool_to_bool($line['collapsed']); |
afcfe6ca | 174 | $cat['type'] = 'category'; |
2ecd2df5 | 175 | $cat['unread'] = 0; |
2c5f231e | 176 | $cat['child_unread'] = 0; |
afcfe6ca | 177 | |
2a060a94 | 178 | $cat['items'] = $this->get_category_items($line['id']); |
afcfe6ca AD |
179 | |
180 | $cat['param'] = T_sprintf('(%d feeds)', count($cat['items'])); | |
181 | ||
5b7bd238 | 182 | if (count($cat['items']) > 0 || $show_empty_cats) |
afcfe6ca AD |
183 | array_push($root['items'], $cat); |
184 | ||
185 | $root['param'] += count($cat['items']); | |
186 | } | |
187 | ||
188 | /* Uncategorized is a special case */ | |
189 | ||
190 | $cat = array(); | |
191 | $cat['id'] = 'CAT:0'; | |
192 | $cat['bare_id'] = 0; | |
193 | $cat['name'] = __("Uncategorized"); | |
194 | $cat['items'] = array(); | |
2ecd2df5 | 195 | $cat['hidden'] = get_pref($this->link, "_COLLAPSED_UNCAT"); |
afcfe6ca AD |
196 | $cat['type'] = 'category'; |
197 | $cat['checkbox'] = false; | |
2ecd2df5 | 198 | $cat['unread'] = 0; |
2c5f231e | 199 | $cat['child_unread'] = 0; |
afcfe6ca AD |
200 | |
201 | $feed_result = db_query($this->link, "SELECT id, title,last_error, | |
202 | ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated | |
203 | FROM ttrss_feeds | |
204 | WHERE cat_id IS NULL AND owner_uid = ".$_SESSION["uid"]. | |
205 | "$search_qpart ORDER BY order_id, title"); | |
206 | ||
207 | while ($feed_line = db_fetch_assoc($feed_result)) { | |
208 | $feed = array(); | |
209 | $feed['id'] = 'FEED:' . $feed_line['id']; | |
2ecd2df5 | 210 | $feed['bare_id'] = (int)$feed_line['id']; |
afcfe6ca AD |
211 | $feed['name'] = $feed_line['title']; |
212 | $feed['checkbox'] = false; | |
213 | $feed['error'] = $feed_line['last_error']; | |
214 | $feed['icon'] = getFeedIcon($feed_line['id']); | |
215 | $feed['param'] = make_local_datetime($this->link, | |
216 | $feed_line['last_updated'], true); | |
2ecd2df5 AD |
217 | $feed['unread'] = 0; |
218 | $feed['type'] = 'feed'; | |
afcfe6ca AD |
219 | |
220 | array_push($cat['items'], $feed); | |
221 | } | |
222 | ||
223 | $cat['param'] = T_sprintf('(%d feeds)', count($cat['items'])); | |
224 | ||
5b7bd238 | 225 | if (count($cat['items']) > 0 || $show_empty_cats) |
afcfe6ca AD |
226 | array_push($root['items'], $cat); |
227 | ||
228 | $root['param'] += count($cat['items']); | |
229 | $root['param'] = T_sprintf('(%d feeds)', $root['param']); | |
230 | ||
231 | } else { | |
232 | $feed_result = db_query($this->link, "SELECT id, title, last_error, | |
233 | ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated | |
234 | FROM ttrss_feeds | |
235 | WHERE owner_uid = ".$_SESSION["uid"]. | |
236 | "$search_qpart ORDER BY order_id, title"); | |
237 | ||
238 | while ($feed_line = db_fetch_assoc($feed_result)) { | |
239 | $feed = array(); | |
240 | $feed['id'] = 'FEED:' . $feed_line['id']; | |
2ecd2df5 | 241 | $feed['bare_id'] = (int)$feed_line['id']; |
afcfe6ca AD |
242 | $feed['name'] = $feed_line['title']; |
243 | $feed['checkbox'] = false; | |
244 | $feed['error'] = $feed_line['last_error']; | |
245 | $feed['icon'] = getFeedIcon($feed_line['id']); | |
246 | $feed['param'] = make_local_datetime($this->link, | |
247 | $feed_line['last_updated'], true); | |
2ecd2df5 AD |
248 | $feed['unread'] = 0; |
249 | $feed['type'] = 'feed'; | |
afcfe6ca AD |
250 | |
251 | array_push($root['items'], $feed); | |
252 | } | |
253 | ||
254 | $root['param'] = T_sprintf('(%d feeds)', count($root['items'])); | |
afcfe6ca AD |
255 | } |
256 | ||
257 | $fl = array(); | |
258 | $fl['identifier'] = 'id'; | |
259 | $fl['label'] = 'name'; | |
2ecd2df5 AD |
260 | |
261 | if ($_REQUEST['mode'] != 2) { | |
262 | $fl['items'] = array($root); | |
263 | } else { | |
264 | $fl['items'] =& $root['items']; | |
265 | } | |
afcfe6ca AD |
266 | |
267 | print json_encode($fl); | |
268 | return; | |
269 | } | |
270 | ||
271 | function catsortreset() { | |
272 | db_query($this->link, "UPDATE ttrss_feed_categories | |
273 | SET order_id = 0 WHERE owner_uid = " . $_SESSION["uid"]); | |
274 | return; | |
275 | } | |
276 | ||
277 | function feedsortreset() { | |
278 | db_query($this->link, "UPDATE ttrss_feeds | |
279 | SET order_id = 0 WHERE owner_uid = " . $_SESSION["uid"]); | |
280 | return; | |
281 | } | |
282 | ||
5b7bd238 AD |
283 | function togglehiddenfeedcats() { |
284 | set_pref($this->link, '_PREFS_SHOW_EMPTY_CATS', | |
285 | (get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS') ? 'false' : 'true')); | |
286 | } | |
287 | ||
95ee44b3 AD |
288 | private function process_category_order(&$data_map, $item_id, $parent_id = false, $nest_level = 0) { |
289 | $debug = isset($_REQUEST["debug"]); | |
290 | ||
291 | $prefix = ""; | |
292 | for ($i = 0; $i < $nest_level; $i++) | |
293 | $prefix .= " "; | |
294 | ||
295 | if ($debug) _debug("$prefix C: $item_id P: $parent_id"); | |
296 | ||
297 | $bare_item_id = substr($item_id, strpos($item_id, ':')+1); | |
2a060a94 AD |
298 | |
299 | if ($item_id != 'root') { | |
300 | if ($parent_id && $parent_id != 'root') { | |
301 | $parent_bare_id = substr($parent_id, strpos($parent_id, ':')+1); | |
302 | $parent_qpart = db_escape_string($parent_bare_id); | |
303 | } else { | |
304 | $parent_qpart = 'NULL'; | |
305 | } | |
306 | ||
307 | db_query($this->link, "UPDATE ttrss_feed_categories | |
95ee44b3 | 308 | SET parent_cat = $parent_qpart WHERE id = '$bare_item_id' AND |
2a060a94 AD |
309 | owner_uid = " . $_SESSION["uid"]); |
310 | } | |
311 | ||
312 | $order_id = 0; | |
313 | ||
314 | $cat = $data_map[$item_id]; | |
315 | ||
316 | if ($cat && is_array($cat)) { | |
317 | foreach ($cat as $item) { | |
318 | $id = $item['_reference']; | |
319 | $bare_id = substr($id, strpos($id, ':')+1); | |
320 | ||
95ee44b3 | 321 | if ($debug) _debug("$prefix [$order_id] $id/$bare_id"); |
2a060a94 AD |
322 | |
323 | if ($item['_reference']) { | |
324 | ||
325 | if (strpos($id, "FEED") === 0) { | |
326 | ||
95ee44b3 AD |
327 | $cat_id = ($item_id != "root") ? |
328 | db_escape_string($bare_item_id) : "NULL"; | |
329 | ||
49b2401e AD |
330 | $cat_qpart = ($cat_id != 0) ? "cat_id = '$cat_id'" : |
331 | "cat_id = NULL"; | |
332 | ||
2a060a94 | 333 | db_query($this->link, "UPDATE ttrss_feeds |
49b2401e | 334 | SET order_id = $order_id, $cat_qpart |
95ee44b3 | 335 | WHERE id = '$bare_id' AND |
2a060a94 AD |
336 | owner_uid = " . $_SESSION["uid"]); |
337 | ||
338 | } else if (strpos($id, "CAT:") === 0) { | |
95ee44b3 AD |
339 | $this->process_category_order($data_map, $item['_reference'], $item_id, |
340 | $nest_level+1); | |
2a060a94 AD |
341 | |
342 | if ($item_id != 'root') { | |
343 | $parent_qpart = db_escape_string($bare_id); | |
344 | } else { | |
345 | $parent_qpart = 'NULL'; | |
346 | } | |
347 | ||
348 | db_query($this->link, "UPDATE ttrss_feed_categories | |
349 | SET order_id = '$order_id' WHERE id = '$bare_id' AND | |
350 | owner_uid = " . $_SESSION["uid"]); | |
351 | } | |
352 | } | |
353 | ||
354 | ++$order_id; | |
355 | } | |
356 | } | |
357 | } | |
358 | ||
afcfe6ca AD |
359 | function savefeedorder() { |
360 | $data = json_decode($_POST['payload'], true); | |
361 | ||
2a060a94 AD |
362 | #file_put_contents("/tmp/saveorder.json", $_POST['payload']); |
363 | #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true); | |
a26f57e6 | 364 | |
95ee44b3 AD |
365 | if (!is_array($data['items'])) |
366 | $data['items'] = json_decode($data['items'], true); | |
367 | ||
368 | # print_r($data['items']); | |
2a060a94 | 369 | |
afcfe6ca AD |
370 | if (is_array($data) && is_array($data['items'])) { |
371 | $cat_order_id = 0; | |
372 | ||
373 | $data_map = array(); | |
2a060a94 | 374 | $root_item = false; |
afcfe6ca AD |
375 | |
376 | foreach ($data['items'] as $item) { | |
377 | ||
2a060a94 | 378 | # if ($item['id'] != 'root') { |
afcfe6ca AD |
379 | if (is_array($item['items'])) { |
380 | if (isset($item['items']['_reference'])) { | |
381 | $data_map[$item['id']] = array($item['items']); | |
382 | } else { | |
383 | $data_map[$item['id']] =& $item['items']; | |
384 | } | |
385 | } | |
2a060a94 AD |
386 | if ($item['id'] == 'root') { |
387 | $root_item = $item['id']; | |
afcfe6ca AD |
388 | } |
389 | } | |
390 | ||
d04f8c82 | 391 | $this->process_category_order($data_map, $root_item); |
2a060a94 AD |
392 | |
393 | /* foreach ($data['items'][0]['items'] as $item) { | |
afcfe6ca AD |
394 | $id = $item['_reference']; |
395 | $bare_id = substr($id, strpos($id, ':')+1); | |
396 | ||
397 | ++$cat_order_id; | |
398 | ||
399 | if ($bare_id > 0) { | |
400 | db_query($this->link, "UPDATE ttrss_feed_categories | |
401 | SET order_id = '$cat_order_id' WHERE id = '$bare_id' AND | |
402 | owner_uid = " . $_SESSION["uid"]); | |
403 | } | |
404 | ||
405 | $feed_order_id = 0; | |
406 | ||
407 | if (is_array($data_map[$id])) { | |
408 | foreach ($data_map[$id] as $feed) { | |
409 | $id = $feed['_reference']; | |
410 | $feed_id = substr($id, strpos($id, ':')+1); | |
411 | ||
412 | if ($bare_id != 0) | |
413 | $cat_query = "cat_id = '$bare_id'"; | |
414 | else | |
415 | $cat_query = "cat_id = NULL"; | |
416 | ||
417 | db_query($this->link, "UPDATE ttrss_feeds | |
418 | SET order_id = '$feed_order_id', | |
419 | $cat_query | |
420 | WHERE id = '$feed_id' AND | |
421 | owner_uid = " . $_SESSION["uid"]); | |
422 | ||
423 | ++$feed_order_id; | |
424 | } | |
425 | } | |
2a060a94 | 426 | } */ |
afcfe6ca AD |
427 | } |
428 | ||
429 | return; | |
430 | } | |
431 | ||
432 | function removeicon() { | |
433 | $feed_id = db_escape_string($_REQUEST["feed_id"]); | |
434 | ||
435 | $result = db_query($this->link, "SELECT id FROM ttrss_feeds | |
436 | WHERE id = '$feed_id' AND owner_uid = ". $_SESSION["uid"]); | |
437 | ||
438 | if (db_num_rows($result) != 0) { | |
439 | unlink(ICONS_DIR . "/$feed_id.ico"); | |
440 | } | |
441 | ||
442 | return; | |
443 | } | |
444 | ||
445 | function uploadicon() { | |
446 | $icon_file = $_FILES['icon_file']['tmp_name']; | |
447 | $feed_id = db_escape_string($_REQUEST["feed_id"]); | |
448 | ||
449 | if (is_file($icon_file) && $feed_id) { | |
450 | if (filesize($icon_file) < 20000) { | |
451 | ||
452 | $result = db_query($this->link, "SELECT id FROM ttrss_feeds | |
453 | WHERE id = '$feed_id' AND owner_uid = ". $_SESSION["uid"]); | |
454 | ||
455 | if (db_num_rows($result) != 0) { | |
456 | unlink(ICONS_DIR . "/$feed_id.ico"); | |
457 | move_uploaded_file($icon_file, ICONS_DIR . "/$feed_id.ico"); | |
458 | $rc = 0; | |
459 | } else { | |
460 | $rc = 2; | |
461 | } | |
462 | } else { | |
463 | $rc = 1; | |
464 | } | |
465 | } else { | |
466 | $rc = 2; | |
467 | } | |
468 | ||
469 | print "<script type=\"text/javascript\">"; | |
470 | print "parent.uploadIconHandler($rc);"; | |
471 | print "</script>"; | |
472 | return; | |
473 | } | |
474 | ||
475 | function editfeed() { | |
476 | global $purge_intervals; | |
477 | global $update_intervals; | |
afcfe6ca AD |
478 | |
479 | $feed_id = db_escape_string($_REQUEST["id"]); | |
480 | ||
481 | $result = db_query($this->link, | |
482 | "SELECT * FROM ttrss_feeds WHERE id = '$feed_id' AND | |
483 | owner_uid = " . $_SESSION["uid"]); | |
484 | ||
485 | $title = htmlspecialchars(db_fetch_result($result, | |
486 | 0, "title")); | |
487 | ||
488 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$feed_id\">"; | |
489 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-feeds\">"; | |
490 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"editSave\">"; | |
491 | ||
492 | print "<div class=\"dlgSec\">".__("Feed")."</div>"; | |
493 | print "<div class=\"dlgSecCont\">"; | |
494 | ||
495 | /* Title */ | |
496 | ||
497 | print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" | |
498 | placeHolder=\"".__("Feed Title")."\" | |
499 | style=\"font-size : 16px; width: 20em\" name=\"title\" value=\"$title\">"; | |
500 | ||
501 | /* Feed URL */ | |
502 | ||
503 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
504 | $feed_url = htmlspecialchars(db_fetch_result($result, | |
505 | 0, "feed_url")); | |
506 | ||
507 | print "<hr/>"; | |
508 | ||
509 | print __('URL:') . " "; | |
510 | print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" | |
511 | placeHolder=\"".__("Feed URL")."\" | |
512 | regExp='^(http|https)://.*' style=\"width : 20em\" | |
513 | name=\"feed_url\" value=\"$feed_url\">"; | |
514 | ||
515 | $last_error = db_fetch_result($result, 0, "last_error"); | |
516 | ||
517 | if ($last_error) { | |
518 | print " <span title=\"".htmlspecialchars($last_error)."\" | |
519 | class=\"feed_error\">(error)</span>"; | |
520 | ||
521 | } | |
522 | ||
523 | /* Category */ | |
524 | ||
525 | if (get_pref($this->link, 'ENABLE_FEED_CATS')) { | |
526 | ||
527 | $cat_id = db_fetch_result($result, 0, "cat_id"); | |
528 | ||
529 | print "<hr/>"; | |
530 | ||
531 | print __('Place in category:') . " "; | |
532 | ||
533 | print_feed_cat_select($this->link, "cat_id", $cat_id, | |
534 | 'dojoType="dijit.form.Select"'); | |
535 | } | |
536 | ||
537 | print "</div>"; | |
538 | ||
539 | print "<div class=\"dlgSec\">".__("Update")."</div>"; | |
540 | print "<div class=\"dlgSecCont\">"; | |
541 | ||
542 | /* Update Interval */ | |
543 | ||
544 | $update_interval = db_fetch_result($result, 0, "update_interval"); | |
545 | ||
546 | print_select_hash("update_interval", $update_interval, $update_intervals, | |
547 | 'dojoType="dijit.form.Select"'); | |
548 | ||
19b3992b | 549 | /* Purge intl */ |
afcfe6ca AD |
550 | |
551 | $purge_interval = db_fetch_result($result, 0, "purge_interval"); | |
552 | ||
afcfe6ca AD |
553 | print "<hr/>"; |
554 | print __('Article purging:') . " "; | |
555 | ||
556 | print_select_hash("purge_interval", $purge_interval, $purge_intervals, | |
557 | 'dojoType="dijit.form.Select" ' . | |
558 | ((FORCE_ARTICLE_PURGE == 0) ? "" : 'disabled="1"')); | |
559 | ||
560 | print "</div>"; | |
561 | print "<div class=\"dlgSec\">".__("Authentication")."</div>"; | |
562 | print "<div class=\"dlgSecCont\">"; | |
563 | ||
564 | $auth_login = htmlspecialchars(db_fetch_result($result, 0, "auth_login")); | |
565 | ||
566 | print "<input dojoType=\"dijit.form.TextBox\" id=\"feedEditDlg_login\" | |
567 | placeHolder=\"".__("Login")."\" | |
568 | name=\"auth_login\" value=\"$auth_login\"><hr/>"; | |
569 | ||
570 | $auth_pass = htmlspecialchars(db_fetch_result($result, 0, "auth_pass")); | |
571 | ||
572 | print "<input dojoType=\"dijit.form.TextBox\" type=\"password\" name=\"auth_pass\" | |
573 | placeHolder=\"".__("Password")."\" | |
574 | value=\"$auth_pass\">"; | |
575 | ||
576 | print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedEditDlg_login\" position=\"below\"> | |
577 | ".__('<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.')." | |
578 | </div>"; | |
579 | ||
580 | print "</div>"; | |
581 | print "<div class=\"dlgSec\">".__("Options")."</div>"; | |
582 | print "<div class=\"dlgSecCont\">"; | |
583 | ||
584 | $private = sql_bool_to_bool(db_fetch_result($result, 0, "private")); | |
585 | ||
586 | if ($private) { | |
587 | $checked = "checked=\"1\""; | |
588 | } else { | |
589 | $checked = ""; | |
590 | } | |
591 | ||
592 | print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"private\" id=\"private\" | |
593 | $checked> <label for=\"private\">".__('Hide from Popular feeds')."</label>"; | |
594 | ||
595 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
596 | ||
597 | if ($rtl_content) { | |
598 | $checked = "checked=\"1\""; | |
599 | } else { | |
600 | $checked = ""; | |
601 | } | |
602 | ||
603 | print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\" | |
604 | $checked> <label for=\"rtl_content\">".__('Right-to-left content')."</label>"; | |
605 | ||
606 | $include_in_digest = sql_bool_to_bool(db_fetch_result($result, 0, "include_in_digest")); | |
607 | ||
608 | if ($include_in_digest) { | |
609 | $checked = "checked=\"1\""; | |
610 | } else { | |
611 | $checked = ""; | |
612 | } | |
613 | ||
614 | print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"include_in_digest\" | |
615 | name=\"include_in_digest\" | |
616 | $checked> <label for=\"include_in_digest\">".__('Include in e-mail digest')."</label>"; | |
617 | ||
618 | ||
619 | $always_display_enclosures = sql_bool_to_bool(db_fetch_result($result, 0, "always_display_enclosures")); | |
620 | ||
621 | if ($always_display_enclosures) { | |
622 | $checked = "checked"; | |
623 | } else { | |
624 | $checked = ""; | |
625 | } | |
626 | ||
627 | print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"always_display_enclosures\" | |
628 | name=\"always_display_enclosures\" | |
629 | $checked> <label for=\"always_display_enclosures\">".__('Always display image attachments')."</label>"; | |
630 | ||
631 | ||
632 | $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images")); | |
633 | ||
634 | if ($cache_images) { | |
635 | $checked = "checked=\"1\""; | |
636 | } else { | |
637 | $checked = ""; | |
638 | } | |
639 | ||
3c696512 AD |
640 | print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"cache_images\" |
641 | name=\"cache_images\" | |
afcfe6ca | 642 | $checked> <label for=\"cache_images\">". |
3c696512 | 643 | __('Cache images locally')."</label>"; |
afcfe6ca | 644 | |
87764a50 | 645 | |
1b03e1de AD |
646 | if (defined('_FEEDS_CONTENT_CACHE') && _FEEDS_CONTENT_CACHE) { |
647 | $cache_content = sql_bool_to_bool(db_fetch_result($result, 0, "cache_content")); | |
87764a50 | 648 | |
1b03e1de AD |
649 | if ($cache_content) { |
650 | $checked = "checked=\"1\""; | |
651 | } else { | |
652 | $checked = ""; | |
653 | } | |
654 | ||
655 | print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"cache_content\" | |
87764a50 | 656 | name=\"cache_content\" |
1b03e1de AD |
657 | $checked> <label for=\"cache_content\">". |
658 | __('Cache content locally')."</label>"; | |
659 | ||
660 | } | |
87764a50 | 661 | |
afcfe6ca AD |
662 | $mark_unread_on_update = sql_bool_to_bool(db_fetch_result($result, 0, "mark_unread_on_update")); |
663 | ||
664 | if ($mark_unread_on_update) { | |
665 | $checked = "checked"; | |
666 | } else { | |
667 | $checked = ""; | |
668 | } | |
669 | ||
670 | print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"mark_unread_on_update\" | |
671 | name=\"mark_unread_on_update\" | |
672 | $checked> <label for=\"mark_unread_on_update\">".__('Mark updated articles as unread')."</label>"; | |
673 | ||
674 | $update_on_checksum_change = sql_bool_to_bool(db_fetch_result($result, 0, "update_on_checksum_change")); | |
675 | ||
676 | if ($update_on_checksum_change) { | |
677 | $checked = "checked"; | |
678 | } else { | |
679 | $checked = ""; | |
680 | } | |
681 | ||
682 | print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"update_on_checksum_change\" | |
683 | name=\"update_on_checksum_change\" | |
684 | $checked> <label for=\"update_on_checksum_change\">".__('Mark posts as updated on content change')."</label>"; | |
685 | ||
686 | print "</div>"; | |
687 | ||
688 | /* Icon */ | |
689 | ||
690 | print "<div class=\"dlgSec\">".__("Icon")."</div>"; | |
691 | print "<div class=\"dlgSecCont\">"; | |
692 | ||
693 | print "<iframe name=\"icon_upload_iframe\" | |
694 | style=\"width: 400px; height: 100px; display: none;\"></iframe>"; | |
695 | ||
696 | print "<form style='display : block' target=\"icon_upload_iframe\" | |
697 | enctype=\"multipart/form-data\" method=\"POST\" | |
698 | action=\"backend.php\"> | |
699 | <input id=\"icon_file\" size=\"10\" name=\"icon_file\" type=\"file\"> | |
700 | <input type=\"hidden\" name=\"op\" value=\"pref-feeds\"> | |
701 | <input type=\"hidden\" name=\"feed_id\" value=\"$feed_id\"> | |
702 | <input type=\"hidden\" name=\"method\" value=\"uploadicon\"> | |
703 | <button dojoType=\"dijit.form.Button\" onclick=\"return uploadFeedIcon();\" | |
704 | type=\"submit\">".__('Replace')."</button> | |
705 | <button dojoType=\"dijit.form.Button\" onclick=\"return removeFeedIcon($feed_id);\" | |
706 | type=\"submit\">".__('Remove')."</button> | |
707 | </form>"; | |
708 | ||
709 | print "</div>"; | |
710 | ||
711 | $title = htmlspecialchars($title, ENT_QUOTES); | |
712 | ||
713 | print "<div class='dlgButtons'> | |
714 | <div style=\"float : left\"> | |
715 | <button dojoType=\"dijit.form.Button\" onclick='return unsubscribeFeed($feed_id, \"$title\")'>". | |
716 | __('Unsubscribe')."</button>"; | |
717 | ||
718 | if (PUBSUBHUBBUB_ENABLED) { | |
719 | $pubsub_state = db_fetch_result($result, 0, "pubsub_state"); | |
720 | $pubsub_btn_disabled = ($pubsub_state == 2) ? "" : "disabled=\"1\""; | |
721 | ||
722 | print "<button dojoType=\"dijit.form.Button\" id=\"pubsubReset_Btn\" $pubsub_btn_disabled | |
723 | onclick='return resetPubSub($feed_id, \"$title\")'>".__('Resubscribe to push updates'). | |
724 | "</button>"; | |
725 | } | |
726 | ||
727 | print "</div>"; | |
728 | ||
729 | print "<div dojoType=\"dijit.Tooltip\" connectId=\"pubsubReset_Btn\" position=\"below\">". | |
730 | __('Resets PubSubHubbub subscription status for push-enabled feeds.')."</div>"; | |
731 | ||
732 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedEditDlg').execute()\">".__('Save')."</button> | |
733 | <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedEditDlg').hide()\">".__('Cancel')."</button> | |
734 | </div>"; | |
735 | ||
736 | return; | |
737 | } | |
738 | ||
739 | function editfeeds() { | |
740 | global $purge_intervals; | |
741 | global $update_intervals; | |
46da73c2 | 742 | |
afcfe6ca AD |
743 | $feed_ids = db_escape_string($_REQUEST["ids"]); |
744 | ||
ca6a0741 AD |
745 | print "<div class=\"dialogNotice\">" . __("Enable the options you wish to apply using checkboxes on the right:") . "</div>"; |
746 | ||
afcfe6ca AD |
747 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"ids\" value=\"$feed_ids\">"; |
748 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-feeds\">"; | |
749 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"batchEditSave\">"; | |
750 | ||
751 | print "<div class=\"dlgSec\">".__("Feed")."</div>"; | |
752 | print "<div class=\"dlgSecCont\">"; | |
753 | ||
754 | /* Title */ | |
755 | ||
756 | print "<input dojoType=\"dijit.form.ValidationTextBox\" | |
757 | disabled=\"1\" style=\"font-size : 16px; width : 20em;\" required=\"1\" | |
758 | name=\"title\" value=\"$title\">"; | |
759 | ||
760 | $this->batch_edit_cbox("title"); | |
761 | ||
762 | /* Feed URL */ | |
763 | ||
764 | print "<br/>"; | |
765 | ||
766 | print __('URL:') . " "; | |
767 | print "<input dojoType=\"dijit.form.ValidationTextBox\" disabled=\"1\" | |
768 | required=\"1\" regExp='^(http|https)://.*' style=\"width : 20em\" | |
769 | name=\"feed_url\" value=\"$feed_url\">"; | |
770 | ||
771 | $this->batch_edit_cbox("feed_url"); | |
772 | ||
773 | /* Category */ | |
774 | ||
775 | if (get_pref($this->link, 'ENABLE_FEED_CATS')) { | |
776 | ||
777 | print "<br/>"; | |
778 | ||
779 | print __('Place in category:') . " "; | |
780 | ||
781 | print_feed_cat_select($this->link, "cat_id", $cat_id, | |
782 | 'disabled="1" dojoType="dijit.form.Select"'); | |
783 | ||
784 | $this->batch_edit_cbox("cat_id"); | |
785 | ||
786 | } | |
787 | ||
788 | print "</div>"; | |
789 | ||
790 | print "<div class=\"dlgSec\">".__("Update")."</div>"; | |
791 | print "<div class=\"dlgSecCont\">"; | |
792 | ||
793 | /* Update Interval */ | |
794 | ||
795 | print_select_hash("update_interval", $update_interval, $update_intervals, | |
796 | 'disabled="1" dojoType="dijit.form.Select"'); | |
797 | ||
798 | $this->batch_edit_cbox("update_interval"); | |
799 | ||
afcfe6ca AD |
800 | /* Purge intl */ |
801 | ||
802 | if (FORCE_ARTICLE_PURGE == 0) { | |
803 | ||
804 | print "<br/>"; | |
805 | ||
806 | print __('Article purging:') . " "; | |
807 | ||
808 | print_select_hash("purge_interval", $purge_interval, $purge_intervals, | |
809 | 'disabled="1" dojoType="dijit.form.Select"'); | |
810 | ||
811 | $this->batch_edit_cbox("purge_interval"); | |
812 | } | |
813 | ||
814 | print "</div>"; | |
815 | print "<div class=\"dlgSec\">".__("Authentication")."</div>"; | |
816 | print "<div class=\"dlgSecCont\">"; | |
817 | ||
818 | print "<input dojoType=\"dijit.form.TextBox\" | |
819 | placeHolder=\"".__("Login")."\" disabled=\"1\" | |
820 | name=\"auth_login\" value=\"$auth_login\">"; | |
821 | ||
822 | $this->batch_edit_cbox("auth_login"); | |
823 | ||
824 | print "<br/><input dojoType=\"dijit.form.TextBox\" type=\"password\" name=\"auth_pass\" | |
825 | placeHolder=\"".__("Password")."\" disabled=\"1\" | |
826 | value=\"$auth_pass\">"; | |
827 | ||
828 | $this->batch_edit_cbox("auth_pass"); | |
829 | ||
830 | print "</div>"; | |
831 | print "<div class=\"dlgSec\">".__("Options")."</div>"; | |
832 | print "<div class=\"dlgSecCont\">"; | |
833 | ||
834 | print "<input disabled=\"1\" type=\"checkbox\" name=\"private\" id=\"private\" | |
835 | dojoType=\"dijit.form.CheckBox\"> <label id=\"private_l\" class='insensitive' for=\"private\">".__('Hide from Popular feeds')."</label>"; | |
836 | ||
837 | print " "; $this->batch_edit_cbox("private", "private_l"); | |
838 | ||
839 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\" | |
840 | dojoType=\"dijit.form.CheckBox\"> <label class='insensitive' id=\"rtl_content_l\" for=\"rtl_content\">".__('Right-to-left content')."</label>"; | |
841 | ||
842 | print " "; $this->batch_edit_cbox("rtl_content", "rtl_content_l"); | |
843 | ||
844 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"include_in_digest\" | |
845 | name=\"include_in_digest\" | |
846 | dojoType=\"dijit.form.CheckBox\"> <label id=\"include_in_digest_l\" class='insensitive' for=\"include_in_digest\">".__('Include in e-mail digest')."</label>"; | |
847 | ||
848 | print " "; $this->batch_edit_cbox("include_in_digest", "include_in_digest_l"); | |
849 | ||
850 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"always_display_enclosures\" | |
851 | name=\"always_display_enclosures\" | |
852 | dojoType=\"dijit.form.CheckBox\"> <label id=\"always_display_enclosures_l\" class='insensitive' for=\"always_display_enclosures\">".__('Always display image attachments')."</label>"; | |
853 | ||
854 | print " "; $this->batch_edit_cbox("always_display_enclosures", "always_display_enclosures_l"); | |
855 | ||
3c696512 AD |
856 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"cache_images\" |
857 | name=\"cache_images\" | |
858 | dojoType=\"dijit.form.CheckBox\"> <label class='insensitive' id=\"cache_images_l\" | |
859 | for=\"cache_images\">". | |
860 | __('Cache images locally')."</label>"; | |
afcfe6ca | 861 | |
3c696512 | 862 | print " "; $this->batch_edit_cbox("cache_images", "cache_images_l"); |
afcfe6ca AD |
863 | |
864 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"mark_unread_on_update\" | |
865 | name=\"mark_unread_on_update\" | |
866 | dojoType=\"dijit.form.CheckBox\"> <label id=\"mark_unread_on_update_l\" class='insensitive' for=\"mark_unread_on_update\">".__('Mark updated articles as unread')."</label>"; | |
867 | ||
868 | print " "; $this->batch_edit_cbox("mark_unread_on_update", "mark_unread_on_update_l"); | |
869 | ||
870 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"update_on_checksum_change\" | |
871 | name=\"update_on_checksum_change\" | |
872 | dojoType=\"dijit.form.CheckBox\"> <label id=\"update_on_checksum_change_l\" class='insensitive' for=\"update_on_checksum_change\">".__('Mark posts as updated on content change')."</label>"; | |
873 | ||
874 | print " "; $this->batch_edit_cbox("update_on_checksum_change", "update_on_checksum_change_l"); | |
875 | ||
876 | print "</div>"; | |
877 | ||
878 | print "<div class='dlgButtons'> | |
879 | <button dojoType=\"dijit.form.Button\" | |
880 | onclick=\"return dijit.byId('feedEditDlg').execute()\">". | |
881 | __('Save')."</button> | |
882 | <button dojoType=\"dijit.form.Button\" | |
883 | onclick=\"return dijit.byId('feedEditDlg').hide()\">". | |
884 | __('Cancel')."</button> | |
885 | </div>"; | |
886 | ||
887 | return; | |
888 | } | |
889 | ||
890 | function batchEditSave() { | |
3a76e2a2 | 891 | return $this->editsaveops(true); |
afcfe6ca | 892 | } |
46da73c2 | 893 | |
afcfe6ca | 894 | function editSave() { |
3a76e2a2 | 895 | return $this->editsaveops(false); |
afcfe6ca | 896 | } |
46da73c2 AD |
897 | |
898 | function editsaveops($batch) { | |
899 | ||
afcfe6ca AD |
900 | $feed_title = db_escape_string(trim($_POST["title"])); |
901 | $feed_link = db_escape_string(trim($_POST["feed_url"])); | |
902 | $upd_intl = (int) db_escape_string($_POST["update_interval"]); | |
903 | $purge_intl = (int) db_escape_string($_POST["purge_interval"]); | |
904 | $feed_id = (int) db_escape_string($_POST["id"]); /* editSave */ | |
905 | $feed_ids = db_escape_string($_POST["ids"]); /* batchEditSave */ | |
906 | $cat_id = (int) db_escape_string($_POST["cat_id"]); | |
907 | $auth_login = db_escape_string(trim($_POST["auth_login"])); | |
908 | $auth_pass = db_escape_string(trim($_POST["auth_pass"])); | |
909 | $private = checkbox_to_sql_bool(db_escape_string($_POST["private"])); | |
910 | $rtl_content = checkbox_to_sql_bool(db_escape_string($_POST["rtl_content"])); | |
911 | $include_in_digest = checkbox_to_sql_bool( | |
912 | db_escape_string($_POST["include_in_digest"])); | |
913 | $cache_images = checkbox_to_sql_bool( | |
914 | db_escape_string($_POST["cache_images"])); | |
87764a50 AD |
915 | $cache_content = checkbox_to_sql_bool( |
916 | db_escape_string($_POST["cache_content"])); | |
afcfe6ca AD |
917 | |
918 | $always_display_enclosures = checkbox_to_sql_bool( | |
919 | db_escape_string($_POST["always_display_enclosures"])); | |
920 | ||
921 | $mark_unread_on_update = checkbox_to_sql_bool( | |
922 | db_escape_string($_POST["mark_unread_on_update"])); | |
923 | ||
924 | $update_on_checksum_change = checkbox_to_sql_bool( | |
925 | db_escape_string($_POST["update_on_checksum_change"])); | |
926 | ||
927 | if (get_pref($this->link, 'ENABLE_FEED_CATS')) { | |
928 | if ($cat_id && $cat_id != 0) { | |
929 | $category_qpart = "cat_id = '$cat_id',"; | |
930 | $category_qpart_nocomma = "cat_id = '$cat_id'"; | |
931 | } else { | |
932 | $category_qpart = 'cat_id = NULL,'; | |
933 | $category_qpart_nocomma = 'cat_id = NULL'; | |
934 | } | |
935 | } else { | |
936 | $category_qpart = ""; | |
937 | $category_qpart_nocomma = ""; | |
938 | } | |
939 | ||
3a76e2a2 | 940 | if (!$batch) { |
afcfe6ca AD |
941 | |
942 | $result = db_query($this->link, "UPDATE ttrss_feeds SET | |
943 | $category_qpart | |
944 | title = '$feed_title', feed_url = '$feed_link', | |
945 | update_interval = '$upd_intl', | |
946 | purge_interval = '$purge_intl', | |
947 | auth_login = '$auth_login', | |
948 | auth_pass = '$auth_pass', | |
949 | private = $private, | |
950 | rtl_content = $rtl_content, | |
87764a50 AD |
951 | cache_images = $cache_images, |
952 | cache_content = $cache_content, | |
afcfe6ca AD |
953 | include_in_digest = $include_in_digest, |
954 | always_display_enclosures = $always_display_enclosures, | |
955 | mark_unread_on_update = $mark_unread_on_update, | |
715a8239 | 956 | update_on_checksum_change = $update_on_checksum_change |
19b3992b | 957 | WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); |
afcfe6ca | 958 | |
3a76e2a2 | 959 | } else { |
afcfe6ca AD |
960 | $feed_data = array(); |
961 | ||
962 | foreach (array_keys($_POST) as $k) { | |
963 | if ($k != "op" && $k != "method" && $k != "ids") { | |
964 | $feed_data[$k] = $_POST[$k]; | |
965 | } | |
966 | } | |
967 | ||
968 | db_query($this->link, "BEGIN"); | |
969 | ||
970 | foreach (array_keys($feed_data) as $k) { | |
971 | ||
972 | $qpart = ""; | |
973 | ||
974 | switch ($k) { | |
975 | case "title": | |
976 | $qpart = "title = '$feed_title'"; | |
977 | break; | |
978 | ||
979 | case "feed_url": | |
980 | $qpart = "feed_url = '$feed_link'"; | |
981 | break; | |
982 | ||
983 | case "update_interval": | |
984 | $qpart = "update_interval = '$upd_intl'"; | |
985 | break; | |
986 | ||
987 | case "purge_interval": | |
988 | $qpart = "purge_interval = '$purge_intl'"; | |
989 | break; | |
990 | ||
991 | case "auth_login": | |
992 | $qpart = "auth_login = '$auth_login'"; | |
993 | break; | |
994 | ||
995 | case "auth_pass": | |
996 | $qpart = "auth_pass = '$auth_pass'"; | |
997 | break; | |
998 | ||
999 | case "private": | |
a498d18b | 1000 | $qpart = "private = $private"; |
afcfe6ca AD |
1001 | break; |
1002 | ||
1003 | case "include_in_digest": | |
a498d18b | 1004 | $qpart = "include_in_digest = $include_in_digest"; |
afcfe6ca AD |
1005 | break; |
1006 | ||
1007 | case "always_display_enclosures": | |
a498d18b | 1008 | $qpart = "always_display_enclosures = $always_display_enclosures"; |
afcfe6ca AD |
1009 | break; |
1010 | ||
1011 | case "mark_unread_on_update": | |
a498d18b | 1012 | $qpart = "mark_unread_on_update = $mark_unread_on_update"; |
afcfe6ca AD |
1013 | break; |
1014 | ||
1015 | case "update_on_checksum_change": | |
a498d18b | 1016 | $qpart = "update_on_checksum_change = $update_on_checksum_change"; |
afcfe6ca AD |
1017 | break; |
1018 | ||
1019 | case "cache_images": | |
a498d18b | 1020 | $qpart = "cache_images = $cache_images"; |
afcfe6ca AD |
1021 | break; |
1022 | ||
87764a50 AD |
1023 | case "cache_content": |
1024 | $qpart = "cache_content = $cache_content"; | |
1025 | break; | |
1026 | ||
afcfe6ca | 1027 | case "rtl_content": |
a498d18b | 1028 | $qpart = "rtl_content = $rtl_content"; |
afcfe6ca AD |
1029 | break; |
1030 | ||
afcfe6ca AD |
1031 | case "cat_id": |
1032 | $qpart = $category_qpart_nocomma; | |
1033 | break; | |
1034 | ||
1035 | } | |
1036 | ||
1037 | if ($qpart) { | |
1038 | db_query($this->link, | |
1039 | "UPDATE ttrss_feeds SET $qpart WHERE id IN ($feed_ids) | |
1040 | AND owner_uid = " . $_SESSION["uid"]); | |
1041 | print "<br/>"; | |
1042 | } | |
1043 | } | |
1044 | ||
1045 | db_query($this->link, "COMMIT"); | |
1046 | } | |
1047 | return; | |
1048 | } | |
1049 | ||
1050 | function resetPubSub() { | |
1051 | ||
1052 | $ids = db_escape_string($_REQUEST["ids"]); | |
1053 | ||
1054 | db_query($this->link, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ($ids) | |
1055 | AND owner_uid = " . $_SESSION["uid"]); | |
1056 | ||
1057 | return; | |
1058 | } | |
1059 | ||
1060 | function remove() { | |
1061 | ||
1062 | $ids = split(",", db_escape_string($_REQUEST["ids"])); | |
1063 | ||
1064 | foreach ($ids as $id) { | |
1065 | remove_feed($this->link, $id, $_SESSION["uid"]); | |
1066 | } | |
1067 | ||
1068 | return; | |
1069 | } | |
1070 | ||
1071 | function clear() { | |
1072 | $id = db_escape_string($_REQUEST["id"]); | |
1073 | clear_feed_articles($this->link, $id); | |
1074 | } | |
1075 | ||
1076 | function rescore() { | |
92c14e9d AD |
1077 | require_once "rssfuncs.php"; |
1078 | ||
afcfe6ca AD |
1079 | $ids = split(",", db_escape_string($_REQUEST["ids"])); |
1080 | ||
1081 | foreach ($ids as $id) { | |
1082 | ||
1083 | $filters = load_filters($this->link, $id, $_SESSION["uid"], 6); | |
1084 | ||
1085 | $result = db_query($this->link, "SELECT | |
1086 | title, content, link, ref_id, author,". | |
1087 | SUBSTRING_FOR_DATE."(updated, 1, 19) AS updated | |
1088 | FROM | |
1089 | ttrss_user_entries, ttrss_entries | |
1090 | WHERE ref_id = id AND feed_id = '$id' AND | |
1091 | owner_uid = " .$_SESSION['uid']." | |
1092 | "); | |
1093 | ||
1094 | $scores = array(); | |
1095 | ||
1096 | while ($line = db_fetch_assoc($result)) { | |
1097 | ||
1098 | $tags = get_article_tags($this->link, $line["ref_id"]); | |
1099 | ||
1100 | $article_filters = get_article_filters($filters, $line['title'], | |
1101 | $line['content'], $line['link'], strtotime($line['updated']), | |
1102 | $line['author'], $tags); | |
1103 | ||
1104 | $new_score = calculate_article_score($article_filters); | |
1105 | ||
1106 | if (!$scores[$new_score]) $scores[$new_score] = array(); | |
1107 | ||
1108 | array_push($scores[$new_score], $line['ref_id']); | |
1109 | } | |
1110 | ||
1111 | foreach (array_keys($scores) as $s) { | |
1112 | if ($s > 1000) { | |
1113 | db_query($this->link, "UPDATE ttrss_user_entries SET score = '$s', | |
1114 | marked = true WHERE | |
1115 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
1116 | } else if ($s < -500) { | |
1117 | db_query($this->link, "UPDATE ttrss_user_entries SET score = '$s', | |
1118 | unread = false WHERE | |
1119 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
1120 | } else { | |
1121 | db_query($this->link, "UPDATE ttrss_user_entries SET score = '$s' WHERE | |
1122 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
1123 | } | |
1124 | } | |
1125 | } | |
1126 | ||
1127 | print __("All done."); | |
1128 | ||
1129 | } | |
1130 | ||
1131 | function rescoreAll() { | |
1132 | ||
1133 | $result = db_query($this->link, | |
1134 | "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']); | |
1135 | ||
1136 | while ($feed_line = db_fetch_assoc($result)) { | |
1137 | ||
1138 | $id = $feed_line["id"]; | |
1139 | ||
1140 | $filters = load_filters($this->link, $id, $_SESSION["uid"], 6); | |
1141 | ||
1142 | $tmp_result = db_query($this->link, "SELECT | |
1143 | title, content, link, ref_id, author,". | |
1144 | SUBSTRING_FOR_DATE."(updated, 1, 19) AS updated | |
1145 | FROM | |
1146 | ttrss_user_entries, ttrss_entries | |
1147 | WHERE ref_id = id AND feed_id = '$id' AND | |
1148 | owner_uid = " .$_SESSION['uid']." | |
1149 | "); | |
1150 | ||
1151 | $scores = array(); | |
1152 | ||
1153 | while ($line = db_fetch_assoc($tmp_result)) { | |
1154 | ||
1155 | $tags = get_article_tags($this->link, $line["ref_id"]); | |
1156 | ||
1157 | $article_filters = get_article_filters($filters, $line['title'], | |
1158 | $line['content'], $line['link'], strtotime($line['updated']), | |
1159 | $line['author'], $tags); | |
1160 | ||
1161 | $new_score = calculate_article_score($article_filters); | |
1162 | ||
1163 | if (!$scores[$new_score]) $scores[$new_score] = array(); | |
1164 | ||
1165 | array_push($scores[$new_score], $line['ref_id']); | |
1166 | } | |
1167 | ||
1168 | foreach (array_keys($scores) as $s) { | |
1169 | if ($s > 1000) { | |
1170 | db_query($this->link, "UPDATE ttrss_user_entries SET score = '$s', | |
1171 | marked = true WHERE | |
1172 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
1173 | } else { | |
1174 | db_query($this->link, "UPDATE ttrss_user_entries SET score = '$s' WHERE | |
1175 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
1176 | } | |
1177 | } | |
1178 | } | |
1179 | ||
1180 | print __("All done."); | |
1181 | ||
1182 | } | |
1183 | ||
afcfe6ca AD |
1184 | function categorize() { |
1185 | $ids = split(",", db_escape_string($_REQUEST["ids"])); | |
1186 | ||
1187 | $cat_id = db_escape_string($_REQUEST["cat_id"]); | |
1188 | ||
1189 | if ($cat_id == 0) { | |
1190 | $cat_id_qpart = 'NULL'; | |
1191 | } else { | |
1192 | $cat_id_qpart = "'$cat_id'"; | |
1193 | } | |
1194 | ||
1195 | db_query($this->link, "BEGIN"); | |
1196 | ||
1197 | foreach ($ids as $id) { | |
1198 | ||
1199 | db_query($this->link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart | |
1200 | WHERE id = '$id' | |
1201 | AND owner_uid = " . $_SESSION["uid"]); | |
1202 | ||
1203 | } | |
1204 | ||
1205 | db_query($this->link, "COMMIT"); | |
1206 | } | |
1207 | ||
28537341 AD |
1208 | function removeCat() { |
1209 | $ids = split(",", db_escape_string($_REQUEST["ids"])); | |
1210 | foreach ($ids as $id) { | |
1211 | remove_feed_category($this->link, $id, $_SESSION["uid"]); | |
1212 | } | |
1213 | } | |
1214 | ||
1215 | function addCat() { | |
1216 | $feed_cat = db_escape_string(trim($_REQUEST["cat"])); | |
1217 | ||
1218 | add_feed_category($this->link, $feed_cat); | |
1219 | } | |
1220 | ||
afcfe6ca AD |
1221 | function index() { |
1222 | ||
1223 | print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">"; | |
1224 | print "<div id=\"pref-feeds-feeds\" dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Feeds')."\">"; | |
1225 | ||
1226 | $result = db_query($this->link, "SELECT COUNT(id) AS num_errors | |
1227 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]); | |
1228 | ||
1229 | $num_errors = db_fetch_result($result, 0, "num_errors"); | |
1230 | ||
1231 | if ($num_errors > 0) { | |
1232 | ||
1233 | $error_button = "<button dojoType=\"dijit.form.Button\" | |
1234 | onclick=\"showFeedsWithErrors()\" id=\"errorButton\">" . | |
1235 | __("Feeds with errors") . "</button>"; | |
1236 | } | |
1237 | ||
1238 | if (DB_TYPE == "pgsql") { | |
1239 | $interval_qpart = "NOW() - INTERVAL '3 months'"; | |
1240 | } else { | |
1241 | $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)"; | |
1242 | } | |
1243 | ||
1244 | $result = db_query($this->link, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE | |
1245 | (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE | |
1246 | ttrss_entries.id = ref_id AND | |
1247 | ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND | |
1248 | ttrss_feeds.owner_uid = ".$_SESSION["uid"]); | |
1249 | ||
1250 | $num_inactive = db_fetch_result($result, 0, "num_inactive"); | |
1251 | ||
1252 | if ($num_inactive > 0) { | |
1253 | $inactive_button = "<button dojoType=\"dijit.form.Button\" | |
1254 | onclick=\"showInactiveFeeds()\">" . | |
1255 | __("Inactive feeds") . "</button>"; | |
1256 | } | |
1257 | ||
1258 | $feed_search = db_escape_string($_REQUEST["search"]); | |
1259 | ||
1260 | if (array_key_exists("search", $_REQUEST)) { | |
1261 | $_SESSION["prefs_feed_search"] = $feed_search; | |
1262 | } else { | |
1263 | $feed_search = $_SESSION["prefs_feed_search"]; | |
1264 | } | |
1265 | ||
1266 | print '<div dojoType="dijit.layout.BorderContainer" gutters="false">'; | |
1267 | ||
1268 | print "<div region='top' dojoType=\"dijit.Toolbar\">"; #toolbar | |
1269 | ||
1270 | print "<div style='float : right; padding-right : 4px;'> | |
1271 | <input dojoType=\"dijit.form.TextBox\" id=\"feed_search\" size=\"20\" type=\"search\" | |
1272 | value=\"$feed_search\"> | |
1273 | <button dojoType=\"dijit.form.Button\" onclick=\"updateFeedList()\">". | |
1274 | __('Search')."</button> | |
1275 | </div>"; | |
1276 | ||
1277 | print "<div dojoType=\"dijit.form.DropDownButton\">". | |
1278 | "<span>" . __('Select')."</span>"; | |
1279 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
1280 | print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(true)\" | |
1281 | dojoType=\"dijit.MenuItem\">".__('All')."</div>"; | |
1282 | print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(false)\" | |
1283 | dojoType=\"dijit.MenuItem\">".__('None')."</div>"; | |
1284 | print "</div></div>"; | |
1285 | ||
1286 | print "<div dojoType=\"dijit.form.DropDownButton\">". | |
1287 | "<span>" . __('Feeds')."</span>"; | |
1288 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
1289 | print "<div onclick=\"quickAddFeed()\" | |
1290 | dojoType=\"dijit.MenuItem\">".__('Subscribe to feed')."</div>"; | |
1291 | print "<div onclick=\"editSelectedFeed()\" | |
1292 | dojoType=\"dijit.MenuItem\">".__('Edit selected feeds')."</div>"; | |
1293 | print "<div onclick=\"resetFeedOrder()\" | |
1294 | dojoType=\"dijit.MenuItem\">".__('Reset sort order')."</div>"; | |
33f0fdd0 AD |
1295 | print "<div onclick=\"batchSubscribe()\" |
1296 | dojoType=\"dijit.MenuItem\">".__('Batch subscribe')."</div>"; | |
afcfe6ca AD |
1297 | print "</div></div>"; |
1298 | ||
1299 | if (get_pref($this->link, 'ENABLE_FEED_CATS')) { | |
1300 | print "<div dojoType=\"dijit.form.DropDownButton\">". | |
1301 | "<span>" . __('Categories')."</span>"; | |
1302 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
5ef071e0 AD |
1303 | print "<div onclick=\"createCategory()\" |
1304 | dojoType=\"dijit.MenuItem\">".__('Add category')."</div>"; | |
5b7bd238 AD |
1305 | print "<div onclick=\"toggleHiddenFeedCats()\" |
1306 | dojoType=\"dijit.MenuItem\">".__('(Un)hide empty categories')."</div>"; | |
afcfe6ca AD |
1307 | print "<div onclick=\"resetCatOrder()\" |
1308 | dojoType=\"dijit.MenuItem\">".__('Reset sort order')."</div>"; | |
fd26d5bf AD |
1309 | print "<div onclick=\"removeSelectedCategories()\" |
1310 | dojoType=\"dijit.MenuItem\">".__('Remove selected')."</div>"; | |
afcfe6ca AD |
1311 | print "</div></div>"; |
1312 | ||
1313 | } | |
1314 | ||
1315 | print $error_button; | |
1316 | print $inactive_button; | |
1317 | ||
1318 | print "<button dojoType=\"dijit.form.Button\" onclick=\"removeSelectedFeeds()\">" | |
1319 | .__('Unsubscribe')."</button dojoType=\"dijit.form.Button\"> "; | |
1320 | ||
1321 | if (defined('_ENABLE_FEED_DEBUGGING')) { | |
1322 | ||
1323 | print "<select id=\"feedActionChooser\" onchange=\"feedActionChange()\"> | |
1324 | <option value=\"facDefault\" selected>".__('More actions...')."</option>"; | |
1325 | ||
1326 | if (FORCE_ARTICLE_PURGE == 0) { | |
1327 | ||
1328 | "<option value=\"facPurge\">".__('Manual purge')."</option>"; | |
1329 | } | |
1330 | ||
1331 | print " | |
1332 | <option value=\"facClear\">".__('Clear feed data')."</option> | |
1333 | <option value=\"facRescore\">".__('Rescore articles')."</option>"; | |
1334 | ||
1335 | print "</select>"; | |
1336 | ||
1337 | } | |
1338 | ||
1339 | print "</div>"; # toolbar | |
1340 | ||
1341 | //print '</div>'; | |
1342 | print '<div dojoType="dijit.layout.ContentPane" region="center">'; | |
1343 | ||
1344 | print "<div id=\"feedlistLoading\"> | |
1345 | <img src='images/indicator_tiny.gif'>". | |
1346 | __("Loading, please wait...")."</div>"; | |
1347 | ||
1348 | print "<div dojoType=\"fox.PrefFeedStore\" jsId=\"feedStore\" | |
1349 | url=\"backend.php?op=pref-feeds&method=getfeedtree\"> | |
1350 | </div> | |
1351 | <div dojoType=\"lib.CheckBoxStoreModel\" jsId=\"feedModel\" store=\"feedStore\" | |
1352 | query=\"{id:'root'}\" rootId=\"root\" rootLabel=\"Feeds\" | |
1353 | childrenAttrs=\"items\" checkboxStrict=\"false\" checkboxAll=\"false\"> | |
1354 | </div> | |
1355 | <div dojoType=\"fox.PrefFeedTree\" id=\"feedTree\" | |
1356 | dndController=\"dijit.tree.dndSource\" | |
1357 | betweenThreshold=\"5\" | |
1358 | model=\"feedModel\" openOnClick=\"false\"> | |
1359 | <script type=\"dojo/method\" event=\"onClick\" args=\"item\"> | |
1360 | var id = String(item.id); | |
1361 | var bare_id = id.substr(id.indexOf(':')+1); | |
1362 | ||
1363 | if (id.match('FEED:')) { | |
1364 | editFeed(bare_id); | |
1365 | } else if (id.match('CAT:')) { | |
1366 | editCat(bare_id, item); | |
1367 | } | |
1368 | </script> | |
1369 | <script type=\"dojo/method\" event=\"onLoad\" args=\"item\"> | |
1370 | Element.hide(\"feedlistLoading\"); | |
1371 | </script> | |
1372 | </div>"; | |
1373 | ||
ba5296a1 AD |
1374 | # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\"> |
1375 | # ".__('<b>Hint:</b> you can drag feeds and categories around.')." | |
1376 | # </div>"; | |
afcfe6ca AD |
1377 | |
1378 | print '</div>'; | |
1379 | print '</div>'; | |
1380 | ||
1381 | print "</div>"; # feeds pane | |
1382 | ||
6c2637d9 | 1383 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('OPML')."\">"; |
afcfe6ca | 1384 | |
566faa14 | 1385 | print "<p>" . __("Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings.") . " "; |
afcfe6ca | 1386 | |
566faa14 | 1387 | print __("Only main settings profile can be migrated using OPML.") . "</p>"; |
afcfe6ca | 1388 | |
55f34b81 | 1389 | print "<iframe id=\"upload_iframe\" |
afcfe6ca AD |
1390 | name=\"upload_iframe\" onload=\"opmlImportComplete(this)\" |
1391 | style=\"width: 400px; height: 100px; display: none;\"></iframe>"; | |
1392 | ||
1393 | print "<form name=\"opml_form\" style='display : block' target=\"upload_iframe\" | |
1394 | enctype=\"multipart/form-data\" method=\"POST\" | |
55f34b81 | 1395 | action=\"backend.php\"> |
afcfe6ca AD |
1396 | <input id=\"opml_file\" name=\"opml_file\" type=\"file\"> |
1397 | <input type=\"hidden\" name=\"op\" value=\"dlg\"> | |
c4c74732 | 1398 | <input type=\"hidden\" name=\"method\" value=\"importOpml\"> |
afcfe6ca | 1399 | <button dojoType=\"dijit.form.Button\" onclick=\"return opmlImport();\" type=\"submit\">" . |
a1159c01 | 1400 | __('Import my OPML') . "</button>"; |
afcfe6ca | 1401 | |
a1159c01 | 1402 | print "<hr>"; |
afcfe6ca AD |
1403 | |
1404 | print "<p>" . __('Filename:') . | |
1405 | " <input type=\"text\" id=\"filename\" value=\"TinyTinyRSS.opml\" /> " . | |
a1159c01 | 1406 | __('Include settings') . "<input type=\"checkbox\" id=\"settings\" checked=\"1\"/>"; |
afcfe6ca | 1407 | |
a1159c01 | 1408 | print "</p><button dojoType=\"dijit.form.Button\" |
afcfe6ca | 1409 | onclick=\"gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked)\" >" . |
a1159c01 | 1410 | __('Export OPML') . "</button></p></form>"; |
afcfe6ca | 1411 | |
a1159c01 | 1412 | print "<hr>"; |
afcfe6ca AD |
1413 | |
1414 | print "<p>".__('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.') . " "; | |
1415 | ||
566faa14 | 1416 | print __("Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds.") . "</p>"; |
afcfe6ca AD |
1417 | |
1418 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('pubOPMLUrl')\">". | |
a1159c01 | 1419 | __('Display published OPML URL')."</button> "; |
afcfe6ca | 1420 | |
699daf58 AD |
1421 | global $pluginhost; |
1422 | $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION, | |
1423 | "hook_prefs_tab_section", "prefFeedsOPML"); | |
1424 | ||
afcfe6ca AD |
1425 | print "</div>"; # pane |
1426 | ||
1427 | if (strpos($_SERVER['HTTP_USER_AGENT'], "Firefox") !== false) { | |
1428 | ||
1429 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Firefox integration')."\">"; | |
1430 | ||
1431 | print "<p>" . __('This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.') . "</p>"; | |
1432 | ||
1433 | print "<p>"; | |
1434 | ||
1435 | print "<button onclick='window.navigator.registerContentHandler(" . | |
1436 | "\"application/vnd.mozilla.maybe.feed\", " . | |
1437 | "\"" . add_feed_url() . "\", " . " \"Tiny Tiny RSS\")'>" . | |
1438 | __('Click here to register this site as a feed reader.') . | |
1439 | "</button>"; | |
1440 | ||
1441 | print "</p>"; | |
1442 | ||
1443 | print "</div>"; # pane | |
1444 | } | |
1445 | ||
e95e7819 | 1446 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Published & shared articles / Generated feeds')."\">"; |
afcfe6ca AD |
1447 | |
1448 | print "<h3>" . __("Published articles and generated feeds") . "</h3>"; | |
1449 | ||
1450 | print "<p>".__('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.')."</p>"; | |
1451 | ||
1452 | $rss_url = '-2::' . htmlspecialchars(get_self_url_prefix() . | |
1453 | "/public.php?op=rss&id=-2&view-mode=all_articles");; | |
1454 | ||
1455 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('generatedFeed', '$rss_url')\">". | |
1456 | __('Display URL')."</button> "; | |
1457 | ||
1458 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return clearFeedAccessKeys()\">". | |
1459 | __('Clear all generated URLs')."</button> "; | |
1460 | ||
1461 | print "<h3>" . __("Articles shared by URL") . "</h3>"; | |
1462 | ||
1463 | print "<p>" . __("You can disable all articles shared by unique URLs here.") . "</p>"; | |
1464 | ||
1465 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return clearArticleAccessKeys()\">". | |
1466 | __('Unshare all articles')."</button> "; | |
1467 | ||
699daf58 AD |
1468 | global $pluginhost; |
1469 | $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION, | |
1470 | "hook_prefs_tab_section", "prefFeedsPublishedGenerated"); | |
1471 | ||
afcfe6ca AD |
1472 | print "</div>"; #pane |
1473 | ||
6065f3ad | 1474 | global $pluginhost; |
de612e7a | 1475 | |
6065f3ad AD |
1476 | $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB, |
1477 | "hook_prefs_tab", "prefFeeds"); | |
1478 | ||
afcfe6ca | 1479 | print "</div>"; #container |
afcfe6ca | 1480 | } |
2ecd2df5 AD |
1481 | |
1482 | private function feedlist_init_cat($cat_id, $hidden = false) { | |
1483 | $obj = array(); | |
1484 | $cat_id = (int) $cat_id; | |
1485 | ||
1486 | if ($cat_id > 0) { | |
1487 | $cat_unread = ccache_find($this->link, $cat_id, $_SESSION["uid"], true); | |
1488 | } else if ($cat_id == 0 || $cat_id == -2) { | |
1489 | $cat_unread = getCategoryUnread($this->link, $cat_id); | |
1490 | } | |
1491 | ||
1492 | $obj['id'] = 'CAT:' . $cat_id; | |
1493 | $obj['items'] = array(); | |
1494 | $obj['name'] = getCategoryTitle($this->link, $cat_id); | |
1495 | $obj['type'] = 'category'; | |
1496 | $obj['unread'] = (int) $cat_unread; | |
1497 | $obj['hidden'] = $hidden; | |
1498 | $obj['bare_id'] = $cat_id; | |
1499 | ||
1500 | return $obj; | |
1501 | } | |
1502 | ||
1503 | private function feedlist_init_feed($feed_id, $title = false, $unread = false, $error = '', $updated = '') { | |
1504 | $obj = array(); | |
1505 | $feed_id = (int) $feed_id; | |
1506 | ||
1507 | if (!$title) | |
1508 | $title = getFeedTitle($this->link, $feed_id, false); | |
1509 | ||
1510 | if ($unread === false) | |
1511 | $unread = getFeedUnread($this->link, $feed_id, false); | |
1512 | ||
1513 | $obj['id'] = 'FEED:' . $feed_id; | |
1514 | $obj['name'] = $title; | |
1515 | $obj['unread'] = (int) $unread; | |
1516 | $obj['type'] = 'feed'; | |
1517 | $obj['error'] = $error; | |
1518 | $obj['updated'] = $updated; | |
1519 | $obj['icon'] = getFeedIcon($feed_id); | |
1520 | $obj['bare_id'] = $feed_id; | |
1521 | ||
1522 | return $obj; | |
1523 | } | |
1524 | ||
bc6fa236 AD |
1525 | function inactiveFeeds() { |
1526 | ||
1527 | if (DB_TYPE == "pgsql") { | |
1528 | $interval_qpart = "NOW() - INTERVAL '3 months'"; | |
1529 | } else { | |
1530 | $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)"; | |
1531 | } | |
1532 | ||
1533 | $result = db_query($this->link, "SELECT ttrss_feeds.title, ttrss_feeds.site_url, | |
1534 | ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article | |
1535 | FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE | |
1536 | (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE | |
1537 | ttrss_entries.id = ref_id AND | |
1538 | ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart | |
1539 | AND ttrss_feeds.owner_uid = ".$_SESSION["uid"]." AND | |
1540 | ttrss_user_entries.feed_id = ttrss_feeds.id AND | |
1541 | ttrss_entries.id = ref_id | |
1542 | GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url | |
1543 | ORDER BY last_article"); | |
1544 | ||
1545 | print "<div class=\"dialogNotice\">" . __("These feeds have not been updated with new content for 3 months (oldest first):") . "</div>"; | |
1546 | ||
1547 | print "<div dojoType=\"dijit.Toolbar\">"; | |
1548 | print "<div dojoType=\"dijit.form.DropDownButton\">". | |
1549 | "<span>" . __('Select')."</span>"; | |
1550 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
1551 | print "<div onclick=\"selectTableRows('prefInactiveFeedList', 'all')\" | |
1552 | dojoType=\"dijit.MenuItem\">".__('All')."</div>"; | |
1553 | print "<div onclick=\"selectTableRows('prefInactiveFeedList', 'none')\" | |
1554 | dojoType=\"dijit.MenuItem\">".__('None')."</div>"; | |
1555 | print "</div></div>"; | |
1556 | print "</div>"; #toolbar | |
1557 | ||
1558 | print "<div class=\"inactiveFeedHolder\">"; | |
1559 | ||
1560 | print "<table width=\"100%\" cellspacing=\"0\" id=\"prefInactiveFeedList\">"; | |
1561 | ||
1562 | $lnum = 1; | |
1563 | ||
1564 | while ($line = db_fetch_assoc($result)) { | |
1565 | ||
1566 | $class = ($lnum % 2) ? "even" : "odd"; | |
1567 | $feed_id = $line["id"]; | |
1568 | $this_row_id = "id=\"FUPDD-$feed_id\""; | |
1569 | ||
1570 | # class needed for selectTableRows() | |
1571 | print "<tr class=\"placeholder\" $this_row_id>"; | |
1572 | ||
1573 | $edit_title = htmlspecialchars($line["title"]); | |
1574 | ||
1575 | # id needed for selectTableRows() | |
1576 | print "<td width='5%' align='center'><input | |
1577 | onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\" | |
1578 | type=\"checkbox\" id=\"FUPDC-$feed_id\"></td>"; | |
1579 | print "<td>"; | |
1580 | ||
1581 | print "<a class=\"visibleLink\" href=\"#\" ". | |
1582 | "title=\"".__("Click to edit feed")."\" ". | |
1583 | "onclick=\"editFeed(".$line["id"].")\">". | |
1584 | htmlspecialchars($line["title"])."</a>"; | |
1585 | ||
1586 | print "</td><td class=\"insensitive\" align='right'>"; | |
1587 | print make_local_datetime($this->link, $line['last_article'], false); | |
1588 | print "</td>"; | |
1589 | print "</tr>"; | |
1590 | ||
1591 | ++$lnum; | |
1592 | } | |
1593 | ||
1594 | print "</table>"; | |
1595 | print "</div>"; | |
1596 | ||
1597 | print "<div class='dlgButtons'>"; | |
1598 | print "<div style='float : left'>"; | |
1599 | print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').removeSelected()\">" | |
1600 | .__('Unsubscribe from selected feeds')."</button> "; | |
1601 | print "</div>"; | |
1602 | ||
1603 | print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').hide()\">". | |
1604 | __('Close this window')."</button>"; | |
1605 | ||
1606 | print "</div>"; | |
1607 | ||
1608 | } | |
1609 | ||
1610 | function feedsWithErrors() { | |
1611 | print "<div class=\"dialogNotice\">" . __("These feeds have not been updated because of errors:") . "</div>"; | |
1612 | ||
1613 | $result = db_query($this->link, "SELECT id,title,feed_url,last_error,site_url | |
1614 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]); | |
1615 | ||
1616 | print "<div dojoType=\"dijit.Toolbar\">"; | |
1617 | print "<div dojoType=\"dijit.form.DropDownButton\">". | |
1618 | "<span>" . __('Select')."</span>"; | |
1619 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
1620 | print "<div onclick=\"selectTableRows('prefErrorFeedList', 'all')\" | |
1621 | dojoType=\"dijit.MenuItem\">".__('All')."</div>"; | |
1622 | print "<div onclick=\"selectTableRows('prefErrorFeedList', 'none')\" | |
1623 | dojoType=\"dijit.MenuItem\">".__('None')."</div>"; | |
1624 | print "</div></div>"; | |
1625 | print "</div>"; #toolbar | |
1626 | ||
1627 | print "<div class=\"inactiveFeedHolder\">"; | |
1628 | ||
1629 | print "<table width=\"100%\" cellspacing=\"0\" id=\"prefErrorFeedList\">"; | |
1630 | ||
1631 | $lnum = 1; | |
1632 | ||
1633 | while ($line = db_fetch_assoc($result)) { | |
1634 | ||
1635 | $class = ($lnum % 2) ? "even" : "odd"; | |
1636 | $feed_id = $line["id"]; | |
1637 | $this_row_id = "id=\"FERDD-$feed_id\""; | |
1638 | ||
1639 | # class needed for selectTableRows() | |
1640 | print "<tr class=\"placeholder\" $this_row_id>"; | |
1641 | ||
1642 | $edit_title = htmlspecialchars($line["title"]); | |
1643 | ||
1644 | # id needed for selectTableRows() | |
1645 | print "<td width='5%' align='center'><input | |
1646 | onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\" | |
1647 | type=\"checkbox\" id=\"FERDC-$feed_id\"></td>"; | |
1648 | print "<td>"; | |
1649 | ||
1650 | print "<a class=\"visibleLink\" href=\"#\" ". | |
1651 | "title=\"".__("Click to edit feed")."\" ". | |
1652 | "onclick=\"editFeed(".$line["id"].")\">". | |
1653 | htmlspecialchars($line["title"])."</a>: "; | |
1654 | ||
1655 | print "<span class=\"insensitive\">"; | |
1656 | print htmlspecialchars($line["last_error"]); | |
1657 | print "</span>"; | |
1658 | ||
1659 | print "</td>"; | |
1660 | print "</tr>"; | |
1661 | ||
1662 | ++$lnum; | |
1663 | } | |
1664 | ||
1665 | print "</table>"; | |
1666 | print "</div>"; | |
1667 | ||
1668 | print "<div class='dlgButtons'>"; | |
1669 | print "<div style='float : left'>"; | |
1670 | print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').removeSelected()\">" | |
1671 | .__('Unsubscribe from selected feeds')."</button> "; | |
1672 | print "</div>"; | |
1673 | ||
1674 | print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').hide()\">". | |
1675 | __('Close this window')."</button>"; | |
1676 | ||
1677 | print "</div>"; | |
1678 | } | |
1679 | ||
afcfe6ca AD |
1680 | } |
1681 | ?> |