]> git.wh0rd.org - tt-rss.git/blame - plugins/flattr/init.php
remove deprecated theme_image()
[tt-rss.git] / plugins / flattr / init.php
CommitLineData
7252abe3 1<?php
5a0e0392 2class Flattr extends Plugin {
7252abe3
AD
3 private $link;
4 private $host;
5
d2a421e3 6 function init($host) {
7252abe3
AD
7 $this->link = $host->get_link();
8 $this->host = $host;
9
10 $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
11 }
12
d2a421e3 13 function about() {
e0abb8d7 14 return array(1.1,
15 "Share articles on Flattr (if they exist in their catalogue)",
16 "F. Eitel, N. Honing");
7a866114
AD
17 }
18
7252abe3
AD
19 function hook_article_button($line) {
20
e0abb8d7 21 $rv = "";
22 $article_link = $line['link'];
7252abe3 23
7252abe3 24 if ($article_link) {
e0abb8d7 25 $encoded = urlencode($article_link);
26 $r = file_get_contents("https://api.flattr.com/rest/v2/things/lookup/?url=$encoded");
27 $response = json_decode($r, true);
2a3b6de0 28 $image = "<img src=\"plugins/flattr/flattr.png\"
e0abb8d7 29 class='tagsPic' style=\"cursor : pointer\"
30 title='".__('Flattr this article.')."'>";
31 // if Flattr has it in the catalogue, we display the button
32 if ($response and array_key_exists('link', $response)) {
33 $rv = "<a id='flattr' target='_blank' href='" . $response['link'] . "'> . $image . </a>";
34 } else {
35 // We can't submit a thing to the catalogue without giving a Flattr user id (who would be the owner)
36 // see http://developers.flattr.net/auto-submit
37 //$rv = "<a id='flattr' href='https://flattr.com/submit/auto?url=" . $encoded . "'>" . $image . "</a>";
38 $rv = '';
39 // Another useful thing would be any rel=payment link (which would have the user id as well),
40 // but tt-rss is not checking that (yet), I believe. See http://developers.flattr.net/feed
41 }
7252abe3 42 }
7252abe3
AD
43 return $rv;
44 }
45}
46?>