summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/gallery/libraries/Admin_View.php34
-rw-r--r--modules/gallery/libraries/Theme_View.php26
2 files changed, 51 insertions, 9 deletions
diff --git a/modules/gallery/libraries/Admin_View.php b/modules/gallery/libraries/Admin_View.php
index 62645d18..ba348d7a 100644
--- a/modules/gallery/libraries/Admin_View.php
+++ b/modules/gallery/libraries/Admin_View.php
@@ -93,7 +93,28 @@ class Admin_View_Core extends Gallery_View {
case "body_attributes":
case "html_attributes":
$blocks = array();
+ if (method_exists("gallery_theme", $function)) {
+ switch (count($args)) {
+ case 0:
+ $blocks[] = gallery_theme::$function($this);
+ break;
+ case 1:
+ $blocks[] = gallery_theme::$function($this, $args[0]);
+ break;
+ case 2:
+ $blocks[] = gallery_theme::$function($this, $args[0], $args[1]);
+ break;
+ default:
+ $blocks[] = call_user_func_array(
+ array("gallery_theme", $function),
+ array_merge(array($this), $args));
+ }
+ }
+
foreach (module::active() as $module) {
+ if ($module->name == "gallery") {
+ continue;
+ }
$helper_class = "{$module->name}_theme";
if (class_exists($helper_class) && method_exists($helper_class, $function)) {
$blocks[] = call_user_func_array(
@@ -102,15 +123,22 @@ class Admin_View_Core extends Gallery_View {
}
}
+ $helper_class = theme::$admin_theme_name . "_theme";
+ if (class_exists($helper_class) && method_exists($helper_class, $function)) {
+ $blocks[] = call_user_func_array(
+ array($helper_class, $function),
+ array_merge(array($this), $args));
+ }
+
if (Session::instance()->get("debug")) {
- if ($function != "admin_head") {
+ if ($function != "admin_head" && $function != "body_attributes") {
array_unshift(
- $blocks, "<div class=\"g-annotated-theme-block g-annotated-theme-block_$function\">" .
+ $blocks,
+ "<div class=\"g-annotated-theme-block g-annotated-theme-block_$function g-clear-fix\">" .
"<div class=\"title\">$function</div>");
$blocks[] = "</div>";
}
}
-
return implode("\n", $blocks);
default:
diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php
index 0a4c96e1..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() {