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