]>
Commit | Line | Data |
---|---|---|
1afd6227 AD |
1 | <?php |
2 | define('MOBILE_FEEDLIST_ENABLE_ICONS', false); | |
3 | define('TTRSS_SESSION_NAME', 'ttrss_m_sid'); | |
4 | ||
5 | function render_feeds_list($link) { | |
6 | ||
7 | $tags = $_GET["tags"]; | |
8 | ||
9 | print "<div id=\"heading\">"; | |
10 | ||
11 | if ($tags) { | |
12 | print __("Tags")."<span id=\"headingAddon\"> | |
13 | (<a href=\"index.php\">".__("View feeds")."</a>, "; | |
14 | } else { | |
15 | print __("Feeds")." <span id=\"headingAddon\"> | |
16 | (<a href=\"index.php?tags=1\">".__("View tags")."</a>, "; | |
17 | } | |
18 | ||
19 | print "<a href=\"index.php?go=sform\">".__("Search")."</a>, "; | |
20 | ||
21 | print "<a href=\"logout.php\">".__("Logout")."</a>)</span>"; | |
22 | print "</div>"; | |
23 | ||
24 | print "<ul class=\"feedList\">"; | |
25 | ||
26 | $owner_uid = $_SESSION["uid"]; | |
27 | ||
28 | if (!$tags) { | |
29 | ||
30 | /* virtual feeds */ | |
31 | ||
32 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
57937c42 AD |
33 | |
34 | $collapsed = get_pref($link, "_COLLAPSED_SPECIAL"); | |
1afd6227 AD |
35 | |
36 | if ($collapsed == "t" || $collapsed == "1") { | |
37 | $holder_class = "invisible"; | |
38 | $ellipsis = "..."; | |
39 | } else { | |
40 | $holder_class = "feedCatHolder"; | |
41 | $ellipsis = ""; | |
42 | } | |
43 | ||
44 | $tmp_category = __("Special"); | |
45 | ||
46 | print "<li class=\"feedCat\"> | |
47 | <a href=\"?subop=tc&id=-1\">$tmp_category</a>$ellipsis | |
48 | </li>"; | |
49 | ||
50 | print "<li class=\"$holder_class\"><ul class=\"feedCatList\">"; | |
51 | } | |
52 | ||
53 | $num_total = getFeedUnread($link, -4); | |
54 | ||
55 | $class = "virt"; | |
56 | ||
57 | if ($num_total > 0) $class .= "Unread"; | |
58 | ||
59 | printMobileFeedEntry(-4, $class, __("All articles"), $num_total, | |
60 | "../../images/fresh.png", $link); | |
61 | ||
62 | $num_fresh = getFeedUnread($link, -3); | |
63 | ||
64 | $class = "virt"; | |
65 | ||
66 | if ($num_fresh > 0) $class .= "Unread"; | |
67 | ||
68 | printMobileFeedEntry(-3, $class, __("Fresh articles"), $num_fresh, | |
69 | "../../images/fresh.png", $link); | |
70 | ||
71 | $num_starred = getFeedUnread($link, -1); | |
72 | ||
73 | $class = "virt"; | |
74 | ||
75 | if ($num_starred > 0) $class .= "Unread"; | |
76 | ||
77 | printMobileFeedEntry(-1, $class, __("Starred articles"), $num_starred, | |
78 | "../../images/mark_set.png", $link); | |
79 | ||
80 | $class = "virt"; | |
81 | ||
82 | $num_published = getFeedUnread($link, -2); | |
83 | ||
84 | if ($num_published > 0) $class .= "Unread"; | |
85 | ||
86 | printMobileFeedEntry(-2, $class, __("Published articles"), $num_published, | |
87 | "../../images/pub_set.png", $link); | |
88 | ||
89 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
90 | print "</ul>"; | |
91 | } | |
92 | ||
93 | ||
94 | $result = db_query($link, "SELECT id,caption FROM | |
95 | ttrss_labels2 WHERE owner_uid = '$owner_uid' ORDER by caption"); | |
96 | ||
97 | if (db_num_rows($result) > 0) { | |
98 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
99 | ||
57937c42 | 100 | $collapsed = get_pref($link, "_COLLAPSED_LABELS"); |
1afd6227 AD |
101 | |
102 | if ($collapsed == "t" || $collapsed == "1") { | |
103 | $holder_class = "invisible"; | |
104 | $ellipsis = "..."; | |
105 | } else { | |
106 | $holder_class = "feedCatHolder"; | |
107 | $ellipsis = ""; | |
108 | } | |
109 | ||
110 | $tmp_category = __("Labels"); | |
111 | ||
112 | print "<li class=\"feedCat\"> | |
113 | <a href=\"?subop=tc&id=-2\">$tmp_category</a>$ellipsis | |
114 | </li>"; | |
115 | ||
116 | print "<li class=\"$holder_class\"><ul class=\"feedCatList\">"; | |
117 | } else { | |
118 | // print "<li><hr></li>"; | |
119 | } | |
120 | } | |
121 | ||
122 | while ($line = db_fetch_assoc($result)) { | |
123 | ||
124 | $count = getFeedUnread($link, -$line["id"]-11); | |
125 | ||
126 | $class = "label"; | |
127 | ||
128 | if ($count > 0) { | |
129 | $class .= "Unread"; | |
130 | } | |
131 | ||
132 | printMobileFeedEntry(-$line["id"]-11, | |
133 | $class, $line["caption"], $count, "../images/label.png", $link); | |
134 | ||
135 | } | |
136 | ||
137 | if (db_num_rows($result) > 0) { | |
138 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
139 | print "</ul>"; | |
140 | } | |
141 | } | |
142 | ||
143 | ||
144 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
145 | $order_by_qpart = "category,title"; | |
146 | } else { | |
147 | $order_by_qpart = "title"; | |
148 | } | |
149 | ||
150 | $result = db_query($link, "SELECT ttrss_feeds.*, | |
151 | ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated_noms, | |
152 | (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries | |
153 | WHERE feed_id = ttrss_feeds.id AND | |
154 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
155 | owner_uid = '$owner_uid') AS total, | |
156 | (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries | |
157 | WHERE feed_id = ttrss_feeds.id AND unread = true | |
158 | AND ttrss_user_entries.ref_id = ttrss_entries.id | |
159 | AND owner_uid = '$owner_uid') as unread, | |
160 | cat_id,last_error, | |
161 | ttrss_feed_categories.title AS category, | |
162 | ttrss_feed_categories.collapsed | |
163 | FROM ttrss_feeds LEFT JOIN ttrss_feed_categories | |
164 | ON (ttrss_feed_categories.id = cat_id) | |
165 | WHERE | |
166 | ttrss_feeds.hidden = false AND | |
167 | ttrss_feeds.owner_uid = '$owner_uid' AND parent_feed IS NULL | |
168 | ORDER BY $order_by_qpart"); | |
169 | ||
170 | $actid = $_GET["actid"]; | |
171 | ||
172 | /* real feeds */ | |
173 | ||
174 | $lnum = 0; | |
175 | ||
176 | $category = ""; | |
177 | ||
178 | while ($line = db_fetch_assoc($result)) { | |
179 | if (get_pref($link, 'HIDE_READ_FEEDS') && (int)$line['unread']==0) { | |
180 | continue; | |
181 | } | |
182 | ||
183 | $feed = db_unescape_string($line["title"]); | |
184 | $feed_id = $line["id"]; | |
185 | ||
186 | $subop = $_GET["subop"]; | |
187 | ||
188 | $total = $line["total"]; | |
189 | $unread = $line["unread"]; | |
190 | ||
191 | $rtl_content = sql_bool_to_bool($line["rtl_content"]); | |
192 | ||
193 | if ($rtl_content) { | |
194 | $rtl_tag = "dir=\"RTL\""; | |
195 | } else { | |
196 | $rtl_tag = ""; | |
197 | } | |
198 | ||
199 | $tmp_result = db_query($link, | |
200 | "SELECT id,COUNT(unread) AS unread | |
201 | FROM ttrss_feeds LEFT JOIN ttrss_user_entries | |
202 | ON (ttrss_feeds.id = ttrss_user_entries.feed_id) | |
203 | WHERE parent_feed = '$feed_id' AND unread = true | |
204 | GROUP BY ttrss_feeds.id"); | |
205 | ||
206 | if (db_num_rows($tmp_result) > 0) { | |
207 | while ($l = db_fetch_assoc($tmp_result)) { | |
208 | $unread += $l["unread"]; | |
209 | } | |
210 | } | |
211 | ||
212 | $cat_id = $line["cat_id"]; | |
213 | ||
214 | $tmp_category = $line["category"]; | |
215 | ||
216 | if (!$tmp_category) { | |
217 | $tmp_category = "Uncategorized"; | |
218 | } | |
219 | ||
220 | // $class = ($lnum % 2) ? "even" : "odd"; | |
221 | ||
222 | if ($line["last_error"]) { | |
223 | $class = "error"; | |
224 | } else { | |
225 | $class = "feed"; | |
226 | } | |
227 | ||
228 | if ($unread > 0) $class .= "Unread"; | |
229 | ||
230 | if ($actid == $feed_id) { | |
231 | $class .= "Selected"; | |
232 | } | |
233 | ||
234 | if ($category != $tmp_category && get_pref($link, 'ENABLE_FEED_CATS')) { | |
235 | ||
236 | if ($category) { | |
237 | print "</ul></li>"; | |
238 | } | |
239 | ||
240 | $category = $tmp_category; | |
241 | ||
242 | $collapsed = $line["collapsed"]; | |
243 | ||
244 | // workaround for NULL category | |
245 | if ($category == "Uncategorized") { | |
57937c42 | 246 | $collapsed = get_pref($link, "_COLLAPSED_UNCAT"); |
1afd6227 AD |
247 | } |
248 | ||
249 | if ($collapsed == "t" || $collapsed == "1") { | |
250 | $holder_class = "invisible"; | |
251 | $ellipsis = "..."; | |
252 | } else { | |
253 | $holder_class = "feedCatHolder"; | |
254 | $ellipsis = ""; | |
255 | } | |
256 | ||
257 | if ($cat_id) { | |
258 | $cat_id_qpart = "cat_id = '$cat_id'"; | |
259 | } else { | |
260 | $cat_id_qpart = "cat_id IS NULL"; | |
261 | } | |
262 | ||
263 | $cat_id = sprintf("%d", $cat_id); | |
264 | $cat_unread = getCategoryUnread($link, $cat_id); | |
265 | ||
266 | if ($cat_unread > 0) { | |
267 | $catctr_class = ""; | |
268 | } else { | |
269 | $catctr_class = "invisible"; | |
270 | } | |
271 | ||
272 | print "<li class=\"feedCat\"> | |
273 | <a href=\"?subop=tc&id=$cat_id\">$tmp_category</a> | |
274 | <a href=\"?go=vf&id=$cat_id&cat=true\"> | |
275 | <span class=\"$catctr_class\">($cat_unread)$ellipsis</span> | |
276 | </a></li>"; | |
277 | ||
278 | print "<li id=\"feedCatHolder\" class=\"$holder_class\"> | |
279 | <ul class=\"feedCatList\">"; | |
280 | } | |
281 | ||
282 | printMobileFeedEntry($feed_id, $class, $feed, $unread, | |
283 | "../icons/$feed_id.ico", $link, $rtl_content); | |
284 | ||
285 | ++$lnum; | |
286 | } | |
287 | ||
288 | } else { | |
289 | // tags | |
290 | ||
291 | $result = db_query($link, "SELECT tag_name,SUM((SELECT COUNT(int_id) | |
292 | FROM ttrss_user_entries WHERE int_id = post_int_id | |
293 | AND unread = true)) AS count FROM ttrss_tags | |
294 | WHERE owner_uid = '".$_SESSION['uid']."' GROUP BY tag_name ORDER BY tag_name"); | |
295 | ||
296 | $tags = array(); | |
297 | ||
298 | while ($line = db_fetch_assoc($result)) { | |
299 | $tags[$line["tag_name"]] += $line["count"]; | |
300 | } | |
301 | ||
302 | foreach (array_keys($tags) as $tag) { | |
303 | ||
304 | $unread = $tags[$tag]; | |
305 | ||
306 | $class = "tag"; | |
307 | ||
308 | if ($unread > 0) { | |
309 | $class .= "Unread"; | |
310 | } | |
311 | ||
312 | printMobileFeedEntry($tag, $class, $tag, $unread, | |
313 | "../images/tag.png", $link); | |
314 | ||
315 | } | |
316 | ||
317 | ||
318 | } | |
319 | } | |
320 | ||
321 | function printMobileFeedEntry($feed_id, $class, $feed_title, $unread, $icon_file, $link, | |
322 | $rtl_content = false) { | |
323 | ||
324 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
325 | $feed_icon = "<img src=\"$icon_file\">"; | |
326 | } else { | |
327 | $feed_icon = "<img src=\"../../images/blank_icon.gif\">"; | |
328 | } | |
329 | ||
330 | if ($rtl_content) { | |
331 | $rtl_tag = "dir=\"rtl\""; | |
332 | } else { | |
333 | $rtl_tag = "dir=\"ltr\""; | |
334 | } | |
335 | ||
336 | $feed = "<a href=\"?go=vf&id=$feed_id\">$feed_title</a>"; | |
337 | ||
338 | print "<li class=\"$class\">"; | |
339 | # if (get_pref($link, 'ENABLE_FEED_ICONS')) { | |
340 | # print "$feed_icon"; | |
341 | # } | |
342 | ||
343 | print "<span $rtl_tag>$feed</span> "; | |
344 | ||
345 | if ($unread != 0) { | |
346 | print "<span $rtl_tag>($unread)</span>"; | |
347 | } | |
348 | ||
349 | print "</li>"; | |
350 | ||
351 | } | |
352 | ||
353 | function render_headlines($link) { | |
354 | ||
355 | $feed = db_escape_string($_GET["id"]); | |
356 | $limit = db_escape_string($_GET["limit"]); | |
357 | $view_mode = db_escape_string($_GET["viewmode"]); | |
358 | $cat_view = db_escape_string($_GET["cat"]); | |
359 | $subop = $_GET["subop"]; | |
360 | $catchup_op = $_GET["catchup_op"]; | |
361 | ||
362 | if (!$view_mode) { | |
363 | if ($_SESSION["mobile:viewmode"]) { | |
364 | $view_mode = $_SESSION["mobile:viewmode"]; | |
365 | } else { | |
366 | $view_mode = "adaptive"; | |
367 | } | |
368 | } | |
369 | ||
370 | $_SESSION["mobile:viewmode"] = $view_mode; | |
371 | ||
372 | if (!$limit) $limit = 30; | |
373 | if (!$feed) $feed = 0; | |
374 | ||
375 | if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) { | |
376 | ||
377 | $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds | |
378 | WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); | |
379 | ||
380 | if (db_num_rows($result) == 1) { | |
381 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
382 | } else { | |
383 | $rtl_content = false; | |
384 | } | |
385 | ||
386 | if ($rtl_content) { | |
387 | $rtl_tag = "dir=\"RTL\""; | |
388 | } else { | |
389 | $rtl_tag = ""; | |
390 | } | |
391 | } else { | |
392 | $rtl_content = false; | |
393 | $rtl_tag = ""; | |
394 | } | |
395 | ||
396 | print "<div id=\"headlines\" $rtl_tag>"; | |
397 | ||
398 | if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) { | |
399 | update_generic_feed($link, $feed, $cat_view, true); | |
400 | } | |
401 | ||
402 | if ($subop == "MarkAllRead" || $catchup_op == "feed") { | |
403 | catchup_feed($link, $feed, $cat_view); | |
404 | } | |
405 | ||
406 | if ($catchup_op == "selection") { | |
407 | $ids_to_mark = array_keys($_GET["sel_ids"]); | |
408 | if ($ids_to_mark) { | |
409 | foreach ($ids_to_mark as $id) { | |
410 | db_query($link, "UPDATE ttrss_user_entries SET | |
411 | unread = false,last_read = NOW() | |
412 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
413 | } | |
414 | } | |
415 | } | |
416 | ||
417 | if ($subop == "MarkPageRead" || $catchup_op == "page") { | |
418 | $ids_to_mark = $_SESSION["last_page_ids.$feed"]; | |
419 | ||
420 | if ($ids_to_mark) { | |
421 | ||
422 | foreach ($ids_to_mark as $id) { | |
423 | db_query($link, "UPDATE ttrss_user_entries SET | |
424 | unread = false,last_read = NOW() | |
425 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
426 | } | |
427 | } | |
428 | } | |
429 | ||
430 | ||
431 | /// START ///////////////////////////////////////////////////////////////////////////////// | |
432 | ||
433 | $search = db_escape_string($_GET["query"]); | |
434 | $search_mode = db_escape_string($_GET["search_mode"]); | |
435 | $match_on = db_escape_string($_GET["match_on"]); | |
436 | ||
437 | if (!$match_on) { | |
438 | $match_on = "both"; | |
439 | } | |
440 | ||
441 | $real_offset = $offset * $limit; | |
442 | ||
443 | if ($_GET["debug"]) $timing_info = print_checkpoint("H0", $timing_info); | |
444 | ||
445 | $qfh_ret = queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, | |
446 | $search, $search_mode, $match_on, false, $real_offset); | |
447 | ||
448 | if ($_GET["debug"]) $timing_info = print_checkpoint("H1", $timing_info); | |
449 | ||
450 | $result = $qfh_ret[0]; | |
451 | $feed_title = $qfh_ret[1]; | |
452 | $feed_site_url = $qfh_ret[2]; | |
453 | $last_error = $qfh_ret[3]; | |
454 | ||
455 | /// STOP ////////////////////////////////////////////////////////////////////////////////// | |
456 | ||
457 | if (!$result) { | |
458 | print "<div align='center'>". | |
459 | __("Could not display feed (query failed). Please check label match syntax or local configuration."). | |
460 | "</div>"; | |
461 | return; | |
462 | } | |
463 | ||
464 | print "<div id=\"heading\">"; | |
465 | # if (!$cat_view && file_exists("../icons/$feed.ico") && filesize("../icons/$feed.ico") > 0) { | |
466 | # print "<img class=\"feedIcon\" src=\"../icons/$feed.ico\">"; | |
467 | # } | |
468 | ||
469 | print "$feed_title <span id=\"headingAddon\">("; | |
470 | print "<a href=\"index.php\">".__("Back")."</a>, "; | |
471 | print "<a href=\"index.php?go=sform&aid=$feed&ic=$cat_view\">".__("Search")."</a>, "; | |
472 | print "<a href=\"index.php?go=vf&id=$feed&subop=ForceUpdate\">".__("Update")."</a>"; | |
473 | ||
474 | # print "Mark as read: "; | |
475 | # print "<a href=\"index.php?go=vf&id=$feed&subop=MarkAsRead\">Page</a>, "; | |
476 | # print "<a href=\"index.php?go=vf&id=$feed&subop=MarkAllRead\">Feed</a>"; | |
477 | ||
478 | print ")</span>"; | |
479 | ||
480 | print " " . __('View:'); | |
481 | ||
482 | print "<form style=\"display : inline\" method=\"GET\" action=\"index.php\">"; | |
483 | ||
484 | /* print "<select name=\"viewmode\"> | |
485 | <option selected value=\"adaptive\"> " . __('Adaptive') . "</option> | |
486 | <option value=\"all_articles\">" . __('All Articles') . "</option> | |
487 | <option value=\"marked\">" . __('Starred') . "</option> | |
488 | <option value=\"unread\">" . __('Unread') . "</option> | |
489 | </select>"; */ | |
490 | ||
491 | $sel_values = array( | |
492 | "adaptive" => __("Adaptive"), | |
493 | "all_articles" => __("All Articles"), | |
494 | "unread" => __("Unread"), | |
495 | "marked" => __("Starred")); | |
496 | ||
497 | print_select_hash("viewmode", $view_mode, $sel_values); | |
498 | ||
499 | print "<input type=\"hidden\" name=\"id\" value=\"$feed\"> | |
500 | <input type=\"hidden\" name=\"cat\" value=\"$cat_view\"> | |
501 | <input type=\"hidden\" name=\"go\" value=\"vf\"> | |
502 | <input type=\"submit\" value=\"".__('Refresh')."\">"; | |
503 | print "</form>"; | |
504 | ||
505 | print "</div>"; | |
506 | ||
507 | if (db_num_rows($result) > 0) { | |
508 | ||
509 | print "<form method=\"GET\" action=\"index.php\">"; | |
510 | print "<input type=\"hidden\" name=\"go\" value=\"vf\">"; | |
511 | print "<input type=\"hidden\" name=\"id\" value=\"$feed\">"; | |
512 | print "<input type=\"hidden\" name=\"cat\" value=\"$cat_view\">"; | |
513 | ||
514 | print "<ul class=\"headlines\" id=\"headlines\">"; | |
515 | ||
516 | $page_art_ids = array(); | |
517 | ||
518 | $lnum = 0; | |
519 | ||
520 | error_reporting (DEFAULT_ERROR_LEVEL); | |
521 | ||
522 | $num_unread = 0; | |
523 | ||
524 | while ($line = db_fetch_assoc($result)) { | |
525 | ||
526 | $class = ($lnum % 2) ? "even" : "odd"; | |
527 | ||
528 | $id = $line["id"]; | |
529 | $feed_id = $line["feed_id"]; | |
530 | ||
531 | array_push($page_art_ids, $id); | |
532 | ||
533 | if ($line["last_read"] == "" && | |
534 | ($line["unread"] != "t" && $line["unread"] != "1")) { | |
535 | ||
536 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\" | |
537 | alt=\"".__("Updated")."\">"; | |
538 | } else { | |
539 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\" | |
540 | alt=\"".__("Updated")."\">"; | |
541 | } | |
542 | ||
543 | if ($line["unread"] == "t" || $line["unread"] == "1") { | |
544 | $class .= "Unread"; | |
545 | ++$num_unread; | |
546 | $is_unread = true; | |
547 | } else { | |
548 | $is_unread = false; | |
549 | } | |
550 | ||
551 | if ($line["marked"] == "t" || $line["marked"] == "1") { | |
552 | $marked_pic = "<img alt=\"S\" class='marked' src=\"../../images/mark_set.png\">"; | |
553 | } else { | |
554 | $marked_pic = "<img alt=\"s\" class='marked' src=\"../../images/mark_unset.png\">"; | |
555 | } | |
556 | ||
557 | if ($line["published"] == "t" || $line["published"] == "1") { | |
558 | $published_pic = "<img alt=\"P\" class='marked' src=\"../../images/pub_set.gif\">"; | |
559 | } else { | |
560 | $published_pic = "<img alt=\"p\" class='marked' src=\"../../images/pub_unset.gif\">"; | |
561 | } | |
562 | ||
563 | $content_link = "<a href=\"?go=view&id=$id&cat=$cat_view&ret_feed=$feed&feed=$feed_id\">" . | |
564 | $line["title"] . "</a>"; | |
565 | ||
566 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
567 | $updated_fmt = smart_date_time(strtotime($line["updated"])); | |
568 | } else { | |
569 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
570 | $updated_fmt = date($short_date, strtotime($line["updated"])); | |
571 | } | |
572 | ||
573 | print "<li class='$class' id=\"HROW-$id\">"; | |
574 | ||
575 | print "<input type=\"checkbox\" name=\"sel_ids[$id]\" | |
576 | id=\"HSCB-$id\" onchange=\"toggleSelectRow(this, $id)\">"; | |
577 | ||
578 | print "<a href=\"?go=vf&id=$feed&ts=$id&cat=$cat_view\">$marked_pic</a>"; | |
579 | print "<a href=\"?go=vf&id=$feed&tp=$id&cat=$cat_view\">$published_pic</a>"; | |
580 | ||
581 | print $content_link; | |
582 | ||
583 | if ($line["feed_title"]) { | |
584 | print " (<a href='?go=vf&id=$feed_id'>". | |
585 | $line["feed_title"]."</a>)"; | |
586 | } | |
587 | ||
588 | print "<span class='hlUpdated'> ($updated_fmt)</span>"; | |
589 | ||
590 | print "</li>"; | |
591 | ||
592 | ||
593 | ++$lnum; | |
594 | } | |
595 | ||
596 | print "</ul>"; | |
597 | ||
598 | print "<div class='footerAddon'>"; | |
599 | ||
600 | $_SESSION["last_page_ids.$feed"] = $page_art_ids; | |
601 | ||
602 | /* print "<a href=\"index.php?go=vf&id=$feed&subop=MarkPageRead\">Page</a>, "; | |
603 | print "<a href=\"index.php?go=vf&id=$feed&subop=MarkAllRead\">Feed</a></div>"; */ | |
604 | ||
605 | print "Select: | |
606 | <a href=\"javascript:selectHeadlines(1)\">".__("All")."</a>, | |
607 | <a href=\"javascript:selectHeadlines(2)\">".__("Unread")."</a>, | |
608 | <a href=\"javascript:selectHeadlines(3)\">".__("None")."</a>, | |
609 | <a href=\"javascript:selectHeadlines(4)\">".__("Invert")."</a>"; | |
610 | ||
611 | print " "; | |
612 | ||
613 | print "<select name=\"catchup_op\"> | |
614 | <option value=\"selection\">".__("Selection")."</option> | |
615 | <option value=\"page\">".__("Page")."</option> | |
616 | <option value=\"feed\">".__("Entire feed")."</option> | |
617 | </select> | |
618 | <input type=\"hidden\" name=\"cat\" value=\"$cat_view\"> | |
619 | <input type=\"submit\" value=\"".__("Mark as read")."\">"; | |
620 | ||
621 | print "</form>"; | |
622 | ||
623 | } else { | |
624 | print "<div align='center'>No articles found.</div>"; | |
625 | } | |
626 | ||
627 | } | |
628 | ||
629 | function render_article($link) { | |
630 | ||
631 | $id = db_escape_string($_GET["id"]); | |
632 | $feed_id = db_escape_string($_GET["feed"]); | |
633 | $ret_feed_id = db_escape_string($_GET["ret_feed"]); | |
634 | $cat_view = db_escape_string($_GET["cat"]); | |
635 | ||
636 | $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds | |
637 | WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); | |
638 | ||
639 | if (db_num_rows($result) == 1) { | |
640 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
641 | } else { | |
642 | $rtl_content = false; | |
643 | } | |
644 | ||
645 | if ($rtl_content) { | |
646 | $rtl_tag = "dir=\"RTL\""; | |
647 | $rtl_class = "RTL"; | |
648 | } else { | |
649 | $rtl_tag = ""; | |
650 | $rtl_class = ""; | |
651 | } | |
652 | ||
653 | $result = db_query($link, "UPDATE ttrss_user_entries | |
654 | SET unread = false,last_read = NOW() | |
655 | WHERE ref_id = '$id' AND feed_id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); | |
656 | ||
657 | $result = db_query($link, "SELECT title,link,content,feed_id,comments,int_id, | |
658 | marked,published, | |
659 | ".SUBSTRING_FOR_DATE."(updated,1,16) as updated, | |
660 | (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url, | |
661 | num_comments, | |
662 | author | |
663 | FROM ttrss_entries,ttrss_user_entries | |
664 | WHERE id = '$id' AND ref_id = id"); | |
665 | ||
666 | if ($result) { | |
667 | ||
668 | $line = db_fetch_assoc($result); | |
669 | ||
670 | $num_comments = $line["num_comments"]; | |
671 | $entry_comments = ""; | |
672 | ||
673 | if ($num_comments > 0) { | |
674 | if ($line["comments"]) { | |
675 | $comments_url = $line["comments"]; | |
676 | } else { | |
677 | $comments_url = $line["link"]; | |
678 | } | |
679 | $entry_comments = "<a href=\"$comments_url\">$num_comments comments</a>"; | |
680 | } else { | |
681 | if ($line["comments"] && $line["link"] != $line["comments"]) { | |
682 | $entry_comments = "<a href=\"".$line["comments"]."\">comments</a>"; | |
683 | } | |
684 | } | |
685 | ||
686 | $tmp_result = db_query($link, "SELECT DISTINCT tag_name FROM | |
687 | ttrss_tags WHERE post_int_id = " . $line["int_id"] . " | |
688 | ORDER BY tag_name"); | |
689 | ||
690 | $tags_str = ""; | |
691 | $f_tags_str = ""; | |
692 | ||
693 | $num_tags = 0; | |
694 | ||
695 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
696 | $num_tags++; | |
697 | $tag = $tmp_line["tag_name"]; | |
698 | $tag_str = "<a href=\"?go=vf&id=$tag\">$tag</a>, "; | |
699 | $tags_str .= $tag_str; | |
700 | } | |
701 | ||
702 | $tags_str = preg_replace("/, $/", "", $tags_str); | |
703 | ||
704 | $parsed_updated = date(get_pref($link, 'SHORT_DATE_FORMAT'), | |
705 | strtotime($line["updated"])); | |
706 | ||
707 | print "<div id=\"heading\">"; | |
708 | ||
709 | # if (file_exists("../icons/$feed_id.ico") && filesize("../icons/$feed_id.ico") > 0) { | |
710 | # print "<img class=\"feedIcon\" src=\"../icons/$feed_id.ico\">"; | |
711 | # } | |
712 | ||
713 | if (!$cat_view) { | |
714 | $feed_title = getFeedTitle($link, $ret_feed_id); | |
715 | } else { | |
716 | $feed_title = getCategoryTitle($link, $ret_feed_id); | |
717 | $feed_title_native = getFeedTitle($link, $feed_id); | |
718 | } | |
719 | ||
720 | if ($feed_title_native) { | |
721 | $feed_link = "<a href=\"index.php?go=vf&id=$feed_id\">$feed_title_native</a>"; | |
722 | $feed_link .= " in <a href=\"index.php?go=vf&id=$ret_feed_id&cat=$cat_view\"> | |
723 | $feed_title</a>"; | |
724 | } else { | |
725 | $feed_link = "<a href=\"index.php?go=vf&id=$ret_feed_id\">$feed_title</a>"; | |
726 | } | |
727 | ||
728 | $feedlist = "<a href=\"index.php\">".__('Back to feedlist')."</a>"; | |
729 | ||
730 | print "<a href=\"" . $line["link"] . "\">" . | |
731 | truncate_string($line["title"], 30) . "</a>"; | |
732 | print " <span id=\"headingAddon\">$parsed_updated ($feed_link, $feedlist)</span>"; | |
733 | print "</div>"; | |
734 | ||
735 | if ($num_tags > 0) { | |
736 | print "<div class=\"postTags\">".__("Tags:")." $tags_str</div>"; | |
737 | } | |
738 | ||
739 | if ($line["marked"] == "t" || $line["marked"] == "1") { | |
740 | $marked_pic = "<img class='marked' src=\"../../images/mark_set.png\">"; | |
741 | } else { | |
742 | $marked_pic = "<img class='marked' src=\"../../images/mark_unset.png\">"; | |
743 | } | |
744 | ||
745 | if ($line["published"] == "t" || $line["published"] == "1") { | |
746 | $published_pic = "<img class='marked' src=\"../../images/pub_set.gif\">"; | |
747 | } else { | |
748 | $published_pic = "<img class='marked' src=\"../../images/pub_unset.gif\">"; | |
749 | } | |
750 | ||
751 | ||
752 | print "<div class=\"postStarOps\">"; | |
753 | print "<a title=\"".__('Toggle starred')."\"href=\"?go=view&id=$id&ret_feed=$ret_feed_id&feed=$feed_id&sop=ts\">$marked_pic</a>"; | |
754 | print "<a title=\"".__('Toggle published')."\" href=\"?go=view&id=$id&ret_feed=$ret_feed_id&feed=$feed_id&sop=tp\">$published_pic</a>"; | |
755 | // Mark unread | |
756 | print "<a title=\"".__('Mark as unread')."\" href=\"?go=vf&id=$ret_feed_id&feed=$feed_id&sop=mu&aid=$id"; | |
757 | if ($cat_view) { print "&cat=$cat_view"; } | |
758 | print "\"><img class='marked' src=\"../../images/art-set-unread.png\"></a>"; | |
759 | print "</div>"; | |
760 | ||
761 | print sanitize_rss($link, $line["content"], true);; | |
762 | ||
763 | } | |
764 | ||
765 | print "</body></html>"; | |
766 | } | |
767 | ||
768 | function render_search_form($link, $active_feed_id = false, $is_cat = false) { | |
769 | ||
770 | print "<div id=\"heading\">"; | |
771 | ||
772 | print __("Search")." <span id=\"headingAddon\"> | |
773 | (<a href=\"index.php\">".__("Go back")."</a>)</span></div>"; | |
774 | ||
775 | print "<form method=\"GET\" action=\"index.php\" class=\"searchForm\">"; | |
776 | ||
777 | print "<input type=\"hidden\" name=\"go\" value=\"vf\">"; | |
778 | print "<input type=\"hidden\" name=\"id\" value=\"$active_feed_id\">"; | |
779 | print "<input type=\"hidden\" name=\"cat\" value=\"$is_cat\">"; | |
780 | ||
781 | print "<table><tr><td>".__('Search:')."</td><td>"; | |
782 | print "<input name=\"query\"></td></tr>"; | |
783 | ||
784 | print "<tr><td>".__('Where:')."</td><td>"; | |
785 | ||
786 | print "<select name=\"search_mode\"> | |
787 | <option value=\"all_feeds\">".__('All feeds')."</option>"; | |
788 | ||
789 | $feed_title = getFeedTitle($link, $active_feed_id); | |
790 | ||
791 | if (!$is_cat) { | |
792 | $feed_cat_title = getFeedCatTitle($link, $active_feed_id); | |
793 | } else { | |
794 | $feed_cat_title = getCategoryTitle($link, $active_feed_id); | |
795 | } | |
796 | ||
797 | if ($active_feed_id && !$is_cat) { | |
798 | print "<option selected value=\"this_feed\">$feed_title</option>"; | |
799 | } else { | |
800 | print "<option disabled>".__('This feed')."</option>"; | |
801 | } | |
802 | ||
803 | if ($is_cat) { | |
804 | $cat_preselected = "selected"; | |
805 | } | |
806 | ||
807 | if (get_pref($link, 'ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) { | |
808 | print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>"; | |
809 | } else { | |
810 | //print "<option disabled>".__('This category')."</option>"; | |
811 | } | |
812 | ||
813 | print "</select></td></tr>"; | |
814 | ||
815 | print "<tr><td>".__('Match on:')."</td><td>"; | |
816 | ||
817 | $search_fields = array( | |
818 | "title" => __("Title"), | |
819 | "content" => __("Content"), | |
820 | "both" => __("Title or content")); | |
821 | ||
822 | print_select_hash("match_on", 3, $search_fields); | |
823 | ||
824 | print "</td></tr></table>"; | |
825 | ||
826 | print "<input type=\"submit\" value=\"".__('Search')."\">"; | |
827 | ||
828 | print "</form>"; | |
829 | ||
830 | print "</div>"; | |
831 | } | |
832 | ||
833 | function toggleMarked($link, $ts_id) { | |
834 | $result = db_query($link, "UPDATE ttrss_user_entries SET marked = NOT marked | |
835 | WHERE ref_id = '$ts_id' AND owner_uid = " . $_SESSION["uid"]); | |
836 | } | |
837 | ||
838 | function togglePublished($link, $tp_id) { | |
839 | $result = db_query($link, "UPDATE ttrss_user_entries SET published = NOT published | |
840 | WHERE ref_id = '$tp_id' AND owner_uid = " . $_SESSION["uid"]); | |
841 | } | |
842 | ||
843 | function markUnread($link, $mu_id) { | |
844 | $result = db_query($link, "UPDATE ttrss_user_entries SET unread = true | |
845 | WHERE ref_id = '$mu_id' AND owner_uid = " . $_SESSION["uid"]); | |
846 | } | |
847 | ||
848 | ?> |