]>
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 | ||
d8bf94c2 AD |
30 | $ids = explode(",", $_REQUEST['param']); |
31 | $ids_qmarks = arr_qmarks($ids); | |
1d5cf085 AD |
32 | |
33 | require_once "lib/MiniTemplator.class.php"; | |
34 | ||
35 | $tpl = new MiniTemplator; | |
1d5cf085 AD |
36 | |
37 | $tpl->readTemplateFromFile("templates/email_article_template.txt"); | |
38 | ||
39 | $tpl->setVariable('USER_NAME', $_SESSION["name"], true); | |
21ce7d9e | 40 | //$tpl->setVariable('USER_EMAIL', $user_email, true); |
1d5cf085 AD |
41 | $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); |
42 | ||
43 | ||
d8bf94c2 | 44 | $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title |
1d5cf085 | 45 | FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND |
d8bf94c2 AD |
46 | id IN ($ids_qmarks) AND owner_uid = ?"); |
47 | $sth->execute(array_merge($ids, [$_SESSION['uid']])); | |
1d5cf085 | 48 | |
d8bf94c2 | 49 | if (count($ids) > 1) { |
1d5cf085 | 50 | $subject = __("[Forwarded]") . " " . __("Multiple articles"); |
d8bf94c2 AD |
51 | } else { |
52 | $subject = ""; | |
1d5cf085 AD |
53 | } |
54 | ||
d8bf94c2 | 55 | while ($line = $sth->fetch()) { |
1d5cf085 AD |
56 | |
57 | if (!$subject) | |
58 | $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]); | |
59 | ||
60 | $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); | |
61 | $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); | |
62 | ||
63 | $tpl->addBlock('article'); | |
64 | } | |
65 | ||
66 | $tpl->addBlock('email'); | |
67 | ||
68 | $content = ""; | |
69 | $tpl->generateOutputToString($content); | |
70 | ||
6bc50a82 | 71 | $mailto_link = htmlspecialchars("mailto:?subject=".rawurlencode($subject). |
8131e83c | 72 | "&body=".rawurlencode($content)); |
1d5cf085 AD |
73 | |
74 | print __("Clicking the following link to invoke your mail client:"); | |
75 | ||
76 | print "<div class=\"tagCloudContainer\">"; | |
77 | print "<a target=\"_blank\" href=\"$mailto_link\">". | |
78 | __("Forward selected article(s) by email.")."</a>"; | |
79 | print "</div>"; | |
80 | ||
81 | print __("You should be able to edit the message before sending in your mail client."); | |
82 | ||
83 | print "<p>"; | |
84 | ||
85 | print "<div style='text-align : center'>"; | |
86 | print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Close this dialog')."</button>"; | |
87 | print "</div>"; | |
88 | ||
89 | //return; | |
90 | } | |
91 | ||
106a3de9 AD |
92 | function api_version() { |
93 | return 2; | |
94 | } | |
95 | ||
1d5cf085 | 96 | } |