init.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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->readTemplateFromFile("templates/email_article_template.txt");
  27. $tpl->setVariable('USER_NAME', $_SESSION["name"], true);
  28. //$tpl->setVariable('USER_EMAIL', $user_email, true);
  29. $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true);
  30. $result = db_query("SELECT DISTINCT link, content, title
  31. FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND
  32. id IN ($param) AND owner_uid = " . $_SESSION["uid"]);
  33. if (db_num_rows($result) > 1) {
  34. $subject = __("[Forwarded]") . " " . __("Multiple articles");
  35. }
  36. while ($line = db_fetch_assoc($result)) {
  37. if (!$subject)
  38. $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]);
  39. $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"]));
  40. $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"]));
  41. $tpl->addBlock('article');
  42. }
  43. $tpl->addBlock('email');
  44. $content = "";
  45. $tpl->generateOutputToString($content);
  46. $mailto_link = htmlspecialchars("mailto:?subject=".rawurlencode($subject).
  47. "&body=".rawurlencode($content));
  48. print __("Clicking the following link to invoke your mail client:");
  49. print "<div class=\"tagCloudContainer\">";
  50. print "<a target=\"_blank\" href=\"$mailto_link\">".
  51. __("Forward selected article(s) by email.")."</a>";
  52. print "</div>";
  53. print __("You should be able to edit the message before sending in your mail client.");
  54. print "<p>";
  55. print "<div style='text-align : center'>";
  56. print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Close this dialog')."</button>";
  57. print "</div>";
  58. //return;
  59. }
  60. function api_version() {
  61. return 2;
  62. }
  63. }