diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-07-19 13:46:22 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-07-19 13:46:22 -0700 |
commit | 5ee2e3e02c5ce927e2ecf553549f443aa4356551 (patch) | |
tree | 2b9ef754e71c0362eb17f18414cfbe0446e8aac5 | |
parent | 788a458a11f04e47fe1c241463785d0f0b12cf3c (diff) |
Create tag::item_tags which returns all the tags for any one item.
-rw-r--r-- | modules/tag/helpers/tag.php | 19 | ||||
-rw-r--r-- | modules/tag/helpers/tag_search.php | 2 |
2 files changed, 20 insertions, 1 deletions
diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php index 7c4b56ba..ab5ee303 100644 --- a/modules/tag/helpers/tag.php +++ b/modules/tag/helpers/tag.php @@ -79,6 +79,25 @@ class tag_Core { } } + + /** + * Return all the tags for a given item. + * @return array + */ + static function item_tags($item) { + access::required("view", $item); + $tags = array(); + foreach (Database::instance() + ->select("name") + ->from("tags") + ->join("items_tags", "tags.id", "items_tags.tag_id", "left") + ->where("items_tags.item_id", $item->id) + ->get() as $row) { + $tags[] = $row->name; + } + return $tags; + } + static function get_add_form($item) { $form = new Forge("tags", "", "post", array("id" => "gAddTagForm")); $label = $item->is_album() ? diff --git a/modules/tag/helpers/tag_search.php b/modules/tag/helpers/tag_search.php index e14b9f4d..034b7af5 100644 --- a/modules/tag/helpers/tag_search.php +++ b/modules/tag/helpers/tag_search.php @@ -19,6 +19,6 @@ */ class tag_search_Core { static function item_index_data($item) { - return join(" ", tag::get_tags($item)); + return join(" ", tag::item_tags($item)); } } |