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