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