init.php 2.4 KB

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