summaryrefslogtreecommitdiff
path: root/modules/gallery/libraries/Theme_View.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/libraries/Theme_View.php')
-rw-r--r--modules/gallery/libraries/Theme_View.php30
1 files changed, 22 insertions, 8 deletions
diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php
index 986fc8a2..fbc58258 100644
--- a/modules/gallery/libraries/Theme_View.php
+++ b/modules/gallery/libraries/Theme_View.php
@@ -58,23 +58,37 @@ class Theme_View_Core extends Gallery_View {
}
/**
- * Proportion of the current thumb_size's to default
+ * Proportion of the current thumb_size's to default.
+ *
+ * Themes can optionally use the $dimension parameter to choose which of the album's
+ * children will be used to determine the proportion. If set, the proportion will be
+ * calculated based on the child item with the largest width or height.
+ *
* @param object Item_Model (optional) check the proportions for this item
+ * @param int (optional) minimum thumbnail width
+ * @param string (optional) "width" or "height"
* @return int
*/
- public function thumb_proportion($item=null) {
- // If the item is an album with children, grab the first item in that album instead. We're
+ public function thumb_proportion($item=null, $minimum_size=0, $dimension=null) {
+ if (!in_array($dimension, array("height", "width"))) {
+ $dimension = null;
+ }
+
+ // If the item is an album with children, grab an item from that album instead. We're
// interested in the size of the thumbnails in this album, not the thumbnail of the
// album itself.
if ($item && $item->is_album() && $item->children_count()) {
- $item = $item->children(1)->current();
+ $orderBy = (is_null($dimension)) ? array()
+ : array("thumb_".$dimension => "desc");
+
+ $item = $item->children(1, null, array(), $orderBy)->current();
}
// By default we have a globally fixed thumbnail size In core code, we just return a fixed
// proportion based on the global thumbnail size, but since modules can override that, we
// return the actual proportions when we have them.
if ($item && $item->has_thumb()) {
- return max($item->thumb_width, $item->thumb_height) / 200;
+ return max($item->thumb_width, $item->thumb_height, $minimum_size) / 200;
} else {
// @TODO change the 200 to a theme supplied value when and if we come up with an
// API to allow the theme to set defaults.
@@ -89,7 +103,7 @@ class Theme_View_Core extends Gallery_View {
public function siblings($limit=null, $offset=null) {
return call_user_func_array(
$this->siblings_callback[0],
- array_merge($this->siblings_callback[1], array($offset, $limit)));
+ array_merge($this->siblings_callback[1], array($limit, $offset)));
}
public function tag() {
@@ -239,7 +253,7 @@ class Theme_View_Core extends Gallery_View {
continue;
}
$helper_class = "{$module->name}_theme";
- if (method_exists($helper_class, $function)) {
+ if (class_exists($helper_class) && method_exists($helper_class, $function)) {
$blocks[] = call_user_func_array(
array($helper_class, $function),
array_merge(array($this), $args));
@@ -247,7 +261,7 @@ class Theme_View_Core extends Gallery_View {
}
$helper_class = theme::$site_theme_name . "_theme";
- if (method_exists($helper_class, $function)) {
+ if (class_exists($helper_class) && method_exists($helper_class, $function)) {
$blocks[] = call_user_func_array(
array($helper_class, $function),
array_merge(array($this), $args));