diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2011-08-11 22:11:24 -0700 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2011-08-11 22:11:24 -0700 |
commit | c92d34a86b0515363f790056293cea2b0a738782 (patch) | |
tree | 9d5b794e434d26ef7ee50281b3ebee716e3327a5 /modules/tag/helpers | |
parent | a5b1972bbe9676479886ca94bb23f09407a87561 (diff) | |
parent | 933a34986dbca248f388e8aa3c3aea4a6d71a94b (diff) |
Merge branch 'displayContext' into display_context_compressed
Conflicts:
modules/gallery/controllers/movies.php
modules/gallery/controllers/photos.php
modules/tag/controllers/tag.php
Diffstat (limited to 'modules/tag/helpers')
-rw-r--r-- | modules/tag/helpers/tag.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php index c21104ee..83a00080 100644 --- a/modules/tag/helpers/tag.php +++ b/modules/tag/helpers/tag.php @@ -136,4 +136,23 @@ class tag_Core { // extremely rare case. db::build()->delete("tags")->where("count", "=", 0)->execute(); } + + /** + * Find the position of the given item in the tag collection. The resulting + * value is 1-indexed, so the first child in the album is at position 1. + * + * @param Tag_Model $tag + * @param Item_Model $item + * @param array $where an array of arrays, each compatible with ORM::where() + */ + static function get_position($tag, $item, $where=array()) { + return ORM::factory("item") + ->viewable() + ->join("items_tags", "items.id", "items_tags.item_id") + ->where("items_tags.tag_id", "=", $tag->id) + ->where("items.id", "<=", $item->id) + ->merge_where($where) + ->order_by("items.id") + ->count_all(); + } }
\ No newline at end of file |