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