init.php 2.4 KB

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