]>
git.wh0rd.org - tt-rss.git/blob - plugins/digest/digest.php
cb906e3c1c4533a835c0698ad2a76879445b6e74
2 class Digest
extends Plugin
implements IHandler
{
9 "Digest mode for tt-rss (tablet friendly UI)",
14 function __construct($host) {
15 $this->link
= $host->get_link();
18 $host->add_handler("digest", "*", $this);
20 //$host->add_handler("rpc", "digestinit", $this);
21 //$host->add_handler("rpc", "digestupdate", $this);
22 //$host->add_handler("rpc", "digestgetcontents", $this);
26 header("Content-type: text/html; charset=utf-8");
28 login_sequence($this->link
);
33 require_once dirname(__FILE__
) . "/digest_body.php";
36 /* function get_js() {
37 return file_get_contents(dirname(__FILE__) . "/digest.js");
40 function csrf_ignore($method) {
41 return in_array($method, array("index"));
44 function before($method) {
52 function digestgetcontents() {
53 $article_id = db_escape_string($_REQUEST['article_id']);
55 $result = db_query($this->link
, "SELECT content,title,link,marked,published
56 FROM ttrss_entries, ttrss_user_entries
57 WHERE id = '$article_id' AND ref_id = id AND owner_uid = ".$_SESSION['uid']);
59 $content = sanitize($this->link
, db_fetch_result($result, 0, "content"));
60 $title = strip_tags(db_fetch_result($result, 0, "title"));
61 $article_url = htmlspecialchars(db_fetch_result($result, 0, "link"));
62 $marked = sql_bool_to_bool(db_fetch_result($result, 0, "marked"));
63 $published = sql_bool_to_bool(db_fetch_result($result, 0, "published"));
65 print json_encode(array("article" =>
66 array("id" => $article_id, "url" => $article_url,
67 "tags" => get_article_tags($this->link
, $article_id),
68 "marked" => $marked, "published" => $published,
69 "title" => $title, "content" => $content)));
72 function digestupdate() {
73 $feed_id = db_escape_string($_REQUEST['feed_id']);
74 $offset = db_escape_string($_REQUEST['offset']);
75 $seq = db_escape_string($_REQUEST['seq']);
77 if (!$feed_id) $feed_id = -4;
78 if (!$offset) $offset = 0;
84 $headlines = api_get_headlines($this->link
, $feed_id, 30, $offset,
85 '', ($feed_id == -4), true, false, "unread", "updated DESC", 0, 0);
87 $reply['headlines'] = array();
88 $reply['headlines']['title'] = getFeedTitle($this->link
, $feed_id);
89 $reply['headlines']['content'] = $headlines;
91 print json_encode($reply);
94 function digestinit() {
95 $tmp_feeds = api_get_feeds($this->link
, -4, true, false, 0);
99 foreach ($tmp_feeds as $f) {
100 if ($f['id'] > 0 ||
$f['id'] == -4) array_push($feeds, $f);
103 print json_encode(array("feeds" => $feeds));