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