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