]>
git.wh0rd.org - tt-rss.git/blob - plugins/digest/digest.php
2 class Digest
extends Plugin
implements IHandler
{
7 function __construct($host) {
8 $this->link
= $host->get_link();
11 $host->add_handler("digest", "*", $this);
13 //$host->add_handler("rpc", "digestinit", $this);
14 //$host->add_handler("rpc", "digestupdate", $this);
15 //$host->add_handler("rpc", "digestgetcontents", $this);
19 header("Content-type: text/html; charset=utf-8");
21 login_sequence($this->link
);
26 require_once dirname(__FILE__
) . "/digest_body.php";
29 /* function get_js() {
30 return file_get_contents(dirname(__FILE__) . "/digest.js");
33 function csrf_ignore($method) {
34 return in_array($method, array("index"));
37 function before($method) {
45 function digestgetcontents() {
46 $article_id = db_escape_string($_REQUEST['article_id']);
48 $result = db_query($this->link
, "SELECT content,title,link,marked,published
49 FROM ttrss_entries, ttrss_user_entries
50 WHERE id = '$article_id' AND ref_id = id AND owner_uid = ".$_SESSION['uid']);
52 $content = sanitize($this->link
, db_fetch_result($result, 0, "content"));
53 $title = strip_tags(db_fetch_result($result, 0, "title"));
54 $article_url = htmlspecialchars(db_fetch_result($result, 0, "link"));
55 $marked = sql_bool_to_bool(db_fetch_result($result, 0, "marked"));
56 $published = sql_bool_to_bool(db_fetch_result($result, 0, "published"));
58 print json_encode(array("article" =>
59 array("id" => $article_id, "url" => $article_url,
60 "tags" => get_article_tags($this->link
, $article_id),
61 "marked" => $marked, "published" => $published,
62 "title" => $title, "content" => $content)));
65 function digestupdate() {
66 $feed_id = db_escape_string($_REQUEST['feed_id']);
67 $offset = db_escape_string($_REQUEST['offset']);
68 $seq = db_escape_string($_REQUEST['seq']);
70 if (!$feed_id) $feed_id = -4;
71 if (!$offset) $offset = 0;
77 $headlines = api_get_headlines($this->link
, $feed_id, 30, $offset,
78 '', ($feed_id == -4), true, false, "unread", "updated DESC", 0, 0);
80 $reply['headlines'] = array();
81 $reply['headlines']['title'] = getFeedTitle($this->link
, $feed_id);
82 $reply['headlines']['content'] = $headlines;
84 print json_encode($reply);
87 function digestinit() {
88 $tmp_feeds = api_get_feeds($this->link
, -4, true, false, 0);
92 foreach ($tmp_feeds as $f) {
93 if ($f['id'] > 0 ||
$f['id'] == -4) array_push($feeds, $f);
96 print json_encode(array("feeds" => $feeds));