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