From d62a3b6349e5bd5c7bf860e5c5a8a27b7aa1d89b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 7 Dec 2006 10:27:34 +0100 Subject: [PATCH] add tag dropbox to tag editor --- functions.php | 10 ++++++++++ modules/backend-rpc.php | 2 +- modules/popup-dialog.php | 29 +++++++++++++++++++++++++++-- viewfeed.js | 25 +++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 3 deletions(-) diff --git a/functions.php b/functions.php index 84b863e7..5fe75c28 100644 --- a/functions.php +++ b/functions.php @@ -3039,4 +3039,14 @@ return $tags; } + function trim_value(&$value) { + $value = trim($value); + } + + function trim_array($array) { + $tmp = $array; + array_walk($tmp, 'trim_value'); + return $tmp; + } + ?> diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index 3cba704e..1a019af5 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -210,7 +210,7 @@ $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"); diff --git a/modules/popup-dialog.php b/modules/popup-dialog.php index a1ead2b0..40f4df8a 100644 --- a/modules/popup-dialog.php +++ b/modules/popup-dialog.php @@ -283,9 +283,34 @@ $tags_str = join(", ", $tags); - print ""; + print ""; + + print ""; + + print ""; + + print ""; - print ""; + $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 ""; + + print ""; + + print "
Add existing tag:"; + + print_select("found_tags", '', $found_tags, "onchange=\"javascript:editTagsInsert()\""); + + print "
"; print ""; diff --git a/viewfeed.js b/viewfeed.js index 5f338e46..d89cac34 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -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"); + } +} -- 2.39.2