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