summaryrefslogtreecommitdiff
path: root/plugins/flattr
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/flattr')
-rw-r--r--plugins/flattr/flattr.php46
-rw-r--r--plugins/flattr/flattr.pngbin0 -> 693 bytes
2 files changed, 46 insertions, 0 deletions
diff --git a/plugins/flattr/flattr.php b/plugins/flattr/flattr.php
new file mode 100644
index 000000000..6af6cb9c3
--- /dev/null
+++ b/plugins/flattr/flattr.php
@@ -0,0 +1,46 @@
+<?php
+class Flattr {
+ private $link;
+ private $host;
+
+ function __construct($host) {
+ $this->link = $host->get_link();
+ $this->host = $host;
+
+ $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
+ }
+
+ function hook_article_button($line) {
+
+ $article_id = $line["id"];
+
+ $result = db_query($this->link, "SELECT link
+ FROM ttrss_entries, ttrss_user_entries
+ WHERE id = '$article_id' AND ref_id = id AND owner_uid = " .$_SESSION['uid']);
+
+ if (db_num_rows($result) != 0) {
+ $article_link = db_fetch_result($result, 0, 'link');
+ }
+
+ $response = null;
+ if ($article_link) {
+ $encoded = urlencode($article_link);
+ $r = file_get_contents("https://api.flattr.com/rest/v2/things/lookup/?url=$encoded");
+ $response = json_decode($r, true);
+ }
+
+ $rv = null;
+ if ($response and array_key_exists('link', $response)) {
+ $rv = "<a id='flattr' href='" . $response['link'] . "'>
+ <img src=\"".theme_image($this->link, 'plugins/flattr/flattr.png')."\"
+ class='tagsPic' style=\"cursor : pointer\"
+ title='".__('Flattr article')."'>
+ </a>";
+ } else {
+ $rv = "";
+ }
+
+ return $rv;
+ }
+}
+?>
diff --git a/plugins/flattr/flattr.png b/plugins/flattr/flattr.png
new file mode 100644
index 000000000..4933ffc21
--- /dev/null
+++ b/plugins/flattr/flattr.png
Binary files differ