]> git.wh0rd.org - tt-rss.git/blame - plugins/pinterest/pinterest.php
more work on user-selectable plugins; properly process system and user plugins
[tt-rss.git] / plugins / pinterest / pinterest.php
CommitLineData
7252abe3 1<?php
5a0e0392 2class Pinterest extends Plugin {
7252abe3
AD
3 private $link;
4 private $host;
5
d2a421e3 6 function about() {
7a866114
AD
7 return array(1.0,
8 "Share article via Pinterest",
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
26 $rv = "<img src=\"".theme_image($this->link, 'plugins/pinterest/pinterest.png')."\"
27 class='tagsPic' style=\"cursor : pointer\"
28 onclick=\"pinterest($article_id)\"
29 title='".__('Pinterest')."'>";
30
31 return $rv;
32 }
33
34 function getInfo() {
35 $id = db_escape_string($_REQUEST['id']);
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?>