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