]>
git.wh0rd.org - tt-rss.git/blob - plugins/note/init.php
2 class Note
extends Plugin
{
4 /* @var PluginHost $host */
9 "Adds support for setting article notes",
13 function init($host) {
16 $host->add_hook($host::HOOK_ARTICLE_BUTTON
, $this);
20 return file_get_contents(dirname(__FILE__
) . "/note.js");
24 function hook_article_button($line) {
25 return "<img src=\"plugins/note/note.png\"
26 style=\"cursor : pointer\" style=\"cursor : pointer\"
27 onclick=\"editArticleNote(".$line["id"].")\"
28 class='tagsPic' title='".__('Edit article note')."'>";
32 $param = $_REQUEST['param'];
34 $sth = $this->pdo
->prepare("SELECT note FROM ttrss_user_entries WHERE
35 ref_id = ? AND owner_uid = ?");
36 $sth->execute([$param, $_SESSION['uid']]);
38 if ($row = $sth->fetch()) {
42 print_hidden("id", "$param");
43 print_hidden("op", "pluginhandler");
44 print_hidden("method", "setNote");
45 print_hidden("plugin", "note");
47 print "<table width='100%'><tr><td>";
48 print "<textarea dojoType=\"dijit.form.SimpleTextarea\"
49 style='font-size : 12px; width : 98%; height: 100px;'
50 placeHolder='body#ttrssMain { font-size : 14px; };'
51 name='note'>$note</textarea>";
52 print "</td></tr></table>";
56 print "<div class='dlgButtons'>";
57 print "<button dojoType=\"dijit.form.Button\"
58 onclick=\"dijit.byId('editNoteDlg').execute()\">".__('Save')."</button> ";
59 print "<button dojoType=\"dijit.form.Button\"
60 onclick=\"dijit.byId('editNoteDlg').hide()\">".__('Cancel')."</button>";
66 $id = $_REQUEST["id"];
67 $note = trim(strip_tags($_REQUEST["note"]));
69 $sth = $this->pdo
->prepare("UPDATE ttrss_user_entries SET note = ?
70 WHERE ref_id = ? AND owner_uid = ?");
71 $sth->execute([$note, $id, $_SESSION['uid']]);
73 $formatted_note = Article
::format_article_note($id, $note);
75 print json_encode(array("note" => $formatted_note,
76 "raw_length" => mb_strlen($note)));
79 function api_version() {