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