]> git.wh0rd.org - tt-rss.git/blob - plugins/note/note.php
c6c1ef903fac1596e855b493e906ff809dcdf8a7
[tt-rss.git] / plugins / note / note.php
1 <?php
2 class Note extends Plugin {
3 private $link;
4 private $host;
5
6 function _about() {
7 return array(1.0,
8 "Adds support for setting article notes",
9 "fox");
10 }
11
12 function __construct($host) {
13 $this->link = $host->get_link();
14 $this->host = $host;
15
16 $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
17 }
18
19 function get_js() {
20 return file_get_contents(dirname(__FILE__) . "/note.js");
21 }
22
23
24 function hook_article_button($line) {
25 return "<img src=\"".theme_image($this->link, "plugins/note/note.png")."\"
26 style=\"cursor : pointer\" style=\"cursor : pointer\"
27 onclick=\"editArticleNote(".$line["id"].")\"
28 class='tagsPic' title='".__('Edit article note')."'>";
29 }
30
31 function edit() {
32 $param = db_escape_string($_REQUEST['param']);
33
34 $result = db_query($this->link, "SELECT note FROM ttrss_user_entries WHERE
35 ref_id = '$param' AND owner_uid = " . $_SESSION['uid']);
36
37 $note = db_fetch_result($result, 0, "note");
38
39 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$param\">";
40 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pluginhandler\">";
41 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setNote\">";
42 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"plugin\" value=\"note\">";
43
44 print "<table width='100%'><tr><td>";
45 print "<textarea dojoType=\"dijit.form.SimpleTextarea\"
46 style='font-size : 12px; width : 100%; height: 100px;'
47 placeHolder='body#ttrssMain { font-size : 14px; };'
48 name='note'>$note</textarea>";
49 print "</td></tr></table>";
50
51 print "<div class='dlgButtons'>";
52 print "<button dojoType=\"dijit.form.Button\"
53 onclick=\"dijit.byId('editNoteDlg').execute()\">".__('Save')."</button> ";
54 print "<button dojoType=\"dijit.form.Button\"
55 onclick=\"dijit.byId('editNoteDlg').hide()\">".__('Cancel')."</button>";
56 print "</div>";
57
58 }
59
60 function setNote() {
61 $id = db_escape_string($_REQUEST["id"]);
62 $note = trim(strip_tags(db_escape_string($_REQUEST["note"])));
63
64 db_query($this->link, "UPDATE ttrss_user_entries SET note = '$note'
65 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
66
67 $formatted_note = format_article_note($id, $note);
68
69 print json_encode(array("note" => $formatted_note,
70 "raw_length" => mb_strlen($note)));
71 }
72
73 }
74 ?>