]>
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 | ||
318260cc | 35 | $num_starred = getFeedUnread($link, -1); |
0d3adafe AD |
36 | |
37 | $class = "virt"; | |
38 | ||
39 | if ($num_starred > 0) $class .= "Unread"; | |
40 | ||
8e3f7217 | 41 | printMobileFeedEntry(-1, $class, "Starred articles", $num_starred, |
0d3adafe AD |
42 | "../images/mark_set.png", $link); |
43 | ||
44 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
45 | print "</ul>"; | |
46 | } | |
47 | ||
48 | if (GLOBAL_ENABLE_LABELS && get_pref($link, 'ENABLE_LABELS')) { | |
49 | ||
318260cc | 50 | $result = db_query($link, "SELECT id,description FROM |
0d3adafe AD |
51 | ttrss_labels WHERE owner_uid = '$owner_uid' ORDER by description"); |
52 | ||
53 | if (db_num_rows($result) > 0) { | |
54 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
55 | print "<li class=\"feedCat\">Labels</li>"; | |
ab1486d5 | 56 | print "<li class=\"feedCatHolder\"><ul class=\"feedCatList\">"; |
0d3adafe | 57 | } else { |
ab1486d5 | 58 | // print "<li><hr></li>"; |
0d3adafe AD |
59 | } |
60 | } | |
61 | ||
62 | while ($line = db_fetch_assoc($result)) { | |
63 | ||
64 | error_reporting (0); | |
65 | ||
318260cc | 66 | $count = getFeedUnread($link, -$line["id"]-11); |
0d3adafe AD |
67 | |
68 | $class = "label"; | |
69 | ||
70 | if ($count > 0) { | |
71 | $class .= "Unread"; | |
72 | } | |
73 | ||
74 | error_reporting (DEFAULT_ERROR_LEVEL); | |
75 | ||
8e3f7217 | 76 | printMobileFeedEntry(-$line["id"]-11, |
0d3adafe AD |
77 | $class, $line["description"], $count, "../images/label.png", $link); |
78 | ||
79 | } | |
80 | ||
81 | if (db_num_rows($result) > 0) { | |
82 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
83 | print "</ul>"; | |
84 | } | |
85 | } | |
86 | ||
87 | } | |
88 | ||
0d3adafe AD |
89 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
90 | $order_by_qpart = "category,title"; | |
91 | } else { | |
92 | $order_by_qpart = "title"; | |
93 | } | |
94 | ||
95 | $result = db_query($link, "SELECT ttrss_feeds.*, | |
0da49bad | 96 | SUBSTRING(last_updated,1,19) AS last_updated_noms, |
0d3adafe AD |
97 | (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries |
98 | WHERE feed_id = ttrss_feeds.id AND | |
99 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
100 | owner_uid = '$owner_uid') AS total, | |
101 | (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries | |
102 | WHERE feed_id = ttrss_feeds.id AND unread = true | |
103 | AND ttrss_user_entries.ref_id = ttrss_entries.id | |
104 | AND owner_uid = '$owner_uid') as unread, | |
105 | cat_id,last_error, | |
106 | ttrss_feed_categories.title AS category, | |
107 | ttrss_feed_categories.collapsed | |
108 | FROM ttrss_feeds LEFT JOIN ttrss_feed_categories | |
109 | ON (ttrss_feed_categories.id = cat_id) | |
110 | WHERE | |
0da49bad | 111 | ttrss_feeds.hidden = false AND |
0d3adafe AD |
112 | ttrss_feeds.owner_uid = '$owner_uid' AND parent_feed IS NULL |
113 | ORDER BY $order_by_qpart"); | |
114 | ||
115 | $actid = $_GET["actid"]; | |
116 | ||
117 | /* real feeds */ | |
118 | ||
119 | $lnum = 0; | |
120 | ||
0d3adafe AD |
121 | $category = ""; |
122 | ||
123 | while ($line = db_fetch_assoc($result)) { | |
124 | ||
125 | $feed = db_unescape_string($line["title"]); | |
126 | $feed_id = $line["id"]; | |
127 | ||
128 | $subop = $_GET["subop"]; | |
129 | ||
130 | $total = $line["total"]; | |
131 | $unread = $line["unread"]; | |
132 | ||
133 | $rtl_content = sql_bool_to_bool($line["rtl_content"]); | |
134 | ||
135 | if ($rtl_content) { | |
136 | $rtl_tag = "dir=\"RTL\""; | |
137 | } else { | |
138 | $rtl_tag = ""; | |
139 | } | |
140 | ||
141 | $tmp_result = db_query($link, | |
142 | "SELECT id,COUNT(unread) AS unread | |
143 | FROM ttrss_feeds LEFT JOIN ttrss_user_entries | |
144 | ON (ttrss_feeds.id = ttrss_user_entries.feed_id) | |
145 | WHERE parent_feed = '$feed_id' AND unread = true | |
146 | GROUP BY ttrss_feeds.id"); | |
147 | ||
148 | if (db_num_rows($tmp_result) > 0) { | |
149 | while ($l = db_fetch_assoc($tmp_result)) { | |
150 | $unread += $l["unread"]; | |
151 | } | |
152 | } | |
153 | ||
154 | $cat_id = $line["cat_id"]; | |
155 | ||
156 | $tmp_category = $line["category"]; | |
157 | ||
158 | if (!$tmp_category) { | |
159 | $tmp_category = "Uncategorized"; | |
160 | } | |
161 | ||
162 | // $class = ($lnum % 2) ? "even" : "odd"; | |
163 | ||
164 | if ($line["last_error"]) { | |
165 | $class = "error"; | |
166 | } else { | |
167 | $class = "feed"; | |
168 | } | |
169 | ||
170 | if ($unread > 0) $class .= "Unread"; | |
171 | ||
172 | if ($actid == $feed_id) { | |
173 | $class .= "Selected"; | |
174 | } | |
0d3adafe AD |
175 | |
176 | if ($category != $tmp_category && get_pref($link, 'ENABLE_FEED_CATS')) { | |
177 | ||
178 | if ($category) { | |
179 | print "</ul></li>"; | |
180 | } | |
181 | ||
182 | $category = $tmp_category; | |
183 | ||
184 | $collapsed = $line["collapsed"]; | |
185 | ||
186 | // workaround for NULL category | |
187 | if ($category == "Uncategorized") { | |
188 | if ($_COOKIE["ttrss_vf_uclps"] == 1) { | |
189 | $collapsed = "t"; | |
190 | } | |
191 | } | |
192 | ||
193 | if ($collapsed == "t" || $collapsed == "1") { | |
194 | $holder_class = "invisible"; | |
195 | $ellipsis = "..."; | |
196 | } else { | |
ab1486d5 | 197 | $holder_class = "feedCatHolder"; |
0d3adafe AD |
198 | $ellipsis = ""; |
199 | } | |
200 | ||
201 | if ($cat_id) { | |
202 | $cat_id_qpart = "cat_id = '$cat_id'"; | |
203 | } else { | |
204 | $cat_id_qpart = "cat_id IS NULL"; | |
205 | } | |
206 | ||
0d3adafe | 207 | $cat_id = sprintf("%d", $cat_id); |
26eb0119 AD |
208 | $cat_unread = getCategoryUnread($link, $cat_id); |
209 | ||
0d3adafe | 210 | print "<li class=\"feedCat\"> |
42096f52 | 211 | <a href=\"?subop=tc&id=$cat_id\">$tmp_category</a> |
ab1486d5 AD |
212 | <a href=\"?go=vf&id=$cat_id&cat=true\"> |
213 | <span class=\"$catctr_class\">($cat_unread | |
214 | unread)$ellipsis</span></a></li>"; | |
0d3adafe | 215 | |
ab1486d5 AD |
216 | print "<li id=\"feedCatHolder\" class=\"$holder_class\"> |
217 | <ul class=\"feedCatList\">"; | |
0d3adafe AD |
218 | } |
219 | ||
8e3f7217 AD |
220 | printMobileFeedEntry($feed_id, $class, $feed, $unread, |
221 | "../icons/$feed_id.ico", $link, $rtl_content); | |
0d3adafe AD |
222 | |
223 | ++$lnum; | |
224 | } | |
225 | ||
8e3f7217 | 226 | } else { |
eead4d26 AD |
227 | // tags |
228 | ||
229 | $result = db_query($link, "SELECT tag_name,SUM((SELECT COUNT(int_id) | |
230 | FROM ttrss_user_entries WHERE int_id = post_int_id | |
231 | AND unread = true)) AS count FROM ttrss_tags | |
232 | WHERE owner_uid = 2 GROUP BY tag_name ORDER BY tag_name"); | |
233 | ||
234 | $tags = array(); | |
235 | ||
236 | while ($line = db_fetch_assoc($result)) { | |
237 | $tags[$line["tag_name"]] += $line["count"]; | |
238 | } | |
239 | ||
240 | foreach (array_keys($tags) as $tag) { | |
241 | ||
242 | $unread = $tags[$tag]; | |
243 | ||
244 | $class = "tag"; | |
245 | ||
246 | if ($unread > 0) { | |
247 | $class .= "Unread"; | |
248 | } | |
249 | ||
250 | printMobileFeedEntry($tag, $class, $tag, $unread, | |
251 | "../images/tag.png", $link); | |
252 | ||
253 | } | |
254 | ||
255 | ||
8e3f7217 | 256 | } |
0d3adafe | 257 | } |
8e3f7217 AD |
258 | |
259 | function printMobileFeedEntry($feed_id, $class, $feed_title, $unread, $icon_file, $link, | |
260 | $rtl_content = false) { | |
261 | ||
262 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
263 | $feed_icon = "<img src=\"$icon_file\">"; | |
264 | } else { | |
265 | $feed_icon = "<img src=\"../images/blank_icon.gif\">"; | |
266 | } | |
267 | ||
268 | if ($rtl_content) { | |
269 | $rtl_tag = "dir=\"rtl\""; | |
270 | } else { | |
271 | $rtl_tag = "dir=\"ltr\""; | |
272 | } | |
273 | ||
274 | $feed = "<a href=\"?go=vf&id=$feed_id\">$feed_title</a>"; | |
275 | ||
276 | print "<li class=\"$class\">"; | |
581e6bb5 AD |
277 | # if (get_pref($link, 'ENABLE_FEED_ICONS')) { |
278 | # print "$feed_icon"; | |
279 | # } | |
8e3f7217 AD |
280 | |
281 | print "<span $rtl_tag>$feed</span> "; | |
282 | ||
283 | if ($unread != 0) { | |
ab1486d5 | 284 | print "<span $rtl_tag>($unread)</span>"; |
8e3f7217 | 285 | } |
8e3f7217 AD |
286 | |
287 | print "</li>"; | |
288 | ||
0d3adafe AD |
289 | } |
290 | ||
ab1486d5 AD |
291 | function render_headlines($link) { |
292 | ||
2f468537 AD |
293 | $feed = db_escape_string($_GET["id"]); |
294 | $limit = db_escape_string($_GET["limit"]); | |
295 | $view_mode = db_escape_string($_GET["viewmode"]); | |
ab1486d5 | 296 | $cat_view = db_escape_string($_GET["cat"]); |
bbf3ba8d | 297 | $subop = $_GET["subop"]; |
2f468537 AD |
298 | |
299 | if (!$view_mode) $view_mode = "Adaptive"; | |
300 | if (!$limit) $limit = 30; | |
301 | ||
eead4d26 | 302 | if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) { |
2f468537 | 303 | |
eead4d26 AD |
304 | $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds |
305 | WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); | |
2f468537 | 306 | |
eead4d26 AD |
307 | if (db_num_rows($result) == 1) { |
308 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
309 | } else { | |
310 | $rtl_content = false; | |
311 | } | |
312 | ||
313 | if ($rtl_content) { | |
314 | $rtl_tag = "dir=\"RTL\""; | |
315 | } else { | |
316 | $rtl_tag = ""; | |
317 | } | |
2f468537 | 318 | } else { |
eead4d26 | 319 | $rtl_content = false; |
2f468537 AD |
320 | $rtl_tag = ""; |
321 | } | |
322 | ||
323 | print "<div id=\"headlines\" $rtl_tag>"; | |
324 | ||
325 | if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) { | |
326 | update_generic_feed($link, $feed, $cat_view); | |
327 | } | |
328 | ||
329 | if ($subop == "MarkAllRead") { | |
330 | catchup_feed($link, $feed, $cat_view); | |
331 | } | |
332 | ||
c878bc01 AD |
333 | if ($subop == "MarkPageRead") { |
334 | $ids_to_mark = $_SESSION["last_page_ids.$feed"]; | |
335 | ||
336 | if ($ids_to_mark) { | |
337 | ||
338 | foreach ($ids_to_mark as $id) { | |
339 | db_query($link, "UPDATE ttrss_user_entries SET | |
340 | unread = false,last_read = NOW() | |
341 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
342 | } | |
343 | } | |
344 | } | |
345 | ||
2f468537 AD |
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\">"; |
581e6bb5 AD |
573 | # if (!$cat_view && file_exists("../icons/$feed.ico") && filesize("../icons/$feed.ico") > 0) { |
574 | # print "<img class=\"feedIcon\" src=\"../icons/$feed.ico\">"; | |
575 | # } | |
42096f52 | 576 | |
062c1de5 | 577 | print "$feed_title <span id=\"headingAddon\">("; |
24ac6776 | 578 | print "<a href=\"tt-rss.php\">Back</a>, "; |
c878bc01 AD |
579 | print "<a href=\"tt-rss.php?go=vf&id=$feed&subop=ForceUpdate\">Update</a>"; |
580 | # print "Mark as read: "; | |
581 | # print "<a href=\"tt-rss.php?go=vf&id=$feed&subop=MarkAsRead\">Page</a>, "; | |
582 | # print "<a href=\"tt-rss.php?go=vf&id=$feed&subop=MarkAllRead\">Feed</a>"; | |
062c1de5 | 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 | 590 | |
c878bc01 AD |
591 | $page_art_ids = array(); |
592 | ||
2f468537 AD |
593 | $lnum = 0; |
594 | ||
595 | error_reporting (DEFAULT_ERROR_LEVEL); | |
596 | ||
597 | $num_unread = 0; | |
598 | ||
599 | while ($line = db_fetch_assoc($result)) { | |
600 | ||
601 | $class = ($lnum % 2) ? "even" : "odd"; | |
602 | ||
603 | $id = $line["id"]; | |
604 | $feed_id = $line["feed_id"]; | |
c878bc01 AD |
605 | |
606 | array_push($page_art_ids, $id); | |
2f468537 AD |
607 | |
608 | if ($line["last_read"] == "" && | |
609 | ($line["unread"] != "t" && $line["unread"] != "1")) { | |
610 | ||
611 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\" | |
612 | alt=\"Updated\">"; | |
613 | } else { | |
614 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\" | |
615 | alt=\"Updated\">"; | |
616 | } | |
617 | ||
618 | if ($line["unread"] == "t" || $line["unread"] == "1") { | |
619 | $class .= "Unread"; | |
620 | ++$num_unread; | |
621 | $is_unread = true; | |
622 | } else { | |
623 | $is_unread = false; | |
624 | } | |
625 | ||
626 | if ($line["marked"] == "t" || $line["marked"] == "1") { | |
24ac6776 | 627 | $marked_pic = "<img class='marked' src=\"../images/mark_set.png\">"; |
2f468537 | 628 | } else { |
24ac6776 | 629 | $marked_pic = "<img class='marked' src=\"../images/mark_unset.png\">"; |
2f468537 AD |
630 | } |
631 | ||
632 | $content_link = "<a href=\"?go=view&id=$id&feed=$feed_id\">" . | |
633 | $line["title"] . "</a>"; | |
634 | ||
635 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
636 | $updated_fmt = smart_date_time(strtotime($line["updated"])); | |
637 | } else { | |
638 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
639 | $updated_fmt = date($short_date, strtotime($line["updated"])); | |
640 | } | |
641 | ||
ab1486d5 | 642 | print "<li class='$class'>"; |
2f468537 | 643 | |
24ac6776 AD |
644 | print "<a href=\"?go=vf&id=$feed_id&ts=$id\">$marked_pic</a>"; |
645 | ||
ab1486d5 AD |
646 | print $content_link; |
647 | ||
2f468537 AD |
648 | if ($line["feed_title"]) { |
649 | print " (<a href='?go=vf&id=$feed_id'>". | |
650 | $line["feed_title"]."</a>)"; | |
651 | } | |
652 | ||
581e6bb5 | 653 | print "<span class='hlUpdated'> ($updated_fmt)</span>"; |
ab1486d5 AD |
654 | |
655 | print "</li>"; | |
2f468537 | 656 | |
2f468537 AD |
657 | |
658 | ++$lnum; | |
659 | } | |
660 | ||
ab1486d5 | 661 | print "</ul>"; |
2f468537 | 662 | |
c878bc01 AD |
663 | print "<div class='footerAddon'>Mark as read: "; |
664 | ||
665 | $_SESSION["last_page_ids.$feed"] = $page_art_ids; | |
666 | ||
667 | print "<a href=\"tt-rss.php?go=vf&id=$feed&subop=MarkPageRead\">Page</a>, "; | |
668 | print "<a href=\"tt-rss.php?go=vf&id=$feed&subop=MarkAllRead\">Feed</a></div>"; | |
669 | ||
2f468537 AD |
670 | } else { |
671 | print "<div align='center'>No articles found.</div>"; | |
672 | } | |
673 | ||
674 | } | |
675 | ||
42096f52 AD |
676 | function render_article($link) { |
677 | ||
678 | $id = db_escape_string($_GET["id"]); | |
679 | $feed_id = db_escape_string($_GET["feed"]); | |
680 | ||
681 | $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds | |
682 | WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); | |
683 | ||
684 | if (db_num_rows($result) == 1) { | |
685 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
686 | } else { | |
687 | $rtl_content = false; | |
688 | } | |
689 | ||
690 | if ($rtl_content) { | |
691 | $rtl_tag = "dir=\"RTL\""; | |
692 | $rtl_class = "RTL"; | |
693 | } else { | |
694 | $rtl_tag = ""; | |
695 | $rtl_class = ""; | |
696 | } | |
697 | ||
698 | $result = db_query($link, "UPDATE ttrss_user_entries | |
699 | SET unread = false,last_read = NOW() | |
700 | WHERE ref_id = '$id' AND feed_id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); | |
701 | ||
702 | $result = db_query($link, "SELECT title,link,content,feed_id,comments,int_id, | |
703 | SUBSTRING(updated,1,16) as updated, | |
704 | (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url, | |
705 | num_comments, | |
706 | author | |
707 | FROM ttrss_entries,ttrss_user_entries | |
708 | WHERE id = '$id' AND ref_id = id"); | |
709 | ||
42096f52 AD |
710 | if ($result) { |
711 | ||
712 | $line = db_fetch_assoc($result); | |
713 | ||
42096f52 AD |
714 | $num_comments = $line["num_comments"]; |
715 | $entry_comments = ""; | |
716 | ||
717 | if ($num_comments > 0) { | |
718 | if ($line["comments"]) { | |
719 | $comments_url = $line["comments"]; | |
720 | } else { | |
721 | $comments_url = $line["link"]; | |
722 | } | |
723 | $entry_comments = "<a href=\"$comments_url\">$num_comments comments</a>"; | |
724 | } else { | |
725 | if ($line["comments"] && $line["link"] != $line["comments"]) { | |
726 | $entry_comments = "<a href=\"".$line["comments"]."\">comments</a>"; | |
727 | } | |
728 | } | |
729 | ||
eead4d26 AD |
730 | $tmp_result = db_query($link, "SELECT DISTINCT tag_name FROM |
731 | ttrss_tags WHERE post_int_id = " . $line["int_id"] . " | |
732 | ORDER BY tag_name"); | |
733 | ||
734 | $tags_str = ""; | |
735 | $f_tags_str = ""; | |
736 | ||
737 | $num_tags = 0; | |
738 | ||
739 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
740 | $num_tags++; | |
741 | $tag = $tmp_line["tag_name"]; | |
742 | $tag_str = "<a href=\"?go=vf&id=$tag\">$tag</a>, "; | |
743 | $tags_str .= $tag_str; | |
744 | } | |
745 | ||
746 | $tags_str = preg_replace("/, $/", "", $tags_str); | |
747 | ||
24ac6776 | 748 | $parsed_updated = date(get_pref($link, 'SHORT_DATE_FORMAT'), |
42096f52 | 749 | strtotime($line["updated"])); |
42096f52 | 750 | |
ab1486d5 | 751 | print "<div id=\"heading\">"; |
24ac6776 | 752 | |
581e6bb5 AD |
753 | # if (file_exists("../icons/$feed_id.ico") && filesize("../icons/$feed_id.ico") > 0) { |
754 | # print "<img class=\"feedIcon\" src=\"../icons/$feed_id.ico\">"; | |
755 | # } | |
24ac6776 AD |
756 | |
757 | $feed_link = "<a href=\"tt-rss.php?go=vf&id=$feed_id\">Feed</a>"; | |
758 | ||
3d7d6cdd AD |
759 | print "<a href=\"" . $line["link"] . "\">" . |
760 | truncate_string($line["title"], 30) . "</a>"; | |
24ac6776 | 761 | print " <span id=\"headingAddon\">$parsed_updated ($feed_link)</span>"; |
ab1486d5 | 762 | print "</div>"; |
42096f52 | 763 | |
eead4d26 AD |
764 | if ($num_tags > 0) { |
765 | print "<div class=\"postTags\">Tags: $tags_str</div>"; | |
766 | } | |
24ac6776 | 767 | |
eead4d26 AD |
768 | print $line["content"]; |
769 | ||
42096f52 AD |
770 | } |
771 | ||
772 | print "</body></html>"; | |
42096f52 AD |
773 | } |
774 | ||
0d3adafe | 775 | ?> |