]> git.wh0rd.org - tt-rss.git/blame - plugins/digest/digest.php
feedlist_init: do not wait before calling viewfeed(-3)
[tt-rss.git] / plugins / digest / digest.php
CommitLineData
ac220751
AD
1<?
2class Digest extends Plugin implements IHandler {
3
4 private $link;
5 private $host;
6
7a866114
AD
7 function _about() {
8 return array(1.0,
9 "Digest mode for tt-rss (tablet friendly UI)",
10 "fox");
11 }
12
ac220751
AD
13 function __construct($host) {
14 $this->link = $host->get_link();
15 $this->host = $host;
16
17 $host->add_handler("digest", "*", $this);
18
19 //$host->add_handler("rpc", "digestinit", $this);
20 //$host->add_handler("rpc", "digestupdate", $this);
21 //$host->add_handler("rpc", "digestgetcontents", $this);
22 }
23
24 function index() {
25 header("Content-type: text/html; charset=utf-8");
26
27 login_sequence($this->link);
28
29 global $link;
30 $link = $this->link;
31
32 require_once dirname(__FILE__) . "/digest_body.php";
33 }
34
35 /* function get_js() {
36 return file_get_contents(dirname(__FILE__) . "/digest.js");
37 } */
38
39 function csrf_ignore($method) {
40 return in_array($method, array("index"));
41 }
42
43 function before($method) {
44 return true;
45 }
46
47 function after() {
48
49 }
50
51 function digestgetcontents() {
52 $article_id = db_escape_string($_REQUEST['article_id']);
53
54 $result = db_query($this->link, "SELECT content,title,link,marked,published
55 FROM ttrss_entries, ttrss_user_entries
56 WHERE id = '$article_id' AND ref_id = id AND owner_uid = ".$_SESSION['uid']);
57
58 $content = sanitize($this->link, db_fetch_result($result, 0, "content"));
59 $title = strip_tags(db_fetch_result($result, 0, "title"));
60 $article_url = htmlspecialchars(db_fetch_result($result, 0, "link"));
61 $marked = sql_bool_to_bool(db_fetch_result($result, 0, "marked"));
62 $published = sql_bool_to_bool(db_fetch_result($result, 0, "published"));
63
64 print json_encode(array("article" =>
65 array("id" => $article_id, "url" => $article_url,
66 "tags" => get_article_tags($this->link, $article_id),
67 "marked" => $marked, "published" => $published,
68 "title" => $title, "content" => $content)));
69 }
70
71 function digestupdate() {
72 $feed_id = db_escape_string($_REQUEST['feed_id']);
73 $offset = db_escape_string($_REQUEST['offset']);
74 $seq = db_escape_string($_REQUEST['seq']);
75
76 if (!$feed_id) $feed_id = -4;
77 if (!$offset) $offset = 0;
78
79 $reply = array();
80
81 $reply['seq'] = $seq;
82
83 $headlines = api_get_headlines($this->link, $feed_id, 30, $offset,
84 '', ($feed_id == -4), true, false, "unread", "updated DESC", 0, 0);
85
86 $reply['headlines'] = array();
87 $reply['headlines']['title'] = getFeedTitle($this->link, $feed_id);
88 $reply['headlines']['content'] = $headlines;
89
90 print json_encode($reply);
91 }
92
93 function digestinit() {
94 $tmp_feeds = api_get_feeds($this->link, -4, true, false, 0);
95
96 $feeds = array();
97
98 foreach ($tmp_feeds as $f) {
99 if ($f['id'] > 0 || $f['id'] == -4) array_push($feeds, $f);
100 }
101
102 print json_encode(array("feeds" => $feeds));
103 }
104
105}
106?>