From 7252abe3ea5703b3cf75a3745e560499cfde500a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 23 Dec 2012 15:18:41 +0400 Subject: add contributed plugins; load note plugin by default --- plugins/googleplus/googleplus.js | 29 +++++++++++++++++++++++ plugins/googleplus/googleplus.php | 47 ++++++++++++++++++++++++++++++++++++++ plugins/googleplus/googleplus.png | Bin 0 -> 827 bytes 3 files changed, 76 insertions(+) create mode 100644 plugins/googleplus/googleplus.js create mode 100644 plugins/googleplus/googleplus.php create mode 100644 plugins/googleplus/googleplus.png (limited to 'plugins/googleplus') diff --git a/plugins/googleplus/googleplus.js b/plugins/googleplus/googleplus.js new file mode 100644 index 000000000..027d9b40e --- /dev/null +++ b/plugins/googleplus/googleplus.js @@ -0,0 +1,29 @@ + function shareArticleToGooglePlus(id) { + try { + var query = "?op=pluginhandler&plugin=googleplus&method=getInfo&id=" + param_escape(id); + + console.log(query); + + var d = new Date(); + var ts = d.getTime(); + + var w = window.open('backend.php?op=backend&method=loading', 'ttrss_tweet', + "status=0,toolbar=0,location=0,width=500,height=450,scrollbars=1,menubar=0"); + + new Ajax.Request("backend.php", { + parameters: query, + onComplete: function(transport) { + var ti = JSON.parse(transport.responseText); + + var share_url = "https://plus.google.com/share?url=" + param_escape(ti.link); + + w.location.href = share_url; + + } }); + + + } catch (e) { + exception_error("tweetArticle", e); + } + } + diff --git a/plugins/googleplus/googleplus.php b/plugins/googleplus/googleplus.php new file mode 100644 index 000000000..1c5128eed --- /dev/null +++ b/plugins/googleplus/googleplus.php @@ -0,0 +1,47 @@ +link = $host->get_link(); + $this->host = $host; + + $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); + } + + function get_js() { + return file_get_contents(dirname(__FILE__) . "/googleplus.js"); + } + + function hook_article_button($line) { + $article_id = $line["id"]; + + $rv = "link, 'plugins/googleplus/googleplus.png')."\" + class='tagsPic' style=\"cursor : pointer\" + onclick=\"shareArticleToGooglePlus($article_id)\" + title='".__('Share on Google+')."'>"; + + return $rv; + } + + function getInfo() { + $id = db_escape_string($_REQUEST['id']); + + $result = db_query($this->link, "SELECT title, link + FROM ttrss_entries, ttrss_user_entries + WHERE id = '$id' AND ref_id = id AND owner_uid = " .$_SESSION['uid']); + + if (db_num_rows($result) != 0) { + $title = truncate_string(strip_tags(db_fetch_result($result, 0, 'title')), + 100, '...'); + $article_link = db_fetch_result($result, 0, 'link'); + } + + print json_encode(array("title" => $title, "link" => $article_link, + "id" => $id)); + } + + +} +?> diff --git a/plugins/googleplus/googleplus.png b/plugins/googleplus/googleplus.png new file mode 100644 index 000000000..8c64b81a2 Binary files /dev/null and b/plugins/googleplus/googleplus.png differ -- cgit v1.2.3