]>
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 AD |
645 | $cache_content = sql_bool_to_bool(db_fetch_result($result, 0, "cache_content")); |
646 | ||
647 | if ($cache_content) { | |
648 | $checked = "checked=\"1\""; | |
649 | } else { | |
650 | $checked = ""; | |
651 | } | |
652 | ||
653 | print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"cache_content\" | |
654 | name=\"cache_content\" | |
655 | $checked> <label for=\"cache_content\">". | |
656 | __('Cache content locally')."</label>"; | |
657 | ||
afcfe6ca AD |
658 | $mark_unread_on_update = sql_bool_to_bool(db_fetch_result($result, 0, "mark_unread_on_update")); |
659 | ||
660 | if ($mark_unread_on_update) { | |
661 | $checked = "checked"; | |
662 | } else { | |
663 | $checked = ""; | |
664 | } | |
665 | ||
666 | print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"mark_unread_on_update\" | |
667 | name=\"mark_unread_on_update\" | |
668 | $checked> <label for=\"mark_unread_on_update\">".__('Mark updated articles as unread')."</label>"; | |
669 | ||
670 | $update_on_checksum_change = sql_bool_to_bool(db_fetch_result($result, 0, "update_on_checksum_change")); | |
671 | ||
672 | if ($update_on_checksum_change) { | |
673 | $checked = "checked"; | |
674 | } else { | |
675 | $checked = ""; | |
676 | } | |
677 | ||
678 | print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"update_on_checksum_change\" | |
679 | name=\"update_on_checksum_change\" | |
680 | $checked> <label for=\"update_on_checksum_change\">".__('Mark posts as updated on content change')."</label>"; | |
681 | ||
682 | print "</div>"; | |
683 | ||
684 | /* Icon */ | |
685 | ||
686 | print "<div class=\"dlgSec\">".__("Icon")."</div>"; | |
687 | print "<div class=\"dlgSecCont\">"; | |
688 | ||
689 | print "<iframe name=\"icon_upload_iframe\" | |
690 | style=\"width: 400px; height: 100px; display: none;\"></iframe>"; | |
691 | ||
692 | print "<form style='display : block' target=\"icon_upload_iframe\" | |
693 | enctype=\"multipart/form-data\" method=\"POST\" | |
694 | action=\"backend.php\"> | |
695 | <input id=\"icon_file\" size=\"10\" name=\"icon_file\" type=\"file\"> | |
696 | <input type=\"hidden\" name=\"op\" value=\"pref-feeds\"> | |
697 | <input type=\"hidden\" name=\"feed_id\" value=\"$feed_id\"> | |
698 | <input type=\"hidden\" name=\"method\" value=\"uploadicon\"> | |
699 | <button dojoType=\"dijit.form.Button\" onclick=\"return uploadFeedIcon();\" | |
700 | type=\"submit\">".__('Replace')."</button> | |
701 | <button dojoType=\"dijit.form.Button\" onclick=\"return removeFeedIcon($feed_id);\" | |
702 | type=\"submit\">".__('Remove')."</button> | |
703 | </form>"; | |
704 | ||
705 | print "</div>"; | |
706 | ||
707 | $title = htmlspecialchars($title, ENT_QUOTES); | |
708 | ||
709 | print "<div class='dlgButtons'> | |
710 | <div style=\"float : left\"> | |
711 | <button dojoType=\"dijit.form.Button\" onclick='return unsubscribeFeed($feed_id, \"$title\")'>". | |
712 | __('Unsubscribe')."</button>"; | |
713 | ||
714 | if (PUBSUBHUBBUB_ENABLED) { | |
715 | $pubsub_state = db_fetch_result($result, 0, "pubsub_state"); | |
716 | $pubsub_btn_disabled = ($pubsub_state == 2) ? "" : "disabled=\"1\""; | |
717 | ||
718 | print "<button dojoType=\"dijit.form.Button\" id=\"pubsubReset_Btn\" $pubsub_btn_disabled | |
719 | onclick='return resetPubSub($feed_id, \"$title\")'>".__('Resubscribe to push updates'). | |
720 | "</button>"; | |
721 | } | |
722 | ||
723 | print "</div>"; | |
724 | ||
725 | print "<div dojoType=\"dijit.Tooltip\" connectId=\"pubsubReset_Btn\" position=\"below\">". | |
726 | __('Resets PubSubHubbub subscription status for push-enabled feeds.')."</div>"; | |
727 | ||
728 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedEditDlg').execute()\">".__('Save')."</button> | |
729 | <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedEditDlg').hide()\">".__('Cancel')."</button> | |
730 | </div>"; | |
731 | ||
732 | return; | |
733 | } | |
734 | ||
735 | function editfeeds() { | |
736 | global $purge_intervals; | |
737 | global $update_intervals; | |
46da73c2 | 738 | |
afcfe6ca AD |
739 | $feed_ids = db_escape_string($_REQUEST["ids"]); |
740 | ||
ca6a0741 AD |
741 | print "<div class=\"dialogNotice\">" . __("Enable the options you wish to apply using checkboxes on the right:") . "</div>"; |
742 | ||
afcfe6ca AD |
743 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"ids\" value=\"$feed_ids\">"; |
744 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-feeds\">"; | |
745 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"batchEditSave\">"; | |
746 | ||
747 | print "<div class=\"dlgSec\">".__("Feed")."</div>"; | |
748 | print "<div class=\"dlgSecCont\">"; | |
749 | ||
750 | /* Title */ | |
751 | ||
752 | print "<input dojoType=\"dijit.form.ValidationTextBox\" | |
753 | disabled=\"1\" style=\"font-size : 16px; width : 20em;\" required=\"1\" | |
754 | name=\"title\" value=\"$title\">"; | |
755 | ||
756 | $this->batch_edit_cbox("title"); | |
757 | ||
758 | /* Feed URL */ | |
759 | ||
760 | print "<br/>"; | |
761 | ||
762 | print __('URL:') . " "; | |
763 | print "<input dojoType=\"dijit.form.ValidationTextBox\" disabled=\"1\" | |
764 | required=\"1\" regExp='^(http|https)://.*' style=\"width : 20em\" | |
765 | name=\"feed_url\" value=\"$feed_url\">"; | |
766 | ||
767 | $this->batch_edit_cbox("feed_url"); | |
768 | ||
769 | /* Category */ | |
770 | ||
771 | if (get_pref($this->link, 'ENABLE_FEED_CATS')) { | |
772 | ||
773 | print "<br/>"; | |
774 | ||
775 | print __('Place in category:') . " "; | |
776 | ||
777 | print_feed_cat_select($this->link, "cat_id", $cat_id, | |
778 | 'disabled="1" dojoType="dijit.form.Select"'); | |
779 | ||
780 | $this->batch_edit_cbox("cat_id"); | |
781 | ||
782 | } | |
783 | ||
784 | print "</div>"; | |
785 | ||
786 | print "<div class=\"dlgSec\">".__("Update")."</div>"; | |
787 | print "<div class=\"dlgSecCont\">"; | |
788 | ||
789 | /* Update Interval */ | |
790 | ||
791 | print_select_hash("update_interval", $update_interval, $update_intervals, | |
792 | 'disabled="1" dojoType="dijit.form.Select"'); | |
793 | ||
794 | $this->batch_edit_cbox("update_interval"); | |
795 | ||
afcfe6ca AD |
796 | /* Purge intl */ |
797 | ||
798 | if (FORCE_ARTICLE_PURGE == 0) { | |
799 | ||
800 | print "<br/>"; | |
801 | ||
802 | print __('Article purging:') . " "; | |
803 | ||
804 | print_select_hash("purge_interval", $purge_interval, $purge_intervals, | |
805 | 'disabled="1" dojoType="dijit.form.Select"'); | |
806 | ||
807 | $this->batch_edit_cbox("purge_interval"); | |
808 | } | |
809 | ||
810 | print "</div>"; | |
811 | print "<div class=\"dlgSec\">".__("Authentication")."</div>"; | |
812 | print "<div class=\"dlgSecCont\">"; | |
813 | ||
814 | print "<input dojoType=\"dijit.form.TextBox\" | |
815 | placeHolder=\"".__("Login")."\" disabled=\"1\" | |
816 | name=\"auth_login\" value=\"$auth_login\">"; | |
817 | ||
818 | $this->batch_edit_cbox("auth_login"); | |
819 | ||
820 | print "<br/><input dojoType=\"dijit.form.TextBox\" type=\"password\" name=\"auth_pass\" | |
821 | placeHolder=\"".__("Password")."\" disabled=\"1\" | |
822 | value=\"$auth_pass\">"; | |
823 | ||
824 | $this->batch_edit_cbox("auth_pass"); | |
825 | ||
826 | print "</div>"; | |
827 | print "<div class=\"dlgSec\">".__("Options")."</div>"; | |
828 | print "<div class=\"dlgSecCont\">"; | |
829 | ||
830 | print "<input disabled=\"1\" type=\"checkbox\" name=\"private\" id=\"private\" | |
831 | dojoType=\"dijit.form.CheckBox\"> <label id=\"private_l\" class='insensitive' for=\"private\">".__('Hide from Popular feeds')."</label>"; | |
832 | ||
833 | print " "; $this->batch_edit_cbox("private", "private_l"); | |
834 | ||
835 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\" | |
836 | dojoType=\"dijit.form.CheckBox\"> <label class='insensitive' id=\"rtl_content_l\" for=\"rtl_content\">".__('Right-to-left content')."</label>"; | |
837 | ||
838 | print " "; $this->batch_edit_cbox("rtl_content", "rtl_content_l"); | |
839 | ||
840 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"include_in_digest\" | |
841 | name=\"include_in_digest\" | |
842 | dojoType=\"dijit.form.CheckBox\"> <label id=\"include_in_digest_l\" class='insensitive' for=\"include_in_digest\">".__('Include in e-mail digest')."</label>"; | |
843 | ||
844 | print " "; $this->batch_edit_cbox("include_in_digest", "include_in_digest_l"); | |
845 | ||
846 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"always_display_enclosures\" | |
847 | name=\"always_display_enclosures\" | |
848 | dojoType=\"dijit.form.CheckBox\"> <label id=\"always_display_enclosures_l\" class='insensitive' for=\"always_display_enclosures\">".__('Always display image attachments')."</label>"; | |
849 | ||
850 | print " "; $this->batch_edit_cbox("always_display_enclosures", "always_display_enclosures_l"); | |
851 | ||
3c696512 AD |
852 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"cache_images\" |
853 | name=\"cache_images\" | |
854 | dojoType=\"dijit.form.CheckBox\"> <label class='insensitive' id=\"cache_images_l\" | |
855 | for=\"cache_images\">". | |
856 | __('Cache images locally')."</label>"; | |
afcfe6ca | 857 | |
3c696512 | 858 | print " "; $this->batch_edit_cbox("cache_images", "cache_images_l"); |
afcfe6ca AD |
859 | |
860 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"mark_unread_on_update\" | |
861 | name=\"mark_unread_on_update\" | |
862 | dojoType=\"dijit.form.CheckBox\"> <label id=\"mark_unread_on_update_l\" class='insensitive' for=\"mark_unread_on_update\">".__('Mark updated articles as unread')."</label>"; | |
863 | ||
864 | print " "; $this->batch_edit_cbox("mark_unread_on_update", "mark_unread_on_update_l"); | |
865 | ||
866 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"update_on_checksum_change\" | |
867 | name=\"update_on_checksum_change\" | |
868 | 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>"; | |
869 | ||
870 | print " "; $this->batch_edit_cbox("update_on_checksum_change", "update_on_checksum_change_l"); | |
871 | ||
872 | print "</div>"; | |
873 | ||
874 | print "<div class='dlgButtons'> | |
875 | <button dojoType=\"dijit.form.Button\" | |
876 | onclick=\"return dijit.byId('feedEditDlg').execute()\">". | |
877 | __('Save')."</button> | |
878 | <button dojoType=\"dijit.form.Button\" | |
879 | onclick=\"return dijit.byId('feedEditDlg').hide()\">". | |
880 | __('Cancel')."</button> | |
881 | </div>"; | |
882 | ||
883 | return; | |
884 | } | |
885 | ||
886 | function batchEditSave() { | |
3a76e2a2 | 887 | return $this->editsaveops(true); |
afcfe6ca | 888 | } |
46da73c2 | 889 | |
afcfe6ca | 890 | function editSave() { |
3a76e2a2 | 891 | return $this->editsaveops(false); |
afcfe6ca | 892 | } |
46da73c2 AD |
893 | |
894 | function editsaveops($batch) { | |
895 | ||
afcfe6ca AD |
896 | $feed_title = db_escape_string(trim($_POST["title"])); |
897 | $feed_link = db_escape_string(trim($_POST["feed_url"])); | |
898 | $upd_intl = (int) db_escape_string($_POST["update_interval"]); | |
899 | $purge_intl = (int) db_escape_string($_POST["purge_interval"]); | |
900 | $feed_id = (int) db_escape_string($_POST["id"]); /* editSave */ | |
901 | $feed_ids = db_escape_string($_POST["ids"]); /* batchEditSave */ | |
902 | $cat_id = (int) db_escape_string($_POST["cat_id"]); | |
903 | $auth_login = db_escape_string(trim($_POST["auth_login"])); | |
904 | $auth_pass = db_escape_string(trim($_POST["auth_pass"])); | |
905 | $private = checkbox_to_sql_bool(db_escape_string($_POST["private"])); | |
906 | $rtl_content = checkbox_to_sql_bool(db_escape_string($_POST["rtl_content"])); | |
907 | $include_in_digest = checkbox_to_sql_bool( | |
908 | db_escape_string($_POST["include_in_digest"])); | |
909 | $cache_images = checkbox_to_sql_bool( | |
910 | db_escape_string($_POST["cache_images"])); | |
87764a50 AD |
911 | $cache_content = checkbox_to_sql_bool( |
912 | db_escape_string($_POST["cache_content"])); | |
afcfe6ca AD |
913 | |
914 | $always_display_enclosures = checkbox_to_sql_bool( | |
915 | db_escape_string($_POST["always_display_enclosures"])); | |
916 | ||
917 | $mark_unread_on_update = checkbox_to_sql_bool( | |
918 | db_escape_string($_POST["mark_unread_on_update"])); | |
919 | ||
920 | $update_on_checksum_change = checkbox_to_sql_bool( | |
921 | db_escape_string($_POST["update_on_checksum_change"])); | |
922 | ||
923 | if (get_pref($this->link, 'ENABLE_FEED_CATS')) { | |
924 | if ($cat_id && $cat_id != 0) { | |
925 | $category_qpart = "cat_id = '$cat_id',"; | |
926 | $category_qpart_nocomma = "cat_id = '$cat_id'"; | |
927 | } else { | |
928 | $category_qpart = 'cat_id = NULL,'; | |
929 | $category_qpart_nocomma = 'cat_id = NULL'; | |
930 | } | |
931 | } else { | |
932 | $category_qpart = ""; | |
933 | $category_qpart_nocomma = ""; | |
934 | } | |
935 | ||
3a76e2a2 | 936 | if (!$batch) { |
afcfe6ca AD |
937 | |
938 | $result = db_query($this->link, "UPDATE ttrss_feeds SET | |
939 | $category_qpart | |
940 | title = '$feed_title', feed_url = '$feed_link', | |
941 | update_interval = '$upd_intl', | |
942 | purge_interval = '$purge_intl', | |
943 | auth_login = '$auth_login', | |
944 | auth_pass = '$auth_pass', | |
945 | private = $private, | |
946 | rtl_content = $rtl_content, | |
87764a50 AD |
947 | cache_images = $cache_images, |
948 | cache_content = $cache_content, | |
afcfe6ca AD |
949 | include_in_digest = $include_in_digest, |
950 | always_display_enclosures = $always_display_enclosures, | |
951 | mark_unread_on_update = $mark_unread_on_update, | |
952 | update_on_checksum_change = $update_on_checksum_change, | |
19b3992b | 953 | WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); |
afcfe6ca | 954 | |
3a76e2a2 | 955 | } else { |
afcfe6ca AD |
956 | $feed_data = array(); |
957 | ||
958 | foreach (array_keys($_POST) as $k) { | |
959 | if ($k != "op" && $k != "method" && $k != "ids") { | |
960 | $feed_data[$k] = $_POST[$k]; | |
961 | } | |
962 | } | |
963 | ||
964 | db_query($this->link, "BEGIN"); | |
965 | ||
966 | foreach (array_keys($feed_data) as $k) { | |
967 | ||
968 | $qpart = ""; | |
969 | ||
970 | switch ($k) { | |
971 | case "title": | |
972 | $qpart = "title = '$feed_title'"; | |
973 | break; | |
974 | ||
975 | case "feed_url": | |
976 | $qpart = "feed_url = '$feed_link'"; | |
977 | break; | |
978 | ||
979 | case "update_interval": | |
980 | $qpart = "update_interval = '$upd_intl'"; | |
981 | break; | |
982 | ||
983 | case "purge_interval": | |
984 | $qpart = "purge_interval = '$purge_intl'"; | |
985 | break; | |
986 | ||
987 | case "auth_login": | |
988 | $qpart = "auth_login = '$auth_login'"; | |
989 | break; | |
990 | ||
991 | case "auth_pass": | |
992 | $qpart = "auth_pass = '$auth_pass'"; | |
993 | break; | |
994 | ||
995 | case "private": | |
a498d18b | 996 | $qpart = "private = $private"; |
afcfe6ca AD |
997 | break; |
998 | ||
999 | case "include_in_digest": | |
a498d18b | 1000 | $qpart = "include_in_digest = $include_in_digest"; |
afcfe6ca AD |
1001 | break; |
1002 | ||
1003 | case "always_display_enclosures": | |
a498d18b | 1004 | $qpart = "always_display_enclosures = $always_display_enclosures"; |
afcfe6ca AD |
1005 | break; |
1006 | ||
1007 | case "mark_unread_on_update": | |
a498d18b | 1008 | $qpart = "mark_unread_on_update = $mark_unread_on_update"; |
afcfe6ca AD |
1009 | break; |
1010 | ||
1011 | case "update_on_checksum_change": | |
a498d18b | 1012 | $qpart = "update_on_checksum_change = $update_on_checksum_change"; |
afcfe6ca AD |
1013 | break; |
1014 | ||
1015 | case "cache_images": | |
a498d18b | 1016 | $qpart = "cache_images = $cache_images"; |
afcfe6ca AD |
1017 | break; |
1018 | ||
87764a50 AD |
1019 | case "cache_content": |
1020 | $qpart = "cache_content = $cache_content"; | |
1021 | break; | |
1022 | ||
afcfe6ca | 1023 | case "rtl_content": |
a498d18b | 1024 | $qpart = "rtl_content = $rtl_content"; |
afcfe6ca AD |
1025 | break; |
1026 | ||
afcfe6ca AD |
1027 | case "cat_id": |
1028 | $qpart = $category_qpart_nocomma; | |
1029 | break; | |
1030 | ||
1031 | } | |
1032 | ||
1033 | if ($qpart) { | |
1034 | db_query($this->link, | |
1035 | "UPDATE ttrss_feeds SET $qpart WHERE id IN ($feed_ids) | |
1036 | AND owner_uid = " . $_SESSION["uid"]); | |
1037 | print "<br/>"; | |
1038 | } | |
1039 | } | |
1040 | ||
1041 | db_query($this->link, "COMMIT"); | |
1042 | } | |
1043 | return; | |
1044 | } | |
1045 | ||
1046 | function resetPubSub() { | |
1047 | ||
1048 | $ids = db_escape_string($_REQUEST["ids"]); | |
1049 | ||
1050 | db_query($this->link, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ($ids) | |
1051 | AND owner_uid = " . $_SESSION["uid"]); | |
1052 | ||
1053 | return; | |
1054 | } | |
1055 | ||
1056 | function remove() { | |
1057 | ||
1058 | $ids = split(",", db_escape_string($_REQUEST["ids"])); | |
1059 | ||
1060 | foreach ($ids as $id) { | |
1061 | remove_feed($this->link, $id, $_SESSION["uid"]); | |
1062 | } | |
1063 | ||
1064 | return; | |
1065 | } | |
1066 | ||
1067 | function clear() { | |
1068 | $id = db_escape_string($_REQUEST["id"]); | |
1069 | clear_feed_articles($this->link, $id); | |
1070 | } | |
1071 | ||
1072 | function rescore() { | |
92c14e9d AD |
1073 | require_once "rssfuncs.php"; |
1074 | ||
afcfe6ca AD |
1075 | $ids = split(",", db_escape_string($_REQUEST["ids"])); |
1076 | ||
1077 | foreach ($ids as $id) { | |
1078 | ||
1079 | $filters = load_filters($this->link, $id, $_SESSION["uid"], 6); | |
1080 | ||
1081 | $result = db_query($this->link, "SELECT | |
1082 | title, content, link, ref_id, author,". | |
1083 | SUBSTRING_FOR_DATE."(updated, 1, 19) AS updated | |
1084 | FROM | |
1085 | ttrss_user_entries, ttrss_entries | |
1086 | WHERE ref_id = id AND feed_id = '$id' AND | |
1087 | owner_uid = " .$_SESSION['uid']." | |
1088 | "); | |
1089 | ||
1090 | $scores = array(); | |
1091 | ||
1092 | while ($line = db_fetch_assoc($result)) { | |
1093 | ||
1094 | $tags = get_article_tags($this->link, $line["ref_id"]); | |
1095 | ||
1096 | $article_filters = get_article_filters($filters, $line['title'], | |
1097 | $line['content'], $line['link'], strtotime($line['updated']), | |
1098 | $line['author'], $tags); | |
1099 | ||
1100 | $new_score = calculate_article_score($article_filters); | |
1101 | ||
1102 | if (!$scores[$new_score]) $scores[$new_score] = array(); | |
1103 | ||
1104 | array_push($scores[$new_score], $line['ref_id']); | |
1105 | } | |
1106 | ||
1107 | foreach (array_keys($scores) as $s) { | |
1108 | if ($s > 1000) { | |
1109 | db_query($this->link, "UPDATE ttrss_user_entries SET score = '$s', | |
1110 | marked = true WHERE | |
1111 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
1112 | } else if ($s < -500) { | |
1113 | db_query($this->link, "UPDATE ttrss_user_entries SET score = '$s', | |
1114 | unread = false WHERE | |
1115 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
1116 | } else { | |
1117 | db_query($this->link, "UPDATE ttrss_user_entries SET score = '$s' WHERE | |
1118 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
1119 | } | |
1120 | } | |
1121 | } | |
1122 | ||
1123 | print __("All done."); | |
1124 | ||
1125 | } | |
1126 | ||
1127 | function rescoreAll() { | |
1128 | ||
1129 | $result = db_query($this->link, | |
1130 | "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']); | |
1131 | ||
1132 | while ($feed_line = db_fetch_assoc($result)) { | |
1133 | ||
1134 | $id = $feed_line["id"]; | |
1135 | ||
1136 | $filters = load_filters($this->link, $id, $_SESSION["uid"], 6); | |
1137 | ||
1138 | $tmp_result = db_query($this->link, "SELECT | |
1139 | title, content, link, ref_id, author,". | |
1140 | SUBSTRING_FOR_DATE."(updated, 1, 19) AS updated | |
1141 | FROM | |
1142 | ttrss_user_entries, ttrss_entries | |
1143 | WHERE ref_id = id AND feed_id = '$id' AND | |
1144 | owner_uid = " .$_SESSION['uid']." | |
1145 | "); | |
1146 | ||
1147 | $scores = array(); | |
1148 | ||
1149 | while ($line = db_fetch_assoc($tmp_result)) { | |
1150 | ||
1151 | $tags = get_article_tags($this->link, $line["ref_id"]); | |
1152 | ||
1153 | $article_filters = get_article_filters($filters, $line['title'], | |
1154 | $line['content'], $line['link'], strtotime($line['updated']), | |
1155 | $line['author'], $tags); | |
1156 | ||
1157 | $new_score = calculate_article_score($article_filters); | |
1158 | ||
1159 | if (!$scores[$new_score]) $scores[$new_score] = array(); | |
1160 | ||
1161 | array_push($scores[$new_score], $line['ref_id']); | |
1162 | } | |
1163 | ||
1164 | foreach (array_keys($scores) as $s) { | |
1165 | if ($s > 1000) { | |
1166 | db_query($this->link, "UPDATE ttrss_user_entries SET score = '$s', | |
1167 | marked = true WHERE | |
1168 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
1169 | } else { | |
1170 | db_query($this->link, "UPDATE ttrss_user_entries SET score = '$s' WHERE | |
1171 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
1172 | } | |
1173 | } | |
1174 | } | |
1175 | ||
1176 | print __("All done."); | |
1177 | ||
1178 | } | |
1179 | ||
afcfe6ca AD |
1180 | function categorize() { |
1181 | $ids = split(",", db_escape_string($_REQUEST["ids"])); | |
1182 | ||
1183 | $cat_id = db_escape_string($_REQUEST["cat_id"]); | |
1184 | ||
1185 | if ($cat_id == 0) { | |
1186 | $cat_id_qpart = 'NULL'; | |
1187 | } else { | |
1188 | $cat_id_qpart = "'$cat_id'"; | |
1189 | } | |
1190 | ||
1191 | db_query($this->link, "BEGIN"); | |
1192 | ||
1193 | foreach ($ids as $id) { | |
1194 | ||
1195 | db_query($this->link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart | |
1196 | WHERE id = '$id' | |
1197 | AND owner_uid = " . $_SESSION["uid"]); | |
1198 | ||
1199 | } | |
1200 | ||
1201 | db_query($this->link, "COMMIT"); | |
1202 | } | |
1203 | ||
28537341 AD |
1204 | function removeCat() { |
1205 | $ids = split(",", db_escape_string($_REQUEST["ids"])); | |
1206 | foreach ($ids as $id) { | |
1207 | remove_feed_category($this->link, $id, $_SESSION["uid"]); | |
1208 | } | |
1209 | } | |
1210 | ||
1211 | function addCat() { | |
1212 | $feed_cat = db_escape_string(trim($_REQUEST["cat"])); | |
1213 | ||
1214 | add_feed_category($this->link, $feed_cat); | |
1215 | } | |
1216 | ||
afcfe6ca AD |
1217 | function index() { |
1218 | ||
1219 | print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">"; | |
1220 | print "<div id=\"pref-feeds-feeds\" dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Feeds')."\">"; | |
1221 | ||
1222 | $result = db_query($this->link, "SELECT COUNT(id) AS num_errors | |
1223 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]); | |
1224 | ||
1225 | $num_errors = db_fetch_result($result, 0, "num_errors"); | |
1226 | ||
1227 | if ($num_errors > 0) { | |
1228 | ||
1229 | $error_button = "<button dojoType=\"dijit.form.Button\" | |
1230 | onclick=\"showFeedsWithErrors()\" id=\"errorButton\">" . | |
1231 | __("Feeds with errors") . "</button>"; | |
1232 | } | |
1233 | ||
1234 | if (DB_TYPE == "pgsql") { | |
1235 | $interval_qpart = "NOW() - INTERVAL '3 months'"; | |
1236 | } else { | |
1237 | $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)"; | |
1238 | } | |
1239 | ||
1240 | $result = db_query($this->link, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE | |
1241 | (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE | |
1242 | ttrss_entries.id = ref_id AND | |
1243 | ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND | |
1244 | ttrss_feeds.owner_uid = ".$_SESSION["uid"]); | |
1245 | ||
1246 | $num_inactive = db_fetch_result($result, 0, "num_inactive"); | |
1247 | ||
1248 | if ($num_inactive > 0) { | |
1249 | $inactive_button = "<button dojoType=\"dijit.form.Button\" | |
1250 | onclick=\"showInactiveFeeds()\">" . | |
1251 | __("Inactive feeds") . "</button>"; | |
1252 | } | |
1253 | ||
1254 | $feed_search = db_escape_string($_REQUEST["search"]); | |
1255 | ||
1256 | if (array_key_exists("search", $_REQUEST)) { | |
1257 | $_SESSION["prefs_feed_search"] = $feed_search; | |
1258 | } else { | |
1259 | $feed_search = $_SESSION["prefs_feed_search"]; | |
1260 | } | |
1261 | ||
1262 | print '<div dojoType="dijit.layout.BorderContainer" gutters="false">'; | |
1263 | ||
1264 | print "<div region='top' dojoType=\"dijit.Toolbar\">"; #toolbar | |
1265 | ||
1266 | print "<div style='float : right; padding-right : 4px;'> | |
1267 | <input dojoType=\"dijit.form.TextBox\" id=\"feed_search\" size=\"20\" type=\"search\" | |
1268 | value=\"$feed_search\"> | |
1269 | <button dojoType=\"dijit.form.Button\" onclick=\"updateFeedList()\">". | |
1270 | __('Search')."</button> | |
1271 | </div>"; | |
1272 | ||
1273 | print "<div dojoType=\"dijit.form.DropDownButton\">". | |
1274 | "<span>" . __('Select')."</span>"; | |
1275 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
1276 | print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(true)\" | |
1277 | dojoType=\"dijit.MenuItem\">".__('All')."</div>"; | |
1278 | print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(false)\" | |
1279 | dojoType=\"dijit.MenuItem\">".__('None')."</div>"; | |
1280 | print "</div></div>"; | |
1281 | ||
1282 | print "<div dojoType=\"dijit.form.DropDownButton\">". | |
1283 | "<span>" . __('Feeds')."</span>"; | |
1284 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
1285 | print "<div onclick=\"quickAddFeed()\" | |
1286 | dojoType=\"dijit.MenuItem\">".__('Subscribe to feed')."</div>"; | |
1287 | print "<div onclick=\"editSelectedFeed()\" | |
1288 | dojoType=\"dijit.MenuItem\">".__('Edit selected feeds')."</div>"; | |
1289 | print "<div onclick=\"resetFeedOrder()\" | |
1290 | dojoType=\"dijit.MenuItem\">".__('Reset sort order')."</div>"; | |
33f0fdd0 AD |
1291 | print "<div onclick=\"batchSubscribe()\" |
1292 | dojoType=\"dijit.MenuItem\">".__('Batch subscribe')."</div>"; | |
afcfe6ca AD |
1293 | print "</div></div>"; |
1294 | ||
1295 | if (get_pref($this->link, 'ENABLE_FEED_CATS')) { | |
1296 | print "<div dojoType=\"dijit.form.DropDownButton\">". | |
1297 | "<span>" . __('Categories')."</span>"; | |
1298 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
5ef071e0 AD |
1299 | print "<div onclick=\"createCategory()\" |
1300 | dojoType=\"dijit.MenuItem\">".__('Add category')."</div>"; | |
5b7bd238 AD |
1301 | print "<div onclick=\"toggleHiddenFeedCats()\" |
1302 | dojoType=\"dijit.MenuItem\">".__('(Un)hide empty categories')."</div>"; | |
afcfe6ca AD |
1303 | print "<div onclick=\"resetCatOrder()\" |
1304 | dojoType=\"dijit.MenuItem\">".__('Reset sort order')."</div>"; | |
fd26d5bf AD |
1305 | print "<div onclick=\"removeSelectedCategories()\" |
1306 | dojoType=\"dijit.MenuItem\">".__('Remove selected')."</div>"; | |
afcfe6ca AD |
1307 | print "</div></div>"; |
1308 | ||
1309 | } | |
1310 | ||
1311 | print $error_button; | |
1312 | print $inactive_button; | |
1313 | ||
1314 | print "<button dojoType=\"dijit.form.Button\" onclick=\"removeSelectedFeeds()\">" | |
1315 | .__('Unsubscribe')."</button dojoType=\"dijit.form.Button\"> "; | |
1316 | ||
1317 | if (defined('_ENABLE_FEED_DEBUGGING')) { | |
1318 | ||
1319 | print "<select id=\"feedActionChooser\" onchange=\"feedActionChange()\"> | |
1320 | <option value=\"facDefault\" selected>".__('More actions...')."</option>"; | |
1321 | ||
1322 | if (FORCE_ARTICLE_PURGE == 0) { | |
1323 | ||
1324 | "<option value=\"facPurge\">".__('Manual purge')."</option>"; | |
1325 | } | |
1326 | ||
1327 | print " | |
1328 | <option value=\"facClear\">".__('Clear feed data')."</option> | |
1329 | <option value=\"facRescore\">".__('Rescore articles')."</option>"; | |
1330 | ||
1331 | print "</select>"; | |
1332 | ||
1333 | } | |
1334 | ||
1335 | print "</div>"; # toolbar | |
1336 | ||
1337 | //print '</div>'; | |
1338 | print '<div dojoType="dijit.layout.ContentPane" region="center">'; | |
1339 | ||
1340 | print "<div id=\"feedlistLoading\"> | |
1341 | <img src='images/indicator_tiny.gif'>". | |
1342 | __("Loading, please wait...")."</div>"; | |
1343 | ||
1344 | print "<div dojoType=\"fox.PrefFeedStore\" jsId=\"feedStore\" | |
1345 | url=\"backend.php?op=pref-feeds&method=getfeedtree\"> | |
1346 | </div> | |
1347 | <div dojoType=\"lib.CheckBoxStoreModel\" jsId=\"feedModel\" store=\"feedStore\" | |
1348 | query=\"{id:'root'}\" rootId=\"root\" rootLabel=\"Feeds\" | |
1349 | childrenAttrs=\"items\" checkboxStrict=\"false\" checkboxAll=\"false\"> | |
1350 | </div> | |
1351 | <div dojoType=\"fox.PrefFeedTree\" id=\"feedTree\" | |
1352 | dndController=\"dijit.tree.dndSource\" | |
1353 | betweenThreshold=\"5\" | |
1354 | model=\"feedModel\" openOnClick=\"false\"> | |
1355 | <script type=\"dojo/method\" event=\"onClick\" args=\"item\"> | |
1356 | var id = String(item.id); | |
1357 | var bare_id = id.substr(id.indexOf(':')+1); | |
1358 | ||
1359 | if (id.match('FEED:')) { | |
1360 | editFeed(bare_id); | |
1361 | } else if (id.match('CAT:')) { | |
1362 | editCat(bare_id, item); | |
1363 | } | |
1364 | </script> | |
1365 | <script type=\"dojo/method\" event=\"onLoad\" args=\"item\"> | |
1366 | Element.hide(\"feedlistLoading\"); | |
1367 | </script> | |
1368 | </div>"; | |
1369 | ||
ba5296a1 AD |
1370 | # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\"> |
1371 | # ".__('<b>Hint:</b> you can drag feeds and categories around.')." | |
1372 | # </div>"; | |
afcfe6ca AD |
1373 | |
1374 | print '</div>'; | |
1375 | print '</div>'; | |
1376 | ||
1377 | print "</div>"; # feeds pane | |
1378 | ||
6c2637d9 | 1379 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('OPML')."\">"; |
afcfe6ca | 1380 | |
566faa14 | 1381 | print "<p>" . __("Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings.") . " "; |
afcfe6ca | 1382 | |
566faa14 | 1383 | print __("Only main settings profile can be migrated using OPML.") . "</p>"; |
afcfe6ca | 1384 | |
55f34b81 | 1385 | print "<iframe id=\"upload_iframe\" |
afcfe6ca AD |
1386 | name=\"upload_iframe\" onload=\"opmlImportComplete(this)\" |
1387 | style=\"width: 400px; height: 100px; display: none;\"></iframe>"; | |
1388 | ||
1389 | print "<form name=\"opml_form\" style='display : block' target=\"upload_iframe\" | |
1390 | enctype=\"multipart/form-data\" method=\"POST\" | |
55f34b81 | 1391 | action=\"backend.php\"> |
afcfe6ca AD |
1392 | <input id=\"opml_file\" name=\"opml_file\" type=\"file\"> |
1393 | <input type=\"hidden\" name=\"op\" value=\"dlg\"> | |
c4c74732 | 1394 | <input type=\"hidden\" name=\"method\" value=\"importOpml\"> |
afcfe6ca | 1395 | <button dojoType=\"dijit.form.Button\" onclick=\"return opmlImport();\" type=\"submit\">" . |
a1159c01 | 1396 | __('Import my OPML') . "</button>"; |
afcfe6ca | 1397 | |
a1159c01 | 1398 | print "<hr>"; |
afcfe6ca AD |
1399 | |
1400 | print "<p>" . __('Filename:') . | |
1401 | " <input type=\"text\" id=\"filename\" value=\"TinyTinyRSS.opml\" /> " . | |
a1159c01 | 1402 | __('Include settings') . "<input type=\"checkbox\" id=\"settings\" checked=\"1\"/>"; |
afcfe6ca | 1403 | |
a1159c01 | 1404 | print "</p><button dojoType=\"dijit.form.Button\" |
afcfe6ca | 1405 | onclick=\"gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked)\" >" . |
a1159c01 | 1406 | __('Export OPML') . "</button></p></form>"; |
afcfe6ca | 1407 | |
a1159c01 | 1408 | print "<hr>"; |
afcfe6ca AD |
1409 | |
1410 | print "<p>".__('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.') . " "; | |
1411 | ||
566faa14 | 1412 | print __("Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds.") . "</p>"; |
afcfe6ca AD |
1413 | |
1414 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('pubOPMLUrl')\">". | |
a1159c01 | 1415 | __('Display published OPML URL')."</button> "; |
afcfe6ca AD |
1416 | |
1417 | print "</div>"; # pane | |
1418 | ||
1419 | if (strpos($_SERVER['HTTP_USER_AGENT'], "Firefox") !== false) { | |
1420 | ||
1421 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Firefox integration')."\">"; | |
1422 | ||
1423 | print "<p>" . __('This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.') . "</p>"; | |
1424 | ||
1425 | print "<p>"; | |
1426 | ||
1427 | print "<button onclick='window.navigator.registerContentHandler(" . | |
1428 | "\"application/vnd.mozilla.maybe.feed\", " . | |
1429 | "\"" . add_feed_url() . "\", " . " \"Tiny Tiny RSS\")'>" . | |
1430 | __('Click here to register this site as a feed reader.') . | |
1431 | "</button>"; | |
1432 | ||
1433 | print "</p>"; | |
1434 | ||
1435 | print "</div>"; # pane | |
1436 | } | |
1437 | ||
8361e724 | 1438 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Bookmarklets')."\">"; |
afcfe6ca AD |
1439 | |
1440 | print "<p>" . __("Drag the link below to your browser toolbar, open the feed you're interested in in your browser and click on the link to subscribe to it.") . "</p>"; | |
1441 | ||
1442 | $bm_subscribe_url = str_replace('%s', '', add_feed_url()); | |
1443 | ||
b1e592d3 | 1444 | $confirm_str = str_replace("'", "\'", __('Subscribe to %s in Tiny Tiny RSS?')); |
afcfe6ca AD |
1445 | |
1446 | $bm_url = htmlspecialchars("javascript:{if(confirm('$confirm_str'.replace('%s',window.location.href)))window.location.href='$bm_subscribe_url'+window.location.href}"); | |
1447 | ||
1448 | print "<a href=\"$bm_url\" class='bookmarklet'>" . __('Subscribe in Tiny Tiny RSS'). "</a>"; | |
1449 | ||
8361e724 AD |
1450 | print "<p>" . __("Use this bookmarklet to publish arbitrary pages using Tiny Tiny RSS") . "</p>"; |
1451 | ||
1b4d1a6b | 1452 | $bm_url = htmlspecialchars("javascript:(function(){var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='".SELF_URL_PATH."/public.php?op=sharepopup',l=d.location,e=encodeURIComponent,g=f+'&title='+((e(s))?e(s):e(document.title))+'&url='+e(l.href);function a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=500,height=250')){l.href=g;}}a();})()"); |
8361e724 AD |
1453 | |
1454 | print "<a href=\"$bm_url\" class='bookmarklet'>" . __('Share with Tiny Tiny RSS'). "</a>"; | |
1455 | ||
afcfe6ca AD |
1456 | print "</div>"; #pane |
1457 | ||
e95e7819 | 1458 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Published & shared articles / Generated feeds')."\">"; |
afcfe6ca AD |
1459 | |
1460 | print "<h3>" . __("Published articles and generated feeds") . "</h3>"; | |
1461 | ||
1462 | print "<p>".__('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.')."</p>"; | |
1463 | ||
1464 | $rss_url = '-2::' . htmlspecialchars(get_self_url_prefix() . | |
1465 | "/public.php?op=rss&id=-2&view-mode=all_articles");; | |
1466 | ||
1467 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('generatedFeed', '$rss_url')\">". | |
1468 | __('Display URL')."</button> "; | |
1469 | ||
1470 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return clearFeedAccessKeys()\">". | |
1471 | __('Clear all generated URLs')."</button> "; | |
1472 | ||
1473 | print "<h3>" . __("Articles shared by URL") . "</h3>"; | |
1474 | ||
1475 | print "<p>" . __("You can disable all articles shared by unique URLs here.") . "</p>"; | |
1476 | ||
1477 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return clearArticleAccessKeys()\">". | |
1478 | __('Unshare all articles')."</button> "; | |
1479 | ||
1480 | print "</div>"; #pane | |
1481 | ||
6065f3ad | 1482 | global $pluginhost; |
de612e7a | 1483 | |
6065f3ad AD |
1484 | $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB, |
1485 | "hook_prefs_tab", "prefFeeds"); | |
1486 | ||
afcfe6ca | 1487 | print "</div>"; #container |
afcfe6ca | 1488 | } |
2ecd2df5 AD |
1489 | |
1490 | private function feedlist_init_cat($cat_id, $hidden = false) { | |
1491 | $obj = array(); | |
1492 | $cat_id = (int) $cat_id; | |
1493 | ||
1494 | if ($cat_id > 0) { | |
1495 | $cat_unread = ccache_find($this->link, $cat_id, $_SESSION["uid"], true); | |
1496 | } else if ($cat_id == 0 || $cat_id == -2) { | |
1497 | $cat_unread = getCategoryUnread($this->link, $cat_id); | |
1498 | } | |
1499 | ||
1500 | $obj['id'] = 'CAT:' . $cat_id; | |
1501 | $obj['items'] = array(); | |
1502 | $obj['name'] = getCategoryTitle($this->link, $cat_id); | |
1503 | $obj['type'] = 'category'; | |
1504 | $obj['unread'] = (int) $cat_unread; | |
1505 | $obj['hidden'] = $hidden; | |
1506 | $obj['bare_id'] = $cat_id; | |
1507 | ||
1508 | return $obj; | |
1509 | } | |
1510 | ||
1511 | private function feedlist_init_feed($feed_id, $title = false, $unread = false, $error = '', $updated = '') { | |
1512 | $obj = array(); | |
1513 | $feed_id = (int) $feed_id; | |
1514 | ||
1515 | if (!$title) | |
1516 | $title = getFeedTitle($this->link, $feed_id, false); | |
1517 | ||
1518 | if ($unread === false) | |
1519 | $unread = getFeedUnread($this->link, $feed_id, false); | |
1520 | ||
1521 | $obj['id'] = 'FEED:' . $feed_id; | |
1522 | $obj['name'] = $title; | |
1523 | $obj['unread'] = (int) $unread; | |
1524 | $obj['type'] = 'feed'; | |
1525 | $obj['error'] = $error; | |
1526 | $obj['updated'] = $updated; | |
1527 | $obj['icon'] = getFeedIcon($feed_id); | |
1528 | $obj['bare_id'] = $feed_id; | |
1529 | ||
1530 | return $obj; | |
1531 | } | |
1532 | ||
bc6fa236 AD |
1533 | function inactiveFeeds() { |
1534 | ||
1535 | if (DB_TYPE == "pgsql") { | |
1536 | $interval_qpart = "NOW() - INTERVAL '3 months'"; | |
1537 | } else { | |
1538 | $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)"; | |
1539 | } | |
1540 | ||
1541 | $result = db_query($this->link, "SELECT ttrss_feeds.title, ttrss_feeds.site_url, | |
1542 | ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article | |
1543 | FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE | |
1544 | (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE | |
1545 | ttrss_entries.id = ref_id AND | |
1546 | ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart | |
1547 | AND ttrss_feeds.owner_uid = ".$_SESSION["uid"]." AND | |
1548 | ttrss_user_entries.feed_id = ttrss_feeds.id AND | |
1549 | ttrss_entries.id = ref_id | |
1550 | GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url | |
1551 | ORDER BY last_article"); | |
1552 | ||
1553 | print "<div class=\"dialogNotice\">" . __("These feeds have not been updated with new content for 3 months (oldest first):") . "</div>"; | |
1554 | ||
1555 | print "<div dojoType=\"dijit.Toolbar\">"; | |
1556 | print "<div dojoType=\"dijit.form.DropDownButton\">". | |
1557 | "<span>" . __('Select')."</span>"; | |
1558 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
1559 | print "<div onclick=\"selectTableRows('prefInactiveFeedList', 'all')\" | |
1560 | dojoType=\"dijit.MenuItem\">".__('All')."</div>"; | |
1561 | print "<div onclick=\"selectTableRows('prefInactiveFeedList', 'none')\" | |
1562 | dojoType=\"dijit.MenuItem\">".__('None')."</div>"; | |
1563 | print "</div></div>"; | |
1564 | print "</div>"; #toolbar | |
1565 | ||
1566 | print "<div class=\"inactiveFeedHolder\">"; | |
1567 | ||
1568 | print "<table width=\"100%\" cellspacing=\"0\" id=\"prefInactiveFeedList\">"; | |
1569 | ||
1570 | $lnum = 1; | |
1571 | ||
1572 | while ($line = db_fetch_assoc($result)) { | |
1573 | ||
1574 | $class = ($lnum % 2) ? "even" : "odd"; | |
1575 | $feed_id = $line["id"]; | |
1576 | $this_row_id = "id=\"FUPDD-$feed_id\""; | |
1577 | ||
1578 | # class needed for selectTableRows() | |
1579 | print "<tr class=\"placeholder\" $this_row_id>"; | |
1580 | ||
1581 | $edit_title = htmlspecialchars($line["title"]); | |
1582 | ||
1583 | # id needed for selectTableRows() | |
1584 | print "<td width='5%' align='center'><input | |
1585 | onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\" | |
1586 | type=\"checkbox\" id=\"FUPDC-$feed_id\"></td>"; | |
1587 | print "<td>"; | |
1588 | ||
1589 | print "<a class=\"visibleLink\" href=\"#\" ". | |
1590 | "title=\"".__("Click to edit feed")."\" ". | |
1591 | "onclick=\"editFeed(".$line["id"].")\">". | |
1592 | htmlspecialchars($line["title"])."</a>"; | |
1593 | ||
1594 | print "</td><td class=\"insensitive\" align='right'>"; | |
1595 | print make_local_datetime($this->link, $line['last_article'], false); | |
1596 | print "</td>"; | |
1597 | print "</tr>"; | |
1598 | ||
1599 | ++$lnum; | |
1600 | } | |
1601 | ||
1602 | print "</table>"; | |
1603 | print "</div>"; | |
1604 | ||
1605 | print "<div class='dlgButtons'>"; | |
1606 | print "<div style='float : left'>"; | |
1607 | print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').removeSelected()\">" | |
1608 | .__('Unsubscribe from selected feeds')."</button> "; | |
1609 | print "</div>"; | |
1610 | ||
1611 | print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').hide()\">". | |
1612 | __('Close this window')."</button>"; | |
1613 | ||
1614 | print "</div>"; | |
1615 | ||
1616 | } | |
1617 | ||
1618 | function feedsWithErrors() { | |
1619 | print "<div class=\"dialogNotice\">" . __("These feeds have not been updated because of errors:") . "</div>"; | |
1620 | ||
1621 | $result = db_query($this->link, "SELECT id,title,feed_url,last_error,site_url | |
1622 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]); | |
1623 | ||
1624 | print "<div dojoType=\"dijit.Toolbar\">"; | |
1625 | print "<div dojoType=\"dijit.form.DropDownButton\">". | |
1626 | "<span>" . __('Select')."</span>"; | |
1627 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
1628 | print "<div onclick=\"selectTableRows('prefErrorFeedList', 'all')\" | |
1629 | dojoType=\"dijit.MenuItem\">".__('All')."</div>"; | |
1630 | print "<div onclick=\"selectTableRows('prefErrorFeedList', 'none')\" | |
1631 | dojoType=\"dijit.MenuItem\">".__('None')."</div>"; | |
1632 | print "</div></div>"; | |
1633 | print "</div>"; #toolbar | |
1634 | ||
1635 | print "<div class=\"inactiveFeedHolder\">"; | |
1636 | ||
1637 | print "<table width=\"100%\" cellspacing=\"0\" id=\"prefErrorFeedList\">"; | |
1638 | ||
1639 | $lnum = 1; | |
1640 | ||
1641 | while ($line = db_fetch_assoc($result)) { | |
1642 | ||
1643 | $class = ($lnum % 2) ? "even" : "odd"; | |
1644 | $feed_id = $line["id"]; | |
1645 | $this_row_id = "id=\"FERDD-$feed_id\""; | |
1646 | ||
1647 | # class needed for selectTableRows() | |
1648 | print "<tr class=\"placeholder\" $this_row_id>"; | |
1649 | ||
1650 | $edit_title = htmlspecialchars($line["title"]); | |
1651 | ||
1652 | # id needed for selectTableRows() | |
1653 | print "<td width='5%' align='center'><input | |
1654 | onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\" | |
1655 | type=\"checkbox\" id=\"FERDC-$feed_id\"></td>"; | |
1656 | print "<td>"; | |
1657 | ||
1658 | print "<a class=\"visibleLink\" href=\"#\" ". | |
1659 | "title=\"".__("Click to edit feed")."\" ". | |
1660 | "onclick=\"editFeed(".$line["id"].")\">". | |
1661 | htmlspecialchars($line["title"])."</a>: "; | |
1662 | ||
1663 | print "<span class=\"insensitive\">"; | |
1664 | print htmlspecialchars($line["last_error"]); | |
1665 | print "</span>"; | |
1666 | ||
1667 | print "</td>"; | |
1668 | print "</tr>"; | |
1669 | ||
1670 | ++$lnum; | |
1671 | } | |
1672 | ||
1673 | print "</table>"; | |
1674 | print "</div>"; | |
1675 | ||
1676 | print "<div class='dlgButtons'>"; | |
1677 | print "<div style='float : left'>"; | |
1678 | print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').removeSelected()\">" | |
1679 | .__('Unsubscribe from selected feeds')."</button> "; | |
1680 | print "</div>"; | |
1681 | ||
1682 | print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').hide()\">". | |
1683 | __('Close this window')."</button>"; | |
1684 | ||
1685 | print "</div>"; | |
1686 | } | |
1687 | ||
afcfe6ca AD |
1688 | } |
1689 | ?> |