init.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. // TODO: digest should register digest specific hotkey actions within tt-rss
  3. class Digest extends Plugin implements IHandler {
  4. private $host;
  5. function about() {
  6. return array(1.0,
  7. "Digest mode for tt-rss (tablet friendly UI)",
  8. "fox",
  9. true);
  10. }
  11. function init($host) {
  12. $this->host = $host;
  13. $host->add_handler("digest", "*", $this);
  14. }
  15. function index() {
  16. header("Content-type: text/html; charset=utf-8");
  17. login_sequence();
  18. require_once dirname(__FILE__) . "/digest_body.php";
  19. }
  20. /* function get_js() {
  21. return file_get_contents(dirname(__FILE__) . "/digest.js");
  22. } */
  23. function csrf_ignore($method) {
  24. return in_array($method, array("index"));
  25. }
  26. function before($method) {
  27. return true;
  28. }
  29. function after() {
  30. }
  31. function digestgetcontents() {
  32. $article_id = db_escape_string( $_REQUEST['article_id']);
  33. $result = db_query( "SELECT content,title,link,marked,published
  34. FROM ttrss_entries, ttrss_user_entries
  35. WHERE id = '$article_id' AND ref_id = id AND owner_uid = ".$_SESSION['uid']);
  36. $content = sanitize( db_fetch_result($result, 0, "content"));
  37. $title = strip_tags(db_fetch_result($result, 0, "title"));
  38. $article_url = htmlspecialchars(db_fetch_result($result, 0, "link"));
  39. $marked = sql_bool_to_bool(db_fetch_result($result, 0, "marked"));
  40. $published = sql_bool_to_bool(db_fetch_result($result, 0, "published"));
  41. print json_encode(array("article" =>
  42. array("id" => $article_id, "url" => $article_url,
  43. "tags" => get_article_tags( $article_id),
  44. "marked" => $marked, "published" => $published,
  45. "title" => $title, "content" => $content)));
  46. }
  47. function digestupdate() {
  48. $feed_id = db_escape_string( $_REQUEST['feed_id']);
  49. $offset = db_escape_string( $_REQUEST['offset']);
  50. $seq = db_escape_string( $_REQUEST['seq']);
  51. if (!$feed_id) $feed_id = -4;
  52. if (!$offset) $offset = 0;
  53. $reply = array();
  54. $reply['seq'] = $seq;
  55. $headlines = API::api_get_headlines( $feed_id, 30, $offset,
  56. '', ($feed_id == -4), true, false, "unread", "updated DESC", 0, 0);
  57. $reply['headlines'] = array();
  58. $reply['headlines']['title'] = getFeedTitle( $feed_id);
  59. $reply['headlines']['content'] = $headlines;
  60. print json_encode($reply);
  61. }
  62. function digestinit() {
  63. $tmp_feeds = API::api_get_feeds( -4, true, false, 0);
  64. $params = array();
  65. $feeds = array();
  66. foreach ($tmp_feeds as $f) {
  67. if ($f['id'] > 0 || $f['id'] == -4) array_push($feeds, $f);
  68. }
  69. if ($_REQUEST["init"] == 1) {
  70. $params["hotkeys"] = get_hotkeys_map();
  71. }
  72. $params["feeds"] = $feeds;
  73. print json_encode($params);
  74. }
  75. }
  76. ?>