]>
Commit | Line | Data |
---|---|---|
1d5cf085 AD |
1 | <?php |
2 | class MailTo extends Plugin { | |
3 | ||
4 | private $link; | |
5 | private $host; | |
6 | ||
7 | function about() { | |
8 | return array(1.0, | |
9 | "Share article via email (using mailto: links, invoking your mail client)", | |
10 | "fox"); | |
11 | } | |
12 | ||
13 | function init($host) { | |
14 | $this->link = $host->get_link(); | |
15 | $this->host = $host; | |
16 | ||
17 | $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); | |
18 | } | |
19 | ||
20 | function get_js() { | |
21 | return file_get_contents(dirname(__FILE__) . "/init.js"); | |
22 | } | |
23 | ||
24 | function hook_article_button($line) { | |
2a3b6de0 | 25 | return "<img src=\"plugins/mailto/mail.png\" |
1d5cf085 AD |
26 | class='tagsPic' style=\"cursor : pointer\" |
27 | onclick=\"mailtoArticle(".$line["id"].")\" | |
28 | alt='Zoom' title='".__('Forward by email')."'>"; | |
29 | } | |
30 | ||
31 | function emailArticle() { | |
32 | ||
33 | $param = db_escape_string($_REQUEST['param']); | |
34 | ||
35 | require_once "lib/MiniTemplator.class.php"; | |
36 | ||
37 | $tpl = new MiniTemplator; | |
38 | $tpl_t = new MiniTemplator; | |
39 | ||
40 | $tpl->readTemplateFromFile("templates/email_article_template.txt"); | |
41 | ||
42 | $tpl->setVariable('USER_NAME', $_SESSION["name"], true); | |
43 | $tpl->setVariable('USER_EMAIL', $user_email, true); | |
44 | $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); | |
45 | ||
46 | ||
47 | $result = db_query($this->link, "SELECT link, content, title | |
48 | FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND | |
49 | id IN ($param) AND owner_uid = " . $_SESSION["uid"]); | |
50 | ||
51 | if (db_num_rows($result) > 1) { | |
52 | $subject = __("[Forwarded]") . " " . __("Multiple articles"); | |
53 | } | |
54 | ||
55 | while ($line = db_fetch_assoc($result)) { | |
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 | ||
71 | $mailto_link = htmlspecialchars("mailto: ?subject=".urlencode($subject). | |
72 | "&body=".urlencode($content)); | |
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 | ||
92 | } | |
93 | ?> |