note.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. class Button_Note extends Button {
  3. function render($article_id) {
  4. return "<img src=\"".theme_image($this->link, "images/art-pub-note.png")."\"
  5. style=\"cursor : pointer\" style=\"cursor : pointer\"
  6. onclick=\"editArticleNote($article_id)\"
  7. class='tagsPic' title='".__('Edit article note')."'>";
  8. }
  9. function edit() {
  10. $param = db_escape_string($_REQUEST['param']);
  11. $result = db_query($this->link, "SELECT note FROM ttrss_user_entries WHERE
  12. ref_id = '$param' AND owner_uid = " . $_SESSION['uid']);
  13. $note = db_fetch_result($result, 0, "note");
  14. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$param\">";
  15. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
  16. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"buttonPlugin\">";
  17. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"plugin\" value=\"note\">";
  18. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"plugin_method\" value=\"setNote\">";
  19. print "<table width='100%'><tr><td>";
  20. print "<textarea dojoType=\"dijit.form.SimpleTextarea\"
  21. style='font-size : 12px; width : 100%; height: 100px;'
  22. placeHolder='body#ttrssMain { font-size : 14px; };'
  23. name='note'>$note</textarea>";
  24. print "</td></tr></table>";
  25. print "<div class='dlgButtons'>";
  26. print "<button dojoType=\"dijit.form.Button\"
  27. onclick=\"dijit.byId('editNoteDlg').execute()\">".__('Save')."</button> ";
  28. print "<button dojoType=\"dijit.form.Button\"
  29. onclick=\"dijit.byId('editNoteDlg').hide()\">".__('Cancel')."</button>";
  30. print "</div>";
  31. }
  32. function setNote() {
  33. $id = db_escape_string($_REQUEST["id"]);
  34. $note = trim(strip_tags(db_escape_string($_REQUEST["note"])));
  35. db_query($this->link, "UPDATE ttrss_user_entries SET note = '$note'
  36. WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
  37. $formatted_note = format_article_note($id, $note);
  38. print json_encode(array("note" => $formatted_note,
  39. "raw_length" => mb_strlen($note)));
  40. }
  41. }
  42. ?>