]> git.wh0rd.org Git - tt-rss.git/commitdiff
tag editor
authorAndrew Dolgov <fox@madoka.spb.ru>
Thu, 7 Dec 2006 07:48:00 +0000 (08:48 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Thu, 7 Dec 2006 07:48:00 +0000 (08:48 +0100)
backend.php
functions.php
modules/backend-rpc.php
modules/popup-dialog.php
tt-rss.js
viewfeed.js

index ee8b089d1df990bd40db176f6d25832b59b0293b..b1c0554bb72d7494c86f4d6fff3c1e4523e73422 100644 (file)
                                print "<tr><td width='70%'><a $link_target href=\"" . $line["link"] . "\">" . 
                                        $line["title"] . "</a>$entry_author</td>";
                        } else {
-                               print "<tr><td width='30%'>" . $line["title"] . "$entry_author</td>";
+                               print "<tr><td width='70%'>" . $line["title"] . "$entry_author</td>";
                        }
 
                        $parsed_updated = date(get_pref($link, 'LONG_DATE_FORMAT'), 
                                $tag = $tmp_line["tag_name"];                           
                                $tag_str = "<a href=\"javascript:parent.viewfeed('$tag')\">$tag</a>, "; 
                                
-                               if ($num_tags == 5) {
+                               if ($num_tags == 3) {
                                        $tags_str .= "<a href=\"javascript:showBlockElement('allEntryTags')\">...</a>";
-                               } else if ($num_tags < 5) {
+                               } else if ($num_tags < 3) {
                                        $tags_str .= $tag_str;
                                }
                                $f_tags_str .= $tag_str;
 
 //                     $truncated_link = truncate_string($line["link"], 60);
 
-                       if ($tags_str || $entry_comments) {
+#                      if ($tags_str || $entry_comments) {
                                print "<tr><td width='50%'>
                                        $entry_comments</td>
-                                       <td align=\"right\">$tags_str</td></tr>";
-                       }
+                                       <td align=\"right\">$tags_str <a href=\"javascript:editArticleTags($id, $feed_id)\">(+)</a></td></tr>";
+#                      }
 
                        print "</table></div>";
 
                        print "<div class=\"postIcon\">" . $feed_icon . "</div>";
                        print "<div class=\"postContent\">";
                        
-                       if (db_num_rows($tmp_result) > 5) {
+                       if (db_num_rows($tmp_result) > 0) {
                                print "<div id=\"allEntryTags\">Tags: $f_tags_str</div>";
                        }
 
index 83f37b61905dc7ec002bc9c7b1cc27815504cc0d..7b5da022c25d750abdca9e1a108e889860b82247 100644 (file)
 
        }
 
+       function get_article_tags($link, $id) {
+
+               $a_id = db_escape_string($id);
+
+               $tmp_result = db_query($link, "SELECT DISTINCT tag_name FROM
+                       ttrss_tags WHERE post_int_id = (SELECT int_id FROM ttrss_user_entries WHERE
+                               ref_id = '$a_id' AND owner_uid = '".$_SESSION["uid"]."') ORDER BY tag_name");
+
+               $tags = array();        
+       
+               while ($tmp_line = db_fetch_assoc($tmp_result)) {
+                       array_push($tags, $tmp_line["tag_name"]);                               
+               }
+
+               return $tags;
+       }
+
 ?>
index 92fe23468b71813d99ff5b5ce8d99794b8fdc182..153590589b6b979c2dc5768747e0494f2df963f8 100644 (file)
                                <message>$key : $value</message>
                                </rpc-reply>";
                }
+
+               if ($subop == "setArticleTags") {
+                       $id = db_escape_string($_GET["id"]);
+                       $tags_str = db_escape_string($_GET["tags_str"]);
+
+                       $tags = split(",", $tags_str);
+
+                       db_query($link, "BEGIN");
+
+                       $result = db_query($link, "SELECT int_id FROM ttrss_user_entries WHERE
+                               ref_id = '$id' AND owner_uid = '".$_SESSION["uid"]."' LIMIT 1");
+
+                       if (db_num_rows($result) == 1) {
+
+                               $int_id = db_fetch_result($result, 0, "int_id");
+
+                               db_query($link, "DELETE FROM ttrss_tags WHERE 
+                                       post_int_id = $int_id AND owner_uid = '".$_SESSION["uid"]."'");
+
+                               foreach ($tags as $tag) {
+                                       $tag = trim($tag);
+
+                                       if (preg_match("/^[0-9]*$/", $tag)) {
+                                               continue;
+                                       }
+                                       
+                                       if ($tag != '') {
+                                               db_query($link, "INSERT INTO ttrss_tags 
+                                                       (post_int_id, owner_uid, tag_name) VALUES ('$int_id', '".$_SESSION["uid"]."', '$tag')");
+                                       }
+                               }
+                       }
+
+                       db_query($link, "COMMIT");
+
+                       print "<rpc-reply>
+                               <message>$id</message>
+                               </rpc-reply>";
+
+               }
        }
 ?>
index d3933ae77ae26f565db881eab1bb20cab2ff46a6..a1ead2b00e400af2dfc8f4a2388d23db3f8f2cda 100644 (file)
@@ -1,7 +1,7 @@
 <?php
        function module_popup_dialog($link) {
                $id = $_GET["id"];
-               $param = $_GET["param"];
+               $param = db_escape_string($_GET["param"]);
 
                if ($id == "quickAddFeed") {
 
 
                }
 
+               if ($id == "editArticleTags") {
+
+                       print "<div id=\"infoBoxTitle\">Edit Tags</div>";
+                       print "<div class=\"infoBoxContents\">";
+
+                       print "<form id=\"tag_edit_form\">";
+
+                       print "Tags for this article (separated by commas):<br>";
+
+                       $tags = get_article_tags($link, $param);
+
+                       $tags_str = join(", ", $tags);
+
+                       print "<input type=\"hidden\" name=\"id\" value=\"$param\">";
+
+                       print "<textarea rows='4' class='iedit' name='tags_str'>$tags_str</textarea>";
+
+                       print "</form>";
+
+                       print "<div align='right'>";
+
+                       print "<input class=\"button\"
+                               type=\"submit\" onclick=\"return editTagsSave()\" 
+                               value=\"Save\"> ";
+
+                       print "<input class=\"button\"
+                               type=\"submit\" onclick=\"return closeInfoBox()\" 
+                               value=\"Cancel\">";
+
+
+                       print "</div>";
+
+               }
+
                print "</div>";
        }
 ?>
index 1257f996ba27745756dbe989dce44160ef95ceb6..85616b4f3fab989be7f81632c5f59393e36e9f80 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -22,6 +22,10 @@ var init_params = new Object();
 
 var op_history = new Array();
 
+function tagsAreDisplayed() {
+       return display_tags;
+}
+
 function toggleTags() {
        display_tags = !display_tags;
 
index cc563449a551da8f7ccba1dc776eae2fea8b18ab..5f338e46ede76372e46b37a6b83bfcddf1d5a526 100644 (file)
@@ -1,6 +1,13 @@
 var active_post_id = false;
 var _catchup_callback_func = false;
 var last_article_view = false;
+var active_real_feed_id = false;
+
+var _tag_active_post_id = false;
+var _tag_active_feed_id = false;
+
+// FIXME: kludge, needs proper implementation
+var _reload_feedlist_after_view = false;
 
 function catchup_callback() {
        if (xmlhttp_rpc.readyState == 4) {
@@ -47,7 +54,13 @@ function article_callback() {
                if (typeof correctPNG != 'undefined') {
                        correctPNG();
                }
-               update_all_counters();
+
+               if (_reload_feedlist_after_view) {
+                       setTimeout('updateFeedList(false, false)', 50);                 
+                       _reload_feedlist_after_view = false;
+               } else {
+                       update_all_counters();
+               }
        }
 }
 
@@ -56,6 +69,8 @@ function view(id, feed_id, skip_history) {
        try {
                debug("loading article: " + id + "/" + feed_id);
 
+               active_real_feed_id = feed_id;
+
                if (!skip_history) {
                        history_push("ARTICLE:" + id + ":" + feed_id);
                }
@@ -427,4 +442,50 @@ function labelFromSearch(search, search_mode, match_on, feed_id, is_cat) {
 
 }
 
+function editArticleTags(id, feed_id) {
+       _tag_active_post_id = id;
+       _tag_active_feed_id = feed_id;
+       displayDlg('editArticleTags', id);
+}
+
+
+function tag_saved_callback() {
+       if (xmlhttp_rpc.readyState == 4) {
+               try {
+                       debug("in tag_saved_callback");
+
+                       closeInfoBox();
+                       notify("");
+
+                       if (tagsAreDisplayed()) {
+                               _reload_feedlist_after_view = true;
+                       }
+
+                       if (active_post_id == _tag_active_post_id) {
+                               debug("reloading current article");
+                               view(_tag_active_post_id, _tag_active_feed_id);                 
+                       } 
+
+               } catch (e) {
+                       exception_error("catchup_callback", e);
+               }
+       }
+}
+
+function editTagsSave() {
+
+       if (!xmlhttp_ready(xmlhttp_rpc)) {
+               printLockingError();
+       }
+
+       notify("Saving article tags...");
 
+       var form = document.forms["tag_edit_form"];
+
+       var query = Form.serialize("tag_edit_form");
+
+       xmlhttp_rpc.open("GET", "backend.php?op=rpc&subop=setArticleTags&" + query, true);                      
+       xmlhttp_rpc.onreadystatechange=tag_saved_callback;
+       xmlhttp_rpc.send(null);
+
+}