]> git.wh0rd.org Git - tt-rss.git/blob - plugins/embed_original/init.php
shorten_expanded: also hide embedded attachments behind wrapper
[tt-rss.git] / plugins / embed_original / init.php
1 <?php
2 class Embed_Original extends Plugin {
3
4         /* @var PluginHost $host */
5         private $host;
6
7         function init($host) {
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                         "Try to display original article content inside tt-rss",
16                         "fox");
17         }
18
19         function get_js() {
20                 return file_get_contents(dirname(__FILE__) . "/init.js");
21         }
22
23         function get_css() {
24                 return file_get_contents(dirname(__FILE__) . "/init.css");
25         }
26
27         function hook_article_button($line) {
28                 $id = $line["id"];
29
30                 $rv = "<img src=\"plugins/embed_original/button.png\"
31                         class='tagsPic' style=\"cursor : pointer\"
32                         onclick=\"embedOriginalArticle($id)\"
33                         title='".__('Toggle embed original')."'>";
34
35                 return $rv;
36         }
37
38         function getUrl() {
39                 $id = $_REQUEST['id'];
40
41                 $sth = $this->pdo->prepare("SELECT link
42                                 FROM ttrss_entries, ttrss_user_entries
43                                 WHERE id = ? AND ref_id = id AND owner_uid = ?");
44                 $sth->execute([$id, $_SESSION['uid']]);
45
46                 if ($row = $sth->fetch()) {
47                         $url = $row['link'];
48                 } else {
49                         $url = "";
50                 }
51
52                 print json_encode(array("url" => $url, "id" => $id));
53         }
54
55         function api_version() {
56                 return 2;
57         }
58
59 }