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