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