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