]>
Commit | Line | Data |
---|---|---|
1d5cf085 AD |
1 | <?php |
2 | class MailTo extends Plugin { | |
1d5cf085 AD |
3 | private $host; |
4 | ||
5 | function about() { | |
6 | return array(1.0, | |
7 | "Share article via email (using mailto: links, invoking your mail client)", | |
8 | "fox"); | |
9 | } | |
10 | ||
11 | function init($host) { | |
1d5cf085 AD |
12 | $this->host = $host; |
13 | ||
14 | $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); | |
15 | } | |
16 | ||
17 | function get_js() { | |
18 | return file_get_contents(dirname(__FILE__) . "/init.js"); | |
19 | } | |
20 | ||
21 | function hook_article_button($line) { | |
2a3b6de0 | 22 | return "<img src=\"plugins/mailto/mail.png\" |
1d5cf085 AD |
23 | class='tagsPic' style=\"cursor : pointer\" |
24 | onclick=\"mailtoArticle(".$line["id"].")\" | |
25 | alt='Zoom' title='".__('Forward by email')."'>"; | |
26 | } | |
27 | ||
28 | function emailArticle() { | |
29 | ||
a42c55f0 | 30 | $param = db_escape_string($_REQUEST['param']); |
1d5cf085 AD |
31 | |
32 | require_once "lib/MiniTemplator.class.php"; | |
33 | ||
34 | $tpl = new MiniTemplator; | |
1d5cf085 AD |
35 | |
36 | $tpl->readTemplateFromFile("templates/email_article_template.txt"); | |
37 | ||
38 | $tpl->setVariable('USER_NAME', $_SESSION["name"], true); | |
21ce7d9e | 39 | //$tpl->setVariable('USER_EMAIL', $user_email, true); |
1d5cf085 AD |
40 | $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); |
41 | ||
42 | ||
18c1b21d | 43 | $result = db_query("SELECT DISTINCT link, content, title |
1d5cf085 AD |
44 | FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND |
45 | id IN ($param) AND owner_uid = " . $_SESSION["uid"]); | |
46 | ||
47 | if (db_num_rows($result) > 1) { | |
48 | $subject = __("[Forwarded]") . " " . __("Multiple articles"); | |
49 | } | |
50 | ||
51 | while ($line = db_fetch_assoc($result)) { | |
52 | ||
53 | if (!$subject) | |
54 | $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]); | |
55 | ||
56 | $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); | |
57 | $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); | |
58 | ||
59 | $tpl->addBlock('article'); | |
60 | } | |
61 | ||
62 | $tpl->addBlock('email'); | |
63 | ||
64 | $content = ""; | |
65 | $tpl->generateOutputToString($content); | |
66 | ||
6bc50a82 | 67 | $mailto_link = htmlspecialchars("mailto:?subject=".rawurlencode($subject). |
8131e83c | 68 | "&body=".rawurlencode($content)); |
1d5cf085 AD |
69 | |
70 | print __("Clicking the following link to invoke your mail client:"); | |
71 | ||
72 | print "<div class=\"tagCloudContainer\">"; | |
73 | print "<a target=\"_blank\" href=\"$mailto_link\">". | |
74 | __("Forward selected article(s) by email.")."</a>"; | |
75 | print "</div>"; | |
76 | ||
77 | print __("You should be able to edit the message before sending in your mail client."); | |
78 | ||
79 | print "<p>"; | |
80 | ||
81 | print "<div style='text-align : center'>"; | |
82 | print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Close this dialog')."</button>"; | |
83 | print "</div>"; | |
84 | ||
85 | //return; | |
86 | } | |
87 | ||
106a3de9 AD |
88 | function api_version() { |
89 | return 2; | |
90 | } | |
91 | ||
1d5cf085 | 92 | } |