]>
Commit | Line | Data |
---|---|---|
ef8be8ea | 1 | <?php |
d20f3544 | 2 | |
ef8be8ea AD |
3 | function module_pref_feeds($link) { |
4 | ||
d20f3544 AD |
5 | global $update_intervals; |
6 | global $purge_intervals; | |
16211ddb | 7 | global $update_methods; |
d20f3544 | 8 | |
ef8be8ea AD |
9 | $subop = $_REQUEST["subop"]; |
10 | $quiet = $_REQUEST["quiet"]; | |
11 | ||
12 | if ($subop == "massSubscribe") { | |
13 | $ids = split(",", db_escape_string($_GET["ids"])); | |
14 | ||
15 | $subscribed = array(); | |
16 | ||
17 | foreach ($ids as $id) { | |
18 | $result = db_query($link, "SELECT feed_url,title FROM ttrss_feeds | |
19 | WHERE id = '$id'"); | |
20 | ||
21 | $feed_url = db_escape_string(db_fetch_result($result, 0, "feed_url")); | |
22 | $title = db_escape_string(db_fetch_result($result, 0, "title")); | |
23 | ||
24 | $title_orig = db_fetch_result($result, 0, "title"); | |
25 | ||
26 | $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE | |
27 | feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]); | |
28 | ||
29 | if (db_num_rows($result) == 0) { | |
30 | $result = db_query($link, | |
31 | "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id) | |
32 | VALUES ('".$_SESSION["uid"]."', '$feed_url', '$title', NULL)"); | |
33 | ||
34 | array_push($subscribed, $title_orig); | |
35 | } | |
36 | } | |
37 | ||
38 | if (count($subscribed) > 0) { | |
31cc42f6 | 39 | $msg = "<b>".__('Subscribed to feeds:')."</b>". |
0d32b41e AD |
40 | "<ul class=\"nomarks\">"; |
41 | ||
ef8be8ea | 42 | foreach ($subscribed as $title) { |
0d32b41e | 43 | $msg .= "<li>$title</li>"; |
ef8be8ea | 44 | } |
0d32b41e AD |
45 | $msg .= "</ul>"; |
46 | ||
47 | print format_notice($msg); | |
ef8be8ea AD |
48 | } |
49 | } | |
50 | ||
51 | if ($subop == "browse") { | |
52 | ||
53 | if (!ENABLE_FEED_BROWSER) { | |
31cc42f6 | 54 | print __("Feed browser is administratively disabled."); |
ef8be8ea AD |
55 | return; |
56 | } | |
57 | ||
31cc42f6 | 58 | print "<div id=\"infoBoxTitle\">".__('Other feeds: Top 25')."</div>"; |
ef8be8ea AD |
59 | |
60 | print "<div class=\"infoBoxContents\">"; | |
61 | ||
31cc42f6 | 62 | print "<p>".__("Showing top 25 registered feeds, sorted by popularity:")."</p>"; |
ef8be8ea | 63 | |
ef8be8ea AD |
64 | $owner_uid = $_SESSION["uid"]; |
65 | ||
66 | $result = db_query($link, "SELECT feed_url,COUNT(id) AS subscribers | |
67 | FROM ttrss_feeds WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf | |
68 | WHERE tf.feed_url = ttrss_feeds.feed_url | |
69 | AND owner_uid = '$owner_uid') GROUP BY feed_url | |
70 | ORDER BY subscribers DESC LIMIT 25"); | |
71 | ||
72 | print "<ul class='browseFeedList' id='browseFeedList'>"; | |
73 | ||
74 | $feedctr = 0; | |
75 | ||
76 | while ($line = db_fetch_assoc($result)) { | |
77 | $feed_url = $line["feed_url"]; | |
78 | $subscribers = $line["subscribers"]; | |
79 | ||
80 | $det_result = db_query($link, "SELECT site_url,title,id | |
81 | FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1"); | |
82 | ||
83 | $details = db_fetch_assoc($det_result); | |
84 | ||
85 | $icon_file = ICONS_DIR . "/" . $details["id"] . ".ico"; | |
86 | ||
87 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
88 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . | |
89 | "/".$details["id"].".ico\">"; | |
90 | } else { | |
91 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
92 | } | |
93 | ||
94 | $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB' | |
95 | type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">"; | |
96 | ||
97 | $class = ($feedctr % 2) ? "even" : "odd"; | |
98 | ||
99 | print "<li class='$class' id=\"FBROW-".$details["id"]."\">$check_box". | |
47439031 | 100 | "$feed_icon " . $details["title"] . |
ef8be8ea AD |
101 | " <span class='subscribers'>($subscribers)</span></li>"; |
102 | ||
103 | ++$feedctr; | |
104 | } | |
105 | ||
106 | if ($feedctr == 0) { | |
31cc42f6 | 107 | print "<li>".__('No feeds found to subscribe.')."</li>"; |
ef8be8ea AD |
108 | } |
109 | ||
110 | print "</ul>"; | |
111 | ||
112 | print "<div align='center'> | |
113 | <input type=\"submit\" class=\"button\" | |
31cc42f6 | 114 | onclick=\"feedBrowserSubscribe()\" value=\"".__('Subscribe')."\"> |
ef8be8ea | 115 | <input type='submit' class='button' |
31cc42f6 | 116 | onclick=\"closeInfoBox()\" value=\"".__('Cancel')."\"></div>"; |
ef8be8ea AD |
117 | |
118 | print "</div>"; | |
119 | return; | |
120 | } | |
121 | ||
122 | if ($subop == "editfeed") { | |
123 | $feed_id = db_escape_string($_REQUEST["id"]); | |
124 | ||
125 | $result = db_query($link, | |
126 | "SELECT * FROM ttrss_feeds WHERE id = '$feed_id' AND | |
127 | owner_uid = " . $_SESSION["uid"]); | |
128 | ||
47439031 AD |
129 | $title = htmlspecialchars(db_fetch_result($result, |
130 | 0, "title")); | |
ef8be8ea AD |
131 | |
132 | $icon_file = ICONS_DIR . "/$feed_id.ico"; | |
133 | ||
134 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
135 | $feed_icon = "<img width=\"16\" height=\"16\" | |
136 | src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
137 | } else { | |
138 | $feed_icon = ""; | |
139 | } | |
140 | ||
ecace165 | 141 | print "<div id=\"infoBoxTitle\">".__('Feed Editor')."</div>"; |
ef8be8ea AD |
142 | |
143 | print "<div class=\"infoBoxContents\">"; | |
144 | ||
e6312f6c | 145 | print "<form id=\"edit_feed_form\" onsubmit=\"return false\">"; |
ef8be8ea AD |
146 | |
147 | print "<input type=\"hidden\" name=\"id\" value=\"$feed_id\">"; | |
148 | print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">"; | |
149 | print "<input type=\"hidden\" name=\"subop\" value=\"editSave\">"; | |
150 | ||
ecace165 AD |
151 | print "<div class=\"dlgSec\">".__("Feed")."</div>"; |
152 | print "<div class=\"dlgSecCont\">"; | |
ef8be8ea | 153 | |
ecace165 AD |
154 | /* Title */ |
155 | ||
156 | print "<input style=\"font-size : 16px\" size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\" | |
157 | name=\"title\" value=\"$title\">"; | |
158 | ||
159 | /* Feed URL */ | |
ef8be8ea AD |
160 | |
161 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
47439031 AD |
162 | $feed_url = htmlspecialchars(db_fetch_result($result, |
163 | 0, "feed_url")); | |
ecace165 AD |
164 | |
165 | print "<br/>"; | |
166 | ||
167 | print __('URL:') . " "; | |
168 | print "<input size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\" | |
169 | name=\"feed_url\" value=\"$feed_url\">"; | |
170 | ||
171 | /* Category */ | |
ef8be8ea AD |
172 | |
173 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
174 | ||
175 | $cat_id = db_fetch_result($result, 0, "cat_id"); | |
176 | ||
ecace165 AD |
177 | print "<br/>"; |
178 | ||
179 | print __('Place in category:') . " "; | |
ef8be8ea AD |
180 | |
181 | $parent_feed = db_fetch_result($result, 0, "parent_feed"); | |
182 | ||
183 | if (sprintf("%d", $parent_feed) > 0) { | |
184 | $disabled = "disabled"; | |
185 | } else { | |
186 | $disabled = ""; | |
187 | } | |
188 | ||
ecace165 | 189 | print_feed_cat_select($link, "cat_id", $cat_id, $disabled); |
ef8be8ea AD |
190 | } |
191 | ||
ecace165 | 192 | /* Link to */ |
ef8be8ea | 193 | |
ecace165 | 194 | print "<br/>"; |
ef8be8ea | 195 | |
ecace165 | 196 | print __('Link to feed:') . " "; |
ef8be8ea AD |
197 | |
198 | $tmp_result = db_query($link, "SELECT COUNT(id) AS count | |
199 | FROM ttrss_feeds WHERE parent_feed = '$feed_id'"); | |
200 | ||
201 | $linked_count = db_fetch_result($tmp_result, 0, "count"); | |
202 | ||
203 | $parent_feed = db_fetch_result($result, 0, "parent_feed"); | |
204 | ||
205 | if ($linked_count > 0) { | |
206 | $disabled = "disabled"; | |
207 | } else { | |
208 | $disabled = ""; | |
209 | } | |
210 | ||
ecace165 | 211 | print "<select $disabled name=\"parent_feed\">"; |
ef8be8ea | 212 | |
31cc42f6 | 213 | print "<option value=\"0\">".__('Not linked')."</option>"; |
ef8be8ea AD |
214 | |
215 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
216 | if ($cat_id) { | |
217 | $cat_qpart = "AND cat_id = '$cat_id'"; | |
218 | } else { | |
219 | $cat_qpart = "AND cat_id IS NULL"; | |
220 | } | |
221 | } | |
222 | ||
223 | $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feeds | |
224 | WHERE id != '$feed_id' AND owner_uid = ".$_SESSION["uid"]." AND | |
225 | (SELECT COUNT(id) FROM ttrss_feeds AS T2 WHERE T2.id = ttrss_feeds.parent_feed) = 0 | |
226 | $cat_qpart ORDER BY title"); | |
227 | ||
228 | if (db_num_rows($tmp_result) > 0) { | |
229 | print "<option disabled>--------</option>"; | |
230 | } | |
231 | ||
232 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
233 | if ($tmp_line["id"] == $parent_feed) { | |
234 | $is_selected = "selected"; | |
235 | } else { | |
236 | $is_selected = ""; | |
237 | } | |
238 | printf("<option $is_selected value='%d'>%s</option>", | |
239 | $tmp_line["id"], $tmp_line["title"]); | |
240 | } | |
241 | ||
242 | print "</select>"; | |
ef8be8ea | 243 | |
ef8be8ea | 244 | |
ecace165 | 245 | print "</div>"; |
ef8be8ea | 246 | |
e6bf0f4b | 247 | print "<div class=\"dlgSec\">".__("Update")."</div>"; |
ecace165 | 248 | print "<div class=\"dlgSecCont\">"; |
ef8be8ea | 249 | |
ecace165 | 250 | /* Update Interval */ |
ef8be8ea | 251 | |
ecace165 AD |
252 | $update_interval = db_fetch_result($result, 0, "update_interval"); |
253 | ||
254 | print_select_hash("update_interval", $update_interval, $update_intervals); | |
16211ddb | 255 | |
ecace165 AD |
256 | /* Update method */ |
257 | ||
258 | if (ALLOW_SELECT_UPDATE_METHOD) { | |
34459667 | 259 | $update_method = db_fetch_result($result, 0, "update_method"); |
ecace165 AD |
260 | |
261 | print " " . __('using') . " "; | |
262 | print_select_hash("update_method", $update_method, $update_methods); | |
34459667 | 263 | } |
16211ddb | 264 | |
ecace165 AD |
265 | /* Purge intl */ |
266 | ||
267 | print "<br/>"; | |
268 | ||
269 | $purge_interval = db_fetch_result($result, 0, "purge_interval"); | |
270 | ||
271 | print __('Article purging:') . " "; | |
272 | ||
273 | print_select_hash("purge_interval", $purge_interval, $purge_intervals); | |
274 | ||
275 | print "</div>"; | |
276 | print "<div class=\"dlgSec\">".__("Authentication")."</div>"; | |
277 | print "<div class=\"dlgSecCont\">"; | |
278 | ||
47439031 | 279 | $auth_login = htmlspecialchars(db_fetch_result($result, 0, "auth_login")); |
ef8be8ea | 280 | |
ecace165 AD |
281 | print __('Login:') . " "; |
282 | print "<input size=\"20\" onkeypress=\"return filterCR(event, feedEditSave)\" | |
283 | name=\"auth_login\" value=\"$auth_login\">"; | |
284 | ||
285 | print " " . __("Password:") . " "; | |
ef8be8ea | 286 | |
47439031 | 287 | $auth_pass = htmlspecialchars(db_fetch_result($result, 0, "auth_pass")); |
ef8be8ea | 288 | |
ecace165 | 289 | print "<input size=\"20\" type=\"password\" name=\"auth_pass\" |
ef8be8ea | 290 | onkeypress=\"return filterCR(event, feedEditSave)\" |
ecace165 | 291 | value=\"$auth_pass\">"; |
ef8be8ea | 292 | |
ecace165 AD |
293 | print "</div>"; |
294 | print "<div class=\"dlgSec\">".__("Options")."</div>"; | |
295 | print "<div class=\"dlgSecCont\">"; | |
ef8be8ea | 296 | |
ecace165 | 297 | print "<div style=\"line-height : 100%\">"; |
ef8be8ea | 298 | |
ecace165 AD |
299 | print "<input type=\"checkbox\" name=\"private\" id=\"private\" |
300 | $checked> <label for=\"private\">".__('Hide from "Other Feeds"')."</label>"; | |
ef8be8ea AD |
301 | |
302 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
303 | ||
304 | if ($rtl_content) { | |
305 | $checked = "checked"; | |
306 | } else { | |
307 | $checked = ""; | |
308 | } | |
309 | ||
ecace165 AD |
310 | print "<br/><input type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\" |
311 | $checked> <label for=\"rtl_content\">".__('Right-to-left content')."</label>"; | |
ef8be8ea AD |
312 | |
313 | $hidden = sql_bool_to_bool(db_fetch_result($result, 0, "hidden")); | |
314 | ||
315 | if ($hidden) { | |
316 | $checked = "checked"; | |
317 | } else { | |
318 | $checked = ""; | |
319 | } | |
320 | ||
ecace165 AD |
321 | print "<br/><input type=\"checkbox\" id=\"hidden\" name=\"hidden\" |
322 | $checked> <label for=\"hidden\">".__('Hide from my feed list')."</label>"; | |
ef8be8ea AD |
323 | |
324 | $include_in_digest = sql_bool_to_bool(db_fetch_result($result, 0, "include_in_digest")); | |
325 | ||
326 | if ($include_in_digest) { | |
327 | $checked = "checked"; | |
328 | } else { | |
329 | $checked = ""; | |
330 | } | |
331 | ||
ecace165 | 332 | print "<br/><input type=\"checkbox\" id=\"include_in_digest\" |
ef8be8ea | 333 | name=\"include_in_digest\" |
ecace165 | 334 | $checked> <label for=\"include_in_digest\">".__('Include in e-mail digest')."</label>"; |
ef8be8ea | 335 | |
bc0f0785 AD |
336 | $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images")); |
337 | ||
338 | if ($cache_images) { | |
339 | $checked = "checked"; | |
340 | } else { | |
341 | $checked = ""; | |
342 | } | |
343 | ||
344 | if (ENABLE_SIMPLEPIE && SIMPLEPIE_CACHE_IMAGES) { | |
345 | $disabled = ""; | |
346 | $label_class = ""; | |
347 | } else { | |
348 | $disabled = "disabled"; | |
349 | $label_class = "class='insensitive'"; | |
350 | } | |
351 | ||
ecace165 | 352 | print "<br/><input type=\"checkbox\" id=\"cache_images\" |
bc0f0785 | 353 | name=\"cache_images\" $disabled |
ecace165 | 354 | $checked> <label $label_class for=\"cache_images\">". |
bc0f0785 AD |
355 | __('Cache images locally')."</label>"; |
356 | ||
ef8be8ea | 357 | |
ecace165 AD |
358 | print "</div>"; |
359 | print "</div>"; | |
ef8be8ea AD |
360 | |
361 | print "</form>"; | |
362 | ||
ecace165 | 363 | print "<div class='dlgButtons'> |
143a4973 AD |
364 | <div style=\"float : left\"> |
365 | <input type='submit' class='button' | |
366 | onclick='return unsubscribeFeed($feed_id, \"$title\")' value=\"".__('Unsubscribe')."\"> | |
367 | </div> | |
ef8be8ea | 368 | <input type=\"submit\" class=\"button\" |
31cc42f6 | 369 | onclick=\"return feedEditSave()\" value=\"".__('Save')."\"> |
ef8be8ea | 370 | <input type='submit' class='button' |
c8d5dcfe | 371 | onclick=\"return feedEditCancel()\" value=\"".__('Cancel')."\"> |
c8d5dcfe | 372 | </div>"; |
ef8be8ea | 373 | |
ef8be8ea AD |
374 | return; |
375 | } | |
376 | ||
377 | if ($subop == "editSave") { | |
378 | ||
379 | $feed_title = db_escape_string(trim($_POST["title"])); | |
380 | $feed_link = db_escape_string(trim($_POST["feed_url"])); | |
381 | $upd_intl = db_escape_string($_POST["update_interval"]); | |
382 | $purge_intl = db_escape_string($_POST["purge_interval"]); | |
383 | $feed_id = db_escape_string($_POST["id"]); | |
384 | $cat_id = db_escape_string($_POST["cat_id"]); | |
385 | $auth_login = db_escape_string(trim($_POST["auth_login"])); | |
386 | $auth_pass = db_escape_string(trim($_POST["auth_pass"])); | |
387 | $parent_feed = db_escape_string($_POST["parent_feed"]); | |
388 | $private = checkbox_to_sql_bool(db_escape_string($_POST["private"])); | |
389 | $rtl_content = checkbox_to_sql_bool(db_escape_string($_POST["rtl_content"])); | |
390 | $hidden = checkbox_to_sql_bool(db_escape_string($_POST["hidden"])); | |
391 | $include_in_digest = checkbox_to_sql_bool( | |
392 | db_escape_string($_POST["include_in_digest"])); | |
bc0f0785 AD |
393 | $cache_images = checkbox_to_sql_bool( |
394 | db_escape_string($_POST["cache_images"])); | |
16211ddb | 395 | $update_method = (int) db_escape_string($_POST["update_method"]); |
ef8be8ea AD |
396 | |
397 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
398 | if ($cat_id && $cat_id != 0) { | |
399 | $category_qpart = "cat_id = '$cat_id',"; | |
400 | $category_qpart_nocomma = "cat_id = '$cat_id'"; | |
401 | } else { | |
402 | $category_qpart = 'cat_id = NULL,'; | |
403 | $category_qpart_nocomma = 'cat_id = NULL'; | |
404 | } | |
405 | } else { | |
406 | $category_qpart = ""; | |
407 | $category_qpart_nocomma = ""; | |
408 | } | |
409 | ||
410 | if ($parent_feed && $parent_feed != 0) { | |
411 | $parent_qpart = "parent_feed = '$parent_feed'"; | |
412 | } else { | |
413 | $parent_qpart = 'parent_feed = NULL'; | |
414 | } | |
415 | ||
bc0f0785 AD |
416 | if (ENABLE_SIMPLEPIE && SIMPLEPIE_CACHE_IMAGES) { |
417 | $cache_images_qpart = "cache_images = $cache_images,"; | |
418 | } else { | |
419 | $cache_images_qpart = ""; | |
420 | } | |
421 | ||
ef8be8ea AD |
422 | $result = db_query($link, "UPDATE ttrss_feeds SET |
423 | $category_qpart $parent_qpart, | |
424 | title = '$feed_title', feed_url = '$feed_link', | |
425 | update_interval = '$upd_intl', | |
426 | purge_interval = '$purge_intl', | |
427 | auth_login = '$auth_login', | |
428 | auth_pass = '$auth_pass', | |
429 | private = $private, | |
430 | rtl_content = $rtl_content, | |
431 | hidden = $hidden, | |
bc0f0785 | 432 | $cache_images_qpart |
16211ddb AD |
433 | include_in_digest = $include_in_digest, |
434 | update_method = '$update_method' | |
ef8be8ea AD |
435 | WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); |
436 | ||
437 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
438 | # update linked feed categories | |
439 | $result = db_query($link, "UPDATE ttrss_feeds SET | |
440 | $category_qpart_nocomma WHERE parent_feed = '$feed_id' AND | |
441 | owner_uid = " . $_SESSION["uid"]); | |
442 | } | |
443 | } | |
444 | ||
ef8be8ea AD |
445 | if ($subop == "remove") { |
446 | ||
447 | if (!WEB_DEMO_MODE) { | |
448 | ||
449 | $ids = split(",", db_escape_string($_GET["ids"])); | |
450 | ||
451 | foreach ($ids as $id) { | |
452 | ||
453 | if ($id > 0) { | |
454 | ||
455 | db_query($link, "DELETE FROM ttrss_feeds | |
456 | WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
457 | ||
458 | $icons_dir = ICONS_DIR; | |
459 | ||
460 | if (file_exists($icons_dir . "/$id.ico")) { | |
461 | unlink($icons_dir . "/$id.ico"); | |
462 | } | |
463 | } else if ($id < -10) { | |
464 | ||
465 | $label_id = -$id - 11; | |
466 | ||
467 | db_query($link, "DELETE FROM ttrss_labels | |
468 | WHERE id = '$label_id' AND owner_uid = " . $_SESSION["uid"]); | |
469 | } | |
470 | } | |
471 | } | |
472 | } | |
473 | ||
d1f0c584 AD |
474 | if ($subop == "clear") { |
475 | $id = db_escape_string($_GET["id"]); | |
476 | clear_feed_articles($link, $id); | |
477 | } | |
478 | ||
fee840fb AD |
479 | if ($subop == "rescore") { |
480 | $ids = split(",", db_escape_string($_GET["ids"])); | |
481 | ||
482 | foreach ($ids as $id) { | |
483 | ||
484 | $filters = load_filters($link, $id, $_SESSION["uid"], 6); | |
485 | ||
486 | $result = db_query($link, "SELECT title, content, link, ref_id FROM | |
487 | ttrss_user_entries, ttrss_entries | |
488 | WHERE ref_id = id AND feed_id = '$id' AND | |
489 | owner_uid = " .$_SESSION['uid']." | |
ef1b0366 | 490 | "); |
fee840fb AD |
491 | |
492 | $scores = array(); | |
493 | ||
494 | while ($line = db_fetch_assoc($result)) { | |
495 | ||
496 | $article_filters = get_article_filters($filters, $line['title'], | |
497 | $line['content'], $line['link']); | |
498 | ||
499 | $new_score = calculate_article_score($article_filters); | |
500 | ||
501 | if (!$scores[$new_score]) $scores[$new_score] = array(); | |
502 | ||
503 | array_push($scores[$new_score], $line['ref_id']); | |
504 | } | |
505 | ||
506 | foreach (array_keys($scores) as $s) { | |
507 | if ($s > 1000) { | |
508 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s', | |
509 | marked = true WHERE | |
95a948a5 | 510 | ref_id IN (" . join(',', $scores[$s]) . ")"); |
1618a849 AD |
511 | } else if ($s < -500) { |
512 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s', | |
513 | unread = false WHERE | |
514 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
95a948a5 AD |
515 | } else { |
516 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE | |
517 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
518 | } | |
519 | } | |
520 | } | |
521 | ||
522 | print __("All done."); | |
523 | ||
524 | } | |
525 | ||
526 | if ($subop == "rescoreAll") { | |
527 | ||
528 | $result = db_query($link, | |
529 | "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']); | |
530 | ||
531 | while ($feed_line = db_fetch_assoc($result)) { | |
532 | ||
533 | $id = $feed_line["id"]; | |
534 | ||
535 | $filters = load_filters($link, $id, $_SESSION["uid"], 6); | |
536 | ||
537 | $tmp_result = db_query($link, "SELECT title, content, link, ref_id FROM | |
538 | ttrss_user_entries, ttrss_entries | |
539 | WHERE ref_id = id AND feed_id = '$id' AND | |
540 | owner_uid = " .$_SESSION['uid']." | |
541 | "); | |
542 | ||
543 | $scores = array(); | |
544 | ||
545 | while ($line = db_fetch_assoc($tmp_result)) { | |
546 | ||
547 | $article_filters = get_article_filters($filters, $line['title'], | |
548 | $line['content'], $line['link']); | |
549 | ||
550 | $new_score = calculate_article_score($article_filters); | |
551 | ||
552 | if (!$scores[$new_score]) $scores[$new_score] = array(); | |
553 | ||
554 | array_push($scores[$new_score], $line['ref_id']); | |
555 | } | |
556 | ||
557 | foreach (array_keys($scores) as $s) { | |
558 | if ($s > 1000) { | |
559 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s', | |
560 | marked = true WHERE | |
fee840fb AD |
561 | ref_id IN (" . join(',', $scores[$s]) . ")"); |
562 | } else { | |
563 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE | |
564 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
565 | } | |
566 | } | |
567 | } | |
568 | ||
569 | print __("All done."); | |
570 | ||
571 | } | |
572 | ||
ef8be8ea AD |
573 | if ($subop == "add") { |
574 | ||
575 | if (!WEB_DEMO_MODE) { | |
576 | ||
f27de515 AD |
577 | $feed_url = db_escape_string(trim($_REQUEST["feed_url"])); |
578 | $cat_id = db_escape_string($_REQUEST["cat_id"]); | |
579 | $p_from = db_escape_string($_REQUEST["from"]); | |
580 | ||
581 | /* only read authentication information from POST */ | |
582 | ||
583 | $auth_login = db_escape_string(trim($_POST["auth_login"])); | |
584 | $auth_pass = db_escape_string(trim($_POST["auth_pass"])); | |
aa2122d4 | 585 | |
e513a74a | 586 | if ($p_from != 'tt-rss') { |
aa2122d4 AD |
587 | print "<html> |
588 | <head> | |
589 | <title>Tiny Tiny RSS - Subscribe to feed...</title> | |
590 | <link rel=\"stylesheet\" type=\"text/css\" href=\"quicksub.css\"> | |
591 | </head> | |
592 | <body> | |
593 | <img class=\"logo\" src=\"images/ttrss_logo.png\" | |
594 | alt=\"Tiny Tiny RSS\"/> | |
e513a74a AD |
595 | <h1>Subscribe to feed...</h1> |
596 | <div class=\"content\">"; | |
aa2122d4 | 597 | } |
ef8be8ea | 598 | |
f27de515 | 599 | if (subscribe_to_feed($link, $feed_url, $cat_id, $auth_login, $auth_pass)) { |
4dccf1ed | 600 | print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url)); |
ef8be8ea | 601 | } else { |
4dccf1ed | 602 | print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url)); |
ef8be8ea | 603 | } |
aa2122d4 | 604 | |
e513a74a | 605 | if ($p_from != 'tt-rss') { |
d70c5ae4 | 606 | $tt_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'tt-rss.php', $_SERVER["REQUEST_URI"]); |
aa2122d4 | 607 | |
d70c5ae4 AD |
608 | |
609 | $tp_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'prefs.php', $_SERVER["REQUEST_URI"]); | |
e513a74a AD |
610 | |
611 | print "<p><a href='$tt_uri'>Return to Tiny Tiny RSS</a> |"; | |
612 | ||
613 | $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE | |
614 | feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]); | |
615 | ||
616 | $feed_id = db_fetch_result($result, 0, "id"); | |
617 | ||
618 | if ($feed_id) { | |
619 | print "<a href='$tp_uri?tab=feedConfig&subop=editFeed:$feed_id'> | |
620 | Edit subscription options</a> | "; | |
621 | } | |
622 | ||
623 | print "<a href='javascript:window.close()'>Close this window</a>.</p>"; | |
aa2122d4 | 624 | |
e513a74a | 625 | print "</div></body></html>"; |
aa2122d4 AD |
626 | return; |
627 | } | |
442d77f1 | 628 | |
ef8be8ea AD |
629 | } |
630 | } | |
631 | ||
ef8be8ea AD |
632 | if ($subop == "categorize") { |
633 | ||
634 | if (!WEB_DEMO_MODE) { | |
635 | ||
636 | $ids = split(",", db_escape_string($_GET["ids"])); | |
637 | ||
638 | $cat_id = db_escape_string($_GET["cat_id"]); | |
639 | ||
640 | if ($cat_id == 0) { | |
641 | $cat_id_qpart = 'NULL'; | |
642 | } else { | |
643 | $cat_id_qpart = "'$cat_id'"; | |
644 | } | |
645 | ||
646 | db_query($link, "BEGIN"); | |
647 | ||
648 | foreach ($ids as $id) { | |
649 | ||
650 | db_query($link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart | |
651 | WHERE id = '$id' AND parent_feed IS NULL | |
652 | AND owner_uid = " . $_SESSION["uid"]); | |
653 | ||
654 | # update linked feed categories | |
655 | db_query($link, "UPDATE ttrss_feeds SET | |
656 | cat_id = $cat_id_qpart WHERE parent_feed = '$id' AND | |
657 | owner_uid = " . $_SESSION["uid"]); | |
658 | ||
659 | } | |
660 | ||
661 | db_query($link, "COMMIT"); | |
662 | } | |
663 | ||
664 | } | |
665 | ||
9c483746 AD |
666 | if ($subop == "editCats") { |
667 | ||
9c483746 AD |
668 | $action = $_REQUEST["action"]; |
669 | ||
670 | if ($action == "save") { | |
671 | ||
11f083e7 AD |
672 | $cat_title = db_escape_string(trim($_REQUEST["value"])); |
673 | $cat_id = db_escape_string($_GET["cid"]); | |
9c483746 AD |
674 | |
675 | $result = db_query($link, "UPDATE ttrss_feed_categories SET | |
676 | title = '$cat_title' WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]); | |
11f083e7 AD |
677 | |
678 | print $_REQUEST["value"]; | |
679 | ||
680 | return; | |
681 | ||
9c483746 AD |
682 | } |
683 | ||
11f083e7 AD |
684 | print "<div id=\"infoBoxTitle\">".__('Category editor')."</div>"; |
685 | ||
686 | print "<div class=\"infoBoxContents\">"; | |
687 | ||
688 | ||
9c483746 AD |
689 | if ($action == "add") { |
690 | ||
691 | if (!WEB_DEMO_MODE) { | |
692 | ||
693 | $feed_cat = db_escape_string(trim($_GET["cat"])); | |
694 | ||
695 | $result = db_query($link, | |
696 | "SELECT id FROM ttrss_feed_categories | |
697 | WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]); | |
698 | ||
699 | if (db_num_rows($result) == 0) { | |
700 | ||
701 | $result = db_query($link, | |
702 | "INSERT INTO ttrss_feed_categories (owner_uid,title) | |
703 | VALUES ('".$_SESSION["uid"]."', '$feed_cat')"); | |
704 | ||
705 | } else { | |
706 | ||
4dccf1ed AD |
707 | print_warning(T_sprintf("Category <b>$%s</b> already exists in the database.", |
708 | $feed_cat)); | |
9c483746 AD |
709 | } |
710 | ||
711 | } | |
712 | } | |
713 | ||
714 | if ($action == "remove") { | |
715 | ||
716 | if (!WEB_DEMO_MODE) { | |
717 | ||
718 | $ids = split(",", db_escape_string($_GET["ids"])); | |
719 | ||
720 | foreach ($ids as $id) { | |
721 | ||
722 | db_query($link, "BEGIN"); | |
723 | ||
724 | $result = db_query($link, | |
725 | "SELECT count(id) as num_feeds FROM ttrss_feeds | |
726 | WHERE cat_id = '$id'"); | |
727 | ||
728 | $num_feeds = db_fetch_result($result, 0, "num_feeds"); | |
729 | ||
730 | if ($num_feeds == 0) { | |
731 | db_query($link, "DELETE FROM ttrss_feed_categories | |
732 | WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
733 | } else { | |
734 | ||
31cc42f6 | 735 | print format_warning(__("Unable to delete non empty feed categories.")); |
9c483746 AD |
736 | |
737 | } | |
738 | ||
739 | db_query($link, "COMMIT"); | |
740 | } | |
741 | } | |
742 | } | |
743 | ||
744 | print "<div class=\"prefGenericAddBox\"> | |
745 | <input id=\"fadd_cat\" | |
1043a8c3 | 746 | onkeypress=\"return filterCR(event, addFeedCat)\" |
9c483746 | 747 | onkeyup=\"toggleSubmitNotEmpty(this, 'catadd_submit_btn')\" |
b5015f72 | 748 | onchange=\"toggleSubmitNotEmpty(this, 'catadd_submit_btn')\" |
9c483746 AD |
749 | size=\"40\"> |
750 | <input | |
751 | type=\"submit\" class=\"button\" disabled=\"true\" id=\"catadd_submit_btn\" | |
31cc42f6 | 752 | onclick=\"javascript:addFeedCat()\" value=\"".__('Create category')."\"></div>"; |
9c483746 AD |
753 | |
754 | $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories | |
755 | WHERE owner_uid = ".$_SESSION["uid"]." | |
756 | ORDER BY title"); | |
757 | ||
758 | print "<p>"; | |
759 | ||
760 | if (db_num_rows($result) != 0) { | |
761 | ||
762 | print "<table width=\"100%\" class=\"prefFeedCatList\" | |
763 | cellspacing=\"0\">"; | |
764 | ||
765 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
e8d0177d AD |
766 | ".__('Select:')." |
767 | <a href=\"javascript:selectPrefRows('fcat', true)\">".__('All')."</a>, | |
768 | <a href=\"javascript:selectPrefRows('fcat', false)\">".__('None')."</a> | |
9c483746 AD |
769 | </td></tr>"; |
770 | ||
771 | print "</table>"; | |
772 | ||
773 | print "<div class=\"prefFeedCatHolder\">"; | |
774 | ||
e6312f6c | 775 | print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">"; |
9c483746 AD |
776 | |
777 | print "<table width=\"100%\" class=\"prefFeedCatList\" | |
778 | cellspacing=\"0\" id=\"prefFeedCatList\">"; | |
9c483746 AD |
779 | |
780 | $lnum = 0; | |
781 | ||
782 | while ($line = db_fetch_assoc($result)) { | |
783 | ||
784 | $class = ($lnum % 2) ? "even" : "odd"; | |
785 | ||
786 | $cat_id = $line["id"]; | |
11f083e7 | 787 | $this_row_id = "id=\"FCATR-$cat_id\""; |
9c483746 AD |
788 | |
789 | print "<tr class=\"$class\" $this_row_id>"; | |
790 | ||
47439031 | 791 | $edit_title = htmlspecialchars($line["title"]); |
9c483746 | 792 | |
11f083e7 AD |
793 | print "<td width='5%' align='center'><input |
794 | onclick='toggleSelectPrefRow(this, \"fcat\");' | |
795 | type=\"checkbox\" id=\"FCCHK-$cat_id\"></td>"; | |
796 | ||
797 | print "<td><span id=\"FCATT-$cat_id\">" . | |
798 | $edit_title . "</span></td>"; | |
9c483746 AD |
799 | |
800 | print "</tr>"; | |
801 | ||
802 | ++$lnum; | |
803 | } | |
804 | ||
805 | print "</table>"; | |
806 | ||
807 | print "</form>"; | |
808 | ||
809 | print "</div>"; | |
810 | ||
6f5b1e04 | 811 | } else { |
31cc42f6 | 812 | print "<p>".__('No feed categories defined.')."</p>"; |
6f5b1e04 | 813 | } |
9c483746 | 814 | |
6f5b1e04 AD |
815 | print "<div style='float : right'> |
816 | <input type='submit' class='button' | |
31cc42f6 | 817 | onclick=\"selectTab('feedConfig')\" value=\"".__('Close this window')."\"></div>"; |
9c483746 | 818 | |
6f5b1e04 | 819 | print "<div id=\"catOpToolbar\">"; |
9c483746 | 820 | |
11f083e7 | 821 | print " |
6f5b1e04 | 822 | <input type=\"submit\" class=\"button\" disabled=\"true\" |
31cc42f6 | 823 | onclick=\"return removeSelectedFeedCats()\" value=\"".__('Remove')."\">"; |
11f083e7 | 824 | |
9c483746 AD |
825 | print "</div>"; |
826 | ||
6f5b1e04 AD |
827 | print "</div>"; |
828 | ||
9c483746 AD |
829 | return; |
830 | ||
831 | } | |
832 | ||
ef8be8ea AD |
833 | if ($quiet) return; |
834 | ||
442d77f1 AD |
835 | set_pref($link, "_PREFS_ACTIVE_TAB", "feedConfig"); |
836 | ||
a3656a41 | 837 | $result = db_query($link, "SELECT COUNT(id) AS num_errors |
ef8be8ea AD |
838 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]); |
839 | ||
a3656a41 | 840 | $num_errors = db_fetch_result($result, 0, "num_errors"); |
ef8be8ea | 841 | |
a3656a41 | 842 | if ($num_errors > 0) { |
ef8be8ea | 843 | |
31cc42f6 AD |
844 | print format_notice("<a href=\"javascript:showFeedsWithErrors()\">". |
845 | __('Some feeds have update errors (click for details)')."</a>"); | |
ef8be8ea AD |
846 | } |
847 | ||
848 | $feed_search = db_escape_string($_GET["search"]); | |
849 | ||
850 | if (array_key_exists("search", $_GET)) { | |
851 | $_SESSION["prefs_feed_search"] = $feed_search; | |
852 | } else { | |
853 | $feed_search = $_SESSION["prefs_feed_search"]; | |
854 | } | |
855 | ||
856 | print "<div class=\"feedEditSearch\"> | |
3dc8ee84 | 857 | <input id=\"feed_search\" size=\"20\" type=\"search\" |
4cf6fc6a AD |
858 | onfocus=\"javascript:disableHotkeys();\" |
859 | onblur=\"javascript:enableHotkeys();\" | |
ef8be8ea AD |
860 | onchange=\"javascript:updateFeedList()\" value=\"$feed_search\"> |
861 | <input type=\"submit\" class=\"button\" | |
a3c159c4 | 862 | onclick=\"javascript:updateFeedList()\" value=\"".__('Search')."\"> |
ef8be8ea | 863 | </div>"; |
5e6f933a | 864 | |
442d77f1 | 865 | print "<input onclick=\"javascript:displayDlg('quickAddFeed')\" |
a349077c | 866 | type=\"submit\" id=\"subscribe_to_feed_btn\" |
442d77f1 | 867 | class=\"button\" value=\"".__('Subscribe to feed')."\">"; |
ef8be8ea AD |
868 | |
869 | if (ENABLE_FEED_BROWSER && !SINGLE_USER_MODE) { | |
870 | print " <input type=\"submit\" class=\"button\" | |
a349077c | 871 | id=\"top25_feeds_btn\" |
a3c159c4 | 872 | onclick=\"javascript:browseFeeds()\" value=\"".__('Top 25')."\">"; |
ef8be8ea AD |
873 | } |
874 | ||
ef8be8ea AD |
875 | $feeds_sort = db_escape_string($_GET["sort"]); |
876 | ||
877 | if (!$feeds_sort || $feeds_sort == "undefined") { | |
878 | $feeds_sort = $_SESSION["pref_sort_feeds"]; | |
879 | if (!$feeds_sort) $feeds_sort = "title"; | |
880 | } | |
881 | ||
882 | $_SESSION["pref_sort_feeds"] = $feeds_sort; | |
883 | ||
884 | if ($feed_search) { | |
885 | $search_qpart = "(UPPER(F1.title) LIKE UPPER('%$feed_search%') OR | |
886 | UPPER(F1.feed_url) LIKE UPPER('%$feed_search%')) AND"; | |
887 | } else { | |
888 | $search_qpart = ""; | |
889 | } | |
890 | ||
400b60d8 AD |
891 | $show_last_article_info = false; |
892 | $show_last_article_checked = ""; | |
893 | $show_last_article_qpart = ""; | |
894 | ||
895 | if ($_GET["slat"] == "true") { | |
896 | $show_last_article_info = true; | |
897 | $show_last_article_checked = "checked"; | |
fc2b26a6 | 898 | $show_last_article_qpart = ", (SELECT ".SUBSTRING_FOR_DATE."(MAX(updated),1,16) FROM ttrss_user_entries, |
400b60d8 AD |
899 | ttrss_entries WHERE ref_id = ttrss_entries.id |
900 | AND feed_id = F1.id) AS last_article"; | |
d2ca9130 AD |
901 | } else if ($feeds_sort == "last_article") { |
902 | $feeds_sort = "title"; | |
903 | } | |
904 | ||
905 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
906 | $order_by_qpart = "category,$feeds_sort,title"; | |
907 | } else { | |
908 | $order_by_qpart = "$feeds_sort,title"; | |
400b60d8 AD |
909 | } |
910 | ||
ef8be8ea AD |
911 | $result = db_query($link, "SELECT |
912 | F1.id, | |
913 | F1.title, | |
914 | F1.feed_url, | |
2ac6b765 | 915 | ".SUBSTRING_FOR_DATE."(F1.last_updated,1,16) AS last_updated, |
ef8be8ea AD |
916 | F1.parent_feed, |
917 | F1.update_interval, | |
365f95dc | 918 | F1.last_error, |
ef8be8ea AD |
919 | F1.purge_interval, |
920 | F1.cat_id, | |
921 | F2.title AS parent_title, | |
922 | C1.title AS category, | |
923 | F1.hidden, | |
400b60d8 AD |
924 | F1.include_in_digest |
925 | $show_last_article_qpart | |
ef8be8ea AD |
926 | FROM |
927 | ttrss_feeds AS F1 | |
928 | LEFT JOIN ttrss_feeds AS F2 | |
929 | ON (F1.parent_feed = F2.id) | |
930 | LEFT JOIN ttrss_feed_categories AS C1 | |
931 | ON (F1.cat_id = C1.id) | |
932 | WHERE | |
933 | $search_qpart F1.owner_uid = '".$_SESSION["uid"]."' | |
934 | ORDER by $order_by_qpart"); | |
935 | ||
936 | if (db_num_rows($result) != 0) { | |
937 | ||
938 | // print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>"; | |
939 | ||
940 | print "<p><table width=\"100%\" cellspacing=\"0\" | |
941 | class=\"prefFeedList\" id=\"prefFeedList\">"; | |
400b60d8 AD |
942 | print "<tr><td class=\"selectPrompt\" colspan=\"8\">". |
943 | "<div style='float : right'>". | |
944 | "<input id='show_last_article_times' type='checkbox' onchange='feedlistToggleSLAT()' | |
945 | $show_last_article_checked><label | |
946 | for='show_last_article_times'>".__('Show last article times')."</label></div>". | |
947 | __('Select:')." | |
e8d0177d AD |
948 | <a href=\"javascript:selectPrefRows('feed', true)\">".__('All')."</a>, |
949 | <a href=\"javascript:selectPrefRows('feed', false)\">".__('None')."</a> | |
ef8be8ea AD |
950 | </td</tr>"; |
951 | ||
952 | if (!get_pref($link, 'ENABLE_FEED_CATS')) { | |
953 | print "<tr class=\"title\"> | |
954 | <td width='5%' align='center'> </td>"; | |
955 | ||
956 | if (get_pref($link, 'ENABLE_FEED_ICONS')) { | |
957 | print "<td width='3%'> </td>"; | |
958 | } | |
959 | ||
c4b0f96c AD |
960 | print "<td width='60%'><a href=\"javascript:updateFeedList('title')\">".__('Title')."</a></td>"; |
961 | ||
962 | if ($show_last_article_info) { | |
963 | print "<td width='20%' align='right'><a href=\"javascript:updateFeedList('last_article')\">".__('Last Article')."</a></td>"; | |
964 | } | |
965 | ||
966 | print "<td width='20%' align='right'><a href=\"javascript:updateFeedList('last_updated')\">".__('Updated')."</a></td>"; | |
ef8be8ea AD |
967 | } |
968 | ||
969 | $lnum = 0; | |
970 | ||
971 | $cur_cat_id = -1; | |
972 | ||
973 | while ($line = db_fetch_assoc($result)) { | |
974 | ||
975 | $feed_id = $line["id"]; | |
976 | $cat_id = $line["cat_id"]; | |
977 | ||
47439031 AD |
978 | $edit_title = htmlspecialchars($line["title"]); |
979 | $edit_cat = htmlspecialchars($line["category"]); | |
ef8be8ea AD |
980 | |
981 | $hidden = sql_bool_to_bool($line["hidden"]); | |
982 | ||
365f95dc AD |
983 | $last_error = $line["last_error"]; |
984 | ||
3692e98f | 985 | if (!$edit_cat) $edit_cat = __("Uncategorized"); |
ef8be8ea AD |
986 | |
987 | $last_updated = $line["last_updated"]; | |
988 | ||
7a74abd5 AD |
989 | if (!$last_updated) { |
990 | $last_updated = "—"; | |
991 | } else if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
ef8be8ea AD |
992 | $last_updated = smart_date_time(strtotime($last_updated)); |
993 | } else { | |
994 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
995 | $last_updated = date($short_date, strtotime($last_updated)); | |
996 | } | |
997 | ||
998 | $last_article = $line["last_article"]; | |
999 | ||
7a74abd5 AD |
1000 | if (!$last_article) { |
1001 | $last_article = "—"; | |
1002 | } else if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
ef8be8ea AD |
1003 | $last_article = smart_date_time(strtotime($last_article)); |
1004 | } else { | |
1005 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
1006 | $last_article = date($short_date, strtotime($last_article)); | |
1007 | } | |
1008 | ||
1009 | if (get_pref($link, 'ENABLE_FEED_CATS') && $cur_cat_id != $cat_id) { | |
1010 | $lnum = 0; | |
1011 | ||
1012 | print "<tr><td colspan=\"6\" class=\"feedEditCat\">$edit_cat</td></tr>"; | |
1013 | ||
1014 | print "<tr class=\"title\"> | |
1015 | <td width='5%'> </td>"; | |
1016 | ||
1017 | if (get_pref($link, 'ENABLE_FEED_ICONS')) { | |
1018 | print "<td width='3%'> </td>"; | |
1019 | } | |
1020 | ||
400b60d8 AD |
1021 | print "<td width='60%'><a href=\"javascript:updateFeedList('title')\">".__('Title')."</a></td>"; |
1022 | ||
1023 | if ($show_last_article_info) { | |
1024 | print "<td width='20%' align='right'> | |
1025 | <a href=\"javascript:updateFeedList('last_article')\">".__('Last Article')."</a></td>"; | |
1026 | } | |
1027 | ||
1028 | print "<td width='20%' align='right'> | |
1029 | <a href=\"javascript:updateFeedList('last_updated')\">".__('Updated')."</a></td>"; | |
ef8be8ea AD |
1030 | |
1031 | $cur_cat_id = $cat_id; | |
1032 | } | |
1033 | ||
1034 | $class = ($lnum % 2) ? "even" : "odd"; | |
1035 | $this_row_id = "id=\"FEEDR-$feed_id\""; | |
1036 | ||
1037 | print "<tr class=\"$class\" $this_row_id>"; | |
1038 | ||
1039 | $icon_file = ICONS_DIR . "/$feed_id.ico"; | |
1040 | ||
1041 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
1042 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
1043 | } else { | |
1044 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
1045 | } | |
1046 | ||
1047 | print "<td class='feedSelect'><input onclick='toggleSelectPrefRow(this, \"feed\");' | |
1048 | type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>"; | |
1049 | ||
a95da136 AD |
1050 | $onclick = "onclick='editFeed($feed_id)' title='".__('Click to edit')."'"; |
1051 | ||
ef8be8ea | 1052 | if (get_pref($link, 'ENABLE_FEED_ICONS')) { |
a95da136 | 1053 | print "<td $onclick class='feedIcon'>$feed_icon</td>"; |
ef8be8ea AD |
1054 | } |
1055 | ||
ef8be8ea AD |
1056 | if ($hidden) { |
1057 | $edit_title = "<span class=\"insensitive\">$edit_title (Hidden)</span>"; | |
ef8be8ea AD |
1058 | $last_updated = "<span class=\"insensitive\">$last_updated</span>"; |
1059 | $last_article = "<span class=\"insensitive\">$last_article</span>"; | |
365f95dc AD |
1060 | } |
1061 | ||
1062 | if ($last_error) { | |
1fc77c25 | 1063 | $edit_title = "<span class=\"feed_error\">$edit_title</span>"; |
365f95dc AD |
1064 | $last_updated = "<span class=\"feed_error\">$last_updated</span>"; |
1065 | $last_article = "<span class=\"feed_error\">$last_article</span>"; | |
ef8be8ea AD |
1066 | } |
1067 | ||
1068 | $parent_title = $line["parent_title"]; | |
1069 | if ($parent_title) { | |
1070 | $parent_title = "<span class='groupPrompt'>(linked to | |
1071 | $parent_title)</span>"; | |
1072 | } | |
1073 | ||
a95da136 | 1074 | print "<td $onclick>" . "$edit_title $parent_title" . "</td>"; |
ef8be8ea | 1075 | |
400b60d8 | 1076 | if ($show_last_article_info) { |
a95da136 AD |
1077 | print "<td align='right' $onclick>" . |
1078 | "$last_article</td>"; | |
400b60d8 | 1079 | } |
ef8be8ea | 1080 | |
fe5bfa00 | 1081 | print "<td $onclick align='right'>$last_updated</td>"; |
ef8be8ea AD |
1082 | |
1083 | print "</tr>"; | |
1084 | ||
1085 | ++$lnum; | |
1086 | } | |
1087 | ||
1088 | print "</table>"; | |
1089 | ||
e88a65f4 | 1090 | print "<p>"; |
c4a36709 | 1091 | |
19d96beb AD |
1092 | print "<div id=\"feedOpToolbar\">"; |
1093 | ||
1094 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
1095 | ||
1096 | print __('Selection:') . " "; | |
1097 | ||
1098 | print_feed_cat_select($link, "sfeed_set_fcat", "", "disabled"); | |
1099 | ||
1100 | print " <input type=\"submit\" class=\"button\" disabled=\"true\" | |
1101 | onclick=\"javascript:categorizeSelectedFeeds()\" value=\"". | |
1102 | __('Recategorize')."\">"; | |
1103 | } | |
1104 | ||
1105 | print "</div>"; | |
1106 | ||
c4a36709 AD |
1107 | print "<select id=\"feedActionChooser\" onchange=\"feedActionChange()\"> |
1108 | <option value=\"facDefault\" selected>".__('Actions...')."</option> | |
1109 | <option disabled>--------</option> | |
1110 | <option style=\"color : #5050aa\" disabled>".__('Selection:')."</option> | |
1111 | <option value=\"facEdit\"> ".__('Edit')."</option> | |
e88a65f4 | 1112 | <option value=\"facPurge\"> ".__('Manual purge')."</option> |
c4a36709 | 1113 | <option value=\"facClear\"> ".__('Clear feed data')."</option> |
fee840fb | 1114 | <option value=\"facRescore\"> ".__('Rescore articles')."</option> |
c4a36709 AD |
1115 | <option value=\"facUnsubscribe\"> ".__('Unsubscribe')."</option>"; |
1116 | ||
1117 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
1118 | ||
1119 | print "<option disabled>--------</option> | |
1120 | <option style=\"color : #5050aa\" disabled>".__('Other:')."</option> | |
1121 | <option value=\"facEditCats\"> ".__('Edit categories')." | |
1122 | </option>"; | |
1123 | } | |
1124 | ||
19d96beb | 1125 | print "</select>"; |
ef8be8ea AD |
1126 | } |
1127 | ||
a3c159c4 | 1128 | print "<h3>".__('OPML')."</h3> |
94a4ba88 AD |
1129 | |
1130 | <div style='float : left'> | |
ef8be8ea | 1131 | <form enctype=\"multipart/form-data\" method=\"POST\" action=\"opml.php\"> |
999703d1 AD |
1132 | ".__('File:')." <input id=\"opml_file\" name=\"opml_file\" type=\"file\"> |
1133 | <input type=\"hidden\" name=\"op\" value=\"Import\"> | |
1134 | <input class=\"button\" onclick=\"return validateOpmlImport();\" | |
a3c159c4 | 1135 | type=\"submit\" value=\"".__('Import')."\"> |
94a4ba88 AD |
1136 | </form></div>"; |
1137 | ||
3692e98f | 1138 | print " "; |
94a4ba88 AD |
1139 | |
1140 | print "<input type=\"submit\" | |
1141 | class=\"button\" onclick=\"gotoExportOpml()\" | |
a3c159c4 | 1142 | value=\"".__('Export OPML')."\">"; |
94a4ba88 | 1143 | |
e4f4b46f | 1144 | |
755a43ee AD |
1145 | print "<h3>" . __("Firefox Integration") . "</h3>"; |
1146 | ||
1147 | print "<p>" . __('This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.'); | |
e635d56a | 1148 | print "</p><p> <a class='visibleLink' href='javascript:window.navigator.registerContentHandler(" . |
755a43ee AD |
1149 | "\"application/vnd.mozilla.maybe.feed\", " . |
1150 | "\"" . add_feed_url() . "\", " . " \"Tiny Tiny RSS\")'>" . | |
1151 | __('Click here to register this site as a feed reader.') . "</a></p>"; | |
1152 | ||
1153 | ||
e400230e | 1154 | print "<h3>".__("Published articles")."</h3>"; |
e4f4b46f AD |
1155 | |
1156 | if (!get_pref($link, "_PREFS_PUBLISH_KEY")) { | |
1157 | set_pref($link, "_PREFS_PUBLISH_KEY", generate_publish_key()); | |
1158 | } | |
1159 | ||
e635d56a | 1160 | print "<p>".__('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.')."</p>"; |
e4f4b46f | 1161 | |
f56e3080 | 1162 | $url_path = article_publish_url($link); |
e4f4b46f | 1163 | |
562ecfcf | 1164 | print "<p><a class=\"visibleLink\" id=\"pubGenAddress\" target=\"_blank\" href=\"$url_path\">Link to published articles feed.</a></p>"; |
e4f4b46f | 1165 | |
8a8f7c55 | 1166 | print "<p><input type=\"submit\" onclick=\"return pubRegenKey()\" class=\"button\" |
e635d56a AD |
1167 | value=\"".__('Generate another link')."\">"; |
1168 | /* print " <input type=\"submit\" onclick=\"return pubToClipboard()\" class=\"button\" | |
1169 | value=\"".__('Copy link to clipboard')."\">"; */ | |
1170 | print "</p>"; | |
e4f4b46f | 1171 | |
ef8be8ea AD |
1172 | } |
1173 | ?> |