]> git.wh0rd.org - tt-rss.git/blob - plugins/mailto/init.php
mailto: remove unneeded space
[tt-rss.git] / plugins / mailto / init.php
1 <?php
2 class MailTo extends Plugin {
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) {
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) {
22 return "<img src=\"plugins/mailto/mail.png\"
23 class='tagsPic' style=\"cursor : pointer\"
24 onclick=\"mailtoArticle(".$line["id"].")\"
25 alt='Zoom' title='".__('Forward by email')."'>";
26 }
27
28 function emailArticle() {
29
30 $param = db_escape_string($_REQUEST['param']);
31
32 require_once "lib/MiniTemplator.class.php";
33
34 $tpl = new MiniTemplator;
35 $tpl_t = new MiniTemplator;
36
37 $tpl->readTemplateFromFile("templates/email_article_template.txt");
38
39 $tpl->setVariable('USER_NAME', $_SESSION["name"], true);
40 $tpl->setVariable('USER_EMAIL', $user_email, true);
41 $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true);
42
43
44 $result = db_query("SELECT DISTINCT link, content, title
45 FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND
46 id IN ($param) AND owner_uid = " . $_SESSION["uid"]);
47
48 if (db_num_rows($result) > 1) {
49 $subject = __("[Forwarded]") . " " . __("Multiple articles");
50 }
51
52 while ($line = db_fetch_assoc($result)) {
53
54 if (!$subject)
55 $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]);
56
57 $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"]));
58 $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"]));
59
60 $tpl->addBlock('article');
61 }
62
63 $tpl->addBlock('email');
64
65 $content = "";
66 $tpl->generateOutputToString($content);
67
68 $mailto_link = htmlspecialchars("mailto:?subject=".rawurlencode($subject).
69 "&body=".rawurlencode($content));
70
71 print __("Clicking the following link to invoke your mail client:");
72
73 print "<div class=\"tagCloudContainer\">";
74 print "<a target=\"_blank\" href=\"$mailto_link\">".
75 __("Forward selected article(s) by email.")."</a>";
76 print "</div>";
77
78 print __("You should be able to edit the message before sending in your mail client.");
79
80 print "<p>";
81
82 print "<div style='text-align : center'>";
83 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Close this dialog')."</button>";
84 print "</div>";
85
86 //return;
87 }
88
89 function api_version() {
90 return 2;
91 }
92
93 }
94 ?>