]> git.wh0rd.org - tt-rss.git/blob - plugins/pocket/pocket.php
add contributed plugins; load note plugin by default
[tt-rss.git] / plugins / pocket / pocket.php
1 <?php
2 class Pocket {
3
4 private $link;
5 private $host;
6
7 function __construct($host) {
8 $this->link = $host->get_link();
9 $this->host = $host;
10
11 $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
12 }
13
14 function get_js() {
15 return file_get_contents(dirname(__FILE__) . "/pocket.js");
16 }
17
18 function hook_article_button($line) {
19 $article_id = $line["id"];
20
21 $rv = "<img src=\"".theme_image($this->link, 'plugins/pocket/pocket.png')."\"
22 class='tagsPic' style=\"cursor : pointer\"
23 onclick=\"shareArticleToPocket($article_id)\"
24 title='".__('Pocket')."'>";
25
26 return $rv;
27 }
28
29 function getInfo() {
30 $id = db_escape_string($_REQUEST['id']);
31
32 $result = db_query($this->link, "SELECT title, link
33 FROM ttrss_entries, ttrss_user_entries
34 WHERE id = '$id' AND ref_id = id AND owner_uid = " .$_SESSION['uid']);
35
36 if (db_num_rows($result) != 0) {
37 $title = truncate_string(strip_tags(db_fetch_result($result, 0, 'title')),
38 100, '...');
39 $article_link = db_fetch_result($result, 0, 'link');
40 }
41
42 print json_encode(array("title" => $title, "link" => $article_link,
43 "id" => $id));
44 }
45
46
47 }
48 ?>