]>
Commit | Line | Data |
---|---|---|
22890cce AD |
1 | <?php |
2 | class Tweet extends Plugin { | |
3 | private $link; | |
4 | private $host; | |
5 | ||
6 | function init($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 about() { | |
14 | return array(1.0, | |
15 | "Share article on Twitter", | |
16 | "fox"); | |
17 | } | |
18 | ||
19 | function get_js() { | |
20 | return file_get_contents(dirname(__FILE__) . "/tweet.js"); | |
21 | } | |
22 | ||
23 | function hook_article_button($line) { | |
24 | $article_id = $line["id"]; | |
25 | ||
2a3b6de0 | 26 | $rv = "<img src=\"plugins/tweet/tweet.png\" |
22890cce AD |
27 | class='tagsPic' style=\"cursor : pointer\" |
28 | onclick=\"tweetArticle($article_id)\" | |
29 | title='".__('Share on Twitter')."'>"; | |
30 | ||
31 | return $rv; | |
32 | } | |
33 | ||
34 | function getInfo() { | |
3972bf59 | 35 | $id = db_escape_string($this->link, $_REQUEST['id']); |
22890cce 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 | ?> |