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