diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-05-22 16:14:42 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-05-22 16:14:42 +0000 |
commit | ee0bd765b6792d42eefda46f63a72e66ddd0a93a (patch) | |
tree | e1e5549d05af15266b3102a13637102c2e1da520 /modules/tag/helpers | |
parent | 0451351f5127d17e3fbb0084659538c683a19333 (diff) |
Implement a basic tag management interface with the organize drawer
Diffstat (limited to 'modules/tag/helpers')
-rw-r--r-- | modules/tag/helpers/tag.php | 25 | ||||
-rw-r--r-- | modules/tag/helpers/tag_event.php | 5 |
2 files changed, 29 insertions, 1 deletions
diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php index ba67fbbd..50c4b41a 100644 --- a/modules/tag/helpers/tag.php +++ b/modules/tag/helpers/tag.php @@ -104,4 +104,27 @@ class tag_Core { $group->submit("")->value(t("Delete Tag")); return $form; } -} + + static function get_organize_form($itemids) { + $tagPane = new Forge("tags/__FUNCTION__", "", "post", + array("id" => "gEditTags", "ref" => "organize")); + $tagPane->hidden("item")->value(implode("|", $itemids)); + $item_count = count($itemids); + $ids = implode(", ", $itemids); + $tags = Database::instance()->query( + "SELECT t.name, COUNT(it.item_id) as count + FROM {items_tags} it, {tags} t + WHERE it.tag_id = t.id + AND it.item_id in($ids) + GROUP BY it.tag_id + ORDER BY t.name ASC"); + $taglist = array(); + foreach ($tags as $tag) { + $taglist[] = $tag->name . ($item_count > $tag->count ? "*" : ""); + } + $taglist = implode("; ", $taglist); + $tagPane->textarea("tags")->label(t("Tags"))->value($taglist); + + return $tagPane; + } +}
\ No newline at end of file diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php index 735422b5..2a08cb6d 100644 --- a/modules/tag/helpers/tag_event.php +++ b/modules/tag/helpers/tag_event.php @@ -59,4 +59,9 @@ class tag_event_Core { "SELECT `tag_id` from {items_tags} WHERE `item_id` = $item->id)"); $db->delete("items_tags", array("item_id" => "$item->id")); } + + static function organize_form_creation($event_parms) { + $event_parms->panes[] = array("label" => t("Manage Tags"), + "content" => tag::get_organize_form($event_parms->itemids)); + } } |