]> git.wh0rd.org - tt-rss.git/blob - plugins/googleplus/googleplus.php
9505b409612f50da19af4316c64649f582ade155
[tt-rss.git] / plugins / googleplus / googleplus.php
1 <?php
2 class GooglePlus extends Plugin {
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__) . "/googleplus.js");
15 }
16
17 function hook_article_button($line) {
18 $article_id = $line["id"];
19
20 $rv = "<img src=\"".theme_image($this->link, 'plugins/googleplus/googleplus.png')."\"
21 class='tagsPic' style=\"cursor : pointer\"
22 onclick=\"shareArticleToGooglePlus($article_id)\"
23 title='".__('Share on Google+')."'>";
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 ?>