summaryrefslogtreecommitdiff
path: root/modules/tag/models
diff options
context:
space:
mode:
authorNathan Kinkade <nath@nkinka.de>2011-09-28 20:39:05 +0000
committerNathan Kinkade <nath@nkinka.de>2011-09-28 20:39:05 +0000
commit47456c0de8a408bca9b5a02a0fbc835ff1c01a68 (patch)
treedca2ead5e7159b28aa323465a363f81813f75acd /modules/tag/models
parentd8dffba94277c2179a59eb72d6927a5bdb879648 (diff)
parentdfbfe090168ee4ed44e2c8208e79d3fe40f90437 (diff)
Manually fixed a merge conflict after pulling.
Diffstat (limited to 'modules/tag/models')
-rw-r--r--modules/tag/models/tag.php37
1 files changed, 20 insertions, 17 deletions
diff --git a/modules/tag/models/tag.php b/modules/tag/models/tag.php
index 3dd71d8d..9ce091a2 100644
--- a/modules/tag/models/tag.php
+++ b/modules/tag/models/tag.php
@@ -33,36 +33,39 @@ class Tag_Model_Core extends ORM {
* Return all viewable items associated with this tag.
* @param integer $limit number of rows to limit result to
* @param integer $offset offset in result to start returning rows from
- * @param string $type the type of item (album, photo)
+ * @param string $where an array of arrays, each compatible with ORM::where()
* @return ORM_Iterator
*/
- public function items($limit=null, $offset=null, $type=null) {
- $model = ORM::factory("item")
+ public function items($limit=null, $offset=null, $where=array()) {
+ if (is_scalar($where)) {
+ // backwards compatibility
+ $where = array(array("items.type", "=", $where));
+ }
+ return ORM::factory("item")
->viewable()
->join("items_tags", "items.id", "items_tags.item_id")
->where("items_tags.tag_id", "=", $this->id)
- ->order_by("captured", "DESC");
- if ($type) {
- $model->where("items.type", "=", $type);
- }
- return $model->find_all($limit, $offset);
+ ->merge_where($where)
+ ->order_by("items.id")
+ ->find_all($limit, $offset);
}
/**
* Return the count of all viewable items associated with this tag.
- * @param string $type the type of item (album, photo)
+ * @param string $where an array of arrays, each compatible with ORM::where()
* @return integer
*/
- public function items_count($type=null) {
- $model = ORM::factory("item")
+ public function items_count($where=array()) {
+ if (is_scalar($where)) {
+ // backwards compatibility
+ $where = array(array("items.type", "=", $where));
+ }
+ return $model = ORM::factory("item")
->viewable()
->join("items_tags", "items.id", "items_tags.item_id")
- ->where("items_tags.tag_id", "=", $this->id);
-
- if ($type) {
- $model->where("items.type", "=", $type);
- }
- return $model->count_all();
+ ->where("items_tags.tag_id", "=", $this->id)
+ ->merge_where($where)
+ ->count_all();
}
/**