summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-05-02 19:11:22 +0000
committerBharat Mediratta <bharat@menalto.com>2009-05-02 19:11:22 +0000
commit486517fac560a7b9552d2e79624e369d2833ac4a (patch)
tree138fa48830765c581f23041ac62e3737b63f6d80
parentd0b8fbef1dc681ff4f8dcafd8ced56e7c5c40f13 (diff)
Clean up API to be organized around the functionality it provides, not the feature its provided for.
-rw-r--r--core/models/item.php27
-rw-r--r--modules/organize/helpers/organize_task.php2
2 files changed, 15 insertions, 14 deletions
diff --git a/core/models/item.php b/core/models/item.php
index 0d5e6e11..d7a233cc 100644
--- a/core/models/item.php
+++ b/core/models/item.php
@@ -159,7 +159,7 @@ class Item_Model extends ORM_MPTT {
function make_album_cover() {
$parent = $this->parent();
access::required("edit", $parent);
-
+
$parent->album_cover_item_id = $this->is_photo() ? $this->id : $this->album_cover_item_id;
$parent->thumb_dirty = 1;
$parent->save();
@@ -168,7 +168,7 @@ class Item_Model extends ORM_MPTT {
function remove_album_cover() {
@unlink($this->thumb_path());
-
+
// @todo change the album cover to some other random image inside the album
$this->album_cover_item_id = null;
$this->thumb_dirty = 1;
@@ -307,7 +307,7 @@ class Item_Model extends ORM_MPTT {
}
parent::__set($column, $value);
}
-
+
/**
* @see ORM::save()
*/
@@ -360,16 +360,16 @@ class Item_Model extends ORM_MPTT {
* Return an <img> tag for the thumbnail.
* @param array $extra_attrs Extra attributes to add to the img tag
* @param int (optional) $max Maximum size of the thumbnail (default: null)
- * @param boolean (optional) $micro_thumb Center vertically (default: false)
+ * @param boolean (optional) $center_vertically Center vertically (default: false)
* @return string
*/
- public function thumb_tag($extra_attrs=array(), $max=null, $micro_thumb=false) {
- list ($height, $width) = $this->adjust_thumb_size($max);
- if ($micro_thumb && $max) {
+ public function thumb_tag($extra_attrs=array(), $max=null, $center_vertically=false) {
+ list ($height, $width) = $this->scale_dimensions($max);
+ if ($center_vertically && $max) {
// The constant is divide by 2 to calculate the file and 10 to convert to em
$margin_top = ($max - $height) / 20;
$extra_attrs["style"] = "margin-top: {$margin_top}em";
- $extra_attrs["title"] = $this->title;
+ $extra_attrs["title"] = $this->title;
}
$attrs = array_merge($extra_attrs,
array(
@@ -383,11 +383,12 @@ class Item_Model extends ORM_MPTT {
}
/**
- * Adjust the height based on the input maximum size or zero if not thumbnail
- * @param int $max Maximum size of the thumbnail
+ * Calculate the largest width/height that fits inside the given maximum, while preserving the
+ * aspect ratio.
+ * @param int $max Maximum size of the largest dimension
* @return array
*/
- public function adjust_thumb_size($max) {
+ public function scale_dimensions($max) {
$width = $this->thumb_width;
$height = $this->thumb_height;
@@ -409,7 +410,7 @@ class Item_Model extends ORM_MPTT {
}
return array($height, $width);
}
-
+
/**
* Return an <img> tag for the resize.
* @param array $extra_attrs Extra attributes to add to the img tag
@@ -429,7 +430,7 @@ class Item_Model extends ORM_MPTT {
/**
* Return a flowplayer <script> tag for movies
* @param array $extra_attrs
- * @return string
+ * @return string
*/
public function movie_tag($extra_attrs) {
$attrs = array_merge($extra_attrs,
diff --git a/modules/organize/helpers/organize_task.php b/modules/organize/helpers/organize_task.php
index 6c34692d..a3f9b717 100644
--- a/modules/organize/helpers/organize_task.php
+++ b/modules/organize/helpers/organize_task.php
@@ -97,7 +97,7 @@ class organize_task_Core {
$parent->thumb_height = $item->thumb_height;
$parent->save();
}
- list ($height, $width) = $item->adjust_thumb_size(90);
+ list ($height, $width) = $item->scale_dimensions(90);
$margin_top = (90 - $height) / 20;
return array("src" => $item->thumb_url() . "?rnd=" . rand(),