]> git.wh0rd.org - tt-rss.git/commitdiff
add tag dropbox to tag editor
authorAndrew Dolgov <fox@madoka.spb.ru>
Thu, 7 Dec 2006 09:27:34 +0000 (10:27 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Thu, 7 Dec 2006 09:27:34 +0000 (10:27 +0100)
functions.php
modules/backend-rpc.php
modules/popup-dialog.php
viewfeed.js

index 84b863e700952c7182b71cbb05b2812300626d4c..5fe75c2883f9e9fd602edbf1d2352c87ef9790c8 100644 (file)
                return $tags;
        }
 
+       function trim_value(&$value) {
+               $value = trim($value);
+       }       
+
+       function trim_array($array) {
+               $tmp = $array;
+               array_walk($tmp, 'trim_value');
+               return $tmp;
+       }
+
 ?>
index 3cba704e3ee099d89202bf767a6d51db56c0ab00..1a019af5ba8828a83b1c98567b7f355cb566f921 100644 (file)
                        $id = db_escape_string($_GET["id"]);
                        $tags_str = db_escape_string($_GET["tags_str"]);
 
-                       $tags = split(",", $tags_str);
+                       $tags = array_unique(trim_array(split(",", $tags_str)));
 
                        db_query($link, "BEGIN");
 
index a1ead2b00e400af2dfc8f4a2388d23db3f8f2cda..40f4df8a23c9505532e22c1666cade6176223840 100644 (file)
 
                        $tags_str = join(", ", $tags);
 
-                       print "<input type=\"hidden\" name=\"id\" value=\"$param\">";
+                       print "<table width='100%'>";
+
+                       print "<tr><td colspan='2'><input type=\"hidden\" name=\"id\" value=\"$param\"></td></tr>";
+
+                       print "<tr><td colspan='2'><textarea rows='4' class='iedit' name='tags_str'>$tags_str</textarea></td></tr>";
+
+                       print "<tr><td>Add existing tag:</td>";
 
-                       print "<textarea rows='4' class='iedit' name='tags_str'>$tags_str</textarea>";
+                       $result = db_query($link, "SELECT DISTINCT tag_name FROM ttrss_tags 
+                               WHERE owner_uid = '".$_SESSION["uid"]."' ORDER BY tag_name");
+
+                       $found_tags = array();
+
+                       array_push($found_tags, '');
+
+                       while ($line = db_fetch_assoc($result)) {
+                               array_push($found_tags, $line["tag_name"]);
+                       }
+
+                       print "<td align='right'>";
+
+                       print_select("found_tags", '', $found_tags, "onchange=\"javascript:editTagsInsert()\"");
+
+                       print "</td>";
+
+                       print "</tr>";
+
+                       print "</table>";
 
                        print "</form>";
 
index 5f338e46ede76372e46b37a6b83bfcddf1d5a526..d89cac347eb7bce680f4da4c845cfd107abfdde5 100644 (file)
@@ -489,3 +489,28 @@ function editTagsSave() {
        xmlhttp_rpc.send(null);
 
 }
+
+function editTagsInsert() {
+       try {
+
+               var form = document.forms["tag_edit_form"];
+
+               var found_tags = form.found_tags;
+               var tags_str = form.tags_str;
+
+               var tag = found_tags[found_tags.selectedIndex].value;
+
+               if (tags_str.value.length > 0 && 
+                               tags_str.value.lastIndexOf(", ") != tags_str.value.length - 2) {
+
+                       tags_str.value = tags_str.value + ", ";
+               }
+
+               tags_str.value = tags_str.value + tag + ", ";
+
+               found_tags.selectedIndex = 0;
+               
+       } catch (e) {
+               exception_error(e, "editTagsInsert");
+       }
+}