]>
Commit | Line | Data |
---|---|---|
1afd6227 | 1 | <?php |
1afd6227 AD |
2 | define('TTRSS_SESSION_NAME', 'ttrss_m_sid'); |
3 | ||
4 | function render_feeds_list($link) { | |
5 | ||
6 | $tags = $_GET["tags"]; | |
7 | ||
8 | print "<div id=\"heading\">"; | |
9 | ||
10 | if ($tags) { | |
11 | print __("Tags")."<span id=\"headingAddon\"> | |
12 | (<a href=\"index.php\">".__("View feeds")."</a>, "; | |
13 | } else { | |
14 | print __("Feeds")." <span id=\"headingAddon\"> | |
15 | (<a href=\"index.php?tags=1\">".__("View tags")."</a>, "; | |
16 | } | |
17 | ||
18 | print "<a href=\"index.php?go=sform\">".__("Search")."</a>, "; | |
19 | ||
20 | print "<a href=\"logout.php\">".__("Logout")."</a>)</span>"; | |
21 | print "</div>"; | |
22 | ||
23 | print "<ul class=\"feedList\">"; | |
24 | ||
25 | $owner_uid = $_SESSION["uid"]; | |
26 | ||
27 | if (!$tags) { | |
28 | ||
29 | /* virtual feeds */ | |
30 | ||
31 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
57937c42 AD |
32 | |
33 | $collapsed = get_pref($link, "_COLLAPSED_SPECIAL"); | |
1afd6227 AD |
34 | |
35 | if ($collapsed == "t" || $collapsed == "1") { | |
36 | $holder_class = "invisible"; | |
37 | $ellipsis = "..."; | |
38 | } else { | |
39 | $holder_class = "feedCatHolder"; | |
40 | $ellipsis = ""; | |
41 | } | |
42 | ||
43 | $tmp_category = __("Special"); | |
44 | ||
45 | print "<li class=\"feedCat\"> | |
46 | <a href=\"?subop=tc&id=-1\">$tmp_category</a>$ellipsis | |
47 | </li>"; | |
48 | ||
49 | print "<li class=\"$holder_class\"><ul class=\"feedCatList\">"; | |
50 | } | |
51 | ||
2aa709f7 AD |
52 | foreach (array(-4, -3, -1, -2, 0) as $i) { |
53 | printMobileFeedEntry($i, "virt", false, false, | |
54 | false, $link); | |
55 | } | |
1afd6227 AD |
56 | |
57 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
58 | print "</ul>"; | |
59 | } | |
60 | ||
61 | ||
62 | $result = db_query($link, "SELECT id,caption FROM | |
63 | ttrss_labels2 WHERE owner_uid = '$owner_uid' ORDER by caption"); | |
64 | ||
65 | if (db_num_rows($result) > 0) { | |
66 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
67 | ||
57937c42 | 68 | $collapsed = get_pref($link, "_COLLAPSED_LABELS"); |
1afd6227 AD |
69 | |
70 | if ($collapsed == "t" || $collapsed == "1") { | |
71 | $holder_class = "invisible"; | |
72 | $ellipsis = "..."; | |
73 | } else { | |
74 | $holder_class = "feedCatHolder"; | |
75 | $ellipsis = ""; | |
76 | } | |
77 | ||
78 | $tmp_category = __("Labels"); | |
79 | ||
80 | print "<li class=\"feedCat\"> | |
81 | <a href=\"?subop=tc&id=-2\">$tmp_category</a>$ellipsis | |
82 | </li>"; | |
83 | ||
84 | print "<li class=\"$holder_class\"><ul class=\"feedCatList\">"; | |
85 | } else { | |
86 | // print "<li><hr></li>"; | |
87 | } | |
88 | } | |
89 | ||
90 | while ($line = db_fetch_assoc($result)) { | |
91 | ||
92 | $count = getFeedUnread($link, -$line["id"]-11); | |
93 | ||
94 | $class = "label"; | |
95 | ||
1afd6227 | 96 | printMobileFeedEntry(-$line["id"]-11, |
2aa709f7 | 97 | $class, $line["caption"], $count, false, $link); |
1afd6227 AD |
98 | |
99 | } | |
100 | ||
101 | if (db_num_rows($result) > 0) { | |
102 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
103 | print "</ul>"; | |
104 | } | |
105 | } | |
106 | ||
107 | ||
108 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
109 | $order_by_qpart = "category,title"; | |
110 | } else { | |
111 | $order_by_qpart = "title"; | |
112 | } | |
113 | ||
114 | $result = db_query($link, "SELECT ttrss_feeds.*, | |
115 | ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated_noms, | |
116 | (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries | |
117 | WHERE feed_id = ttrss_feeds.id AND | |
118 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
119 | owner_uid = '$owner_uid') AS total, | |
120 | (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries | |
121 | WHERE feed_id = ttrss_feeds.id AND unread = true | |
122 | AND ttrss_user_entries.ref_id = ttrss_entries.id | |
123 | AND owner_uid = '$owner_uid') as unread, | |
124 | cat_id,last_error, | |
125 | ttrss_feed_categories.title AS category, | |
126 | ttrss_feed_categories.collapsed | |
127 | FROM ttrss_feeds LEFT JOIN ttrss_feed_categories | |
128 | ON (ttrss_feed_categories.id = cat_id) | |
129 | WHERE | |
1afd6227 AD |
130 | ttrss_feeds.owner_uid = '$owner_uid' AND parent_feed IS NULL |
131 | ORDER BY $order_by_qpart"); | |
132 | ||
133 | $actid = $_GET["actid"]; | |
134 | ||
135 | /* real feeds */ | |
136 | ||
137 | $lnum = 0; | |
138 | ||
139 | $category = ""; | |
140 | ||
141 | while ($line = db_fetch_assoc($result)) { | |
142 | if (get_pref($link, 'HIDE_READ_FEEDS') && (int)$line['unread']==0) { | |
143 | continue; | |
144 | } | |
145 | ||
146 | $feed = db_unescape_string($line["title"]); | |
147 | $feed_id = $line["id"]; | |
148 | ||
149 | $subop = $_GET["subop"]; | |
150 | ||
151 | $total = $line["total"]; | |
152 | $unread = $line["unread"]; | |
153 | ||
154 | $rtl_content = sql_bool_to_bool($line["rtl_content"]); | |
155 | ||
156 | if ($rtl_content) { | |
157 | $rtl_tag = "dir=\"RTL\""; | |
158 | } else { | |
159 | $rtl_tag = ""; | |
160 | } | |
161 | ||
162 | $tmp_result = db_query($link, | |
163 | "SELECT id,COUNT(unread) AS unread | |
164 | FROM ttrss_feeds LEFT JOIN ttrss_user_entries | |
165 | ON (ttrss_feeds.id = ttrss_user_entries.feed_id) | |
166 | WHERE parent_feed = '$feed_id' AND unread = true | |
167 | GROUP BY ttrss_feeds.id"); | |
168 | ||
169 | if (db_num_rows($tmp_result) > 0) { | |
170 | while ($l = db_fetch_assoc($tmp_result)) { | |
171 | $unread += $l["unread"]; | |
172 | } | |
173 | } | |
174 | ||
175 | $cat_id = $line["cat_id"]; | |
176 | ||
177 | $tmp_category = $line["category"]; | |
178 | ||
179 | if (!$tmp_category) { | |
180 | $tmp_category = "Uncategorized"; | |
181 | } | |
182 | ||
183 | // $class = ($lnum % 2) ? "even" : "odd"; | |
184 | ||
185 | if ($line["last_error"]) { | |
186 | $class = "error"; | |
187 | } else { | |
188 | $class = "feed"; | |
189 | } | |
190 | ||
1afd6227 AD |
191 | if ($category != $tmp_category && get_pref($link, 'ENABLE_FEED_CATS')) { |
192 | ||
193 | if ($category) { | |
194 | print "</ul></li>"; | |
195 | } | |
196 | ||
197 | $category = $tmp_category; | |
198 | ||
199 | $collapsed = $line["collapsed"]; | |
200 | ||
201 | // workaround for NULL category | |
202 | if ($category == "Uncategorized") { | |
57937c42 | 203 | $collapsed = get_pref($link, "_COLLAPSED_UNCAT"); |
1afd6227 AD |
204 | } |
205 | ||
206 | if ($collapsed == "t" || $collapsed == "1") { | |
207 | $holder_class = "invisible"; | |
208 | $ellipsis = "..."; | |
209 | } else { | |
210 | $holder_class = "feedCatHolder"; | |
211 | $ellipsis = ""; | |
212 | } | |
213 | ||
214 | if ($cat_id) { | |
215 | $cat_id_qpart = "cat_id = '$cat_id'"; | |
216 | } else { | |
217 | $cat_id_qpart = "cat_id IS NULL"; | |
218 | } | |
219 | ||
220 | $cat_id = sprintf("%d", $cat_id); | |
221 | $cat_unread = getCategoryUnread($link, $cat_id); | |
222 | ||
223 | if ($cat_unread > 0) { | |
224 | $catctr_class = ""; | |
225 | } else { | |
226 | $catctr_class = "invisible"; | |
227 | } | |
228 | ||
229 | print "<li class=\"feedCat\"> | |
230 | <a href=\"?subop=tc&id=$cat_id\">$tmp_category</a> | |
231 | <a href=\"?go=vf&id=$cat_id&cat=true\"> | |
232 | <span class=\"$catctr_class\">($cat_unread)$ellipsis</span> | |
233 | </a></li>"; | |
234 | ||
235 | print "<li id=\"feedCatHolder\" class=\"$holder_class\"> | |
236 | <ul class=\"feedCatList\">"; | |
237 | } | |
238 | ||
239 | printMobileFeedEntry($feed_id, $class, $feed, $unread, | |
2aa709f7 | 240 | false, $link, $rtl_content); |
1afd6227 AD |
241 | |
242 | ++$lnum; | |
243 | } | |
244 | ||
245 | } else { | |
246 | // tags | |
247 | ||
248 | $result = db_query($link, "SELECT tag_name,SUM((SELECT COUNT(int_id) | |
249 | FROM ttrss_user_entries WHERE int_id = post_int_id | |
250 | AND unread = true)) AS count FROM ttrss_tags | |
251 | WHERE owner_uid = '".$_SESSION['uid']."' GROUP BY tag_name ORDER BY tag_name"); | |
252 | ||
253 | $tags = array(); | |
254 | ||
255 | while ($line = db_fetch_assoc($result)) { | |
256 | $tags[$line["tag_name"]] += $line["count"]; | |
257 | } | |
258 | ||
259 | foreach (array_keys($tags) as $tag) { | |
260 | ||
261 | $unread = $tags[$tag]; | |
262 | ||
263 | $class = "tag"; | |
264 | ||
1afd6227 AD |
265 | printMobileFeedEntry($tag, $class, $tag, $unread, |
266 | "../images/tag.png", $link); | |
267 | ||
268 | } | |
269 | ||
270 | ||
271 | } | |
272 | } | |
273 | ||
274 | function printMobileFeedEntry($feed_id, $class, $feed_title, $unread, $icon_file, $link, | |
275 | $rtl_content = false) { | |
276 | ||
2aa709f7 AD |
277 | if (!$feed_title) $feed_title = getFeedTitle($link, $feed_id, false); |
278 | if (!$unread) $unread = getFeedUnread($link, $feed_id); | |
279 | ||
280 | if ($unread > 0) $class .= "Unread"; | |
281 | ||
282 | if (!$icon_file) $icon_file = "../../" . getFeedIcon($feed_id); | |
283 | ||
1afd6227 AD |
284 | if (file_exists($icon_file) && filesize($icon_file) > 0) { |
285 | $feed_icon = "<img src=\"$icon_file\">"; | |
286 | } else { | |
287 | $feed_icon = "<img src=\"../../images/blank_icon.gif\">"; | |
288 | } | |
289 | ||
290 | if ($rtl_content) { | |
291 | $rtl_tag = "dir=\"rtl\""; | |
292 | } else { | |
293 | $rtl_tag = "dir=\"ltr\""; | |
294 | } | |
295 | ||
296 | $feed = "<a href=\"?go=vf&id=$feed_id\">$feed_title</a>"; | |
297 | ||
298 | print "<li class=\"$class\">"; | |
85a92289 | 299 | print "$feed_icon"; |
1afd6227 AD |
300 | print "<span $rtl_tag>$feed</span> "; |
301 | ||
302 | if ($unread != 0) { | |
303 | print "<span $rtl_tag>($unread)</span>"; | |
304 | } | |
305 | ||
306 | print "</li>"; | |
307 | ||
308 | } | |
309 | ||
310 | function render_headlines($link) { | |
311 | ||
312 | $feed = db_escape_string($_GET["id"]); | |
313 | $limit = db_escape_string($_GET["limit"]); | |
314 | $view_mode = db_escape_string($_GET["viewmode"]); | |
315 | $cat_view = db_escape_string($_GET["cat"]); | |
316 | $subop = $_GET["subop"]; | |
317 | $catchup_op = $_GET["catchup_op"]; | |
318 | ||
319 | if (!$view_mode) { | |
320 | if ($_SESSION["mobile:viewmode"]) { | |
321 | $view_mode = $_SESSION["mobile:viewmode"]; | |
322 | } else { | |
323 | $view_mode = "adaptive"; | |
324 | } | |
325 | } | |
326 | ||
327 | $_SESSION["mobile:viewmode"] = $view_mode; | |
328 | ||
329 | if (!$limit) $limit = 30; | |
330 | if (!$feed) $feed = 0; | |
331 | ||
332 | if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) { | |
333 | ||
334 | $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds | |
335 | WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); | |
336 | ||
337 | if (db_num_rows($result) == 1) { | |
338 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
339 | } else { | |
340 | $rtl_content = false; | |
341 | } | |
342 | ||
343 | if ($rtl_content) { | |
344 | $rtl_tag = "dir=\"RTL\""; | |
345 | } else { | |
346 | $rtl_tag = ""; | |
347 | } | |
348 | } else { | |
349 | $rtl_content = false; | |
350 | $rtl_tag = ""; | |
351 | } | |
352 | ||
353 | print "<div id=\"headlines\" $rtl_tag>"; | |
354 | ||
355 | if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) { | |
356 | update_generic_feed($link, $feed, $cat_view, true); | |
357 | } | |
358 | ||
359 | if ($subop == "MarkAllRead" || $catchup_op == "feed") { | |
360 | catchup_feed($link, $feed, $cat_view); | |
361 | } | |
362 | ||
363 | if ($catchup_op == "selection") { | |
b2a653c3 AD |
364 | if (is_array($_GET["sel_ids"])) { |
365 | $ids_to_mark = array_keys($_GET["sel_ids"]); | |
366 | if ($ids_to_mark) { | |
367 | foreach ($ids_to_mark as $id) { | |
368 | db_query($link, "UPDATE ttrss_user_entries SET | |
369 | unread = false,last_read = NOW() | |
370 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
371 | } | |
1afd6227 AD |
372 | } |
373 | } | |
374 | } | |
375 | ||
376 | if ($subop == "MarkPageRead" || $catchup_op == "page") { | |
377 | $ids_to_mark = $_SESSION["last_page_ids.$feed"]; | |
378 | ||
379 | if ($ids_to_mark) { | |
380 | ||
381 | foreach ($ids_to_mark as $id) { | |
382 | db_query($link, "UPDATE ttrss_user_entries SET | |
383 | unread = false,last_read = NOW() | |
384 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
385 | } | |
386 | } | |
387 | } | |
388 | ||
389 | ||
390 | /// START ///////////////////////////////////////////////////////////////////////////////// | |
391 | ||
392 | $search = db_escape_string($_GET["query"]); | |
393 | $search_mode = db_escape_string($_GET["search_mode"]); | |
394 | $match_on = db_escape_string($_GET["match_on"]); | |
395 | ||
396 | if (!$match_on) { | |
397 | $match_on = "both"; | |
398 | } | |
399 | ||
400 | $real_offset = $offset * $limit; | |
401 | ||
402 | if ($_GET["debug"]) $timing_info = print_checkpoint("H0", $timing_info); | |
403 | ||
404 | $qfh_ret = queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, | |
405 | $search, $search_mode, $match_on, false, $real_offset); | |
406 | ||
407 | if ($_GET["debug"]) $timing_info = print_checkpoint("H1", $timing_info); | |
408 | ||
409 | $result = $qfh_ret[0]; | |
410 | $feed_title = $qfh_ret[1]; | |
411 | $feed_site_url = $qfh_ret[2]; | |
412 | $last_error = $qfh_ret[3]; | |
413 | ||
414 | /// STOP ////////////////////////////////////////////////////////////////////////////////// | |
415 | ||
416 | if (!$result) { | |
417 | print "<div align='center'>". | |
418 | __("Could not display feed (query failed). Please check label match syntax or local configuration."). | |
419 | "</div>"; | |
420 | return; | |
421 | } | |
422 | ||
423 | print "<div id=\"heading\">"; | |
424 | # if (!$cat_view && file_exists("../icons/$feed.ico") && filesize("../icons/$feed.ico") > 0) { | |
425 | # print "<img class=\"feedIcon\" src=\"../icons/$feed.ico\">"; | |
426 | # } | |
427 | ||
428 | print "$feed_title <span id=\"headingAddon\">("; | |
429 | print "<a href=\"index.php\">".__("Back")."</a>, "; | |
430 | print "<a href=\"index.php?go=sform&aid=$feed&ic=$cat_view\">".__("Search")."</a>, "; | |
431 | print "<a href=\"index.php?go=vf&id=$feed&subop=ForceUpdate\">".__("Update")."</a>"; | |
432 | ||
433 | # print "Mark as read: "; | |
434 | # print "<a href=\"index.php?go=vf&id=$feed&subop=MarkAsRead\">Page</a>, "; | |
435 | # print "<a href=\"index.php?go=vf&id=$feed&subop=MarkAllRead\">Feed</a>"; | |
436 | ||
437 | print ")</span>"; | |
438 | ||
439 | print " " . __('View:'); | |
440 | ||
441 | print "<form style=\"display : inline\" method=\"GET\" action=\"index.php\">"; | |
442 | ||
443 | /* print "<select name=\"viewmode\"> | |
444 | <option selected value=\"adaptive\"> " . __('Adaptive') . "</option> | |
445 | <option value=\"all_articles\">" . __('All Articles') . "</option> | |
446 | <option value=\"marked\">" . __('Starred') . "</option> | |
447 | <option value=\"unread\">" . __('Unread') . "</option> | |
448 | </select>"; */ | |
449 | ||
450 | $sel_values = array( | |
451 | "adaptive" => __("Adaptive"), | |
452 | "all_articles" => __("All Articles"), | |
453 | "unread" => __("Unread"), | |
454 | "marked" => __("Starred")); | |
455 | ||
456 | print_select_hash("viewmode", $view_mode, $sel_values); | |
457 | ||
458 | print "<input type=\"hidden\" name=\"id\" value=\"$feed\"> | |
459 | <input type=\"hidden\" name=\"cat\" value=\"$cat_view\"> | |
460 | <input type=\"hidden\" name=\"go\" value=\"vf\"> | |
461 | <input type=\"submit\" value=\"".__('Refresh')."\">"; | |
462 | print "</form>"; | |
463 | ||
464 | print "</div>"; | |
465 | ||
466 | if (db_num_rows($result) > 0) { | |
467 | ||
468 | print "<form method=\"GET\" action=\"index.php\">"; | |
469 | print "<input type=\"hidden\" name=\"go\" value=\"vf\">"; | |
470 | print "<input type=\"hidden\" name=\"id\" value=\"$feed\">"; | |
471 | print "<input type=\"hidden\" name=\"cat\" value=\"$cat_view\">"; | |
472 | ||
473 | print "<ul class=\"headlines\" id=\"headlines\">"; | |
474 | ||
475 | $page_art_ids = array(); | |
476 | ||
477 | $lnum = 0; | |
478 | ||
479 | error_reporting (DEFAULT_ERROR_LEVEL); | |
480 | ||
481 | $num_unread = 0; | |
482 | ||
483 | while ($line = db_fetch_assoc($result)) { | |
484 | ||
485 | $class = ($lnum % 2) ? "even" : "odd"; | |
486 | ||
487 | $id = $line["id"]; | |
488 | $feed_id = $line["feed_id"]; | |
489 | ||
490 | array_push($page_art_ids, $id); | |
491 | ||
492 | if ($line["last_read"] == "" && | |
493 | ($line["unread"] != "t" && $line["unread"] != "1")) { | |
494 | ||
495 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\" | |
496 | alt=\"".__("Updated")."\">"; | |
497 | } else { | |
498 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\" | |
499 | alt=\"".__("Updated")."\">"; | |
500 | } | |
501 | ||
502 | if ($line["unread"] == "t" || $line["unread"] == "1") { | |
503 | $class .= "Unread"; | |
504 | ++$num_unread; | |
505 | $is_unread = true; | |
506 | } else { | |
507 | $is_unread = false; | |
508 | } | |
509 | ||
510 | if ($line["marked"] == "t" || $line["marked"] == "1") { | |
511 | $marked_pic = "<img alt=\"S\" class='marked' src=\"../../images/mark_set.png\">"; | |
512 | } else { | |
513 | $marked_pic = "<img alt=\"s\" class='marked' src=\"../../images/mark_unset.png\">"; | |
514 | } | |
515 | ||
516 | if ($line["published"] == "t" || $line["published"] == "1") { | |
517 | $published_pic = "<img alt=\"P\" class='marked' src=\"../../images/pub_set.gif\">"; | |
518 | } else { | |
519 | $published_pic = "<img alt=\"p\" class='marked' src=\"../../images/pub_unset.gif\">"; | |
520 | } | |
521 | ||
522 | $content_link = "<a href=\"?go=view&id=$id&cat=$cat_view&ret_feed=$feed&feed=$feed_id\">" . | |
523 | $line["title"] . "</a>"; | |
524 | ||
324944f3 AD |
525 | $updated_fmt = make_local_datetime($link, $line['updated'], false); |
526 | ||
1afd6227 AD |
527 | print "<li class='$class' id=\"HROW-$id\">"; |
528 | ||
529 | print "<input type=\"checkbox\" name=\"sel_ids[$id]\" | |
530 | id=\"HSCB-$id\" onchange=\"toggleSelectRow(this, $id)\">"; | |
531 | ||
532 | print "<a href=\"?go=vf&id=$feed&ts=$id&cat=$cat_view\">$marked_pic</a>"; | |
533 | print "<a href=\"?go=vf&id=$feed&tp=$id&cat=$cat_view\">$published_pic</a>"; | |
534 | ||
535 | print $content_link; | |
536 | ||
537 | if ($line["feed_title"]) { | |
538 | print " (<a href='?go=vf&id=$feed_id'>". | |
539 | $line["feed_title"]."</a>)"; | |
540 | } | |
541 | ||
542 | print "<span class='hlUpdated'> ($updated_fmt)</span>"; | |
543 | ||
544 | print "</li>"; | |
545 | ||
546 | ||
547 | ++$lnum; | |
548 | } | |
549 | ||
550 | print "</ul>"; | |
551 | ||
552 | print "<div class='footerAddon'>"; | |
553 | ||
554 | $_SESSION["last_page_ids.$feed"] = $page_art_ids; | |
555 | ||
556 | /* print "<a href=\"index.php?go=vf&id=$feed&subop=MarkPageRead\">Page</a>, "; | |
557 | print "<a href=\"index.php?go=vf&id=$feed&subop=MarkAllRead\">Feed</a></div>"; */ | |
558 | ||
559 | print "Select: | |
560 | <a href=\"javascript:selectHeadlines(1)\">".__("All")."</a>, | |
561 | <a href=\"javascript:selectHeadlines(2)\">".__("Unread")."</a>, | |
562 | <a href=\"javascript:selectHeadlines(3)\">".__("None")."</a>, | |
563 | <a href=\"javascript:selectHeadlines(4)\">".__("Invert")."</a>"; | |
564 | ||
565 | print " "; | |
566 | ||
567 | print "<select name=\"catchup_op\"> | |
568 | <option value=\"selection\">".__("Selection")."</option> | |
569 | <option value=\"page\">".__("Page")."</option> | |
570 | <option value=\"feed\">".__("Entire feed")."</option> | |
571 | </select> | |
572 | <input type=\"hidden\" name=\"cat\" value=\"$cat_view\"> | |
573 | <input type=\"submit\" value=\"".__("Mark as read")."\">"; | |
574 | ||
575 | print "</form>"; | |
576 | ||
577 | } else { | |
578 | print "<div align='center'>No articles found.</div>"; | |
579 | } | |
580 | ||
581 | } | |
582 | ||
583 | function render_article($link) { | |
584 | ||
585 | $id = db_escape_string($_GET["id"]); | |
586 | $feed_id = db_escape_string($_GET["feed"]); | |
587 | $ret_feed_id = db_escape_string($_GET["ret_feed"]); | |
588 | $cat_view = db_escape_string($_GET["cat"]); | |
589 | ||
590 | $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds | |
591 | WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); | |
592 | ||
593 | if (db_num_rows($result) == 1) { | |
594 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
595 | } else { | |
596 | $rtl_content = false; | |
597 | } | |
598 | ||
599 | if ($rtl_content) { | |
600 | $rtl_tag = "dir=\"RTL\""; | |
601 | $rtl_class = "RTL"; | |
602 | } else { | |
603 | $rtl_tag = ""; | |
604 | $rtl_class = ""; | |
605 | } | |
606 | ||
607 | $result = db_query($link, "UPDATE ttrss_user_entries | |
608 | SET unread = false,last_read = NOW() | |
609 | WHERE ref_id = '$id' AND feed_id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); | |
610 | ||
611 | $result = db_query($link, "SELECT title,link,content,feed_id,comments,int_id, | |
612 | marked,published, | |
613 | ".SUBSTRING_FOR_DATE."(updated,1,16) as updated, | |
614 | (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url, | |
615 | num_comments, | |
616 | author | |
617 | FROM ttrss_entries,ttrss_user_entries | |
618 | WHERE id = '$id' AND ref_id = id"); | |
619 | ||
620 | if ($result) { | |
621 | ||
622 | $line = db_fetch_assoc($result); | |
623 | ||
624 | $num_comments = $line["num_comments"]; | |
625 | $entry_comments = ""; | |
626 | ||
627 | if ($num_comments > 0) { | |
628 | if ($line["comments"]) { | |
629 | $comments_url = $line["comments"]; | |
630 | } else { | |
631 | $comments_url = $line["link"]; | |
632 | } | |
633 | $entry_comments = "<a href=\"$comments_url\">$num_comments comments</a>"; | |
634 | } else { | |
635 | if ($line["comments"] && $line["link"] != $line["comments"]) { | |
636 | $entry_comments = "<a href=\"".$line["comments"]."\">comments</a>"; | |
637 | } | |
638 | } | |
639 | ||
640 | $tmp_result = db_query($link, "SELECT DISTINCT tag_name FROM | |
641 | ttrss_tags WHERE post_int_id = " . $line["int_id"] . " | |
642 | ORDER BY tag_name"); | |
643 | ||
644 | $tags_str = ""; | |
645 | $f_tags_str = ""; | |
646 | ||
647 | $num_tags = 0; | |
648 | ||
649 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
650 | $num_tags++; | |
651 | $tag = $tmp_line["tag_name"]; | |
652 | $tag_str = "<a href=\"?go=vf&id=$tag\">$tag</a>, "; | |
653 | $tags_str .= $tag_str; | |
654 | } | |
655 | ||
656 | $tags_str = preg_replace("/, $/", "", $tags_str); | |
657 | ||
658 | $parsed_updated = date(get_pref($link, 'SHORT_DATE_FORMAT'), | |
659 | strtotime($line["updated"])); | |
660 | ||
661 | print "<div id=\"heading\">"; | |
662 | ||
663 | # if (file_exists("../icons/$feed_id.ico") && filesize("../icons/$feed_id.ico") > 0) { | |
664 | # print "<img class=\"feedIcon\" src=\"../icons/$feed_id.ico\">"; | |
665 | # } | |
666 | ||
667 | if (!$cat_view) { | |
668 | $feed_title = getFeedTitle($link, $ret_feed_id); | |
669 | } else { | |
670 | $feed_title = getCategoryTitle($link, $ret_feed_id); | |
671 | $feed_title_native = getFeedTitle($link, $feed_id); | |
672 | } | |
673 | ||
674 | if ($feed_title_native) { | |
675 | $feed_link = "<a href=\"index.php?go=vf&id=$feed_id\">$feed_title_native</a>"; | |
676 | $feed_link .= " in <a href=\"index.php?go=vf&id=$ret_feed_id&cat=$cat_view\"> | |
677 | $feed_title</a>"; | |
678 | } else { | |
679 | $feed_link = "<a href=\"index.php?go=vf&id=$ret_feed_id\">$feed_title</a>"; | |
680 | } | |
681 | ||
682 | $feedlist = "<a href=\"index.php\">".__('Back to feedlist')."</a>"; | |
683 | ||
684 | print "<a href=\"" . $line["link"] . "\">" . | |
685 | truncate_string($line["title"], 30) . "</a>"; | |
686 | print " <span id=\"headingAddon\">$parsed_updated ($feed_link, $feedlist)</span>"; | |
687 | print "</div>"; | |
688 | ||
689 | if ($num_tags > 0) { | |
690 | print "<div class=\"postTags\">".__("Tags:")." $tags_str</div>"; | |
691 | } | |
692 | ||
693 | if ($line["marked"] == "t" || $line["marked"] == "1") { | |
694 | $marked_pic = "<img class='marked' src=\"../../images/mark_set.png\">"; | |
695 | } else { | |
696 | $marked_pic = "<img class='marked' src=\"../../images/mark_unset.png\">"; | |
697 | } | |
698 | ||
699 | if ($line["published"] == "t" || $line["published"] == "1") { | |
700 | $published_pic = "<img class='marked' src=\"../../images/pub_set.gif\">"; | |
701 | } else { | |
702 | $published_pic = "<img class='marked' src=\"../../images/pub_unset.gif\">"; | |
703 | } | |
704 | ||
705 | ||
706 | print "<div class=\"postStarOps\">"; | |
707 | print "<a title=\"".__('Toggle starred')."\"href=\"?go=view&id=$id&ret_feed=$ret_feed_id&feed=$feed_id&sop=ts\">$marked_pic</a>"; | |
708 | print "<a title=\"".__('Toggle published')."\" href=\"?go=view&id=$id&ret_feed=$ret_feed_id&feed=$feed_id&sop=tp\">$published_pic</a>"; | |
709 | // Mark unread | |
710 | print "<a title=\"".__('Mark as unread')."\" href=\"?go=vf&id=$ret_feed_id&feed=$feed_id&sop=mu&aid=$id"; | |
711 | if ($cat_view) { print "&cat=$cat_view"; } | |
712 | print "\"><img class='marked' src=\"../../images/art-set-unread.png\"></a>"; | |
713 | print "</div>"; | |
714 | ||
715 | print sanitize_rss($link, $line["content"], true);; | |
716 | ||
717 | } | |
718 | ||
719 | print "</body></html>"; | |
720 | } | |
721 | ||
722 | function render_search_form($link, $active_feed_id = false, $is_cat = false) { | |
723 | ||
724 | print "<div id=\"heading\">"; | |
725 | ||
726 | print __("Search")." <span id=\"headingAddon\"> | |
727 | (<a href=\"index.php\">".__("Go back")."</a>)</span></div>"; | |
728 | ||
729 | print "<form method=\"GET\" action=\"index.php\" class=\"searchForm\">"; | |
730 | ||
731 | print "<input type=\"hidden\" name=\"go\" value=\"vf\">"; | |
732 | print "<input type=\"hidden\" name=\"id\" value=\"$active_feed_id\">"; | |
733 | print "<input type=\"hidden\" name=\"cat\" value=\"$is_cat\">"; | |
734 | ||
735 | print "<table><tr><td>".__('Search:')."</td><td>"; | |
736 | print "<input name=\"query\"></td></tr>"; | |
737 | ||
738 | print "<tr><td>".__('Where:')."</td><td>"; | |
739 | ||
740 | print "<select name=\"search_mode\"> | |
741 | <option value=\"all_feeds\">".__('All feeds')."</option>"; | |
742 | ||
743 | $feed_title = getFeedTitle($link, $active_feed_id); | |
744 | ||
745 | if (!$is_cat) { | |
746 | $feed_cat_title = getFeedCatTitle($link, $active_feed_id); | |
747 | } else { | |
748 | $feed_cat_title = getCategoryTitle($link, $active_feed_id); | |
749 | } | |
750 | ||
751 | if ($active_feed_id && !$is_cat) { | |
752 | print "<option selected value=\"this_feed\">$feed_title</option>"; | |
753 | } else { | |
754 | print "<option disabled>".__('This feed')."</option>"; | |
755 | } | |
756 | ||
757 | if ($is_cat) { | |
758 | $cat_preselected = "selected"; | |
759 | } | |
760 | ||
761 | if (get_pref($link, 'ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) { | |
762 | print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>"; | |
763 | } else { | |
764 | //print "<option disabled>".__('This category')."</option>"; | |
765 | } | |
766 | ||
767 | print "</select></td></tr>"; | |
768 | ||
769 | print "<tr><td>".__('Match on:')."</td><td>"; | |
770 | ||
771 | $search_fields = array( | |
772 | "title" => __("Title"), | |
773 | "content" => __("Content"), | |
774 | "both" => __("Title or content")); | |
775 | ||
776 | print_select_hash("match_on", 3, $search_fields); | |
777 | ||
778 | print "</td></tr></table>"; | |
779 | ||
780 | print "<input type=\"submit\" value=\"".__('Search')."\">"; | |
781 | ||
782 | print "</form>"; | |
783 | ||
784 | print "</div>"; | |
785 | } | |
786 | ||
787 | function toggleMarked($link, $ts_id) { | |
788 | $result = db_query($link, "UPDATE ttrss_user_entries SET marked = NOT marked | |
789 | WHERE ref_id = '$ts_id' AND owner_uid = " . $_SESSION["uid"]); | |
790 | } | |
791 | ||
792 | function togglePublished($link, $tp_id) { | |
793 | $result = db_query($link, "UPDATE ttrss_user_entries SET published = NOT published | |
794 | WHERE ref_id = '$tp_id' AND owner_uid = " . $_SESSION["uid"]); | |
795 | } | |
796 | ||
797 | function markUnread($link, $mu_id) { | |
798 | $result = db_query($link, "UPDATE ttrss_user_entries SET unread = true | |
799 | WHERE ref_id = '$mu_id' AND owner_uid = " . $_SESSION["uid"]); | |
800 | } | |
801 | ||
802 | ?> |