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