]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | class Note extends Plugin { | |
3 | private $host; | |
4 | ||
5 | function about() { | |
6 | return array(1.0, | |
7 | "Adds support for setting article notes", | |
8 | "fox"); | |
9 | } | |
10 | ||
11 | function init($host) { | |
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) { | |
23 | return "<img src=\"plugins/note/note.png\" | |
24 | style=\"cursor : pointer\" style=\"cursor : pointer\" | |
25 | onclick=\"editArticleNote(".$line["id"].")\" | |
26 | class='tagsPic' title='".__('Edit article note')."'>"; | |
27 | } | |
28 | ||
29 | function edit() { | |
30 | $param = db_escape_string( $_REQUEST['param']); | |
31 | ||
32 | $result = db_query( "SELECT note FROM ttrss_user_entries WHERE | |
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\">"; | |
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\">"; | |
40 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"plugin\" value=\"note\">"; | |
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() { | |
59 | $id = db_escape_string( $_REQUEST["id"]); | |
60 | $note = trim(strip_tags(db_escape_string( $_REQUEST["note"]))); | |
61 | ||
62 | db_query( "UPDATE ttrss_user_entries SET note = '$note' | |
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 | ||
71 | } | |
72 | ?> |