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