summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjhilden <jakobhilden@gmail.com>2009-06-16 22:39:08 -0400
committerjhilden <jakobhilden@gmail.com>2009-06-16 22:39:08 -0400
commita5b314e7e63a67c347bd595f77a114dab5341432 (patch)
tree11a107e8c2ee60da1003057e373eb5af9def54d1
parent0054caa9a8b0984ad8fdce002ad2947c5d75cd06 (diff)
parent7ad5e9ee2c6c912932e8c38c992c9b1194c9107a (diff)
Merge branch 'master' of git@github.com:gallery/gallery3
-rw-r--r--index.php5
-rw-r--r--lib/gallery.show_full_size.js76
-rw-r--r--modules/comment/views/admin_block_recent_comments.html.php4
-rw-r--r--modules/gallery/helpers/gallery_menu.php11
-rw-r--r--modules/gallery/helpers/gallery_theme.php10
-rw-r--r--modules/gallery/js/fullsize.js78
-rw-r--r--modules/gallery/libraries/Theme_View.php41
-rw-r--r--themes/default/views/photo.html.php16
8 files changed, 111 insertions, 130 deletions
diff --git a/index.php b/index.php
index 50c08886..7def7d16 100644
--- a/index.php
+++ b/index.php
@@ -65,7 +65,10 @@ if (PHP_SAPI == "cli") {
break;
default:
- print "Usage: php index.php { upgrade | package | test }\n";
+ print "To upgrade:\n php index.php upgrade\n\n\n";
+ print "Developer-only features:\n ** CAUTION! THESE FEATURES -WILL- DAMAGE YOUR INSTALL **\n";
+ print " php index.php package # create new installer files\n";
+ print " php index.php test # run unit tests\n";
exit(1);
}
} else {
diff --git a/lib/gallery.show_full_size.js b/lib/gallery.show_full_size.js
new file mode 100644
index 00000000..b2895c23
--- /dev/null
+++ b/lib/gallery.show_full_size.js
@@ -0,0 +1,76 @@
+/**
+ * @todo Move inline CSS out to external style sheet (theme style sheet)
+ */
+var show_full_size = function(image_url, image_width, image_height) {
+ /*
+ * Calculate the size of the image panel based on the size of the image and the size of the
+ * window. Scale the image so the entire panel fits in the view port.
+ */
+ function _auto_fit(imageWidth, imageHeight) {
+ // ui-dialog gives a padding of 2 pixels
+ var windowWidth = $(window).width() - 10;
+ var windowHeight = $(window).height() - 10;
+
+ /* If the width is greater then scale the image width first */
+ if (imageWidth > windowWidth) {
+ var ratio = windowWidth / imageWidth;
+ imageWidth *= ratio;
+ imageHeight *= ratio;
+ }
+ /* after scaling the width, check that the height fits */
+ if (imageHeight > windowHeight) {
+ var ratio = windowHeight / imageHeight;
+ imageWidth *= ratio;
+ imageHeight *= ratio;
+ }
+
+ // handle the case where the calculation is almost zero (2.14e-14)
+ return {
+ top: ((windowHeight - imageHeight) / 2).toFixed(2),
+ left: ((windowWidth - imageWidth) / 2).toFixed(2),
+ width: imageWidth.toFixed(2),
+ height: imageHeight.toFixed(2)
+ };
+ }
+
+ var width = $(document).width();
+ var height = $(document).height();
+
+ $("body").append('<div id="gFullsizeOverlay" class="ui-dialog-overlay" ' +
+ 'style="border: none; margin: 0; padding: 0; background-color: #000; ' +
+ 'position: absolute; top: 0px; left: 0px; ' +
+ 'width: ' + width + 'px; height: ' + height + 'px; opacity: 0.7; filter: alpha(opacity=70);' +
+ '-moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; ' +
+ '-moz-background-inline-policy: -moz-initial; z-index: 1001;"> </div>');
+
+ var image_size = _auto_fit(image_width, image_height);
+
+ $("body").append('<div id="gFullsize" class="ui-dialog ui-widget" ' +
+ 'style="overflow: hidden; display: block; ' +
+ 'position: absolute; z-index: 1002; outline-color: -moz-use-text-color; ' +
+ 'outline-style: none; outline-width: 0px; ' +
+ 'height: ' + image_size.height + 'px; ' +
+ 'width: ' + image_size.width + 'px; ' +
+ 'top: ' + image_size.top + 'px; left: ' + image_size.left + 'px;">' +
+ '<img id="gFullSizeImage" src="' + image_url + '"' +
+ 'height="' + image_size.height + '" width="' + image_size.width + '"/></div>');
+
+ $("#gFullsize").append('<span id="gFullsizeClose" class="fg-button ui-icon ui-state-default ' +
+ 'ui-icon-closethick ui-corner-all" style="z-index: 1003; position: absolute; ' +
+ 'right: 1em; top: 1em;"></span>');
+ $("#gFullsizeClose").click(function() {
+ $("#gFullsizeOverlay*").remove();
+ $("#gFullsize").remove();
+ });
+ $(window).resize(function() {
+ $("#gFullsizeOverlay").width($(document).width());
+ $("#gFullsizeOverlay").height($(document).height());
+ image_size = _auto_fit(image_width, image_height);
+ $("#gFullsize").height(image_size.height);
+ $("#gFullsize").width(image_size.width);
+ $("#gFullsize").css("top", image_size.top);
+ $("#gFullsize").css("left", image_size.left);
+ $("#gFullSizeImage").height(image_size.height);
+ $("#gFullSizeImage").width(image_size.width);
+ });
+};
diff --git a/modules/comment/views/admin_block_recent_comments.html.php b/modules/comment/views/admin_block_recent_comments.html.php
index 8b9634c5..edaa19ae 100644
--- a/modules/comment/views/admin_block_recent_comments.html.php
+++ b/modules/comment/views/admin_block_recent_comments.html.php
@@ -8,8 +8,8 @@
width="32"
height="32" />
<?= gallery::date_time($comment->created) ?>
- <?= t("<a href=#>%author_name</a> said <em>%comment_text</em>",
- array("author_name" => p::clean($comment->author_name()),
+ <?= t('<a href="#">%author_name</a> said <em>%comment_text</em>',
+ array("author_name" => p::clean($comment->author_name()),
"comment_text" => text::limit_words(p::clean($comment->text), 50))); ?>
</li>
<? endforeach ?>
diff --git a/modules/gallery/helpers/gallery_menu.php b/modules/gallery/helpers/gallery_menu.php
index 4499e50a..fb0234b1 100644
--- a/modules/gallery/helpers/gallery_menu.php
+++ b/modules/gallery/helpers/gallery_menu.php
@@ -96,12 +96,11 @@ class gallery_menu_Core {
static function photo($menu, $theme) {
if (access::can("view_full", $theme->item())) {
- $menu
- ->append(Menu::factory("link")
- ->id("fullsize")
- ->label(t("View full size"))
- ->url("#")
- ->css_class("gFullSizeLink"));
+ $menu->append(Menu::factory("link")
+ ->id("fullsize")
+ ->label(t("View full size"))
+ ->url($theme->item()->file_url())
+ ->css_class("gFullSizeLink"));
}
}
diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php
index c28c9040..44c1d3f1 100644
--- a/modules/gallery/helpers/gallery_theme.php
+++ b/modules/gallery/helpers/gallery_theme.php
@@ -31,16 +31,6 @@ class gallery_theme_Core {
url::file("modules/gallery/css/quick.css") . "\" />";
$buf .= html::script("modules/gallery/js/quick.js");
}
- if ($theme->page_type == "photo" && access::can("view_full", $theme->item())) {
- $buf .= "<script type=\"text/javascript\" >" .
- " var fullsize_detail = { " .
- " close: \"" . url::file("modules/gallery/images/ico-close.png") . "\", " .
- " url: \"" . $theme->item()->file_url() . "\", " .
- " width: " . $theme->item()->width . ", " .
- " height: " . $theme->item()->height . "};" .
- "</script>";
- $buf .= html::script("modules/gallery/js/fullsize.js");
- }
if (module::is_active("rss")) {
if ($item = $theme->item()) {
diff --git a/modules/gallery/js/fullsize.js b/modules/gallery/js/fullsize.js
deleted file mode 100644
index f95dc428..00000000
--- a/modules/gallery/js/fullsize.js
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * @todo Move inline CSS out to external style sheet (theme style sheet)
- */
-$(document).ready(function() {
- $(".gFullSizeLink").click(function() {
- var width = $(document).width();
- var height = $(document).height();
-
- $("body").append('<div id="gFullsizeOverlay" class="ui-dialog-overlay" ' +
- 'style="border: none; margin: 0; padding: 0; background-color: #000; ' +
- 'position: absolute; top: 0px; left: 0px; ' +
- 'width: ' + width + 'px; height: ' + height + 'px; opacity: 0.7; filter: alpha(opacity=70);' +
- '-moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; ' +
- '-moz-background-inline-policy: -moz-initial; z-index: 1001;"> </div>');
-
- var image_size = _auto_fit(fullsize_detail.width, fullsize_detail.height);
-
- $("body").append('<div id="gFullsize" class="ui-dialog ui-widget" ' +
- 'style="overflow: hidden; display: block; ' +
- 'position: absolute; z-index: 1002; outline-color: -moz-use-text-color; ' +
- 'outline-style: none; outline-width: 0px; ' +
- 'height: ' + image_size.height + 'px; ' +
- 'width: ' + image_size.width + 'px; ' +
- 'top: ' + image_size.top + 'px; left: ' + image_size.left + 'px;">' +
- '<img id="gFullSizeImage" src="' + fullsize_detail.url + '"' +
- 'height="' + image_size.height + '" width="' + image_size.width + '"/></div>');
-
- $("#gFullsize").append('<span id="gFullsizeClose" class="fg-button ui-icon ui-state-default ' +
- 'ui-icon-closethick ui-corner-all" style="z-index: 1003; position: absolute; ' +
- 'right: 1em; top: 1em;"></span>');
- $("#gFullsizeClose").click(function() {
- $("#gFullsizeOverlay*").remove();
- $("#gFullsize").remove();
- });
- $(window).resize(function() {
- $("#gFullsizeOverlay").width($(document).width());
- $("#gFullsizeOverlay").height($(document).height());
- image_size = _auto_fit(fullsize_detail.width, fullsize_detail.height);
- $("#gFullsize").height(image_size.height);
- $("#gFullsize").width(image_size.width);
- $("#gFullsize").css("top", image_size.top);
- $("#gFullsize").css("left", image_size.left);
- $("#gFullSizeImage").height(image_size.height);
- $("#gFullSizeImage").width(image_size.width);
- });
- });
-});
-
-/*
- * Calculate the size of the image panel based on the size of the image and the size of the
- * window. Scale the image so the entire panel fits in the view port.
- */
-function _auto_fit(imageWidth, imageHeight) {
- // ui-dialog gives a padding of 2 pixels
- var windowWidth = $(window).width() - 10;
- var windowHeight = $(window).height() - 10;
-
- /* If the width is greater then scale the image width first */
- if (imageWidth > windowWidth) {
- var ratio = windowWidth / imageWidth;
- imageWidth *= ratio;
- imageHeight *= ratio;
- }
- /* after scaling the width, check that the height fits */
- if (imageHeight > windowHeight) {
- var ratio = windowHeight / imageHeight;
- imageWidth *= ratio;
- imageHeight *= ratio;
- }
-
- // handle the case where the calculation is almost zero (2.14e-14)
- return {
- top: ((windowHeight - imageHeight) / 2).toFixed(2),
- left: ((windowWidth - imageWidth) / 2).toFixed(2),
- width: imageWidth.toFixed(2),
- height: imageHeight.toFixed(2)
- };
-}
diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php
index 484b93b0..31c2faa7 100644
--- a/modules/gallery/libraries/Theme_View.php
+++ b/modules/gallery/libraries/Theme_View.php
@@ -109,50 +109,27 @@ class Theme_View_Core extends View {
}
public function album_menu() {
- $menu = Menu::factory("root");
- gallery_menu::album($menu, $this);
-
- foreach (module::active() as $module) {
- if ($module->name == "gallery") {
- continue;
- }
- $class = "{$module->name}_menu";
- if (method_exists($class, "album")) {
- call_user_func_array(array($class, "album"), array(&$menu, $this));
- }
- }
-
- print $menu;
+ $this->_menu("album");
}
public function tag_menu() {
- $menu = Menu::factory("root");
- gallery_menu::tag($menu, $this);
-
- foreach (module::active() as $module) {
- if ($module->name == "gallery") {
- continue;
- }
- $class = "{$module->name}_menu";
- if (method_exists($class, "tag")) {
- call_user_func_array(array($class, "tag"), array(&$menu, $this));
- }
- }
-
- print $menu;
+ $this->_menu("tag");
}
public function photo_menu() {
- $menu = Menu::factory("root");
- gallery_menu::photo($menu, $this);
+ $this->_menu("photo");
+ }
+ private function _menu($type) {
+ $menu = Menu::factory("root");
+ call_user_func_array(array("gallery_menu", $type), array(&$menu, $this));
foreach (module::active() as $module) {
if ($module->name == "gallery") {
continue;
}
$class = "{$module->name}_menu";
- if (method_exists($class, "photo")) {
- call_user_func_array(array($class, "photo"), array(&$menu, $this));
+ if (method_exists($class, $type)) {
+ call_user_func_array(array($class, $type), array(&$menu, $this));
}
}
diff --git a/themes/default/views/photo.html.php b/themes/default/views/photo.html.php
index cc4cc750..1c3b81a7 100644
--- a/themes/default/views/photo.html.php
+++ b/themes/default/views/photo.html.php
@@ -1,4 +1,18 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
+
+<? if (access::can("view_full", $theme->item())): ?>
+<!-- Use javascript to show the full size as an overlay on the current page -->
+<script src="<?= url::file("lib/gallery.show_full_size.js") ?>" type="text/javascript"></script>
+<script>
+ $(document).ready(function() {
+ $(".gFullSizeLink").click(function() {
+ show_full_size("<?= $theme->item()->file_url() ?>", "<?= $theme->item()->width ?>", "<?= $theme->item()->height ?>");
+ return false;
+ });
+ });
+</script>
+<? endif ?>
+
<div id="gItem">
<?= $theme->photo_top() ?>
@@ -27,7 +41,7 @@
<div id="gPhoto">
<?= $theme->resize_top($item) ?>
<? if (access::can("view_full", $item)): ?>
- <a href="#" class="gFullSizeLink" title="<?= t("View full size") ?>">
+ <a href="<?= $item->file_url() ?>" class="gFullSizeLink" title="<?= t("View full size") ?>">
<? endif ?>
<?= $item->resize_img(array("id" => "gPhotoId-{$item->id}", "class" => "gResize")) ?>
<? if (access::can("view_full", $item)): ?>