summaryrefslogtreecommitdiff
path: root/modules/tag/models
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2011-08-11 22:04:20 -0700
committerTim Almdal <tnalmdal@shaw.ca>2011-08-11 22:04:21 -0700
commit933a34986dbca248f388e8aa3c3aea4a6d71a94b (patch)
tree42251d934b3b257652f8b1658d5343d3f8759fab /modules/tag/models
parentb78f87cb80c1ee4b8608508cb8a9bf8be71c511d (diff)
Patch for tickets #1428 and #1760
Create the concept of a Photo_Display_Context. If the user is browsing a dynamic album (i.e. tags) and chooses to look at an image in that album. The display of the image happens correctly, but the 'next' and 'previous' buttons are no longer consistent. When one of these is clicked, Gallery will open the adjacent image in the actuall album, not the dynamic album.
Diffstat (limited to 'modules/tag/models')
-rw-r--r--modules/tag/models/tag.php38
1 files changed, 21 insertions, 17 deletions
diff --git a/modules/tag/models/tag.php b/modules/tag/models/tag.php
index bb79e707..a7150df8 100644
--- a/modules/tag/models/tag.php
+++ b/modules/tag/models/tag.php
@@ -33,35 +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);
- if ($type) {
- $model->where("items.type", "=", $type);
- }
- return $model->find_all($limit, $offset);
+ ->where("items_tags.tag_id", "=", $this->id)
+ ->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();
}
/**