functions.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789
  1. <?php
  2. define('TTRSS_SESSION_NAME', 'ttrss_m_sid');
  3. function render_feeds_list($link) {
  4. $tags = $_GET["tags"];
  5. print "<div id=\"heading\">";
  6. if ($tags) {
  7. print __("Tags")."<span id=\"headingAddon\">
  8. (<a href=\"index.php\">".__("View feeds")."</a>, ";
  9. } else {
  10. print __("Feeds")." <span id=\"headingAddon\">
  11. (<a href=\"index.php?tags=1\">".__("View tags")."</a>, ";
  12. }
  13. print "<a href=\"index.php?go=sform\">".__("Search")."</a>, ";
  14. print "<a href=\"logout.php\">".__("Logout")."</a>)</span>";
  15. print "</div>";
  16. print "<ul class=\"feedList\">";
  17. $owner_uid = $_SESSION["uid"];
  18. if (!$tags) {
  19. /* virtual feeds */
  20. if (get_pref($link, 'ENABLE_FEED_CATS')) {
  21. $collapsed = get_pref($link, "_COLLAPSED_SPECIAL");
  22. if ($collapsed == "t" || $collapsed == "1") {
  23. $holder_class = "invisible";
  24. $ellipsis = "...";
  25. } else {
  26. $holder_class = "feedCatHolder";
  27. $ellipsis = "";
  28. }
  29. $tmp_category = __("Special");
  30. print "<li class=\"feedCat\">
  31. <a href=\"?subop=tc&id=-1\">$tmp_category</a>$ellipsis
  32. </li>";
  33. print "<li class=\"$holder_class\"><ul class=\"feedCatList\">";
  34. }
  35. foreach (array(-4, -3, -1, -2, 0) as $i) {
  36. printMobileFeedEntry($i, "virt", false, false,
  37. false, $link);
  38. }
  39. if (get_pref($link, 'ENABLE_FEED_CATS')) {
  40. print "</ul>";
  41. }
  42. $result = db_query($link, "SELECT id,caption FROM
  43. ttrss_labels2 WHERE owner_uid = '$owner_uid' ORDER by caption");
  44. if (db_num_rows($result) > 0) {
  45. if (get_pref($link, 'ENABLE_FEED_CATS')) {
  46. $collapsed = get_pref($link, "_COLLAPSED_LABELS");
  47. if ($collapsed == "t" || $collapsed == "1") {
  48. $holder_class = "invisible";
  49. $ellipsis = "...";
  50. } else {
  51. $holder_class = "feedCatHolder";
  52. $ellipsis = "";
  53. }
  54. $tmp_category = __("Labels");
  55. print "<li class=\"feedCat\">
  56. <a href=\"?subop=tc&id=-2\">$tmp_category</a>$ellipsis
  57. </li>";
  58. print "<li class=\"$holder_class\"><ul class=\"feedCatList\">";
  59. } else {
  60. // print "<li><hr></li>";
  61. }
  62. }
  63. while ($line = db_fetch_assoc($result)) {
  64. $count = getFeedUnread($link, -$line["id"]-11);
  65. $class = "label";
  66. printMobileFeedEntry(-$line["id"]-11,
  67. $class, $line["caption"], $count, false, $link);
  68. }
  69. if (db_num_rows($result) > 0) {
  70. if (get_pref($link, 'ENABLE_FEED_CATS')) {
  71. print "</ul>";
  72. }
  73. }
  74. if (get_pref($link, 'ENABLE_FEED_CATS')) {
  75. $order_by_qpart = "category,title";
  76. } else {
  77. $order_by_qpart = "title";
  78. }
  79. $result = db_query($link, "SELECT ttrss_feeds.*,
  80. ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated_noms,
  81. (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries
  82. WHERE feed_id = ttrss_feeds.id AND
  83. ttrss_user_entries.ref_id = ttrss_entries.id AND
  84. owner_uid = '$owner_uid') AS total,
  85. (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries
  86. WHERE feed_id = ttrss_feeds.id AND unread = true
  87. AND ttrss_user_entries.ref_id = ttrss_entries.id
  88. AND owner_uid = '$owner_uid') as unread,
  89. cat_id,last_error,
  90. ttrss_feed_categories.title AS category,
  91. ttrss_feed_categories.collapsed
  92. FROM ttrss_feeds LEFT JOIN ttrss_feed_categories
  93. ON (ttrss_feed_categories.id = cat_id)
  94. WHERE
  95. ttrss_feeds.owner_uid = '$owner_uid'
  96. ORDER BY $order_by_qpart");
  97. $actid = $_GET["actid"];
  98. /* real feeds */
  99. $lnum = 0;
  100. $category = "";
  101. while ($line = db_fetch_assoc($result)) {
  102. if (get_pref($link, 'HIDE_READ_FEEDS') && (int)$line['unread']==0) {
  103. continue;
  104. }
  105. $feed = db_unescape_string($line["title"]);
  106. $feed_id = $line["id"];
  107. $subop = $_GET["subop"];
  108. $total = $line["total"];
  109. $unread = $line["unread"];
  110. $rtl_content = sql_bool_to_bool($line["rtl_content"]);
  111. if ($rtl_content) {
  112. $rtl_tag = "dir=\"RTL\"";
  113. } else {
  114. $rtl_tag = "";
  115. }
  116. $cat_id = $line["cat_id"];
  117. $tmp_category = $line["category"];
  118. if (!$tmp_category) {
  119. $tmp_category = "Uncategorized";
  120. }
  121. // $class = ($lnum % 2) ? "even" : "odd";
  122. if ($line["last_error"]) {
  123. $class = "error";
  124. } else {
  125. $class = "feed";
  126. }
  127. if ($category != $tmp_category && get_pref($link, 'ENABLE_FEED_CATS')) {
  128. if ($category) {
  129. print "</ul></li>";
  130. }
  131. $category = $tmp_category;
  132. $collapsed = $line["collapsed"];
  133. // workaround for NULL category
  134. if ($category == "Uncategorized") {
  135. $collapsed = get_pref($link, "_COLLAPSED_UNCAT");
  136. }
  137. if ($collapsed == "t" || $collapsed == "1") {
  138. $holder_class = "invisible";
  139. $ellipsis = "...";
  140. } else {
  141. $holder_class = "feedCatHolder";
  142. $ellipsis = "";
  143. }
  144. if ($cat_id) {
  145. $cat_id_qpart = "cat_id = '$cat_id'";
  146. } else {
  147. $cat_id_qpart = "cat_id IS NULL";
  148. }
  149. $cat_id = sprintf("%d", $cat_id);
  150. $cat_unread = getCategoryUnread($link, $cat_id);
  151. if ($cat_unread > 0) {
  152. $catctr_class = "";
  153. } else {
  154. $catctr_class = "invisible";
  155. }
  156. print "<li class=\"feedCat\">
  157. <a href=\"?subop=tc&id=$cat_id\">$tmp_category</a>
  158. <a href=\"?go=vf&id=$cat_id&cat=true\">
  159. <span class=\"$catctr_class\">($cat_unread)$ellipsis</span>
  160. </a></li>";
  161. print "<li id=\"feedCatHolder\" class=\"$holder_class\">
  162. <ul class=\"feedCatList\">";
  163. }
  164. printMobileFeedEntry($feed_id, $class, $feed, $unread,
  165. false, $link, $rtl_content);
  166. ++$lnum;
  167. }
  168. } else {
  169. // tags
  170. $result = db_query($link, "SELECT tag_name,SUM((SELECT COUNT(int_id)
  171. FROM ttrss_user_entries WHERE int_id = post_int_id
  172. AND unread = true)) AS count FROM ttrss_tags
  173. WHERE owner_uid = '".$_SESSION['uid']."' GROUP BY tag_name ORDER BY tag_name");
  174. $tags = array();
  175. while ($line = db_fetch_assoc($result)) {
  176. $tags[$line["tag_name"]] += $line["count"];
  177. }
  178. foreach (array_keys($tags) as $tag) {
  179. $unread = $tags[$tag];
  180. $class = "tag";
  181. printMobileFeedEntry($tag, $class, $tag, $unread,
  182. "../images/tag.png", $link);
  183. }
  184. }
  185. }
  186. function printMobileFeedEntry($feed_id, $class, $feed_title, $unread, $icon_file, $link,
  187. $rtl_content = false) {
  188. if (!$feed_title) $feed_title = getFeedTitle($link, $feed_id, false);
  189. if (!$unread) $unread = getFeedUnread($link, $feed_id);
  190. if ($unread > 0) $class .= "Unread";
  191. if (!$icon_file) $icon_file = "../../" . getFeedIcon($feed_id);
  192. if (file_exists($icon_file) && filesize($icon_file) > 0) {
  193. $feed_icon = "<img src=\"$icon_file\">";
  194. } else {
  195. $feed_icon = "<img src=\"../../images/blank_icon.gif\">";
  196. }
  197. if ($rtl_content) {
  198. $rtl_tag = "dir=\"rtl\"";
  199. } else {
  200. $rtl_tag = "dir=\"ltr\"";
  201. }
  202. $feed = "<a href=\"?go=vf&id=$feed_id\">$feed_title</a>";
  203. print "<li class=\"$class\">";
  204. print "$feed_icon";
  205. print "<span $rtl_tag>$feed</span> ";
  206. if ($unread != 0) {
  207. print "<span $rtl_tag>($unread)</span>";
  208. }
  209. print "</li>";
  210. }
  211. function render_headlines($link) {
  212. $feed = db_escape_string($_GET["id"]);
  213. $limit = db_escape_string($_GET["limit"]);
  214. $view_mode = db_escape_string($_GET["viewmode"]);
  215. $cat_view = db_escape_string($_GET["cat"]);
  216. $subop = $_GET["subop"];
  217. $catchup_op = $_GET["catchup_op"];
  218. if (!$view_mode) {
  219. if ($_SESSION["mobile:viewmode"]) {
  220. $view_mode = $_SESSION["mobile:viewmode"];
  221. } else {
  222. $view_mode = "adaptive";
  223. }
  224. }
  225. $_SESSION["mobile:viewmode"] = $view_mode;
  226. if (!$limit) $limit = 30;
  227. if (!$feed) $feed = 0;
  228. if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) {
  229. $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds
  230. WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]);
  231. if (db_num_rows($result) == 1) {
  232. $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
  233. } else {
  234. $rtl_content = false;
  235. }
  236. if ($rtl_content) {
  237. $rtl_tag = "dir=\"RTL\"";
  238. } else {
  239. $rtl_tag = "";
  240. }
  241. } else {
  242. $rtl_content = false;
  243. $rtl_tag = "";
  244. }
  245. print "<div id=\"headlines\" $rtl_tag>";
  246. if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) {
  247. update_generic_feed($link, $feed, $cat_view, true);
  248. }
  249. if ($subop == "MarkAllRead" || $catchup_op == "feed") {
  250. catchup_feed($link, $feed, $cat_view);
  251. }
  252. if ($catchup_op == "selection") {
  253. if (is_array($_GET["sel_ids"])) {
  254. $ids_to_mark = array_keys($_GET["sel_ids"]);
  255. if ($ids_to_mark) {
  256. foreach ($ids_to_mark as $id) {
  257. db_query($link, "UPDATE ttrss_user_entries SET
  258. unread = false,last_read = NOW()
  259. WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
  260. }
  261. }
  262. }
  263. }
  264. if ($subop == "MarkPageRead" || $catchup_op == "page") {
  265. $ids_to_mark = $_SESSION["last_page_ids.$feed"];
  266. if ($ids_to_mark) {
  267. foreach ($ids_to_mark as $id) {
  268. db_query($link, "UPDATE ttrss_user_entries SET
  269. unread = false,last_read = NOW()
  270. WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
  271. }
  272. }
  273. }
  274. /// START /////////////////////////////////////////////////////////////////////////////////
  275. $search = db_escape_string($_GET["query"]);
  276. $search_mode = db_escape_string($_GET["search_mode"]);
  277. $match_on = db_escape_string($_GET["match_on"]);
  278. if (!$match_on) {
  279. $match_on = "both";
  280. }
  281. $real_offset = $offset * $limit;
  282. if ($_GET["debug"]) $timing_info = print_checkpoint("H0", $timing_info);
  283. $qfh_ret = queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view,
  284. $search, $search_mode, $match_on, false, $real_offset);
  285. if ($_GET["debug"]) $timing_info = print_checkpoint("H1", $timing_info);
  286. $result = $qfh_ret[0];
  287. $feed_title = $qfh_ret[1];
  288. $feed_site_url = $qfh_ret[2];
  289. $last_error = $qfh_ret[3];
  290. /// STOP //////////////////////////////////////////////////////////////////////////////////
  291. if (!$result) {
  292. print "<div align='center'>".
  293. __("Could not display feed (query failed). Please check label match syntax or local configuration.").
  294. "</div>";
  295. return;
  296. }
  297. print "<div id=\"heading\">";
  298. # if (!$cat_view && file_exists("../icons/$feed.ico") && filesize("../icons/$feed.ico") > 0) {
  299. # print "<img class=\"feedIcon\" src=\"../icons/$feed.ico\">";
  300. # }
  301. print "$feed_title <span id=\"headingAddon\">(";
  302. print "<a href=\"index.php\">".__("Back")."</a>, ";
  303. print "<a href=\"index.php?go=sform&aid=$feed&ic=$cat_view\">".__("Search")."</a>, ";
  304. print "<a href=\"index.php?go=vf&id=$feed&subop=ForceUpdate\">".__("Update")."</a>";
  305. # print "Mark as read: ";
  306. # print "<a href=\"index.php?go=vf&id=$feed&subop=MarkAsRead\">Page</a>, ";
  307. # print "<a href=\"index.php?go=vf&id=$feed&subop=MarkAllRead\">Feed</a>";
  308. print ")</span>";
  309. print "&nbsp;" . __('View:');
  310. print "<form style=\"display : inline\" method=\"GET\" action=\"index.php\">";
  311. /* print "<select name=\"viewmode\">
  312. <option selected value=\"adaptive\"> " . __('Adaptive') . "</option>
  313. <option value=\"all_articles\">" . __('All Articles') . "</option>
  314. <option value=\"marked\">" . __('Starred') . "</option>
  315. <option value=\"unread\">" . __('Unread') . "</option>
  316. </select>"; */
  317. $sel_values = array(
  318. "adaptive" => __("Adaptive"),
  319. "all_articles" => __("All Articles"),
  320. "unread" => __("Unread"),
  321. "marked" => __("Starred"));
  322. print_select_hash("viewmode", $view_mode, $sel_values);
  323. print "<input type=\"hidden\" name=\"id\" value=\"$feed\">
  324. <input type=\"hidden\" name=\"cat\" value=\"$cat_view\">
  325. <input type=\"hidden\" name=\"go\" value=\"vf\">
  326. <input type=\"submit\" value=\"".__('Refresh')."\">";
  327. print "</form>";
  328. print "</div>";
  329. if (db_num_rows($result) > 0) {
  330. print "<form method=\"GET\" action=\"index.php\">";
  331. print "<input type=\"hidden\" name=\"go\" value=\"vf\">";
  332. print "<input type=\"hidden\" name=\"id\" value=\"$feed\">";
  333. print "<input type=\"hidden\" name=\"cat\" value=\"$cat_view\">";
  334. print "<ul class=\"headlines\" id=\"headlines\">";
  335. $page_art_ids = array();
  336. $lnum = 0;
  337. error_reporting (DEFAULT_ERROR_LEVEL);
  338. $num_unread = 0;
  339. while ($line = db_fetch_assoc($result)) {
  340. $class = ($lnum % 2) ? "even" : "odd";
  341. $id = $line["id"];
  342. $feed_id = $line["feed_id"];
  343. array_push($page_art_ids, $id);
  344. if ($line["last_read"] == "" &&
  345. ($line["unread"] != "t" && $line["unread"] != "1")) {
  346. $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\"
  347. alt=\"".__("Updated")."\">";
  348. } else {
  349. $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\"
  350. alt=\"".__("Updated")."\">";
  351. }
  352. if ($line["unread"] == "t" || $line["unread"] == "1") {
  353. $class .= "Unread";
  354. ++$num_unread;
  355. $is_unread = true;
  356. } else {
  357. $is_unread = false;
  358. }
  359. if ($line["marked"] == "t" || $line["marked"] == "1") {
  360. $marked_pic = "<img alt=\"S\" class='marked' src=\"../../images/mark_set.png\">";
  361. } else {
  362. $marked_pic = "<img alt=\"s\" class='marked' src=\"../../images/mark_unset.png\">";
  363. }
  364. if ($line["published"] == "t" || $line["published"] == "1") {
  365. $published_pic = "<img alt=\"P\" class='marked' src=\"../../images/pub_set.gif\">";
  366. } else {
  367. $published_pic = "<img alt=\"p\" class='marked' src=\"../../images/pub_unset.gif\">";
  368. }
  369. $content_link = "<a href=\"?go=view&id=$id&cat=$cat_view&ret_feed=$feed&feed=$feed_id\">" .
  370. $line["title"] . "</a>";
  371. $updated_fmt = make_local_datetime($link, $line['updated'], false);
  372. print "<li class='$class' id=\"HROW-$id\">";
  373. print "<input type=\"checkbox\" name=\"sel_ids[$id]\"
  374. id=\"HSCB-$id\" onchange=\"toggleSelectRow(this, $id)\">";
  375. print "<a href=\"?go=vf&id=$feed&ts=$id&cat=$cat_view\">$marked_pic</a>";
  376. print "<a href=\"?go=vf&id=$feed&tp=$id&cat=$cat_view\">$published_pic</a>";
  377. print $content_link;
  378. if ($line["feed_title"]) {
  379. print " (<a href='?go=vf&id=$feed_id'>".
  380. $line["feed_title"]."</a>)";
  381. }
  382. print "<span class='hlUpdated'> ($updated_fmt)</span>";
  383. print "</li>";
  384. ++$lnum;
  385. }
  386. print "</ul>";
  387. print "<div class='footerAddon'>";
  388. $_SESSION["last_page_ids.$feed"] = $page_art_ids;
  389. /* print "<a href=\"index.php?go=vf&id=$feed&subop=MarkPageRead\">Page</a>, ";
  390. print "<a href=\"index.php?go=vf&id=$feed&subop=MarkAllRead\">Feed</a></div>"; */
  391. print "Select:
  392. <a href=\"javascript:selectHeadlines(1)\">".__("All")."</a>,
  393. <a href=\"javascript:selectHeadlines(2)\">".__("Unread")."</a>,
  394. <a href=\"javascript:selectHeadlines(3)\">".__("None")."</a>,
  395. <a href=\"javascript:selectHeadlines(4)\">".__("Invert")."</a>";
  396. print " ";
  397. print "<select name=\"catchup_op\">
  398. <option value=\"selection\">".__("Selection")."</option>
  399. <option value=\"page\">".__("Page")."</option>
  400. <option value=\"feed\">".__("Entire feed")."</option>
  401. </select>
  402. <input type=\"hidden\" name=\"cat\" value=\"$cat_view\">
  403. <input type=\"submit\" value=\"".__("Mark as read")."\">";
  404. print "</form>";
  405. } else {
  406. print "<div align='center'>No articles found.</div>";
  407. }
  408. }
  409. function render_article($link) {
  410. $id = db_escape_string($_GET["id"]);
  411. $feed_id = db_escape_string($_GET["feed"]);
  412. $ret_feed_id = db_escape_string($_GET["ret_feed"]);
  413. $cat_view = db_escape_string($_GET["cat"]);
  414. $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds
  415. WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
  416. if (db_num_rows($result) == 1) {
  417. $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
  418. } else {
  419. $rtl_content = false;
  420. }
  421. if ($rtl_content) {
  422. $rtl_tag = "dir=\"RTL\"";
  423. $rtl_class = "RTL";
  424. } else {
  425. $rtl_tag = "";
  426. $rtl_class = "";
  427. }
  428. $result = db_query($link, "UPDATE ttrss_user_entries
  429. SET unread = false,last_read = NOW()
  430. WHERE ref_id = '$id' AND feed_id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
  431. $result = db_query($link, "SELECT title,link,content,feed_id,comments,int_id,
  432. marked,published,
  433. ".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
  434. (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url,
  435. num_comments,
  436. author
  437. FROM ttrss_entries,ttrss_user_entries
  438. WHERE id = '$id' AND ref_id = id");
  439. if ($result) {
  440. $line = db_fetch_assoc($result);
  441. $num_comments = $line["num_comments"];
  442. $entry_comments = "";
  443. if ($num_comments > 0) {
  444. if ($line["comments"]) {
  445. $comments_url = $line["comments"];
  446. } else {
  447. $comments_url = $line["link"];
  448. }
  449. $entry_comments = "<a href=\"$comments_url\">$num_comments comments</a>";
  450. } else {
  451. if ($line["comments"] && $line["link"] != $line["comments"]) {
  452. $entry_comments = "<a href=\"".$line["comments"]."\">comments</a>";
  453. }
  454. }
  455. $tmp_result = db_query($link, "SELECT DISTINCT tag_name FROM
  456. ttrss_tags WHERE post_int_id = " . $line["int_id"] . "
  457. ORDER BY tag_name");
  458. $tags_str = "";
  459. $f_tags_str = "";
  460. $num_tags = 0;
  461. while ($tmp_line = db_fetch_assoc($tmp_result)) {
  462. $num_tags++;
  463. $tag = $tmp_line["tag_name"];
  464. $tag_str = "<a href=\"?go=vf&id=$tag\">$tag</a>, ";
  465. $tags_str .= $tag_str;
  466. }
  467. $tags_str = preg_replace("/, $/", "", $tags_str);
  468. $parsed_updated = date(get_pref($link, 'SHORT_DATE_FORMAT'),
  469. strtotime($line["updated"]));
  470. print "<div id=\"heading\">";
  471. # if (file_exists("../icons/$feed_id.ico") && filesize("../icons/$feed_id.ico") > 0) {
  472. # print "<img class=\"feedIcon\" src=\"../icons/$feed_id.ico\">";
  473. # }
  474. if (!$cat_view) {
  475. $feed_title = getFeedTitle($link, $ret_feed_id);
  476. } else {
  477. $feed_title = getCategoryTitle($link, $ret_feed_id);
  478. $feed_title_native = getFeedTitle($link, $feed_id);
  479. }
  480. if ($feed_title_native) {
  481. $feed_link = "<a href=\"index.php?go=vf&id=$feed_id\">$feed_title_native</a>";
  482. $feed_link .= " in <a href=\"index.php?go=vf&id=$ret_feed_id&cat=$cat_view\">
  483. $feed_title</a>";
  484. } else {
  485. $feed_link = "<a href=\"index.php?go=vf&id=$ret_feed_id\">$feed_title</a>";
  486. }
  487. $feedlist = "<a href=\"index.php\">".__('Back to feedlist')."</a>";
  488. print "<a href=\"" . $line["link"] . "\">" .
  489. truncate_string($line["title"], 30) . "</a>";
  490. print " <span id=\"headingAddon\">$parsed_updated ($feed_link, $feedlist)</span>";
  491. print "</div>";
  492. if ($num_tags > 0) {
  493. print "<div class=\"postTags\">".__("Tags:")." $tags_str</div>";
  494. }
  495. if ($line["marked"] == "t" || $line["marked"] == "1") {
  496. $marked_pic = "<img class='marked' src=\"../../images/mark_set.png\">";
  497. } else {
  498. $marked_pic = "<img class='marked' src=\"../../images/mark_unset.png\">";
  499. }
  500. if ($line["published"] == "t" || $line["published"] == "1") {
  501. $published_pic = "<img class='marked' src=\"../../images/pub_set.gif\">";
  502. } else {
  503. $published_pic = "<img class='marked' src=\"../../images/pub_unset.gif\">";
  504. }
  505. print "<div class=\"postStarOps\">";
  506. print "<a title=\"".__('Toggle starred')."\"href=\"?go=view&id=$id&ret_feed=$ret_feed_id&feed=$feed_id&sop=ts\">$marked_pic</a>";
  507. print "<a title=\"".__('Toggle published')."\" href=\"?go=view&id=$id&ret_feed=$ret_feed_id&feed=$feed_id&sop=tp\">$published_pic</a>";
  508. // Mark unread
  509. print "<a title=\"".__('Mark as unread')."\" href=\"?go=vf&id=$ret_feed_id&feed=$feed_id&sop=mu&aid=$id";
  510. if ($cat_view) { print "&cat=$cat_view"; }
  511. print "\"><img class='marked' src=\"../../images/art-set-unread.png\"></a>";
  512. print "</div>";
  513. print sanitize_rss($link, $line["content"], true);;
  514. }
  515. print "</body></html>";
  516. }
  517. function render_search_form($link, $active_feed_id = false, $is_cat = false) {
  518. print "<div id=\"heading\">";
  519. print __("Search")." <span id=\"headingAddon\">
  520. (<a href=\"index.php\">".__("Go back")."</a>)</span></div>";
  521. print "<form method=\"GET\" action=\"index.php\" class=\"searchForm\">";
  522. print "<input type=\"hidden\" name=\"go\" value=\"vf\">";
  523. print "<input type=\"hidden\" name=\"id\" value=\"$active_feed_id\">";
  524. print "<input type=\"hidden\" name=\"cat\" value=\"$is_cat\">";
  525. print "<table><tr><td>".__('Search:')."</td><td>";
  526. print "<input name=\"query\"></td></tr>";
  527. print "<tr><td>".__('Where:')."</td><td>";
  528. print "<select name=\"search_mode\">
  529. <option value=\"all_feeds\">".__('All feeds')."</option>";
  530. $feed_title = getFeedTitle($link, $active_feed_id);
  531. if (!$is_cat) {
  532. $feed_cat_title = getFeedCatTitle($link, $active_feed_id);
  533. } else {
  534. $feed_cat_title = getCategoryTitle($link, $active_feed_id);
  535. }
  536. if ($active_feed_id && !$is_cat) {
  537. print "<option selected value=\"this_feed\">$feed_title</option>";
  538. } else {
  539. print "<option disabled>".__('This feed')."</option>";
  540. }
  541. if ($is_cat) {
  542. $cat_preselected = "selected";
  543. }
  544. if (get_pref($link, 'ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) {
  545. print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>";
  546. } else {
  547. //print "<option disabled>".__('This category')."</option>";
  548. }
  549. print "</select></td></tr>";
  550. print "<tr><td>".__('Match on:')."</td><td>";
  551. $search_fields = array(
  552. "title" => __("Title"),
  553. "content" => __("Content"),
  554. "both" => __("Title or content"));
  555. print_select_hash("match_on", 3, $search_fields);
  556. print "</td></tr></table>";
  557. print "<input type=\"submit\" value=\"".__('Search')."\">";
  558. print "</form>";
  559. print "</div>";
  560. }
  561. function toggleMarked($link, $ts_id) {
  562. $result = db_query($link, "UPDATE ttrss_user_entries SET marked = NOT marked
  563. WHERE ref_id = '$ts_id' AND owner_uid = " . $_SESSION["uid"]);
  564. }
  565. function togglePublished($link, $tp_id) {
  566. $result = db_query($link, "UPDATE ttrss_user_entries SET published = NOT published
  567. WHERE ref_id = '$tp_id' AND owner_uid = " . $_SESSION["uid"]);
  568. }
  569. function markUnread($link, $mu_id) {
  570. $result = db_query($link, "UPDATE ttrss_user_entries SET unread = true
  571. WHERE ref_id = '$mu_id' AND owner_uid = " . $_SESSION["uid"]);
  572. }
  573. ?>