]>
Commit | Line | Data |
---|---|---|
e9e95dae | 1 | <?php |
581e6bb5 | 2 | define('MOBILE_FEEDLIST_ENABLE_ICONS', false); |
3dd46f19 | 3 | define('TTRSS_SESSION_NAME', 'ttrss_m_sid'); |
0d3adafe | 4 | |
eead4d26 | 5 | function render_feeds_list($link) { |
42096f52 | 6 | |
eead4d26 | 7 | $tags = $_GET["tags"]; |
42096f52 | 8 | |
eead4d26 | 9 | print "<div id=\"heading\">"; |
42096f52 | 10 | |
eead4d26 AD |
11 | if ($tags) { |
12 | print "Tags <span id=\"headingAddon\"> | |
13 | (<a href=\"tt-rss.php\">View feeds</a>, "; | |
14 | } else { | |
15 | print "Feeds <span id=\"headingAddon\"> | |
16 | (<a href=\"tt-rss.php?tags=1\">View tags</a>, "; | |
42096f52 | 17 | } |
0809065e AD |
18 | |
19 | print "<a href=\"tt-rss.php?go=sform\">Search</a>, "; | |
20 | ||
eead4d26 | 21 | print "<a href=\"logout.php\">Logout</a>)</span>"; |
42096f52 AD |
22 | print "</div>"; |
23 | ||
0d3adafe AD |
24 | print "<ul class=\"feedList\">"; |
25 | ||
26 | $owner_uid = $_SESSION["uid"]; | |
27 | ||
28 | if (!$tags) { | |
29 | ||
30 | /* virtual feeds */ | |
31 | ||
32 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
33 | print "<li class=\"feedCat\">Special</li>"; | |
ab1486d5 | 34 | print "<li class=\"feedCatHolder\"><ul class=\"feedCatList\">"; |
0d3adafe AD |
35 | } |
36 | ||
a10d293c AD |
37 | $num_fresh = getFeedUnread($link, -3); |
38 | ||
39 | $class = "virt"; | |
40 | ||
41 | if ($num_fresh > 0) $class .= "Unread"; | |
42 | ||
85233b8e | 43 | printMobileFeedEntry(-3, $class, __("Fresh articles"), $num_fresh, |
a10d293c AD |
44 | "../images/fresh.png", $link); |
45 | ||
318260cc | 46 | $num_starred = getFeedUnread($link, -1); |
0d3adafe AD |
47 | |
48 | $class = "virt"; | |
49 | ||
50 | if ($num_starred > 0) $class .= "Unread"; | |
51 | ||
85233b8e | 52 | printMobileFeedEntry(-1, $class, __("Starred articles"), $num_starred, |
0d3adafe AD |
53 | "../images/mark_set.png", $link); |
54 | ||
85233b8e AD |
55 | $class = "virt"; |
56 | ||
57 | $num_published = getFeedUnread($link, -2); | |
58 | ||
59 | if ($num_published > 0) $class .= "Unread"; | |
60 | ||
61 | printMobileFeedEntry(-2, $class, __("Published articles"), $num_published, | |
62 | "../images/pub_set.png", $link); | |
63 | ||
0d3adafe AD |
64 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
65 | print "</ul>"; | |
66 | } | |
67 | ||
68 | if (GLOBAL_ENABLE_LABELS && get_pref($link, 'ENABLE_LABELS')) { | |
69 | ||
318260cc | 70 | $result = db_query($link, "SELECT id,description FROM |
0d3adafe AD |
71 | ttrss_labels WHERE owner_uid = '$owner_uid' ORDER by description"); |
72 | ||
73 | if (db_num_rows($result) > 0) { | |
74 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
75 | print "<li class=\"feedCat\">Labels</li>"; | |
ab1486d5 | 76 | print "<li class=\"feedCatHolder\"><ul class=\"feedCatList\">"; |
0d3adafe | 77 | } else { |
ab1486d5 | 78 | // print "<li><hr></li>"; |
0d3adafe AD |
79 | } |
80 | } | |
81 | ||
82 | while ($line = db_fetch_assoc($result)) { | |
83 | ||
84 | error_reporting (0); | |
85 | ||
318260cc | 86 | $count = getFeedUnread($link, -$line["id"]-11); |
0d3adafe AD |
87 | |
88 | $class = "label"; | |
89 | ||
90 | if ($count > 0) { | |
91 | $class .= "Unread"; | |
92 | } | |
93 | ||
94 | error_reporting (DEFAULT_ERROR_LEVEL); | |
95 | ||
8e3f7217 | 96 | printMobileFeedEntry(-$line["id"]-11, |
0d3adafe AD |
97 | $class, $line["description"], $count, "../images/label.png", $link); |
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 | ||
0d3adafe AD |
109 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
110 | $order_by_qpart = "category,title"; | |
111 | } else { | |
112 | $order_by_qpart = "title"; | |
113 | } | |
114 | ||
115 | $result = db_query($link, "SELECT ttrss_feeds.*, | |
0da49bad | 116 | SUBSTRING(last_updated,1,19) AS last_updated_noms, |
0d3adafe AD |
117 | (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries |
118 | WHERE feed_id = ttrss_feeds.id AND | |
119 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
120 | owner_uid = '$owner_uid') AS total, | |
121 | (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries | |
122 | WHERE feed_id = ttrss_feeds.id AND unread = true | |
123 | AND ttrss_user_entries.ref_id = ttrss_entries.id | |
124 | AND owner_uid = '$owner_uid') as unread, | |
125 | cat_id,last_error, | |
126 | ttrss_feed_categories.title AS category, | |
127 | ttrss_feed_categories.collapsed | |
128 | FROM ttrss_feeds LEFT JOIN ttrss_feed_categories | |
129 | ON (ttrss_feed_categories.id = cat_id) | |
130 | WHERE | |
0da49bad | 131 | ttrss_feeds.hidden = false AND |
0d3adafe AD |
132 | ttrss_feeds.owner_uid = '$owner_uid' AND parent_feed IS NULL |
133 | ORDER BY $order_by_qpart"); | |
134 | ||
135 | $actid = $_GET["actid"]; | |
136 | ||
137 | /* real feeds */ | |
138 | ||
139 | $lnum = 0; | |
140 | ||
0d3adafe AD |
141 | $category = ""; |
142 | ||
143 | while ($line = db_fetch_assoc($result)) { | |
144 | ||
145 | $feed = db_unescape_string($line["title"]); | |
146 | $feed_id = $line["id"]; | |
147 | ||
148 | $subop = $_GET["subop"]; | |
149 | ||
150 | $total = $line["total"]; | |
151 | $unread = $line["unread"]; | |
152 | ||
153 | $rtl_content = sql_bool_to_bool($line["rtl_content"]); | |
154 | ||
155 | if ($rtl_content) { | |
156 | $rtl_tag = "dir=\"RTL\""; | |
157 | } else { | |
158 | $rtl_tag = ""; | |
159 | } | |
160 | ||
161 | $tmp_result = db_query($link, | |
162 | "SELECT id,COUNT(unread) AS unread | |
163 | FROM ttrss_feeds LEFT JOIN ttrss_user_entries | |
164 | ON (ttrss_feeds.id = ttrss_user_entries.feed_id) | |
165 | WHERE parent_feed = '$feed_id' AND unread = true | |
166 | GROUP BY ttrss_feeds.id"); | |
167 | ||
168 | if (db_num_rows($tmp_result) > 0) { | |
169 | while ($l = db_fetch_assoc($tmp_result)) { | |
170 | $unread += $l["unread"]; | |
171 | } | |
172 | } | |
173 | ||
174 | $cat_id = $line["cat_id"]; | |
175 | ||
176 | $tmp_category = $line["category"]; | |
177 | ||
178 | if (!$tmp_category) { | |
179 | $tmp_category = "Uncategorized"; | |
180 | } | |
181 | ||
182 | // $class = ($lnum % 2) ? "even" : "odd"; | |
183 | ||
184 | if ($line["last_error"]) { | |
185 | $class = "error"; | |
186 | } else { | |
187 | $class = "feed"; | |
188 | } | |
189 | ||
190 | if ($unread > 0) $class .= "Unread"; | |
191 | ||
192 | if ($actid == $feed_id) { | |
193 | $class .= "Selected"; | |
194 | } | |
0d3adafe AD |
195 | |
196 | if ($category != $tmp_category && get_pref($link, 'ENABLE_FEED_CATS')) { | |
197 | ||
198 | if ($category) { | |
199 | print "</ul></li>"; | |
200 | } | |
201 | ||
202 | $category = $tmp_category; | |
203 | ||
204 | $collapsed = $line["collapsed"]; | |
205 | ||
206 | // workaround for NULL category | |
207 | if ($category == "Uncategorized") { | |
208 | if ($_COOKIE["ttrss_vf_uclps"] == 1) { | |
209 | $collapsed = "t"; | |
210 | } | |
211 | } | |
212 | ||
213 | if ($collapsed == "t" || $collapsed == "1") { | |
214 | $holder_class = "invisible"; | |
215 | $ellipsis = "..."; | |
216 | } else { | |
ab1486d5 | 217 | $holder_class = "feedCatHolder"; |
0d3adafe AD |
218 | $ellipsis = ""; |
219 | } | |
220 | ||
221 | if ($cat_id) { | |
222 | $cat_id_qpart = "cat_id = '$cat_id'"; | |
223 | } else { | |
224 | $cat_id_qpart = "cat_id IS NULL"; | |
225 | } | |
226 | ||
0d3adafe | 227 | $cat_id = sprintf("%d", $cat_id); |
26eb0119 AD |
228 | $cat_unread = getCategoryUnread($link, $cat_id); |
229 | ||
0d3adafe | 230 | print "<li class=\"feedCat\"> |
42096f52 | 231 | <a href=\"?subop=tc&id=$cat_id\">$tmp_category</a> |
ab1486d5 AD |
232 | <a href=\"?go=vf&id=$cat_id&cat=true\"> |
233 | <span class=\"$catctr_class\">($cat_unread | |
234 | unread)$ellipsis</span></a></li>"; | |
0d3adafe | 235 | |
ab1486d5 AD |
236 | print "<li id=\"feedCatHolder\" class=\"$holder_class\"> |
237 | <ul class=\"feedCatList\">"; | |
0d3adafe AD |
238 | } |
239 | ||
8e3f7217 AD |
240 | printMobileFeedEntry($feed_id, $class, $feed, $unread, |
241 | "../icons/$feed_id.ico", $link, $rtl_content); | |
0d3adafe AD |
242 | |
243 | ++$lnum; | |
244 | } | |
245 | ||
8e3f7217 | 246 | } else { |
eead4d26 AD |
247 | // tags |
248 | ||
249 | $result = db_query($link, "SELECT tag_name,SUM((SELECT COUNT(int_id) | |
250 | FROM ttrss_user_entries WHERE int_id = post_int_id | |
251 | AND unread = true)) AS count FROM ttrss_tags | |
252 | WHERE owner_uid = 2 GROUP BY tag_name ORDER BY tag_name"); | |
253 | ||
254 | $tags = array(); | |
255 | ||
256 | while ($line = db_fetch_assoc($result)) { | |
257 | $tags[$line["tag_name"]] += $line["count"]; | |
258 | } | |
259 | ||
260 | foreach (array_keys($tags) as $tag) { | |
261 | ||
262 | $unread = $tags[$tag]; | |
263 | ||
264 | $class = "tag"; | |
265 | ||
266 | if ($unread > 0) { | |
267 | $class .= "Unread"; | |
268 | } | |
269 | ||
270 | printMobileFeedEntry($tag, $class, $tag, $unread, | |
271 | "../images/tag.png", $link); | |
272 | ||
273 | } | |
274 | ||
275 | ||
8e3f7217 | 276 | } |
0d3adafe | 277 | } |
8e3f7217 AD |
278 | |
279 | function printMobileFeedEntry($feed_id, $class, $feed_title, $unread, $icon_file, $link, | |
280 | $rtl_content = false) { | |
281 | ||
282 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
283 | $feed_icon = "<img src=\"$icon_file\">"; | |
284 | } else { | |
285 | $feed_icon = "<img src=\"../images/blank_icon.gif\">"; | |
286 | } | |
287 | ||
288 | if ($rtl_content) { | |
289 | $rtl_tag = "dir=\"rtl\""; | |
290 | } else { | |
291 | $rtl_tag = "dir=\"ltr\""; | |
292 | } | |
293 | ||
294 | $feed = "<a href=\"?go=vf&id=$feed_id\">$feed_title</a>"; | |
295 | ||
296 | print "<li class=\"$class\">"; | |
581e6bb5 AD |
297 | # if (get_pref($link, 'ENABLE_FEED_ICONS')) { |
298 | # print "$feed_icon"; | |
299 | # } | |
8e3f7217 AD |
300 | |
301 | print "<span $rtl_tag>$feed</span> "; | |
302 | ||
303 | if ($unread != 0) { | |
ab1486d5 | 304 | print "<span $rtl_tag>($unread)</span>"; |
8e3f7217 | 305 | } |
8e3f7217 AD |
306 | |
307 | print "</li>"; | |
308 | ||
0d3adafe AD |
309 | } |
310 | ||
ab1486d5 AD |
311 | function render_headlines($link) { |
312 | ||
2f468537 AD |
313 | $feed = db_escape_string($_GET["id"]); |
314 | $limit = db_escape_string($_GET["limit"]); | |
315 | $view_mode = db_escape_string($_GET["viewmode"]); | |
ab1486d5 | 316 | $cat_view = db_escape_string($_GET["cat"]); |
bbf3ba8d | 317 | $subop = $_GET["subop"]; |
2f468537 AD |
318 | |
319 | if (!$view_mode) $view_mode = "Adaptive"; | |
320 | if (!$limit) $limit = 30; | |
0809065e | 321 | if (!$feed) $feed = 0; |
2f468537 | 322 | |
eead4d26 | 323 | if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) { |
2f468537 | 324 | |
eead4d26 AD |
325 | $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds |
326 | WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); | |
2f468537 | 327 | |
eead4d26 AD |
328 | if (db_num_rows($result) == 1) { |
329 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
330 | } else { | |
331 | $rtl_content = false; | |
332 | } | |
333 | ||
334 | if ($rtl_content) { | |
335 | $rtl_tag = "dir=\"RTL\""; | |
336 | } else { | |
337 | $rtl_tag = ""; | |
338 | } | |
2f468537 | 339 | } else { |
eead4d26 | 340 | $rtl_content = false; |
2f468537 AD |
341 | $rtl_tag = ""; |
342 | } | |
343 | ||
344 | print "<div id=\"headlines\" $rtl_tag>"; | |
345 | ||
346 | if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) { | |
35bf080c | 347 | update_generic_feed($link, $feed, $cat_view, true); |
2f468537 AD |
348 | } |
349 | ||
350 | if ($subop == "MarkAllRead") { | |
351 | catchup_feed($link, $feed, $cat_view); | |
352 | } | |
353 | ||
c878bc01 AD |
354 | if ($subop == "MarkPageRead") { |
355 | $ids_to_mark = $_SESSION["last_page_ids.$feed"]; | |
356 | ||
357 | if ($ids_to_mark) { | |
358 | ||
359 | foreach ($ids_to_mark as $id) { | |
360 | db_query($link, "UPDATE ttrss_user_entries SET | |
361 | unread = false,last_read = NOW() | |
362 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
363 | } | |
364 | } | |
365 | } | |
2f468537 | 366 | |
2f468537 | 367 | |
0809065e | 368 | /// START ///////////////////////////////////////////////////////////////////////////////// |
2f468537 | 369 | |
0809065e AD |
370 | $search = db_escape_string($_GET["query"]); |
371 | $search_mode = db_escape_string($_GET["search_mode"]); | |
372 | $match_on = db_escape_string($_GET["match_on"]); | |
2f468537 | 373 | |
0809065e AD |
374 | if (!$match_on) { |
375 | $match_on = "both"; | |
2f468537 AD |
376 | } |
377 | ||
0809065e | 378 | $real_offset = $offset * $limit; |
2f468537 | 379 | |
0809065e | 380 | if ($_GET["debug"]) $timing_info = print_checkpoint("H0", $timing_info); |
2f468537 | 381 | |
0809065e AD |
382 | $qfh_ret = queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, |
383 | $search, $search_mode, $match_on, false, $real_offset); | |
2f468537 | 384 | |
0809065e | 385 | if ($_GET["debug"]) $timing_info = print_checkpoint("H1", $timing_info); |
2f468537 | 386 | |
0809065e AD |
387 | $result = $qfh_ret[0]; |
388 | $feed_title = $qfh_ret[1]; | |
389 | $feed_site_url = $qfh_ret[2]; | |
390 | $last_error = $qfh_ret[3]; | |
2f468537 | 391 | |
0809065e | 392 | /// STOP ////////////////////////////////////////////////////////////////////////////////// |
2f468537 AD |
393 | |
394 | if (!$result) { | |
395 | print "<div align='center'> | |
396 | Could not display feed (query failed). Please check label match syntax or local configuration.</div>"; | |
397 | return; | |
398 | } | |
42096f52 | 399 | |
42096f52 | 400 | print "<div id=\"heading\">"; |
581e6bb5 AD |
401 | # if (!$cat_view && file_exists("../icons/$feed.ico") && filesize("../icons/$feed.ico") > 0) { |
402 | # print "<img class=\"feedIcon\" src=\"../icons/$feed.ico\">"; | |
403 | # } | |
42096f52 | 404 | |
062c1de5 | 405 | print "$feed_title <span id=\"headingAddon\">("; |
24ac6776 | 406 | print "<a href=\"tt-rss.php\">Back</a>, "; |
0809065e | 407 | print "<a href=\"tt-rss.php?go=sform&aid=$feed&ic=$cat_view\">Search</a>, "; |
c878bc01 AD |
408 | print "<a href=\"tt-rss.php?go=vf&id=$feed&subop=ForceUpdate\">Update</a>"; |
409 | # print "Mark as read: "; | |
410 | # print "<a href=\"tt-rss.php?go=vf&id=$feed&subop=MarkAsRead\">Page</a>, "; | |
411 | # print "<a href=\"tt-rss.php?go=vf&id=$feed&subop=MarkAllRead\">Feed</a>"; | |
0809065e | 412 | |
062c1de5 | 413 | print ")</span>"; |
ab1486d5 | 414 | |
42096f52 | 415 | print "</div>"; |
2f468537 AD |
416 | |
417 | if (db_num_rows($result) > 0) { | |
418 | ||
ab1486d5 | 419 | print "<ul class=\"headlines\">"; |
2f468537 | 420 | |
c878bc01 AD |
421 | $page_art_ids = array(); |
422 | ||
2f468537 AD |
423 | $lnum = 0; |
424 | ||
425 | error_reporting (DEFAULT_ERROR_LEVEL); | |
426 | ||
427 | $num_unread = 0; | |
428 | ||
429 | while ($line = db_fetch_assoc($result)) { | |
430 | ||
431 | $class = ($lnum % 2) ? "even" : "odd"; | |
432 | ||
433 | $id = $line["id"]; | |
434 | $feed_id = $line["feed_id"]; | |
c878bc01 AD |
435 | |
436 | array_push($page_art_ids, $id); | |
2f468537 AD |
437 | |
438 | if ($line["last_read"] == "" && | |
439 | ($line["unread"] != "t" && $line["unread"] != "1")) { | |
440 | ||
441 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\" | |
442 | alt=\"Updated\">"; | |
443 | } else { | |
444 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\" | |
445 | alt=\"Updated\">"; | |
446 | } | |
447 | ||
448 | if ($line["unread"] == "t" || $line["unread"] == "1") { | |
449 | $class .= "Unread"; | |
450 | ++$num_unread; | |
451 | $is_unread = true; | |
452 | } else { | |
453 | $is_unread = false; | |
454 | } | |
455 | ||
456 | if ($line["marked"] == "t" || $line["marked"] == "1") { | |
24ac6776 | 457 | $marked_pic = "<img class='marked' src=\"../images/mark_set.png\">"; |
2f468537 | 458 | } else { |
24ac6776 | 459 | $marked_pic = "<img class='marked' src=\"../images/mark_unset.png\">"; |
2f468537 AD |
460 | } |
461 | ||
31d1b6cf | 462 | $content_link = "<a href=\"?go=view&id=$id&ret_feed=$feed&feed=$feed_id\">" . |
2f468537 AD |
463 | $line["title"] . "</a>"; |
464 | ||
465 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
466 | $updated_fmt = smart_date_time(strtotime($line["updated"])); | |
467 | } else { | |
468 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
469 | $updated_fmt = date($short_date, strtotime($line["updated"])); | |
470 | } | |
471 | ||
ab1486d5 | 472 | print "<li class='$class'>"; |
2f468537 | 473 | |
e9e95dae | 474 | print "<a href=\"?go=vf&id=$feed&ts=$id\">$marked_pic</a>"; |
24ac6776 | 475 | |
ab1486d5 AD |
476 | print $content_link; |
477 | ||
2f468537 AD |
478 | if ($line["feed_title"]) { |
479 | print " (<a href='?go=vf&id=$feed_id'>". | |
480 | $line["feed_title"]."</a>)"; | |
481 | } | |
482 | ||
581e6bb5 | 483 | print "<span class='hlUpdated'> ($updated_fmt)</span>"; |
ab1486d5 AD |
484 | |
485 | print "</li>"; | |
2f468537 | 486 | |
2f468537 AD |
487 | |
488 | ++$lnum; | |
489 | } | |
490 | ||
ab1486d5 | 491 | print "</ul>"; |
2f468537 | 492 | |
c878bc01 AD |
493 | print "<div class='footerAddon'>Mark as read: "; |
494 | ||
495 | $_SESSION["last_page_ids.$feed"] = $page_art_ids; | |
496 | ||
497 | print "<a href=\"tt-rss.php?go=vf&id=$feed&subop=MarkPageRead\">Page</a>, "; | |
498 | print "<a href=\"tt-rss.php?go=vf&id=$feed&subop=MarkAllRead\">Feed</a></div>"; | |
499 | ||
2f468537 AD |
500 | } else { |
501 | print "<div align='center'>No articles found.</div>"; | |
502 | } | |
503 | ||
504 | } | |
505 | ||
42096f52 AD |
506 | function render_article($link) { |
507 | ||
508 | $id = db_escape_string($_GET["id"]); | |
509 | $feed_id = db_escape_string($_GET["feed"]); | |
31d1b6cf | 510 | $ret_feed_id = db_escape_string($_GET["ret_feed"]); |
42096f52 AD |
511 | |
512 | $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds | |
513 | WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); | |
514 | ||
515 | if (db_num_rows($result) == 1) { | |
516 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
517 | } else { | |
518 | $rtl_content = false; | |
519 | } | |
520 | ||
521 | if ($rtl_content) { | |
522 | $rtl_tag = "dir=\"RTL\""; | |
523 | $rtl_class = "RTL"; | |
524 | } else { | |
525 | $rtl_tag = ""; | |
526 | $rtl_class = ""; | |
527 | } | |
528 | ||
529 | $result = db_query($link, "UPDATE ttrss_user_entries | |
530 | SET unread = false,last_read = NOW() | |
531 | WHERE ref_id = '$id' AND feed_id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); | |
532 | ||
533 | $result = db_query($link, "SELECT title,link,content,feed_id,comments,int_id, | |
534 | SUBSTRING(updated,1,16) as updated, | |
535 | (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url, | |
536 | num_comments, | |
537 | author | |
538 | FROM ttrss_entries,ttrss_user_entries | |
539 | WHERE id = '$id' AND ref_id = id"); | |
540 | ||
42096f52 AD |
541 | if ($result) { |
542 | ||
543 | $line = db_fetch_assoc($result); | |
544 | ||
42096f52 AD |
545 | $num_comments = $line["num_comments"]; |
546 | $entry_comments = ""; | |
547 | ||
548 | if ($num_comments > 0) { | |
549 | if ($line["comments"]) { | |
550 | $comments_url = $line["comments"]; | |
551 | } else { | |
552 | $comments_url = $line["link"]; | |
553 | } | |
554 | $entry_comments = "<a href=\"$comments_url\">$num_comments comments</a>"; | |
555 | } else { | |
556 | if ($line["comments"] && $line["link"] != $line["comments"]) { | |
557 | $entry_comments = "<a href=\"".$line["comments"]."\">comments</a>"; | |
558 | } | |
559 | } | |
560 | ||
eead4d26 AD |
561 | $tmp_result = db_query($link, "SELECT DISTINCT tag_name FROM |
562 | ttrss_tags WHERE post_int_id = " . $line["int_id"] . " | |
563 | ORDER BY tag_name"); | |
564 | ||
565 | $tags_str = ""; | |
566 | $f_tags_str = ""; | |
567 | ||
568 | $num_tags = 0; | |
569 | ||
570 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
571 | $num_tags++; | |
572 | $tag = $tmp_line["tag_name"]; | |
573 | $tag_str = "<a href=\"?go=vf&id=$tag\">$tag</a>, "; | |
574 | $tags_str .= $tag_str; | |
575 | } | |
576 | ||
577 | $tags_str = preg_replace("/, $/", "", $tags_str); | |
578 | ||
24ac6776 | 579 | $parsed_updated = date(get_pref($link, 'SHORT_DATE_FORMAT'), |
42096f52 | 580 | strtotime($line["updated"])); |
42096f52 | 581 | |
ab1486d5 | 582 | print "<div id=\"heading\">"; |
24ac6776 | 583 | |
581e6bb5 AD |
584 | # if (file_exists("../icons/$feed_id.ico") && filesize("../icons/$feed_id.ico") > 0) { |
585 | # print "<img class=\"feedIcon\" src=\"../icons/$feed_id.ico\">"; | |
586 | # } | |
24ac6776 | 587 | |
31d1b6cf | 588 | $feed_link = "<a href=\"tt-rss.php?go=vf&id=$ret_feed_id\">Feed</a>"; |
24ac6776 | 589 | |
3d7d6cdd AD |
590 | print "<a href=\"" . $line["link"] . "\">" . |
591 | truncate_string($line["title"], 30) . "</a>"; | |
24ac6776 | 592 | print " <span id=\"headingAddon\">$parsed_updated ($feed_link)</span>"; |
ab1486d5 | 593 | print "</div>"; |
42096f52 | 594 | |
eead4d26 AD |
595 | if ($num_tags > 0) { |
596 | print "<div class=\"postTags\">Tags: $tags_str</div>"; | |
597 | } | |
24ac6776 | 598 | |
1ac0baf4 | 599 | print sanitize_rss($link, $line["content"], true);; |
eead4d26 | 600 | |
42096f52 AD |
601 | } |
602 | ||
603 | print "</body></html>"; | |
42096f52 AD |
604 | } |
605 | ||
0809065e AD |
606 | function render_search_form($link, $active_feed_id = false, $is_cat = false) { |
607 | ||
608 | print "<div id=\"heading\">"; | |
609 | ||
610 | print "Search <span id=\"headingAddon\"> | |
611 | (<a href=\"tt-rss.php\">Go back</a>)</span></div>"; | |
612 | ||
613 | print "<form method=\"GET\" action=\"tt-rss.php\" class=\"searchForm\">"; | |
614 | ||
615 | print "<input type=\"hidden\" name=\"go\" value=\"vf\">"; | |
616 | print "<input type=\"hidden\" name=\"id\" value=\"$active_feed_id\">"; | |
617 | print "<input type=\"hidden\" name=\"cat\" value=\"$is_cat\">"; | |
618 | ||
619 | print "<table><tr><td>".__('Search:')."</td><td>"; | |
620 | print "<input name=\"query\"></td></tr>"; | |
621 | ||
622 | print "<tr><td>".__('Where:')."</td><td>"; | |
623 | ||
624 | print "<select name=\"search_mode\"> | |
625 | <option value=\"all_feeds\">".__('All feeds')."</option>"; | |
626 | ||
627 | $feed_title = getFeedTitle($link, $active_feed_id); | |
628 | ||
629 | if (!$is_cat) { | |
630 | $feed_cat_title = getFeedCatTitle($link, $active_feed_id); | |
631 | } else { | |
632 | $feed_cat_title = getCategoryTitle($link, $active_feed_id); | |
633 | } | |
634 | ||
635 | if ($active_feed_id && !$is_cat) { | |
636 | print "<option selected value=\"this_feed\">$feed_title</option>"; | |
637 | } else { | |
638 | print "<option disabled>".__('This feed')."</option>"; | |
639 | } | |
640 | ||
641 | if ($is_cat) { | |
642 | $cat_preselected = "selected"; | |
643 | } | |
644 | ||
645 | if (get_pref($link, 'ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) { | |
646 | print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>"; | |
647 | } else { | |
648 | //print "<option disabled>".__('This category')."</option>"; | |
649 | } | |
650 | ||
651 | print "</select></td></tr>"; | |
652 | ||
653 | print "<tr><td>".__('Match on:')."</td><td>"; | |
654 | ||
655 | $search_fields = array( | |
656 | "title" => __("Title"), | |
657 | "content" => __("Content"), | |
658 | "both" => __("Title or content")); | |
659 | ||
660 | print_select_hash("match_on", 3, $search_fields); | |
661 | ||
662 | print "</td></tr></table>"; | |
663 | ||
664 | print "<input type=\"submit\" value=\"".__('Search')."\">"; | |
665 | ||
666 | print "</form>"; | |
667 | ||
668 | print "</div>"; | |
669 | } | |
670 | ||
0d3adafe | 671 | ?> |