]>
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"]); |
2f468537 AD |
313 | |
314 | if (!$view_mode) $view_mode = "Adaptive"; | |
315 | if (!$limit) $limit = 30; | |
316 | ||
eead4d26 | 317 | if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) { |
2f468537 | 318 | |
eead4d26 AD |
319 | $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds |
320 | WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); | |
2f468537 | 321 | |
eead4d26 AD |
322 | if (db_num_rows($result) == 1) { |
323 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
324 | } else { | |
325 | $rtl_content = false; | |
326 | } | |
327 | ||
328 | if ($rtl_content) { | |
329 | $rtl_tag = "dir=\"RTL\""; | |
330 | } else { | |
331 | $rtl_tag = ""; | |
332 | } | |
2f468537 | 333 | } else { |
eead4d26 | 334 | $rtl_content = false; |
2f468537 AD |
335 | $rtl_tag = ""; |
336 | } | |
337 | ||
338 | print "<div id=\"headlines\" $rtl_tag>"; | |
339 | ||
340 | if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) { | |
341 | update_generic_feed($link, $feed, $cat_view); | |
342 | } | |
343 | ||
344 | if ($subop == "MarkAllRead") { | |
345 | catchup_feed($link, $feed, $cat_view); | |
346 | } | |
347 | ||
348 | $search = db_escape_string($_GET["search"]); | |
349 | $search_mode = db_escape_string($_GET["smode"]); | |
350 | ||
351 | if ($search) { | |
352 | $search_query_part = "(upper(ttrss_entries.title) LIKE upper('%$search%') | |
353 | OR ttrss_entries.content LIKE '%$search%') AND"; | |
354 | } else { | |
355 | $search_query_part = ""; | |
356 | } | |
357 | ||
358 | $view_query_part = ""; | |
359 | ||
360 | if ($view_mode == "Adaptive") { | |
361 | if ($search) { | |
362 | $view_query_part = " "; | |
363 | } else if ($feed != -1) { | |
364 | $unread = getFeedUnread($link, $feed); | |
365 | if ($unread > 0) { | |
366 | $view_query_part = " unread = true AND "; | |
367 | } | |
368 | } | |
369 | } | |
370 | ||
371 | if ($view_mode == "Starred") { | |
372 | $view_query_part = " marked = true AND "; | |
373 | } | |
374 | ||
375 | if ($view_mode == "Unread") { | |
376 | $view_query_part = " unread = true AND "; | |
377 | } | |
378 | ||
379 | if ($limit && $limit != "All") { | |
380 | $limit_query_part = "LIMIT " . $limit; | |
381 | } | |
382 | ||
383 | $vfeed_query_part = ""; | |
384 | ||
385 | // override query strategy and enable feed display when searching globally | |
386 | if ($search && $search_mode == "All feeds") { | |
387 | $query_strategy_part = "ttrss_entries.id > 0"; | |
388 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; | |
389 | } else if (preg_match("/^-?[0-9][0-9]*$/", $feed) == false) { | |
390 | $query_strategy_part = "ttrss_entries.id > 0"; | |
391 | $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE | |
392 | id = feed_id) as feed_title,"; | |
393 | } else if ($feed >= 0 && $search && $search_mode == "This category") { | |
394 | ||
395 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; | |
396 | ||
397 | $tmp_result = db_query($link, "SELECT id | |
398 | FROM ttrss_feeds WHERE cat_id = | |
399 | (SELECT cat_id FROM ttrss_feeds WHERE id = '$feed') AND id != '$feed'"); | |
400 | ||
401 | $cat_siblings = array(); | |
402 | ||
403 | if (db_num_rows($tmp_result) > 0) { | |
404 | while ($p = db_fetch_assoc($tmp_result)) { | |
405 | array_push($cat_siblings, "feed_id = " . $p["id"]); | |
406 | } | |
407 | ||
408 | $query_strategy_part = sprintf("(feed_id = %d OR %s)", | |
409 | $feed, implode(" OR ", $cat_siblings)); | |
410 | ||
411 | } else { | |
412 | $query_strategy_part = "ttrss_entries.id > 0"; | |
413 | } | |
414 | ||
415 | } else if ($feed >= 0) { | |
416 | ||
417 | if ($cat_view) { | |
418 | ||
419 | if ($feed > 0) { | |
420 | $query_strategy_part = "cat_id = '$feed'"; | |
421 | } else { | |
422 | $query_strategy_part = "cat_id IS NULL"; | |
423 | } | |
424 | ||
425 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; | |
426 | ||
427 | } else { | |
428 | $tmp_result = db_query($link, "SELECT id | |
429 | FROM ttrss_feeds WHERE parent_feed = '$feed' | |
430 | ORDER BY cat_id,title"); | |
431 | ||
432 | $parent_ids = array(); | |
433 | ||
434 | if (db_num_rows($tmp_result) > 0) { | |
435 | while ($p = db_fetch_assoc($tmp_result)) { | |
436 | array_push($parent_ids, "feed_id = " . $p["id"]); | |
437 | } | |
438 | ||
439 | $query_strategy_part = sprintf("(feed_id = %d OR %s)", | |
440 | $feed, implode(" OR ", $parent_ids)); | |
441 | ||
442 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; | |
443 | } else { | |
444 | $query_strategy_part = "feed_id = '$feed'"; | |
445 | } | |
446 | } | |
447 | } else if ($feed == -1) { // starred virtual feed | |
448 | $query_strategy_part = "marked = true"; | |
449 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; | |
450 | } else if ($feed <= -10) { // labels | |
451 | $label_id = -$feed - 11; | |
452 | ||
453 | $tmp_result = db_query($link, "SELECT sql_exp FROM ttrss_labels | |
454 | WHERE id = '$label_id'"); | |
455 | ||
456 | $query_strategy_part = db_fetch_result($tmp_result, 0, "sql_exp"); | |
457 | ||
458 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; | |
459 | } else { | |
460 | $query_strategy_part = "id > 0"; // dumb | |
461 | } | |
462 | ||
463 | $order_by = "updated DESC"; | |
464 | ||
465 | // if ($feed < -10) { | |
466 | // $order_by = "feed_id,updated DESC"; | |
467 | // } | |
468 | ||
469 | $feed_title = ""; | |
470 | ||
471 | if ($search && $search_mode == "All feeds") { | |
472 | $feed_title = "Global search results ($search)"; | |
473 | } else if ($search && preg_match('/^-?[0-9][0-9]*$/', $feed) == false) { | |
474 | $feed_title = "Feed search results ($search, $feed)"; | |
475 | } else if (preg_match('/^-?[0-9][0-9]*$/', $feed) == false) { | |
476 | $feed_title = $feed; | |
477 | } else if (preg_match('/^-?[0-9][0-9]*$/', $feed) != false && $feed >= 0) { | |
478 | ||
479 | if ($cat_view) { | |
480 | ||
481 | if ($feed != 0) { | |
482 | $result = db_query($link, "SELECT title FROM ttrss_feed_categories | |
483 | WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); | |
484 | $feed_title = db_fetch_result($result, 0, "title"); | |
485 | } else { | |
486 | $feed_title = "Uncategorized"; | |
487 | } | |
488 | } else { | |
489 | ||
490 | $result = db_query($link, "SELECT title,site_url,last_error FROM ttrss_feeds | |
491 | WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); | |
492 | ||
493 | $feed_title = db_fetch_result($result, 0, "title"); | |
494 | $feed_site_url = db_fetch_result($result, 0, "site_url"); | |
495 | $last_error = db_fetch_result($result, 0, "last_error"); | |
496 | ||
497 | } | |
498 | ||
499 | } else if ($feed == -1) { | |
500 | $feed_title = "Starred articles"; | |
501 | } else if ($feed < -10) { | |
502 | $label_id = -$feed - 11; | |
503 | $result = db_query($link, "SELECT description FROM ttrss_labels | |
504 | WHERE id = '$label_id'"); | |
505 | $feed_title = db_fetch_result($result, 0, "description"); | |
506 | } else { | |
507 | $feed_title = "?"; | |
508 | } | |
509 | ||
510 | if ($feed < -10) error_reporting (0); | |
511 | ||
512 | if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) { | |
513 | ||
514 | if ($feed >= 0) { | |
515 | $feed_kind = "Feeds"; | |
516 | } else { | |
517 | $feed_kind = "Labels"; | |
518 | } | |
519 | ||
520 | $query = "SELECT | |
521 | ttrss_entries.id,ttrss_entries.title, | |
522 | SUBSTRING(updated,1,16) as updated, | |
523 | unread,feed_id,marked,link,last_read, | |
524 | SUBSTRING(last_read,1,19) as last_read_noms, | |
525 | $vfeed_query_part | |
526 | SUBSTRING(updated,1,19) as updated_noms | |
527 | FROM | |
528 | ttrss_entries,ttrss_user_entries,ttrss_feeds | |
529 | WHERE | |
530 | ttrss_user_entries.feed_id = ttrss_feeds.id AND | |
531 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
532 | ttrss_user_entries.owner_uid = '".$_SESSION["uid"]."' AND | |
533 | $search_query_part | |
534 | $view_query_part | |
535 | $query_strategy_part ORDER BY $order_by | |
536 | $limit_query_part"; | |
537 | ||
538 | $result = db_query($link, $query); | |
539 | ||
540 | if ($_GET["debug"]) print $query; | |
541 | ||
542 | } else { | |
543 | // browsing by tag | |
544 | ||
545 | $feed_kind = "Tags"; | |
546 | ||
547 | $result = db_query($link, "SELECT | |
548 | ttrss_entries.id as id,title, | |
549 | SUBSTRING(updated,1,16) as updated, | |
550 | unread,feed_id, | |
551 | marked,link,last_read, | |
552 | SUBSTRING(last_read,1,19) as last_read_noms, | |
553 | $vfeed_query_part | |
554 | $content_query_part | |
555 | SUBSTRING(updated,1,19) as updated_noms | |
556 | FROM | |
557 | ttrss_entries,ttrss_user_entries,ttrss_tags | |
558 | WHERE | |
559 | ref_id = ttrss_entries.id AND | |
560 | ttrss_user_entries.owner_uid = '".$_SESSION["uid"]."' AND | |
561 | post_int_id = int_id AND tag_name = '$feed' AND | |
562 | $view_query_part | |
563 | $search_query_part | |
564 | $query_strategy_part ORDER BY $order_by | |
565 | $limit_query_part"); | |
566 | } | |
567 | ||
568 | if (!$result) { | |
569 | print "<div align='center'> | |
570 | Could not display feed (query failed). Please check label match syntax or local configuration.</div>"; | |
571 | return; | |
572 | } | |
42096f52 | 573 | |
42096f52 | 574 | print "<div id=\"heading\">"; |
581e6bb5 AD |
575 | # if (!$cat_view && file_exists("../icons/$feed.ico") && filesize("../icons/$feed.ico") > 0) { |
576 | # print "<img class=\"feedIcon\" src=\"../icons/$feed.ico\">"; | |
577 | # } | |
42096f52 | 578 | |
062c1de5 | 579 | print "$feed_title <span id=\"headingAddon\">("; |
24ac6776 AD |
580 | print "<a href=\"tt-rss.php\">Back</a>, "; |
581 | print "<a href=\"tt-rss.php?go=vf&id=$feed&subop=ForceUpdate\">Update</a>, "; | |
062c1de5 AD |
582 | print "<a href=\"tt-rss.php?go=vf&id=$feed&subop=MarkAllRead\">Mark as read</a>"; |
583 | print ")</span>"; | |
ab1486d5 | 584 | |
42096f52 | 585 | print "</div>"; |
2f468537 AD |
586 | |
587 | if (db_num_rows($result) > 0) { | |
588 | ||
ab1486d5 | 589 | print "<ul class=\"headlines\">"; |
2f468537 AD |
590 | |
591 | $lnum = 0; | |
592 | ||
593 | error_reporting (DEFAULT_ERROR_LEVEL); | |
594 | ||
595 | $num_unread = 0; | |
596 | ||
597 | while ($line = db_fetch_assoc($result)) { | |
598 | ||
599 | $class = ($lnum % 2) ? "even" : "odd"; | |
600 | ||
601 | $id = $line["id"]; | |
602 | $feed_id = $line["feed_id"]; | |
603 | ||
604 | if ($line["last_read"] == "" && | |
605 | ($line["unread"] != "t" && $line["unread"] != "1")) { | |
606 | ||
607 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\" | |
608 | alt=\"Updated\">"; | |
609 | } else { | |
610 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\" | |
611 | alt=\"Updated\">"; | |
612 | } | |
613 | ||
614 | if ($line["unread"] == "t" || $line["unread"] == "1") { | |
615 | $class .= "Unread"; | |
616 | ++$num_unread; | |
617 | $is_unread = true; | |
618 | } else { | |
619 | $is_unread = false; | |
620 | } | |
621 | ||
622 | if ($line["marked"] == "t" || $line["marked"] == "1") { | |
24ac6776 | 623 | $marked_pic = "<img class='marked' src=\"../images/mark_set.png\">"; |
2f468537 | 624 | } else { |
24ac6776 | 625 | $marked_pic = "<img class='marked' src=\"../images/mark_unset.png\">"; |
2f468537 AD |
626 | } |
627 | ||
628 | $content_link = "<a href=\"?go=view&id=$id&feed=$feed_id\">" . | |
629 | $line["title"] . "</a>"; | |
630 | ||
631 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
632 | $updated_fmt = smart_date_time(strtotime($line["updated"])); | |
633 | } else { | |
634 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
635 | $updated_fmt = date($short_date, strtotime($line["updated"])); | |
636 | } | |
637 | ||
ab1486d5 | 638 | print "<li class='$class'>"; |
2f468537 | 639 | |
24ac6776 AD |
640 | print "<a href=\"?go=vf&id=$feed_id&ts=$id\">$marked_pic</a>"; |
641 | ||
ab1486d5 AD |
642 | print $content_link; |
643 | ||
2f468537 AD |
644 | if ($line["feed_title"]) { |
645 | print " (<a href='?go=vf&id=$feed_id'>". | |
646 | $line["feed_title"]."</a>)"; | |
647 | } | |
648 | ||
581e6bb5 | 649 | print "<span class='hlUpdated'> ($updated_fmt)</span>"; |
ab1486d5 AD |
650 | |
651 | print "</li>"; | |
2f468537 | 652 | |
2f468537 AD |
653 | |
654 | ++$lnum; | |
655 | } | |
656 | ||
ab1486d5 | 657 | print "</ul>"; |
2f468537 AD |
658 | |
659 | } else { | |
660 | print "<div align='center'>No articles found.</div>"; | |
661 | } | |
662 | ||
663 | } | |
664 | ||
42096f52 AD |
665 | function render_article($link) { |
666 | ||
667 | $id = db_escape_string($_GET["id"]); | |
668 | $feed_id = db_escape_string($_GET["feed"]); | |
669 | ||
670 | $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds | |
671 | WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); | |
672 | ||
673 | if (db_num_rows($result) == 1) { | |
674 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
675 | } else { | |
676 | $rtl_content = false; | |
677 | } | |
678 | ||
679 | if ($rtl_content) { | |
680 | $rtl_tag = "dir=\"RTL\""; | |
681 | $rtl_class = "RTL"; | |
682 | } else { | |
683 | $rtl_tag = ""; | |
684 | $rtl_class = ""; | |
685 | } | |
686 | ||
687 | $result = db_query($link, "UPDATE ttrss_user_entries | |
688 | SET unread = false,last_read = NOW() | |
689 | WHERE ref_id = '$id' AND feed_id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); | |
690 | ||
691 | $result = db_query($link, "SELECT title,link,content,feed_id,comments,int_id, | |
692 | SUBSTRING(updated,1,16) as updated, | |
693 | (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url, | |
694 | num_comments, | |
695 | author | |
696 | FROM ttrss_entries,ttrss_user_entries | |
697 | WHERE id = '$id' AND ref_id = id"); | |
698 | ||
42096f52 AD |
699 | if ($result) { |
700 | ||
701 | $line = db_fetch_assoc($result); | |
702 | ||
42096f52 AD |
703 | $num_comments = $line["num_comments"]; |
704 | $entry_comments = ""; | |
705 | ||
706 | if ($num_comments > 0) { | |
707 | if ($line["comments"]) { | |
708 | $comments_url = $line["comments"]; | |
709 | } else { | |
710 | $comments_url = $line["link"]; | |
711 | } | |
712 | $entry_comments = "<a href=\"$comments_url\">$num_comments comments</a>"; | |
713 | } else { | |
714 | if ($line["comments"] && $line["link"] != $line["comments"]) { | |
715 | $entry_comments = "<a href=\"".$line["comments"]."\">comments</a>"; | |
716 | } | |
717 | } | |
718 | ||
eead4d26 AD |
719 | $tmp_result = db_query($link, "SELECT DISTINCT tag_name FROM |
720 | ttrss_tags WHERE post_int_id = " . $line["int_id"] . " | |
721 | ORDER BY tag_name"); | |
722 | ||
723 | $tags_str = ""; | |
724 | $f_tags_str = ""; | |
725 | ||
726 | $num_tags = 0; | |
727 | ||
728 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
729 | $num_tags++; | |
730 | $tag = $tmp_line["tag_name"]; | |
731 | $tag_str = "<a href=\"?go=vf&id=$tag\">$tag</a>, "; | |
732 | $tags_str .= $tag_str; | |
733 | } | |
734 | ||
735 | $tags_str = preg_replace("/, $/", "", $tags_str); | |
736 | ||
24ac6776 | 737 | $parsed_updated = date(get_pref($link, 'SHORT_DATE_FORMAT'), |
42096f52 | 738 | strtotime($line["updated"])); |
42096f52 | 739 | |
ab1486d5 | 740 | print "<div id=\"heading\">"; |
24ac6776 | 741 | |
581e6bb5 AD |
742 | # if (file_exists("../icons/$feed_id.ico") && filesize("../icons/$feed_id.ico") > 0) { |
743 | # print "<img class=\"feedIcon\" src=\"../icons/$feed_id.ico\">"; | |
744 | # } | |
24ac6776 AD |
745 | |
746 | $feed_link = "<a href=\"tt-rss.php?go=vf&id=$feed_id\">Feed</a>"; | |
747 | ||
748 | print truncate_string($line["title"], 30); | |
749 | print " <span id=\"headingAddon\">$parsed_updated ($feed_link)</span>"; | |
ab1486d5 | 750 | print "</div>"; |
42096f52 | 751 | |
eead4d26 AD |
752 | if ($num_tags > 0) { |
753 | print "<div class=\"postTags\">Tags: $tags_str</div>"; | |
754 | } | |
24ac6776 | 755 | |
eead4d26 AD |
756 | print $line["content"]; |
757 | ||
42096f52 AD |
758 | } |
759 | ||
760 | print "</body></html>"; | |
42096f52 AD |
761 | } |
762 | ||
0d3adafe | 763 | ?> |