From 336632fea0a955d74099cd169b3178c01f250ff5 Mon Sep 17 00:00:00 2001 From: Joe7 Date: Mon, 3 Jan 2011 13:21:54 +0100 Subject: Keep view counters of all item types accurate Added common increment_view_count() func in item model for reuse --- modules/gallery/models/item.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'modules/gallery/models') diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index fc5c3ff9..d4df0a78 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -1078,6 +1078,16 @@ class Item_Model_Core extends ORM_MPTT { return $data; } + /** + * Increments the view counter of this item + * We can't use math in ORM or the query builder, so do this by hand. It's important + * that we do this with math, otherwise concurrent accesses will damage accuracy. + */ + public function increment_view_count() { + db::query("UPDATE {items} SET `view_count` = `view_count` + 1 WHERE `id` = $this->id") + ->execute(); + } + private function _cache_buster($path) { return "?m=" . (string)(file_exists($path) ? filemtime($path) : 0); } -- cgit v1.2.3 From 7ce902d373ac67d2267a886c18238eb53dd98093 Mon Sep 17 00:00:00 2001 From: Joe7 Date: Mon, 3 Jan 2011 15:14:32 +0100 Subject: Removed accidental whitespace --- modules/gallery/models/item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gallery/models') diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index d4df0a78..7ddcb4c2 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -1087,7 +1087,7 @@ class Item_Model_Core extends ORM_MPTT { db::query("UPDATE {items} SET `view_count` = `view_count` + 1 WHERE `id` = $this->id") ->execute(); } - + private function _cache_buster($path) { return "?m=" . (string)(file_exists($path) ? filemtime($path) : 0); } -- cgit v1.2.3 From e2b0f92007eb9ef2fad994c9f8957df0bfcbeccf Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 5 Jan 2011 21:05:20 -0800 Subject: Keep Item_Model::scale_dimensions from upscaling. Fixes #1579. --- modules/gallery/models/item.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'modules/gallery/models') diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 7ddcb4c2..88a444b4 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -653,7 +653,7 @@ class Item_Model_Core extends ORM_MPTT { /** * Calculate the largest width/height that fits inside the given maximum, while preserving the - * aspect ratio. + * aspect ratio. Don't upscale. * @param int $max Maximum size of the largest dimension * @return array */ @@ -661,6 +661,10 @@ class Item_Model_Core extends ORM_MPTT { $width = $this->thumb_width; $height = $this->thumb_height; + if ($width <= $max && $height <= $max) { + return array($height, $width); + } + if ($height) { if (isset($max)) { if ($width > $height) { -- cgit v1.2.3