]>
Commit | Line | Data |
---|---|---|
0d3adafe AD |
1 | <? |
2 | ||
eead4d26 | 3 | function render_feeds_list($link) { |
42096f52 | 4 | |
eead4d26 | 5 | $tags = $_GET["tags"]; |
42096f52 | 6 | |
eead4d26 | 7 | print "<div id=\"heading\">"; |
42096f52 | 8 | |
eead4d26 AD |
9 | if ($tags) { |
10 | print "Tags <span id=\"headingAddon\"> | |
11 | (<a href=\"tt-rss.php\">View feeds</a>, "; | |
12 | } else { | |
13 | print "Feeds <span id=\"headingAddon\"> | |
14 | (<a href=\"tt-rss.php?tags=1\">View tags</a>, "; | |
42096f52 | 15 | } |
eead4d26 AD |
16 | |
17 | print "<a href=\"logout.php\">Logout</a>)</span>"; | |
42096f52 AD |
18 | print "</div>"; |
19 | ||
0d3adafe AD |
20 | print "<ul class=\"feedList\">"; |
21 | ||
22 | $owner_uid = $_SESSION["uid"]; | |
23 | ||
24 | if (!$tags) { | |
25 | ||
26 | /* virtual feeds */ | |
27 | ||
28 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
29 | print "<li class=\"feedCat\">Special</li>"; | |
ab1486d5 | 30 | print "<li class=\"feedCatHolder\"><ul class=\"feedCatList\">"; |
0d3adafe AD |
31 | } |
32 | ||
33 | $result = db_query($link, "SELECT count(id) as num_starred | |
34 | FROM ttrss_entries,ttrss_user_entries | |
35 | WHERE marked = true AND | |
36 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
37 | unread = true AND owner_uid = '$owner_uid'"); | |
38 | $num_starred = db_fetch_result($result, 0, "num_starred"); | |
39 | ||
40 | $class = "virt"; | |
41 | ||
42 | if ($num_starred > 0) $class .= "Unread"; | |
43 | ||
8e3f7217 | 44 | printMobileFeedEntry(-1, $class, "Starred articles", $num_starred, |
0d3adafe AD |
45 | "../images/mark_set.png", $link); |
46 | ||
47 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
48 | print "</ul>"; | |
49 | } | |
50 | ||
51 | if (GLOBAL_ENABLE_LABELS && get_pref($link, 'ENABLE_LABELS')) { | |
52 | ||
53 | $result = db_query($link, "SELECT id,sql_exp,description FROM | |
54 | ttrss_labels WHERE owner_uid = '$owner_uid' ORDER by description"); | |
55 | ||
56 | if (db_num_rows($result) > 0) { | |
57 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
58 | print "<li class=\"feedCat\">Labels</li>"; | |
ab1486d5 | 59 | print "<li class=\"feedCatHolder\"><ul class=\"feedCatList\">"; |
0d3adafe | 60 | } else { |
ab1486d5 | 61 | // print "<li><hr></li>"; |
0d3adafe AD |
62 | } |
63 | } | |
64 | ||
65 | while ($line = db_fetch_assoc($result)) { | |
66 | ||
67 | error_reporting (0); | |
68 | ||
69 | $tmp_result = db_query($link, "SELECT count(id) as count | |
70 | FROM ttrss_entries,ttrss_user_entries | |
71 | WHERE (" . $line["sql_exp"] . ") AND unread = true AND | |
72 | ttrss_user_entries.ref_id = ttrss_entries.id | |
73 | AND owner_uid = '$owner_uid'"); | |
74 | ||
75 | $count = db_fetch_result($tmp_result, 0, "count"); | |
76 | ||
77 | $class = "label"; | |
78 | ||
79 | if ($count > 0) { | |
80 | $class .= "Unread"; | |
81 | } | |
82 | ||
83 | error_reporting (DEFAULT_ERROR_LEVEL); | |
84 | ||
8e3f7217 | 85 | printMobileFeedEntry(-$line["id"]-11, |
0d3adafe AD |
86 | $class, $line["description"], $count, "../images/label.png", $link); |
87 | ||
88 | } | |
89 | ||
90 | if (db_num_rows($result) > 0) { | |
91 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
92 | print "</ul>"; | |
93 | } | |
94 | } | |
95 | ||
96 | } | |
97 | ||
0d3adafe AD |
98 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
99 | $order_by_qpart = "category,title"; | |
100 | } else { | |
101 | $order_by_qpart = "title"; | |
102 | } | |
103 | ||
104 | $result = db_query($link, "SELECT ttrss_feeds.*, | |
105 | (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries | |
106 | WHERE feed_id = ttrss_feeds.id AND | |
107 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
108 | owner_uid = '$owner_uid') AS total, | |
109 | (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries | |
110 | WHERE feed_id = ttrss_feeds.id AND unread = true | |
111 | AND ttrss_user_entries.ref_id = ttrss_entries.id | |
112 | AND owner_uid = '$owner_uid') as unread, | |
113 | cat_id,last_error, | |
114 | ttrss_feed_categories.title AS category, | |
115 | ttrss_feed_categories.collapsed | |
116 | FROM ttrss_feeds LEFT JOIN ttrss_feed_categories | |
117 | ON (ttrss_feed_categories.id = cat_id) | |
118 | WHERE | |
119 | ttrss_feeds.owner_uid = '$owner_uid' AND parent_feed IS NULL | |
120 | ORDER BY $order_by_qpart"); | |
121 | ||
122 | $actid = $_GET["actid"]; | |
123 | ||
124 | /* real feeds */ | |
125 | ||
126 | $lnum = 0; | |
127 | ||
0d3adafe AD |
128 | $category = ""; |
129 | ||
130 | while ($line = db_fetch_assoc($result)) { | |
131 | ||
132 | $feed = db_unescape_string($line["title"]); | |
133 | $feed_id = $line["id"]; | |
134 | ||
135 | $subop = $_GET["subop"]; | |
136 | ||
137 | $total = $line["total"]; | |
138 | $unread = $line["unread"]; | |
139 | ||
140 | $rtl_content = sql_bool_to_bool($line["rtl_content"]); | |
141 | ||
142 | if ($rtl_content) { | |
143 | $rtl_tag = "dir=\"RTL\""; | |
144 | } else { | |
145 | $rtl_tag = ""; | |
146 | } | |
147 | ||
148 | $tmp_result = db_query($link, | |
149 | "SELECT id,COUNT(unread) AS unread | |
150 | FROM ttrss_feeds LEFT JOIN ttrss_user_entries | |
151 | ON (ttrss_feeds.id = ttrss_user_entries.feed_id) | |
152 | WHERE parent_feed = '$feed_id' AND unread = true | |
153 | GROUP BY ttrss_feeds.id"); | |
154 | ||
155 | if (db_num_rows($tmp_result) > 0) { | |
156 | while ($l = db_fetch_assoc($tmp_result)) { | |
157 | $unread += $l["unread"]; | |
158 | } | |
159 | } | |
160 | ||
161 | $cat_id = $line["cat_id"]; | |
162 | ||
163 | $tmp_category = $line["category"]; | |
164 | ||
165 | if (!$tmp_category) { | |
166 | $tmp_category = "Uncategorized"; | |
167 | } | |
168 | ||
169 | // $class = ($lnum % 2) ? "even" : "odd"; | |
170 | ||
171 | if ($line["last_error"]) { | |
172 | $class = "error"; | |
173 | } else { | |
174 | $class = "feed"; | |
175 | } | |
176 | ||
177 | if ($unread > 0) $class .= "Unread"; | |
178 | ||
179 | if ($actid == $feed_id) { | |
180 | $class .= "Selected"; | |
181 | } | |
0d3adafe AD |
182 | |
183 | if ($category != $tmp_category && get_pref($link, 'ENABLE_FEED_CATS')) { | |
184 | ||
185 | if ($category) { | |
186 | print "</ul></li>"; | |
187 | } | |
188 | ||
189 | $category = $tmp_category; | |
190 | ||
191 | $collapsed = $line["collapsed"]; | |
192 | ||
193 | // workaround for NULL category | |
194 | if ($category == "Uncategorized") { | |
195 | if ($_COOKIE["ttrss_vf_uclps"] == 1) { | |
196 | $collapsed = "t"; | |
197 | } | |
198 | } | |
199 | ||
200 | if ($collapsed == "t" || $collapsed == "1") { | |
201 | $holder_class = "invisible"; | |
202 | $ellipsis = "..."; | |
203 | } else { | |
ab1486d5 | 204 | $holder_class = "feedCatHolder"; |
0d3adafe AD |
205 | $ellipsis = ""; |
206 | } | |
207 | ||
208 | if ($cat_id) { | |
209 | $cat_id_qpart = "cat_id = '$cat_id'"; | |
210 | } else { | |
211 | $cat_id_qpart = "cat_id IS NULL"; | |
212 | } | |
213 | ||
214 | $tmp_result = db_query($link, "SELECT count(int_id) AS unread | |
215 | FROM ttrss_user_entries,ttrss_feeds WHERE | |
216 | unread = true AND | |
217 | feed_id = ttrss_feeds.id AND $cat_id_qpart AND | |
218 | ttrss_user_entries.owner_uid = " . $_SESSION["uid"]); | |
219 | ||
220 | $cat_unread = db_fetch_result($tmp_result, 0, "unread"); | |
221 | ||
222 | $cat_id = sprintf("%d", $cat_id); | |
223 | ||
224 | print "<li class=\"feedCat\"> | |
42096f52 | 225 | <a href=\"?subop=tc&id=$cat_id\">$tmp_category</a> |
ab1486d5 AD |
226 | <a href=\"?go=vf&id=$cat_id&cat=true\"> |
227 | <span class=\"$catctr_class\">($cat_unread | |
228 | unread)$ellipsis</span></a></li>"; | |
0d3adafe | 229 | |
ab1486d5 AD |
230 | print "<li id=\"feedCatHolder\" class=\"$holder_class\"> |
231 | <ul class=\"feedCatList\">"; | |
0d3adafe AD |
232 | } |
233 | ||
8e3f7217 AD |
234 | printMobileFeedEntry($feed_id, $class, $feed, $unread, |
235 | "../icons/$feed_id.ico", $link, $rtl_content); | |
0d3adafe AD |
236 | |
237 | ++$lnum; | |
238 | } | |
239 | ||
8e3f7217 | 240 | } else { |
eead4d26 AD |
241 | // tags |
242 | ||
243 | $result = db_query($link, "SELECT tag_name,SUM((SELECT COUNT(int_id) | |
244 | FROM ttrss_user_entries WHERE int_id = post_int_id | |
245 | AND unread = true)) AS count FROM ttrss_tags | |
246 | WHERE owner_uid = 2 GROUP BY tag_name ORDER BY tag_name"); | |
247 | ||
248 | $tags = array(); | |
249 | ||
250 | while ($line = db_fetch_assoc($result)) { | |
251 | $tags[$line["tag_name"]] += $line["count"]; | |
252 | } | |
253 | ||
254 | foreach (array_keys($tags) as $tag) { | |
255 | ||
256 | $unread = $tags[$tag]; | |
257 | ||
258 | $class = "tag"; | |
259 | ||
260 | if ($unread > 0) { | |
261 | $class .= "Unread"; | |
262 | } | |
263 | ||
264 | printMobileFeedEntry($tag, $class, $tag, $unread, | |
265 | "../images/tag.png", $link); | |
266 | ||
267 | } | |
268 | ||
269 | ||
8e3f7217 | 270 | } |
0d3adafe | 271 | } |
8e3f7217 AD |
272 | |
273 | function printMobileFeedEntry($feed_id, $class, $feed_title, $unread, $icon_file, $link, | |
274 | $rtl_content = false) { | |
275 | ||
276 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
277 | $feed_icon = "<img src=\"$icon_file\">"; | |
278 | } else { | |
279 | $feed_icon = "<img src=\"../images/blank_icon.gif\">"; | |
280 | } | |
281 | ||
282 | if ($rtl_content) { | |
283 | $rtl_tag = "dir=\"rtl\""; | |
284 | } else { | |
285 | $rtl_tag = "dir=\"ltr\""; | |
286 | } | |
287 | ||
288 | $feed = "<a href=\"?go=vf&id=$feed_id\">$feed_title</a>"; | |
289 | ||
290 | print "<li class=\"$class\">"; | |
291 | if (get_pref($link, 'ENABLE_FEED_ICONS')) { | |
292 | print "$feed_icon"; | |
293 | } | |
294 | ||
295 | print "<span $rtl_tag>$feed</span> "; | |
296 | ||
297 | if ($unread != 0) { | |
ab1486d5 | 298 | print "<span $rtl_tag>($unread)</span>"; |
8e3f7217 | 299 | } |
8e3f7217 AD |
300 | |
301 | print "</li>"; | |
302 | ||
0d3adafe AD |
303 | } |
304 | ||
ab1486d5 AD |
305 | function render_headlines($link) { |
306 | ||
2f468537 AD |
307 | $feed = db_escape_string($_GET["id"]); |
308 | $limit = db_escape_string($_GET["limit"]); | |
309 | $view_mode = db_escape_string($_GET["viewmode"]); | |
ab1486d5 | 310 | $cat_view = db_escape_string($_GET["cat"]); |
2f468537 AD |
311 | |
312 | if (!$view_mode) $view_mode = "Adaptive"; | |
313 | if (!$limit) $limit = 30; | |
314 | ||
eead4d26 | 315 | if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) { |
2f468537 | 316 | |
eead4d26 AD |
317 | $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds |
318 | WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); | |
2f468537 | 319 | |
eead4d26 AD |
320 | if (db_num_rows($result) == 1) { |
321 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
322 | } else { | |
323 | $rtl_content = false; | |
324 | } | |
325 | ||
326 | if ($rtl_content) { | |
327 | $rtl_tag = "dir=\"RTL\""; | |
328 | } else { | |
329 | $rtl_tag = ""; | |
330 | } | |
2f468537 | 331 | } else { |
eead4d26 | 332 | $rtl_content = false; |
2f468537 AD |
333 | $rtl_tag = ""; |
334 | } | |
335 | ||
336 | print "<div id=\"headlines\" $rtl_tag>"; | |
337 | ||
338 | if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) { | |
339 | update_generic_feed($link, $feed, $cat_view); | |
340 | } | |
341 | ||
342 | if ($subop == "MarkAllRead") { | |
343 | catchup_feed($link, $feed, $cat_view); | |
344 | } | |
345 | ||
346 | $search = db_escape_string($_GET["search"]); | |
347 | $search_mode = db_escape_string($_GET["smode"]); | |
348 | ||
349 | if ($search) { | |
350 | $search_query_part = "(upper(ttrss_entries.title) LIKE upper('%$search%') | |
351 | OR ttrss_entries.content LIKE '%$search%') AND"; | |
352 | } else { | |
353 | $search_query_part = ""; | |
354 | } | |
355 | ||
356 | $view_query_part = ""; | |
357 | ||
358 | if ($view_mode == "Adaptive") { | |
359 | if ($search) { | |
360 | $view_query_part = " "; | |
361 | } else if ($feed != -1) { | |
362 | $unread = getFeedUnread($link, $feed); | |
363 | if ($unread > 0) { | |
364 | $view_query_part = " unread = true AND "; | |
365 | } | |
366 | } | |
367 | } | |
368 | ||
369 | if ($view_mode == "Starred") { | |
370 | $view_query_part = " marked = true AND "; | |
371 | } | |
372 | ||
373 | if ($view_mode == "Unread") { | |
374 | $view_query_part = " unread = true AND "; | |
375 | } | |
376 | ||
377 | if ($limit && $limit != "All") { | |
378 | $limit_query_part = "LIMIT " . $limit; | |
379 | } | |
380 | ||
381 | $vfeed_query_part = ""; | |
382 | ||
383 | // override query strategy and enable feed display when searching globally | |
384 | if ($search && $search_mode == "All feeds") { | |
385 | $query_strategy_part = "ttrss_entries.id > 0"; | |
386 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; | |
387 | } else if (preg_match("/^-?[0-9][0-9]*$/", $feed) == false) { | |
388 | $query_strategy_part = "ttrss_entries.id > 0"; | |
389 | $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE | |
390 | id = feed_id) as feed_title,"; | |
391 | } else if ($feed >= 0 && $search && $search_mode == "This category") { | |
392 | ||
393 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; | |
394 | ||
395 | $tmp_result = db_query($link, "SELECT id | |
396 | FROM ttrss_feeds WHERE cat_id = | |
397 | (SELECT cat_id FROM ttrss_feeds WHERE id = '$feed') AND id != '$feed'"); | |
398 | ||
399 | $cat_siblings = array(); | |
400 | ||
401 | if (db_num_rows($tmp_result) > 0) { | |
402 | while ($p = db_fetch_assoc($tmp_result)) { | |
403 | array_push($cat_siblings, "feed_id = " . $p["id"]); | |
404 | } | |
405 | ||
406 | $query_strategy_part = sprintf("(feed_id = %d OR %s)", | |
407 | $feed, implode(" OR ", $cat_siblings)); | |
408 | ||
409 | } else { | |
410 | $query_strategy_part = "ttrss_entries.id > 0"; | |
411 | } | |
412 | ||
413 | } else if ($feed >= 0) { | |
414 | ||
415 | if ($cat_view) { | |
416 | ||
417 | if ($feed > 0) { | |
418 | $query_strategy_part = "cat_id = '$feed'"; | |
419 | } else { | |
420 | $query_strategy_part = "cat_id IS NULL"; | |
421 | } | |
422 | ||
423 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; | |
424 | ||
425 | } else { | |
426 | $tmp_result = db_query($link, "SELECT id | |
427 | FROM ttrss_feeds WHERE parent_feed = '$feed' | |
428 | ORDER BY cat_id,title"); | |
429 | ||
430 | $parent_ids = array(); | |
431 | ||
432 | if (db_num_rows($tmp_result) > 0) { | |
433 | while ($p = db_fetch_assoc($tmp_result)) { | |
434 | array_push($parent_ids, "feed_id = " . $p["id"]); | |
435 | } | |
436 | ||
437 | $query_strategy_part = sprintf("(feed_id = %d OR %s)", | |
438 | $feed, implode(" OR ", $parent_ids)); | |
439 | ||
440 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; | |
441 | } else { | |
442 | $query_strategy_part = "feed_id = '$feed'"; | |
443 | } | |
444 | } | |
445 | } else if ($feed == -1) { // starred virtual feed | |
446 | $query_strategy_part = "marked = true"; | |
447 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; | |
448 | } else if ($feed <= -10) { // labels | |
449 | $label_id = -$feed - 11; | |
450 | ||
451 | $tmp_result = db_query($link, "SELECT sql_exp FROM ttrss_labels | |
452 | WHERE id = '$label_id'"); | |
453 | ||
454 | $query_strategy_part = db_fetch_result($tmp_result, 0, "sql_exp"); | |
455 | ||
456 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; | |
457 | } else { | |
458 | $query_strategy_part = "id > 0"; // dumb | |
459 | } | |
460 | ||
461 | $order_by = "updated DESC"; | |
462 | ||
463 | // if ($feed < -10) { | |
464 | // $order_by = "feed_id,updated DESC"; | |
465 | // } | |
466 | ||
467 | $feed_title = ""; | |
468 | ||
469 | if ($search && $search_mode == "All feeds") { | |
470 | $feed_title = "Global search results ($search)"; | |
471 | } else if ($search && preg_match('/^-?[0-9][0-9]*$/', $feed) == false) { | |
472 | $feed_title = "Feed search results ($search, $feed)"; | |
473 | } else if (preg_match('/^-?[0-9][0-9]*$/', $feed) == false) { | |
474 | $feed_title = $feed; | |
475 | } else if (preg_match('/^-?[0-9][0-9]*$/', $feed) != false && $feed >= 0) { | |
476 | ||
477 | if ($cat_view) { | |
478 | ||
479 | if ($feed != 0) { | |
480 | $result = db_query($link, "SELECT title FROM ttrss_feed_categories | |
481 | WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); | |
482 | $feed_title = db_fetch_result($result, 0, "title"); | |
483 | } else { | |
484 | $feed_title = "Uncategorized"; | |
485 | } | |
486 | } else { | |
487 | ||
488 | $result = db_query($link, "SELECT title,site_url,last_error FROM ttrss_feeds | |
489 | WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); | |
490 | ||
491 | $feed_title = db_fetch_result($result, 0, "title"); | |
492 | $feed_site_url = db_fetch_result($result, 0, "site_url"); | |
493 | $last_error = db_fetch_result($result, 0, "last_error"); | |
494 | ||
495 | } | |
496 | ||
497 | } else if ($feed == -1) { | |
498 | $feed_title = "Starred articles"; | |
499 | } else if ($feed < -10) { | |
500 | $label_id = -$feed - 11; | |
501 | $result = db_query($link, "SELECT description FROM ttrss_labels | |
502 | WHERE id = '$label_id'"); | |
503 | $feed_title = db_fetch_result($result, 0, "description"); | |
504 | } else { | |
505 | $feed_title = "?"; | |
506 | } | |
507 | ||
508 | if ($feed < -10) error_reporting (0); | |
509 | ||
510 | if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) { | |
511 | ||
512 | if ($feed >= 0) { | |
513 | $feed_kind = "Feeds"; | |
514 | } else { | |
515 | $feed_kind = "Labels"; | |
516 | } | |
517 | ||
518 | $query = "SELECT | |
519 | ttrss_entries.id,ttrss_entries.title, | |
520 | SUBSTRING(updated,1,16) as updated, | |
521 | unread,feed_id,marked,link,last_read, | |
522 | SUBSTRING(last_read,1,19) as last_read_noms, | |
523 | $vfeed_query_part | |
524 | SUBSTRING(updated,1,19) as updated_noms | |
525 | FROM | |
526 | ttrss_entries,ttrss_user_entries,ttrss_feeds | |
527 | WHERE | |
528 | ttrss_user_entries.feed_id = ttrss_feeds.id AND | |
529 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
530 | ttrss_user_entries.owner_uid = '".$_SESSION["uid"]."' AND | |
531 | $search_query_part | |
532 | $view_query_part | |
533 | $query_strategy_part ORDER BY $order_by | |
534 | $limit_query_part"; | |
535 | ||
536 | $result = db_query($link, $query); | |
537 | ||
538 | if ($_GET["debug"]) print $query; | |
539 | ||
540 | } else { | |
541 | // browsing by tag | |
542 | ||
543 | $feed_kind = "Tags"; | |
544 | ||
545 | $result = db_query($link, "SELECT | |
546 | ttrss_entries.id as id,title, | |
547 | SUBSTRING(updated,1,16) as updated, | |
548 | unread,feed_id, | |
549 | marked,link,last_read, | |
550 | SUBSTRING(last_read,1,19) as last_read_noms, | |
551 | $vfeed_query_part | |
552 | $content_query_part | |
553 | SUBSTRING(updated,1,19) as updated_noms | |
554 | FROM | |
555 | ttrss_entries,ttrss_user_entries,ttrss_tags | |
556 | WHERE | |
557 | ref_id = ttrss_entries.id AND | |
558 | ttrss_user_entries.owner_uid = '".$_SESSION["uid"]."' AND | |
559 | post_int_id = int_id AND tag_name = '$feed' AND | |
560 | $view_query_part | |
561 | $search_query_part | |
562 | $query_strategy_part ORDER BY $order_by | |
563 | $limit_query_part"); | |
564 | } | |
565 | ||
566 | if (!$result) { | |
567 | print "<div align='center'> | |
568 | Could not display feed (query failed). Please check label match syntax or local configuration.</div>"; | |
569 | return; | |
570 | } | |
42096f52 | 571 | |
42096f52 | 572 | print "<div id=\"heading\">"; |
ab1486d5 | 573 | if (!$cat_view && file_exists("../icons/$feed.ico") && filesize("../icons/$feed.ico") > 0) { |
42096f52 AD |
574 | print "<img class=\"tinyFeedIcon\" src=\"../icons/$feed.ico\">"; |
575 | } | |
576 | ||
062c1de5 AD |
577 | print "$feed_title <span id=\"headingAddon\">("; |
578 | print "<a href=\"tt-rss.php\">View feeds</a>, "; | |
579 | print "<a href=\"tt-rss.php?go=vf&id=$feed&subop=MarkAllRead\">Mark as read</a>"; | |
580 | print ")</span>"; | |
ab1486d5 | 581 | |
42096f52 | 582 | print "</div>"; |
2f468537 AD |
583 | |
584 | if (db_num_rows($result) > 0) { | |
585 | ||
ab1486d5 AD |
586 | // print "<table class=\"headlines\" cellspacing=\"0\" width=\"100%\">"; |
587 | ||
588 | print "<ul class=\"headlines\">"; | |
2f468537 AD |
589 | |
590 | $lnum = 0; | |
591 | ||
592 | error_reporting (DEFAULT_ERROR_LEVEL); | |
593 | ||
594 | $num_unread = 0; | |
595 | ||
596 | while ($line = db_fetch_assoc($result)) { | |
597 | ||
598 | $class = ($lnum % 2) ? "even" : "odd"; | |
599 | ||
600 | $id = $line["id"]; | |
601 | $feed_id = $line["feed_id"]; | |
602 | ||
603 | if ($line["last_read"] == "" && | |
604 | ($line["unread"] != "t" && $line["unread"] != "1")) { | |
605 | ||
606 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\" | |
607 | alt=\"Updated\">"; | |
608 | } else { | |
609 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\" | |
610 | alt=\"Updated\">"; | |
611 | } | |
612 | ||
613 | if ($line["unread"] == "t" || $line["unread"] == "1") { | |
614 | $class .= "Unread"; | |
615 | ++$num_unread; | |
616 | $is_unread = true; | |
617 | } else { | |
618 | $is_unread = false; | |
619 | } | |
620 | ||
621 | if ($line["marked"] == "t" || $line["marked"] == "1") { | |
622 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"../images/mark_set.png\">"; | |
623 | } else { | |
624 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"../images/mark_unset.png\">"; | |
625 | } | |
626 | ||
627 | $content_link = "<a href=\"?go=view&id=$id&feed=$feed_id\">" . | |
628 | $line["title"] . "</a>"; | |
629 | ||
630 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
631 | $updated_fmt = smart_date_time(strtotime($line["updated"])); | |
632 | } else { | |
633 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
634 | $updated_fmt = date($short_date, strtotime($line["updated"])); | |
635 | } | |
636 | ||
ab1486d5 | 637 | print "<li class='$class'>"; |
2f468537 | 638 | |
ab1486d5 AD |
639 | print $content_link; |
640 | ||
2f468537 AD |
641 | if ($line["feed_title"]) { |
642 | print " (<a href='?go=vf&id=$feed_id'>". | |
643 | $line["feed_title"]."</a>)"; | |
644 | } | |
645 | ||
ab1486d5 AD |
646 | print "<span class='hlUpdated'> — $updated_fmt</span>"; |
647 | ||
648 | print "</li>"; | |
2f468537 | 649 | |
2f468537 AD |
650 | |
651 | ++$lnum; | |
652 | } | |
653 | ||
ab1486d5 | 654 | print "</ul>"; |
2f468537 AD |
655 | |
656 | } else { | |
657 | print "<div align='center'>No articles found.</div>"; | |
658 | } | |
659 | ||
660 | } | |
661 | ||
42096f52 AD |
662 | function render_article($link) { |
663 | ||
664 | $id = db_escape_string($_GET["id"]); | |
665 | $feed_id = db_escape_string($_GET["feed"]); | |
666 | ||
667 | $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds | |
668 | WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); | |
669 | ||
670 | if (db_num_rows($result) == 1) { | |
671 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
672 | } else { | |
673 | $rtl_content = false; | |
674 | } | |
675 | ||
676 | if ($rtl_content) { | |
677 | $rtl_tag = "dir=\"RTL\""; | |
678 | $rtl_class = "RTL"; | |
679 | } else { | |
680 | $rtl_tag = ""; | |
681 | $rtl_class = ""; | |
682 | } | |
683 | ||
684 | $result = db_query($link, "UPDATE ttrss_user_entries | |
685 | SET unread = false,last_read = NOW() | |
686 | WHERE ref_id = '$id' AND feed_id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); | |
687 | ||
688 | $result = db_query($link, "SELECT title,link,content,feed_id,comments,int_id, | |
689 | SUBSTRING(updated,1,16) as updated, | |
690 | (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url, | |
691 | num_comments, | |
692 | author | |
693 | FROM ttrss_entries,ttrss_user_entries | |
694 | WHERE id = '$id' AND ref_id = id"); | |
695 | ||
42096f52 AD |
696 | if ($result) { |
697 | ||
698 | $line = db_fetch_assoc($result); | |
699 | ||
42096f52 AD |
700 | $num_comments = $line["num_comments"]; |
701 | $entry_comments = ""; | |
702 | ||
703 | if ($num_comments > 0) { | |
704 | if ($line["comments"]) { | |
705 | $comments_url = $line["comments"]; | |
706 | } else { | |
707 | $comments_url = $line["link"]; | |
708 | } | |
709 | $entry_comments = "<a href=\"$comments_url\">$num_comments comments</a>"; | |
710 | } else { | |
711 | if ($line["comments"] && $line["link"] != $line["comments"]) { | |
712 | $entry_comments = "<a href=\"".$line["comments"]."\">comments</a>"; | |
713 | } | |
714 | } | |
715 | ||
eead4d26 AD |
716 | $tmp_result = db_query($link, "SELECT DISTINCT tag_name FROM |
717 | ttrss_tags WHERE post_int_id = " . $line["int_id"] . " | |
718 | ORDER BY tag_name"); | |
719 | ||
720 | $tags_str = ""; | |
721 | $f_tags_str = ""; | |
722 | ||
723 | $num_tags = 0; | |
724 | ||
725 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
726 | $num_tags++; | |
727 | $tag = $tmp_line["tag_name"]; | |
728 | $tag_str = "<a href=\"?go=vf&id=$tag\">$tag</a>, "; | |
729 | $tags_str .= $tag_str; | |
730 | } | |
731 | ||
732 | $tags_str = preg_replace("/, $/", "", $tags_str); | |
733 | ||
42096f52 AD |
734 | $parsed_updated = date(get_pref($link, 'LONG_DATE_FORMAT'), |
735 | strtotime($line["updated"])); | |
42096f52 | 736 | |
ab1486d5 | 737 | print "<div id=\"heading\">"; |
eead4d26 | 738 | print $line["title"] . " <span id=\"headingAddon\">($parsed_updated)</span>"; |
ab1486d5 | 739 | print "</div>"; |
42096f52 | 740 | |
eead4d26 AD |
741 | if ($num_tags > 0) { |
742 | print "<div class=\"postTags\">Tags: $tags_str</div>"; | |
743 | } | |
42096f52 | 744 | |
eead4d26 AD |
745 | print $line["content"]; |
746 | ||
42096f52 AD |
747 | } |
748 | ||
749 | print "</body></html>"; | |
750 | ||
751 | ||
752 | ||
753 | } | |
754 | ||
0d3adafe | 755 | ?> |