]> git.wh0rd.org Git - tt-rss.git/commitdiff
rework assigning articles to tags
authorAndrew Dolgov <fox@bah.spb.su>
Fri, 23 Jan 2009 13:20:05 +0000 (14:20 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Fri, 23 Jan 2009 13:20:05 +0000 (14:20 +0100)
functions.php
modules/backend-rpc.php
tt-rss.css
viewfeed.js

index b4636927ccaee5f4914fc730b2e3b2118843bf82..2b81a10c5f60784c95bb85154e9ab1d06ace9658 100644 (file)
                                print "<div clear='both'>" . $line["title"] . "$entry_author</div>";
                        }
 
-                       $tags = get_article_tags($link, $id);
-       
-                       $tags_str = "";
-                       $tags_nolinks_str = "";
-                       $f_tags_str = "";
-
-                       $num_tags = 0;
-
-                       if ($_SESSION["theme"] == "3pane") {
-                               $tag_limit = 3;
-                       } else {
-                               $tag_limit = 6;
-                       }
-
-                       foreach ($tags as $tag) {
-                               $num_tags++;
-                               $tag_escaped = str_replace("'", "\\'", $tag);
-
-                               $tag_str = "<a href=\"javascript:viewfeed('$tag_escaped')\">$tag</a>, ";
-                               
-                               if ($num_tags == $tag_limit) {
-                                       $tags_str .= "&hellip;";
-                                       $tags_nolinks_str .= "&hellip;";
-
-                               } else if ($num_tags < $tag_limit) {
-                                       $tags_str .= $tag_str;
-                                       $tags_nolinks_str .= "$tag, ";
-                               }
-                               $f_tags_str .= $tag_str;
-                       }
-
-                       $tags_str = preg_replace("/, $/", "", $tags_str);
-                       $tags_nolinks_str = preg_replace("/, $/", "", $tags_nolinks_str);
-                       $f_tags_str = preg_replace("/, $/", "", $f_tags_str);
-
-                       $all_tags_div = "<span class='cdmAllTagsCtr'>&hellip;<div class='cdmAllTags'>All Tags: $f_tags_str</div></span>";
-                       $tags_str = preg_replace("/\.\.\.$/", "$all_tags_div", $tags_str);
+                       $tags_str = format_tags_string(get_article_tags($link, $id), $id);
 
                        if (!$entry_comments) $entry_comments = "&nbsp;"; # placeholder
 
-                       if (!$tags_str) $tags_str = '<span class="tagList">'.__('no tags').'</span>';
-                       if (!$tags_nolinks_str) $tags_nolinks_str = '<span class="tagList">'.__('no tags').'</span>';
-
                        print "<div style='float : right'>
                                        <img src='images/tag.png' class='tagsPic' alt='Tags' title='Tags'>";
 
                        if (!$zoom_mode) {
-                               print "$tags_str 
+                               print "<span id=\"ATSTR-$id\">$tags_str</span>
                                        <a title=\"".__('Edit tags for this article')."\" 
                                        href=\"javascript:editArticleTags($id, $feed_id)\">(+)</a>";
 
                                                style=\"cursor : pointer\" style=\"cursor : pointer\"
                                                onclick=\"zoomToArticle($id)\"
                                                alt='Zoom' title='".__('Show article summary in new window')."'>";
-                       } else {
-                               print "$tags_nolinks_str";
                        }
                        print "</div>";
                        print "<div clear='both'>$entry_comments</div>";
 
                        print "<div class=\"postContent\">";
 
-                       #print "<div id=\"allEntryTags\">".__('Tags:')." $f_tags_str</div>";
-
                        $article_content = sanitize_rss($link, $line["content"]);
 
                        if (get_pref($link, 'OPEN_LINKS_IN_NEW_WINDOW')) {
                                                alt='Zoom' 
                                                title='".__('Show article summary in new window')."'></span>";
 
-                                       $tags = get_article_tags($link, $id);
-
-                                       $tags_str = "";
-                                       $full_tags_str = "";
-                                       $num_tags = 0;
-
-                                       foreach ($tags as $tag) {
-                                               $num_tags++;
-                                               $full_tags_str .= "<a href=\"javascript:viewfeed('$tag')\">$tag</a>, "; 
-                                               if ($num_tags < 5) {
-                                                       $tags_str .= "<a href=\"javascript:viewfeed('$tag')\">$tag</a>, "; 
-                                               } else if ($num_tags == 5) {
-                                                       $tags_str .= "&hellip;";
-                                               }
-                                       }
-
-                                       $tags_str = preg_replace("/, $/", "", $tags_str);
-                                       $full_tags_str = preg_replace("/, $/", "", $full_tags_str);
-
-                                       $all_tags_div = "<span class='cdmAllTagsCtr'>&hellip;<div class='cdmAllTags'>All Tags: $full_tags_str</div></span>";
-
-                                       $tags_str = preg_replace("/\.\.\.$/", "$all_tags_div", $tags_str);
-
-
-                                       if ($tags_str == "") $tags_str = "no tags";
+                                       $tags_str = format_tags_string(get_article_tags($link, $id), $id);
 
 //                                     print "<img src='images/tag.png' class='markedPic'>";
 
                                        print "<span class='s1'>
-                                               <img class='tagsPic' src='images/tag.png' alt='Tags' 
-                                                       title='Tags'> $tags_str <a title=\"Edit tags for this article\" 
-                                                       href=\"javascript:editArticleTags($id, $feed_id, true)\">(+)</a>";
+                                               <img class='tagsPic' src='images/tag.png' alt='Tags' title='Tags'>
+                                               <span id=\"ATSTR-$id\">$tags_str</span>
+                                               <a title=\"".__('Edit tags for this article')."\" 
+                                               href=\"javascript:editArticleTags($id, $feed_id, true)\">(+)</a>";
 
                                        print "</span>";
 
                        }
                }
        }
+
+       function format_tags_string($tags, $id) {
+
+               $tags_str = "";
+               $tags_nolinks_str = "";
+
+               $num_tags = 0;
+
+               if ($_SESSION["theme"] == "3pane") {
+                       $tag_limit = 3;
+               } else {
+                       $tag_limit = 6;
+               }
+
+               $formatted_tags = array();
+
+               foreach ($tags as $tag) {
+                       $num_tags++;
+                       $tag_escaped = str_replace("'", "\\'", $tag);
+
+                       $tag_str = "<a href=\"javascript:viewfeed('$tag_escaped')\">$tag</a>";
+
+                       array_push($formatted_tags, $tag_str);
+                               
+                       if ($num_tags == $tag_limit) {
+                               break;
+                       }
+               }
+
+               $tags_str = implode(", ", $formatted_tags);
+
+               if ($num_tags < count($tags)) {
+                       $tags_str .= ", &hellip;";
+               }
+
+               if ($num_tags == 0) {
+                       $tags_str = __("no tags");
+               }
+
+               return $tags_str;
+
+       }
 ?>
index a6ab9340a2f3ee28cf4483ac06092e627cdc3995..b26304c2b79ec31dcb5c551e62ebfaa98a13466b 100644 (file)
                                                continue;
                                        }
 
-                                       print "<!-- $id : $int_id : $tag -->";
+//                                     print "<!-- $id : $int_id : $tag -->";
                                        
                                        if ($tag != '') {
                                                db_query($link, "INSERT INTO ttrss_tags 
 
                        db_query($link, "COMMIT");
 
+                       $tags_str = format_tags_string(get_article_tags($link, $id), $id);
+
                        print "<rpc-reply>
-                               <message>$id</message>
+                               <tags-str id=\"$id\"><![CDATA[$tags_str]]></tags-str>
                                </rpc-reply>";
 
                        return;
index 4bff63dae8d6d60890741f8e5f0b76cae185fe46..26c2729c6a736cd9b3da7141ed6a5958054e0428 100644 (file)
@@ -909,10 +909,6 @@ div.postHeader div.postDateRTL {
        float : right;
 }
 
-div.postReply span.tagList {
-       color : gray;
-}
-
 div.postHeader div {
        padding-bottom : 3px;
        font-size : 12px;
index a638cbe711be28a08b6b17729402d2534762c493..513350497460f0de0ad8f1e5564129d560600dab 100644 (file)
@@ -2,13 +2,6 @@ var active_post_id = false;
 var last_article_view = false;
 var active_real_feed_id = false;
 
-var _tag_active_post_id = false;
-var _tag_active_feed_id = false;
-var _tag_active_cdm = false;
-
-// FIXME: kludge, to restore scrollTop after tag editor terminates
-var _tag_cdm_scroll = false;
-
 // FIXME: kludges, needs proper implementation
 var _reload_feedlist_after_view = false;
 
@@ -233,15 +226,6 @@ function headlines_callback2(transport, feed_cur_page) {
                        debug("not in CDM mode or watchdog disabled");
                }
        
-               if (_tag_cdm_scroll) {
-                       try {
-                               document.getElementById("headlinesInnerContainer").scrollTop = _tag_cdm_scroll;
-                               _tag_cdm_scroll = false;
-                               debug("resetting headlinesInner scrollTop");
-       
-                       } catch (e) { }
-               }
-       
                _feed_cur_page = feed_cur_page;
                _infscroll_request_sent = 0;
 
@@ -1228,15 +1212,6 @@ function catchupSelection() {
 }
 
 function editArticleTags(id, feed_id, cdm_enabled) {
-       _tag_active_post_id = id;
-       _tag_active_feed_id = feed_id;
-       _tag_active_cdm = cdm_enabled;
-
-       cache_invalidate(id);
-
-       try {
-               _tag_cdm_scroll = document.getElementById("headlinesInnerContainer").scrollTop;
-       } catch (e) { }
        displayDlg('editArticleTags', id);
 }
 
@@ -1252,18 +1227,24 @@ function tag_saved_callback(transport) {
                        _reload_feedlist_after_view = true;
                }
 
-               if (!_tag_active_cdm) {
-                       if (active_post_id == _tag_active_post_id) {
-                               debug("reloading current article");
-                               view(_tag_active_post_id, _tag_active_feed_id);                 
+
+               if (transport.responseXML) {
+                       var tags_str = transport.responseXML.getElementsByTagName("tags-str")[0];
+                       
+                       if (tags_str) {
+                               var id = tags_str.getAttribute("id");
+
+                               if (id) {
+                                       var tags = document.getElementById("ATSTR-" + id);
+                                       if (tags) {
+                                               tags.innerHTML = tags_str.firstChild.nodeValue;
+                                       }
+                               }
                        }
-               } else {
-                       debug("reloading current feed");
-                       viewCurrentFeed();
                }
 
        } catch (e) {
-               exception_error("catchup_callback", e);
+               exception_error("tag_saved_callback", e);
        }
 }