]> git.wh0rd.org - tt-rss.git/blob - plugins/digest/init.php
remove $link
[tt-rss.git] / plugins / digest / init.php
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
6 function about() {
7 return array(1.0,
8 "Digest mode for tt-rss (tablet friendly UI)",
9 "fox",
10 true);
11 }
12
13 function init($host) {
14 $this->host = $host;
15
16 $host->add_handler("digest", "*", $this);
17 }
18
19 function index() {
20 header("Content-type: text/html; charset=utf-8");
21
22 login_sequence();
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() {
44 $article_id = db_escape_string( $_REQUEST['article_id']);
45
46 $result = db_query( "SELECT content,title,link,marked,published
47 FROM ttrss_entries, ttrss_user_entries
48 WHERE id = '$article_id' AND ref_id = id AND owner_uid = ".$_SESSION['uid']);
49
50 $content = sanitize( db_fetch_result($result, 0, "content"));
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,
58 "tags" => get_article_tags( $article_id),
59 "marked" => $marked, "published" => $published,
60 "title" => $title, "content" => $content)));
61 }
62
63 function digestupdate() {
64 $feed_id = db_escape_string( $_REQUEST['feed_id']);
65 $offset = db_escape_string( $_REQUEST['offset']);
66 $seq = db_escape_string( $_REQUEST['seq']);
67
68 if (!$feed_id) $feed_id = -4;
69 if (!$offset) $offset = 0;
70
71 $reply = array();
72
73 $reply['seq'] = $seq;
74
75 $headlines = API::api_get_headlines( $feed_id, 30, $offset,
76 '', ($feed_id == -4), true, false, "unread", "updated DESC", 0, 0);
77
78 $reply['headlines'] = array();
79 $reply['headlines']['title'] = getFeedTitle( $feed_id);
80 $reply['headlines']['content'] = $headlines;
81
82 print json_encode($reply);
83 }
84
85 function digestinit() {
86 $tmp_feeds = API::api_get_feeds( -4, true, false, 0);
87
88 $params = array();
89 $feeds = array();
90
91 foreach ($tmp_feeds as $f) {
92 if ($f['id'] > 0 || $f['id'] == -4) array_push($feeds, $f);
93 }
94
95 if ($_REQUEST["init"] == 1) {
96 $params["hotkeys"] = get_hotkeys_map();
97 }
98 $params["feeds"] = $feeds;
99
100 print json_encode($params);
101 }
102
103 }
104 ?>