]> git.wh0rd.org - tt-rss.git/blob - plugins/close_button/init.php
add a close article panel plugin (refs #538)
[tt-rss.git] / plugins / close_button / init.php
1 <?php
2 class Close_Button 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 "Adds a button to close article panel",
16 "fox");
17 }
18
19 function hook_article_button($line) {
20 if (!get_pref($this->link, "COMBINED_DISPLAY_MODE")) {
21 $rv = "<img src=\"".theme_image($this->link, 'plugins/close_button/button.png')."\"
22 class='tagsPic' style=\"cursor : pointer\"
23 onclick=\"closeArticlePanel()\"
24 title='".__('Close article')."'>";
25 }
26
27 return $rv;
28 }
29
30 function getInfo() {
31 $id = db_escape_string($_REQUEST['id']);
32
33 $result = db_query($this->link, "SELECT title, link
34 FROM ttrss_entries, ttrss_user_entries
35 WHERE id = '$id' AND ref_id = id AND owner_uid = " .$_SESSION['uid']);
36
37 if (db_num_rows($result) != 0) {
38 $title = truncate_string(strip_tags(db_fetch_result($result, 0, 'title')),
39 100, '...');
40 $article_link = db_fetch_result($result, 0, 'link');
41 }
42
43 print json_encode(array("title" => $title, "link" => $article_link,
44 "id" => $id));
45 }
46
47
48 }
49 ?>