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