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