]>
git.wh0rd.org - tt-rss.git/blob - plugins/digest/init.php
2 // TODO: digest should register digest specific hotkey actions within tt-rss
3 class Digest
extends Plugin
implements IHandler
{
10 "Digest mode for tt-rss (tablet friendly UI)",
15 function init($host) {
16 $this->link
= $host->get_link();
19 $host->add_handler("digest", "*", $this);
23 header("Content-type: text/html; charset=utf-8");
25 login_sequence($this->link
);
30 require_once dirname(__FILE__
) . "/digest_body.php";
33 /* function get_js() {
34 return file_get_contents(dirname(__FILE__) . "/digest.js");
37 function csrf_ignore($method) {
38 return in_array($method, array("index"));
41 function before($method) {
49 function digestgetcontents() {
50 $article_id = db_escape_string($this->link
, $_REQUEST['article_id']);
52 $result = db_query($this->link
, "SELECT content,title,link,marked,published
53 FROM ttrss_entries, ttrss_user_entries
54 WHERE id = '$article_id' AND ref_id = id AND owner_uid = ".$_SESSION['uid']);
56 $content = sanitize($this->link
, db_fetch_result($result, 0, "content"));
57 $title = strip_tags(db_fetch_result($result, 0, "title"));
58 $article_url = htmlspecialchars(db_fetch_result($result, 0, "link"));
59 $marked = sql_bool_to_bool(db_fetch_result($result, 0, "marked"));
60 $published = sql_bool_to_bool(db_fetch_result($result, 0, "published"));
62 print json_encode(array("article" =>
63 array("id" => $article_id, "url" => $article_url,
64 "tags" => get_article_tags($this->link
, $article_id),
65 "marked" => $marked, "published" => $published,
66 "title" => $title, "content" => $content)));
69 function digestupdate() {
70 $feed_id = db_escape_string($this->link
, $_REQUEST['feed_id']);
71 $offset = db_escape_string($this->link
, $_REQUEST['offset']);
72 $seq = db_escape_string($this->link
, $_REQUEST['seq']);
74 if (!$feed_id) $feed_id = -4;
75 if (!$offset) $offset = 0;
81 $headlines = API
::api_get_headlines($this->link
, $feed_id, 30, $offset,
82 '', ($feed_id == -4), true, false, "unread", "updated DESC", 0, 0);
84 $reply['headlines'] = array();
85 $reply['headlines']['title'] = getFeedTitle($this->link
, $feed_id);
86 $reply['headlines']['content'] = $headlines;
88 print json_encode($reply);
91 function digestinit() {
92 $tmp_feeds = API
::api_get_feeds($this->link
, -4, true, false, 0);
97 foreach ($tmp_feeds as $f) {
98 if ($f['id'] > 0 ||
$f['id'] == -4) array_push($feeds, $f);
101 if ($_REQUEST["init"] == 1) {
102 $params["hotkeys"] = get_hotkeys_map($link);
104 $params["feeds"] = $feeds;
106 print json_encode($params);