ttrss/plugins/digest/init.php

105 lines
2.5 KiB
PHP
Raw Normal View History

2012-12-26 18:44:36 +00:00
<?php
// TODO: digest should register digest specific hotkey actions within tt-rss
2012-12-24 06:16:01 +00:00
class Digest extends Plugin implements IHandler {
private $host;
function about() {
return array(1.0,
"Digest mode for tt-rss (tablet friendly UI)",
"fox",
true);
}
function init($host) {
2012-12-24 06:16:01 +00:00
$this->host = $host;
$host->add_handler("digest", "*", $this);
}
function index() {
header("Content-type: text/html; charset=utf-8");
2013-04-17 12:23:15 +00:00
login_sequence();
2012-12-24 06:16:01 +00:00
require_once dirname(__FILE__) . "/digest_body.php";
}
/* function get_js() {
return file_get_contents(dirname(__FILE__) . "/digest.js");
} */
function csrf_ignore($method) {
return in_array($method, array("index"));
}
function before($method) {
return true;
}
function after() {
}
function digestgetcontents() {
2013-04-17 12:23:15 +00:00
$article_id = db_escape_string( $_REQUEST['article_id']);
2012-12-24 06:16:01 +00:00
2013-04-17 12:23:15 +00:00
$result = db_query( "SELECT content,title,link,marked,published
2012-12-24 06:16:01 +00:00
FROM ttrss_entries, ttrss_user_entries
WHERE id = '$article_id' AND ref_id = id AND owner_uid = ".$_SESSION['uid']);
2013-04-17 12:23:15 +00:00
$content = sanitize( db_fetch_result($result, 0, "content"));
2012-12-24 06:16:01 +00:00
$title = strip_tags(db_fetch_result($result, 0, "title"));
$article_url = htmlspecialchars(db_fetch_result($result, 0, "link"));
$marked = sql_bool_to_bool(db_fetch_result($result, 0, "marked"));
$published = sql_bool_to_bool(db_fetch_result($result, 0, "published"));
print json_encode(array("article" =>
array("id" => $article_id, "url" => $article_url,
2013-04-17 12:23:15 +00:00
"tags" => get_article_tags( $article_id),
2012-12-24 06:16:01 +00:00
"marked" => $marked, "published" => $published,
"title" => $title, "content" => $content)));
}
function digestupdate() {
2013-04-17 12:23:15 +00:00
$feed_id = db_escape_string( $_REQUEST['feed_id']);
$offset = db_escape_string( $_REQUEST['offset']);
$seq = db_escape_string( $_REQUEST['seq']);
2012-12-24 06:16:01 +00:00
if (!$feed_id) $feed_id = -4;
if (!$offset) $offset = 0;
$reply = array();
$reply['seq'] = $seq;
2013-04-17 12:23:15 +00:00
$headlines = API::api_get_headlines( $feed_id, 30, $offset,
2012-12-24 06:16:01 +00:00
'', ($feed_id == -4), true, false, "unread", "updated DESC", 0, 0);
$reply['headlines'] = array();
2013-04-17 12:23:15 +00:00
$reply['headlines']['title'] = getFeedTitle( $feed_id);
2012-12-24 06:16:01 +00:00
$reply['headlines']['content'] = $headlines;
print json_encode($reply);
}
function digestinit() {
2013-04-17 12:23:15 +00:00
$tmp_feeds = API::api_get_feeds( -4, true, false, 0);
2012-12-24 06:16:01 +00:00
$params = array();
2012-12-24 06:16:01 +00:00
$feeds = array();
foreach ($tmp_feeds as $f) {
if ($f['id'] > 0 || $f['id'] == -4) array_push($feeds, $f);
}
if ($_REQUEST["init"] == 1) {
2013-04-17 12:23:15 +00:00
$params["hotkeys"] = get_hotkeys_map();
}
$params["feeds"] = $feeds;
print json_encode($params);
2012-12-24 06:16:01 +00:00
}
}
?>