diff --git a/functions.php b/functions.php index 01785e38c..7c12d538d 100644 --- a/functions.php +++ b/functions.php @@ -4617,12 +4617,12 @@ onclick=\"postOpenInNewTab(event, $id)\" alt='Zoom' title='".__('Open article in new tab')."'>"; - $note_escaped = htmlspecialchars($line['note'], ENT_QUOTES); + //$note_escaped = htmlspecialchars($line['note'], ENT_QUOTES); print "PubNote"; + onclick=\"editArticleNote($id)\" + alt='PubNote' title='".__('Edit article note')."'>"; if (DIGEST_ENABLE) { print "". $feed_icon . ""; - print "
"; - - $article_content = sanitize_rss($link, $line["content"], false, false, - $feed_site_url); - print "
"; if ($line['note']) { print format_article_note($id, $line['note']); } print "
"; + print "
"; + + $article_content = sanitize_rss($link, $line["content"], false, false, + $feed_site_url); + print $article_content; print_article_enclosures($link, $id, $always_display_enclosures, @@ -5234,12 +5234,12 @@ alt='Zoom' title='".__('Open article in new tab')."'>"; - $note_escaped = htmlspecialchars($line['note'], ENT_QUOTES); + //$note_escaped = htmlspecialchars($line['note'], ENT_QUOTES); print "PubNote"; + onclick=\"editArticleNote($id)\" + alt='PubNote' title='".__('Edit article note')."'>"; if (DIGEST_ENABLE) { print "". - __('edit note').""; - $str .= "
"; - $str .= "
"; + $str = "
$note
"; return $str; } diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index b8877da20..239ff60f6 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -209,8 +209,9 @@ return; } - // XML method if ($subop == "publ") { + header("Content-Type: text/plain"); + $pub = $_REQUEST["pub"]; $id = db_escape_string($_REQUEST["id"]); $note = trim(strip_tags(db_escape_string($_REQUEST["note"]))); @@ -221,31 +222,11 @@ $pub = "false"; } - if ($note != 'undefined') { - $note_qpart = "note = '$note',"; - } - - // FIXME this needs collision testing - $result = db_query($link, "UPDATE ttrss_user_entries SET - $note_qpart published = $pub WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); - - print ""; - - if ($note != 'undefined') { - $note_size = strlen($note); - print ""; - print ""; - print ""; - } - - print "UPDATE_COUNTERS"; - - print ""; - + print json_encode(array("message" => "UPDATE_COUNTERS")); return; } @@ -893,6 +874,21 @@ return; } + if ($subop == "setNote") { + header("Content-Type: text/plain"); + + $id = db_escape_string($_REQUEST["id"]); + $note = strip_tags(db_escape_string($_REQUEST["note"])); + + db_query($link, "UPDATE ttrss_user_entries SET note = '$note' + WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); + + $formatted_note = format_article_note($id, $note); + + print json_encode(array("note" => $formatted_note)); + return; + } + print "Unknown method: $subop"; } ?> diff --git a/modules/popup-dialog.php b/modules/popup-dialog.php index 6da30521b..4513c7cfb 100644 --- a/modules/popup-dialog.php +++ b/modules/popup-dialog.php @@ -802,10 +802,12 @@ print ""; print ""; - print "

"; + print ""; print "

"; print " "; + print ""; + print "
"; + + } + + print ""; } ?> diff --git a/tt-rss.css b/tt-rss.css index 4f45e171e..d8b92e5ab 100644 --- a/tt-rss.css +++ b/tt-rss.css @@ -74,31 +74,15 @@ div.postReply img.tagsPic { vertical-align : middle; } -div.articleNote div.articleNoteOps { - text-align : center; - color : #9a8c59; - font-style : italic; - margin-top : 5px; -} - -div.articleNote div.articleNoteOps a { - color : #9a8c59; -} - -div.articleNote div.articleNoteOps a:hover { - color : black; -} - div.articleNote { background-color : #fff7d5; border-width : 1px; padding : 5px; border-style : dashed; border-color : #e7d796; - font-size : 8px; - margin-bottom : 5px; - margin-top : 5px; + font-size : 11px; margin-left : 5px; + margin-top : 5px; float : right; color : #9a8c59; max-width : 150px; diff --git a/viewfeed.js b/viewfeed.js index 0823ed321..5d40fb321 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -483,6 +483,14 @@ function togglePub(id, client_only, no_effects, note) { } if (!client_only) { + new Ajax.Request("backend.php", { + parameters: query, + onComplete: function(transport) { + handle_rpc_json(transport); + } }); + } + +/* if (!client_only) { new Ajax.Request("backend.php", { parameters: query, onComplete: function(transport) { @@ -510,7 +518,7 @@ function togglePub(id, client_only, no_effects, note) { } } }); - } + } */ } catch (e) { exception_error("togglePub", e); @@ -1799,7 +1807,7 @@ function toggleHeadlineActions() { } } -function publishWithNote(id, def_note) { +/* function publishWithNote(id, def_note) { try { if (!def_note) def_note = ''; @@ -1812,7 +1820,7 @@ function publishWithNote(id, def_note) { } catch (e) { exception_error("publishWithNote", e); } -} +} */ function emailArticle(id) { try { @@ -2308,3 +2316,52 @@ function tweetArticle(id) { exception_error("tweetArticle", e); } } + +function editArticleNote(id) { + try { + + var query = "backend.php?op=dlg&id=editArticleNote¶m=" + param_escape(id); + + if (dijit.byId("editNoteDlg")) + dijit.byId("editNoteDlg").destroyRecursive(); + + dialog = new dijit.Dialog({ + id: "editNoteDlg", + title: __("Edit article note"), + style: "width: 600px", + execute: function() { + if (this.validate()) { + var query = dojo.objectToQuery(this.attr('value')); + + notify_progress("Saving article note...", true); + + new Ajax.Request("backend.php", { + parameters: query, + onComplete: function(transport) { + notify(''); + dialog.hide(); + + var reply = JSON.parse(transport.responseText); + + cache_invalidate(id); + + var elem = $("POSTNOTE-" + id); + + if (elem) { + Element.hide(elem); + elem.innerHTML = reply.note; + new Effect.Appear(elem); + } + + }}); + } + }, + href: query, + }); + + dialog.show(); + + } catch (e) { + exception_error("editArticleNote", e); + } +}