diff options
-rw-r--r-- | .build_number | 2 | ||||
-rw-r--r-- | modules/gallery/libraries/Admin_View.php | 34 | ||||
-rw-r--r-- | modules/gallery/libraries/Theme_View.php | 26 | ||||
-rw-r--r-- | themes/wind/views/page.html.php | 2 |
4 files changed, 53 insertions, 11 deletions
diff --git a/.build_number b/.build_number index 99b6a886..0dbee161 100644 --- a/.build_number +++ b/.build_number @@ -3,4 +3,4 @@ ; process. You don't need to edit it. In fact.. ; ; DO NOT EDIT THIS FILE BY HAND! -build_number=391 +build_number=394 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() { diff --git a/themes/wind/views/page.html.php b/themes/wind/views/page.html.php index 1bb329df..0ae41ea7 100644 --- a/themes/wind/views/page.html.php +++ b/themes/wind/views/page.html.php @@ -24,7 +24,7 @@ <link rel="apple-touch-icon-precomposed" href="<?= url::file(module::get_var("gallery", "apple_touch_icon_url")) ?>" /> <? if ($theme->page_type == "collection"): ?> - <? if (($thumb_proportion = $theme->thumb_proportion($theme->item())) != 1): ?> + <? if (($thumb_proportion = $theme->thumb_proportion($theme->item(), 100, "width")) != 1): ?> <? $new_width = round($thumb_proportion * 213) ?> <? $new_height = round($thumb_proportion * 240) ?> <style type="text/css"> |