]> git.wh0rd.org - tt-rss.git/blob - plugins/share/share.php
experimental new plugin system
[tt-rss.git] / plugins / share / share.php
1 <?php
2 class Share {
3 private $link;
4 private $host;
5
6 function __construct($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 get_js() {
14 return file_get_contents(dirname(__FILE__) . "/share.js");
15 }
16
17 function hook_article_button($line) {
18 return "<img src=\"".theme_image($this->link, 'images/art-share.png')."\"
19 class='tagsPic' style=\"cursor : pointer\"
20 onclick=\"shareArticle(".$line['int_id'].")\"
21 title='".__('Share by URL')."'>";
22 }
23
24 function shareArticle() {
25 $param = db_escape_string($_REQUEST['param']);
26
27 $result = db_query($this->link, "SELECT uuid, ref_id FROM ttrss_user_entries WHERE int_id = '$param'
28 AND owner_uid = " . $_SESSION['uid']);
29
30 if (db_num_rows($result) == 0) {
31 print "Article not found.";
32 } else {
33
34 $uuid = db_fetch_result($result, 0, "uuid");
35 $ref_id = db_fetch_result($result, 0, "ref_id");
36
37 if (!$uuid) {
38 $uuid = db_escape_string(sha1(uniqid(rand(), true)));
39 db_query($this->link, "UPDATE ttrss_user_entries SET uuid = '$uuid' WHERE int_id = '$param'
40 AND owner_uid = " . $_SESSION['uid']);
41 }
42
43 print __("You can share this article by the following unique URL:");
44
45 $url_path = get_self_url_prefix();
46 $url_path .= "/public.php?op=share&key=$uuid";
47
48 print "<div class=\"tagCloudContainer\">";
49 print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>";
50 print "</div>";
51
52 /* if (!label_find_id($this->link, __('Shared'), $_SESSION["uid"]))
53 label_create($this->link, __('Shared'), $_SESSION["uid"]);
54
55 label_add_article($this->link, $ref_id, __('Shared'), $_SESSION['uid']); */
56 }
57
58 print "<div align='center'>";
59
60 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('shareArticleDlg').hide()\">".
61 __('Close this window')."</button>";
62
63 print "</div>";
64 }
65
66
67 }
68 ?>