]>
Commit | Line | Data |
---|---|---|
7252abe3 | 1 | <?php |
5a0e0392 | 2 | class Pocket extends Plugin { |
7252abe3 AD |
3 | |
4 | private $link; | |
5 | private $host; | |
6 | ||
d2a421e3 | 7 | function about() { |
7a866114 | 8 | return array(1.0, |
0ac22f29 | 9 | "Share article on Pocket (formerly Read It Later)", |
7a866114 AD |
10 | "?"); |
11 | } | |
12 | ||
d2a421e3 | 13 | function init($host) { |
7252abe3 AD |
14 | $this->link = $host->get_link(); |
15 | $this->host = $host; | |
16 | ||
17 | $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); | |
18 | } | |
19 | ||
20 | function get_js() { | |
21 | return file_get_contents(dirname(__FILE__) . "/pocket.js"); | |
22 | } | |
23 | ||
24 | function hook_article_button($line) { | |
25 | $article_id = $line["id"]; | |
26 | ||
2a3b6de0 | 27 | $rv = "<img src=\"plugins/pocket/pocket.png\" |
7252abe3 AD |
28 | class='tagsPic' style=\"cursor : pointer\" |
29 | onclick=\"shareArticleToPocket($article_id)\" | |
30 | title='".__('Pocket')."'>"; | |
31 | ||
32 | return $rv; | |
33 | } | |
34 | ||
35 | function getInfo() { | |
3972bf59 | 36 | $id = db_escape_string($this->link, $_REQUEST['id']); |
7252abe3 AD |
37 | |
38 | $result = db_query($this->link, "SELECT title, link | |
39 | FROM ttrss_entries, ttrss_user_entries | |
40 | WHERE id = '$id' AND ref_id = id AND owner_uid = " .$_SESSION['uid']); | |
41 | ||
42 | if (db_num_rows($result) != 0) { | |
43 | $title = truncate_string(strip_tags(db_fetch_result($result, 0, 'title')), | |
44 | 100, '...'); | |
45 | $article_link = db_fetch_result($result, 0, 'link'); | |
46 | } | |
47 | ||
48 | print json_encode(array("title" => $title, "link" => $article_link, | |
49 | "id" => $id)); | |
50 | } | |
51 | ||
52 | ||
53 | } | |
54 | ?> |