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