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