diff options
22 files changed, 364 insertions, 360 deletions
@@ -21,7 +21,8 @@ define("IN_PRODUCTION", true); // Gallery requires PHP 5.2+ -version_compare(PHP_VERSION, "5.2.3", "<") and exit("Gallery requires PHP 5.2.3 or newer."); +version_compare(PHP_VERSION, "5.2.3", "<") and + exit("Gallery requires PHP 5.2.3 or newer (you're using " . PHP_VERSION . ")"); // Gallery requires short_tags to be on !ini_get("short_open_tag") and exit("Gallery requires short_open_tag to be on."); diff --git a/lib/gallery.common.js b/lib/gallery.common.js index 1eaa6db2..7e6acad9 100644 --- a/lib/gallery.common.js +++ b/lib/gallery.common.js @@ -1,19 +1,13 @@ -/** - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -(function () { - $.fn.showMessage = function(message) { +(function ($) { + $.fn.gallery_show_message = function(message) { return this.each(function(i){ $(this).effect("highlight", {"color": "white"}, 3000); $(this).animate({opacity: 1.0}, 6000); }); }; -})(jQuery); -// Vertically align a block element's content -(function () { - $.fn.vAlign = function(container) { + // Vertically align a block element's content + $.fn.gallery_valign = function(container) { return this.each(function(i){ if (container == null) { container = 'div'; @@ -26,11 +20,9 @@ $(el).css('margin-top', nh); }); }; -})(jQuery); -// Get the viewport size -(function () { - $.getViewportSize = function() { + // Get the viewport size + $.gallery_get_viewport_size = function() { return { width : function() { return $(window).width(); @@ -40,4 +32,24 @@ } }; }; + + /** + * Toggle the processing indicator, both large and small + * @param elementID Target ID, including #, to apply .gLoadingSize + */ + $.fn.gallery_show_loading = function() { + return this.each(function(i){ + var size; + switch ($(this).attr("id")) { + case "#gDialog": + case "#gPanel": + size = "Large"; + break; + default: + size = "Small"; + break; + } + $(this).toggleClass("gLoading" + size); + }); + }; })(jQuery); diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js index 74c2f20e..51ebb21a 100644 --- a/lib/gallery.dialog.js +++ b/lib/gallery.dialog.js @@ -1,140 +1,136 @@ -/** - * Fire openDialog() and prevent links from opening - * @see openDialog() - */ -function handleDialogEvent(event) { - var target = event.currentTarget; - if (!target) { - target = event.srcElement; - } - openDialog(target); - event.preventDefault(); -} +(function($) { + $.widget("ui.gallery_dialog", { + _init: function() { + var self = this; + this.element.click(function(event){ + event.preventDefault(); + var element = event.currentTarget; + var sHref = $(element).attr("href"); + var sTitle = $(element).attr("title"); + var eDialog = '<div id="gDialog"></div>'; -function ajaxify_dialog() { - $("#gDialog form").ajaxForm({ - dataType: "json", - success: function(data) { - if (data.form) { - $("#gDialog form").replaceWith(data.form); - ajaxify_dialog(); - on_form_loaded(); - if (typeof data.reset == 'function') { - eval(data.reset + '()'); - } - } - if (data.result == "success") { - if (data.location) { - window.location = data.location; - } else { - window.location.reload(); - } - } - } - }); -}; + $("body").append(eDialog); + + if (!self.options.close) { + self.options.close = self.close_dialog; + } + $("#gDialog").dialog(self.options); -/** - * Display modal dialogs, populate dialog with trigger link's href - * @requires ui.core - * @requires ui.draggable - * @requires ui.resizable - * @requires ui.dialog - * @see handleDialogEvent() - * @see showLoading() - */ -function openDialog(element) { - var sHref = $(element).attr("href"); - var sTitle = $(element).attr("title"); - var eDialog = '<div id="gDialog"></div>'; - var dialogWidth; + $("#gDialog").gallery_show_loading(); - $("body").append(eDialog); + $.get(sHref, function(data) { + $("#gDialog").html(data).gallery_show_loading(); - $("#gDialog").dialog({ - autoOpen: false, - autoResize: true, - modal: true, - resizable: false, - close: closeDialog - }); + if ($("#gDialog form").length) { + self._trigger("form_loaded", null, $("#gDialog form")); + } + self._layout(); - showLoading("#gDialog"); + $("#gDialog").dialog("open"); + // Remove titlebar for progress dialogs or set title + if ($("#gDialog #gProgress").length) { + $(".ui-dialog-titlebar").remove(); + } else if ($("#gDialog h1").length) { + $("#gDialog").dialog('option', 'title', $("#gDialog h1:eq(0)").html()); + } else if ($("#gDialog fieldset legend").length) { + $("#gDialog").dialog('option', 'title', $("#gDialog fieldset legend:eq(0)").html()); + } - $.get(sHref, function(data) { - showLoading("#gDialog"); - $("#gDialog").html(data); - var dialogHeight = $("#gDialog").height(); - var cssWidth = new String($("#gDialog form").css("width")); - var childWidth = cssWidth.replace(/[^0-9]/g,""); - if ($("#gDialog iframe").length) { - dialogWidth = $(window).width() - 100; - // Set the iframe width and height - $("#gDialog iframe").width("100%"); - $("#gDialog iframe").height($(window).height() - 100); - } else if (childWidth == "" || childWidth > 300) { - dialogWidth = 500; - } - $("#gDialog").dialog('option', 'width', dialogWidth); + if ($("#gDialog form").length) { + self._ajaxify_dialog(); + } + }); + $("#gDialog").dialog("option", "self", self); + return false; + }); + }, - on_form_loaded(); + destroy: function() { + if ($("#gDialog form").length) { + this._trigger("form_closing", null, $("#gDialog form")); + } + this._trigger("dialog_closing", null, $("#gDialog")); - $("#gDialog").dialog("open"); - // Remove titlebar for progress dialogs or set title - if ($("#gDialog #gProgress").length) { - $(".ui-dialog-titlebar").remove(); - } else if ($("#gDialog h1").length) { - $("#gDialog").dialog('option', 'title', $("#gDialog h1:eq(0)").html()); - } else if ($("#gDialog fieldset legend").length) { - $("#gDialog").dialog('option', 'title', $("#gDialog fieldset legend:eq(0)").html()); - } + $("#gDialog").dialog("destroy").remove(); + }, + + _layout: function() { + var dialogWidth; + var dialogHeight = $("#gDialog").height(); + var cssWidth = new String($("#gDialog form").css("width")); + var childWidth = cssWidth.replace(/[^0-9]/g,""); + if ($("#gDialog iframe").length) { + dialogWidth = $(window).width() - 100; + // Set the iframe width and height + $("#gDialog iframe").width("100%").height($(window).height() - 100); + } else if (childWidth == "" || childWidth > 300) { + dialogWidth = 500; + } + $("#gDialog").dialog('option', 'width', dialogWidth); + }, + + form_loaded: function event(event, ui) { + // Should be defined (and localized) in the theme + MSG_CANCEL = MSG_CANCEL || 'Cancel'; + var eCancel = '<a href="#" class="gCancel">' + MSG_CANCEL + '</a>'; + if ($("#gDialog .submit").length) { + $("#gDialog .submit").addClass("ui-state-default ui-corner-all"); + $("#gDialog .submit").parent().append(eCancel); + $("#gDialog .gCancel").click(function(event) { + $("gDialog").dialog("close"); + event.preventDefault(); + }); + } + $("#gDialog .ui-state-default").hover( + function() { + $(this).addClass("ui-state-hover"); + }, + function() { + $(this).removeClass("ui-state-hover"); + } + ); + }, - ajaxify_dialog(); - }); - return false; -} + close_dialog: function (event, ui) { + var self = $("#gDialog").dialog("option", "self"); + self.destroy(); + }, -function on_form_loaded() { - // Should be defined (and localized) in the theme - MSG_CANCEL = MSG_CANCEL || 'Cancel'; - var eCancel = '<a href="javascript: closeDialog()" class="gCancel">' + MSG_CANCEL + '</a>'; - if ($("#gDialog .submit").length) { - $("#gDialog .submit").addClass("ui-state-default ui-corner-all"); - $("#gDialog .submit").parent().append(eCancel); - } - $("#gDialog").dialog("option", "form", $("#gDialog form")); - $("#gDialog .ui-state-default").hover( - function() { - $(this).addClass("ui-state-hover"); - }, - function() { - $(this).removeClass("ui-state-hover"); - } - ); -} + _ajaxify_dialog: function() { + var self = this; + $("#gDialog form").ajaxForm({ + dataType: "json", + success: function(data) { + if (data.form) { + $("#gDialog form").replaceWith(data.form); + self._ajaxify_dialog(); + self._trigger("form_loaded", null, $("#gDialog form")); + if (typeof data.reset == 'function') { + eval(data.reset + '()'); + } + } + if (data.result == "success") { + if (data.location) { + window.location = data.location; + } else { + window.location.reload(); + } + } + } + }); + }, -function closeDialog() { - var form = $("#gDialog").dialog("option", "form"); - if (form != null) { - $("#gDialog").dialog("option", "form").trigger("form_closing"); - } - $("#gDialog").dialog("destroy").remove(); -} + form_closing: function(event, ui) {}, + dialog_closing: function(event, ui) {} + }); -/** - * Toggle the processing indicator, both large and small - * @param elementID Target ID, including #, to apply .gLoadingSize - */ -function showLoading(elementID) { - var size; - switch (elementID) { - case "#gDialog": - case "#gPanel": - size = "Large"; - break; - default: - size = "Small"; - break; - } - $(elementID).toggleClass("gLoading" + size); -} + $.extend($.ui.gallery_dialog, { + defaults: { + autoOpen: false, + autoResize: true, + modal: true, + resizable: false, + position: "center" + } + }); +})(jQuery); diff --git a/lib/gallery.panel.js b/lib/gallery.panel.js index 022e4878..e0bf4259 100644 --- a/lib/gallery.panel.js +++ b/lib/gallery.panel.js @@ -1,62 +1,58 @@ -/** - * Fire togglePanel() and prevent links from opening - * @see togglePanel() - */ -function handlePanelEvent(event) { - togglePanel(event.currentTarget); - event.preventDefault(); -} +(function($) { + $.widget("ui.gallery_panel", { + _init: function() { + var self = this; + this.element.click(function(event) { + event.preventDefault(); + var element = event.currentTarget; + var parent = $(element).parent().parent(); + var sHref = $(element).attr("href"); + var parentClass = $(parent).attr("class"); + var ePanel = "<tr id=\"gPanel\"><td colspan=\"6\"></td></tr>"; -function togglePanel(element, on_success) { - var parent = $(element).parent().parent(); - var sHref = $(element).attr("href"); - var parentClass = $(parent).attr("class"); - var ePanel = "<tr id=\"gPanel\"><td colspan=\"6\"></td></tr>"; + if ($("#gPanel").length) { + $("#gPanel").slideUp("slow").remove(); + if ($(element).attr("orig_text")) { + $(element).children(".gButtonText").text($(element).attr("orig_text")); + } + } else { + $(parent).after(ePanel); + $("#gPanel td").html(sHref); + $.get(sHref, function(data) { + $("#gPanel td").html(data); + self._ajaxify_panel(); + if ($(element).attr("open_text")) { + $(element).attr("orig_text", $(element).children(".gButtonText").text()); + $(element).children(".gButtonText").text($(element).attr("open_text")); + } + $("#gPanel").addClass(parentClass).show().slideDown("slow"); + }); + } + return false; + }); + }, - if ($("#gPanel").length) { - $("#gPanel").slideUp("slow"); - $("#gPanel *").remove(); - $("#gPanel").remove(); - if ($(element).attr("orig_text")) { - $(element).children(".gButtonText").text($(element).attr("orig_text")); - } - //togglePanel(element, on_success); - } else { - $(parent).after(ePanel); - //showLoading("#here"); - $("#gPanel td").html(sHref); - $("#gPanel").addClass(parentClass).show().slideDown("slow"); - $.get(sHref, function(data) { - $("#gPanel td").html(data); - ajaxify_panel = function() { - $("#gPanel td form").ajaxForm({ - dataType: "json", - success: function(data) { - if (data.form) { - $("#gPanel td form").replaceWith(data.form); - ajaxify_panel(); - } - if (data.result == "success") { - if (on_success) { - on_success(); - } else if (data.location) { - window.location = data.location; - } else { - window.location.reload(); - } - } - } - }); - if ($("#gPanel td").hasClass("gLoadingLarge")) { - showLoading("#gPanel td"); - } - }; - ajaxify_panel(); - if ($(element).attr("open_text")) { - $(element).attr("orig_text", $(element).children(".gButtonText").text()); - $(element).children(".gButtonText").text($(element).attr("open_text")); - } - }); - } - return false; -} + _ajaxify_panel: function () { + var self = this; + $("#gPanel td form").ajaxForm({ + dataType: "json", + success: function(data) { + if (data.form) { + $("#gPanel td form").replaceWith(data.form); + self._ajaxify_panel(); + } + if (data.result == "success") { + self._trigger("success", null, {}); + if (data.location) { + window.location = data.location; + } else { + window.location.reload(); + } + } + } + }); + }, + + success: function(event, ui) {} + }); + })(jQuery); diff --git a/lib/gallery.show_full_size.js b/lib/gallery.show_full_size.js index 8b271db9..c32195f6 100644 --- a/lib/gallery.show_full_size.js +++ b/lib/gallery.show_full_size.js @@ -1,76 +1,78 @@ -/** - * @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; +(function($) { + /** + * @todo Move inline CSS out to external style sheet (theme style sheet) + */ + $.gallery_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; - } + /* 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: Number((windowHeight - imageHeight) / 2), - left: Number((windowWidth - imageWidth) / 2), - width: Number(imageWidth), - height: Number(imageHeight) - }; - } + // handle the case where the calculation is almost zero (2.14e-14) + return { + top: Number((windowHeight - imageHeight) / 2), + left: Number((windowWidth - imageWidth) / 2), + width: Number(imageWidth), + height: Number(imageHeight) + }; + } - var width = $(document).width(); - var height = $(document).height(); + 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>'); + $("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); + 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>'); + $("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); - }); -}; + $("#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()) + .height($(document).height()); + image_size = _auto_fit(image_width, image_height); + $("#gFullsize").height(image_size.height) + .width(image_size.width) + .css("top", image_size.top) + .css("left", image_size.left); + $("#gFullSizeImage").height(image_size.height) + .width(image_size.width); + }); + }; +})(jQuery); diff --git a/modules/akismet/views/admin_akismet.html.php b/modules/akismet/views/admin_akismet.html.php index cc5e3cfc..410902a5 100644 --- a/modules/akismet/views/admin_akismet.html.php +++ b/modules/akismet/views/admin_akismet.html.php @@ -3,8 +3,8 @@ <h1> <?= t("Akismet Spam Filtering") ?> </h1> <p> <?= t("Akismet is a free, automated spam filtering service. In order to use it, you need to sign up for a <a href=\"%api_key_url\">Wordpress.com API Key</a>, which is also free. Your comments will be automatically relayed to <a href=\"%akismet_url\">Akismet.com</a> where they'll be scanned for spam. Spam messages will be flagged accordingly and hidden from your vistors until you approve or delete them.", - array("api_key_url" => "http://wordpress.com/api-keys", - "akismet_url" => "http://akismet.com")) ?> + array("api_key_url" => "http://wordpress.com/api-keys", + "akismet_url" => "http://akismet.com")) ?> </p> <? if ($valid_key): ?> diff --git a/modules/gallery/helpers/gallery_rss.php b/modules/gallery/helpers/gallery_rss.php index 7daf6170..8e887368 100644 --- a/modules/gallery/helpers/gallery_rss.php +++ b/modules/gallery/helpers/gallery_rss.php @@ -50,8 +50,9 @@ class gallery_rss_Core { $feed->children = $item ->viewable() - ->descendants($limit, $offset, "photo"); - $feed->max_pages = ceil($item->viewable()->descendants_count("photo") / $limit); + ->descendants($limit, $offset, array("type" => "photo")); + $feed->max_pages = ceil( + $item->viewable()->descendants_count(array("type" => "photo")) / $limit); $feed->title = p::purify($item->title); $feed->link = url::abs_site("albums/{$item->id}"); $feed->description = nl2br(p::purify($item->description)); diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index 8fe1c768..69c5a091 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -47,6 +47,7 @@ class gallery_theme_Core { } static function admin_head($theme) { + $theme->script("gallery.panel.js"); $session = Session::instance(); if ($session->get("debug")) { $theme->css("debug.css"); diff --git a/modules/gallery/libraries/ORM_MPTT.php b/modules/gallery/libraries/ORM_MPTT.php index 1917d738..a7defba9 100644 --- a/modules/gallery/libraries/ORM_MPTT.php +++ b/modules/gallery/libraries/ORM_MPTT.php @@ -146,69 +146,62 @@ class ORM_MPTT_Core extends ORM { * @chainable * @param integer SQL limit * @param integer SQL offset + * @param array additional where clauses * @param array orderby * @return array ORM */ - function children($limit=null, $offset=0, $orderby=null) { - $this->where("parent_id", $this->id); - if (empty($orderby)) { - $this->orderby("id", "ASC"); - } else { - $this->orderby($orderby); - } - return $this->find_all($limit, $offset); + function children($limit=null, $offset=0, $where=array(), $orderby=array("id" => "ASC")) { + return $this + ->where("parent_id", $this->id) + ->where($where) + ->orderby($orderby) + ->find_all($limit, $offset); } /** * Return all of the children of this node, ordered by id. * * @chainable - * @param integer SQL limit - * @param integer SQL offset + * @param array additional where clauses * @return array ORM */ - function children_count() { - return $this->where("parent_id", $this->id)->count_all(); + function children_count($where=array()) { + return $this + ->where($where) + ->where("parent_id", $this->id) + ->count_all(); } /** - * Return all of the children of the specified type, ordered by id. + * Return all of the decendents of the specified type, ordered by id. * * @param integer SQL limit * @param integer SQL offset - * @param string type to return + * @param array additional where clauses * @param array orderby * @return object ORM_Iterator */ - function descendants($limit=null, $offset=0, $type=null, $orderby=null) { - $this->where("left_ptr >", $this->left_ptr) - ->where("right_ptr <=", $this->right_ptr); - if ($type) { - $this->where("type", $type); - } - - if (empty($orderby)) { - $this->orderby("id", "ASC"); - } else { - $this->orderby($orderby); - } - - return $this->find_all($limit, $offset); + function descendants($limit=null, $offset=0, $where=array(), $orderby=array("id" => "ASC")) { + return $this + ->where("left_ptr >", $this->left_ptr) + ->where("right_ptr <=", $this->right_ptr) + ->where($where) + ->orderby($orderby) + ->find_all($limit, $offset); } /** * Return the count of all the children of the specified type. * - * @param string type to count + * @param array additional where clauses * @return integer child count */ - function descendants_count($type=null) { - $this->where("left_ptr >", $this->left_ptr) - ->where("right_ptr <=", $this->right_ptr); - if ($type) { - $this->where("type", $type); - } - return $this->count_all(); + function descendants_count($where=array()) { + return $this + ->where("left_ptr >", $this->left_ptr) + ->where("right_ptr <=", $this->right_ptr) + ->where($where) + ->count_all(); } /** diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index f3e6b8f3..c4b9826f 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -521,26 +521,38 @@ class Item_Model extends ORM_MPTT { } /** - * Return all of the children of this node, ordered by the defined sort order. + * Return all of the children of this album. Unless you specify a specific sort order, the + * results will be ordered by this album's sort order. * * @chainable * @param integer SQL limit * @param integer SQL offset + * @param array additional where clauses + * @param array orderby * @return array ORM */ - function children($limit=null, $offset=0) { - return parent::children($limit, $offset, array($this->sort_column => $this->sort_order)); + function children($limit=null, $offset=0, $where=array(), $orderby=null) { + if (empty($orderby)) { + $orderby = array($this->sort_column => $this->sort_order); + } + return parent::children($limit, $offset, $where, $orderby); } /** - * Return all of the children of the specified type, ordered by the defined sort order. + * Return the children of this album, and all of it's sub-albums. Unless you specify a specific + * sort order, the results will be ordered by this album's sort order. Note that this + * album's sort order is imposed on all sub-albums, regardless of their sort order. + * + * @chainable * @param integer SQL limit * @param integer SQL offset - * @param string type to return + * @param array additional where clauses * @return object ORM_Iterator */ - function descendants($limit=null, $offset=0, $type=null) { - return parent::descendants($limit, $offset, $type, - array($this->sort_column => $this->sort_order)); + function descendants($limit=null, $offset=0, $where=array(), $orderby=null) { + if (empty($orderby)) { + $orderby = array($this->sort_column => $this->sort_order); + } + return parent::descendants($limit, $offset, $where, $orderby); } } diff --git a/modules/gallery/tests/ORM_MPTT_Test.php b/modules/gallery/tests/ORM_MPTT_Test.php index 943810c3..f77f1f34 100644 --- a/modules/gallery/tests/ORM_MPTT_Test.php +++ b/modules/gallery/tests/ORM_MPTT_Test.php @@ -177,8 +177,8 @@ class ORM_MPTT_Test extends Unit_Test_Case { $parent->reload(); $this->assert_equal(3, $parent->descendants()->count()); - $this->assert_equal(2, $parent->descendants(null, 0, "photo")->count()); - $this->assert_equal(1, $parent->descendants(null, 0, "album")->count()); + $this->assert_equal(2, $parent->descendants(null, 0, array("type" => "photo"))->count()); + $this->assert_equal(1, $parent->descendants(null, 0, array("type" => "album"))->count()); } public function descendant_limit_test() { @@ -215,7 +215,7 @@ class ORM_MPTT_Test extends Unit_Test_Case { $parent->reload(); $this->assert_equal(3, $parent->descendants_count()); - $this->assert_equal(2, $parent->descendants_count("photo")); - $this->assert_equal(1, $parent->descendants_count("album")); + $this->assert_equal(2, $parent->descendants_count(array("type" => "photo"))); + $this->assert_equal(1, $parent->descendants_count(array("type" => "album"))); } } diff --git a/modules/gallery/views/after_install.html.php b/modules/gallery/views/after_install.html.php index e4842163..bfce46f0 100644 --- a/modules/gallery/views/after_install.html.php +++ b/modules/gallery/views/after_install.html.php @@ -16,7 +16,7 @@ title="<?= t("Edit Your Profile") ?>" id="gAfterInstallChangePasswordLink" class="gButtonLink ui-state-default ui-corners-all"><?= t("Change Password Now") ?></a> <script> - $("#gAfterInstallChangePasswordLink").bind("click", handleDialogEvent); + $("#gAfterInstallChangePasswordLink").gallery_dialog(); </script> </p> diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js index f10cbcc9..31657d3a 100644 --- a/modules/organize/js/organize.js +++ b/modules/organize/js/organize.js @@ -391,7 +391,7 @@ function organize_dialog_init() { $(".gBranchText").droppable(treeDroppable); $(".gBranchText").click(organizeOpenFolder); retrieveMicroThumbs(item_id); - //showLoading("#gDialog"); + //$.gallery_show_loading("#gDialog"); $("#gMicroThumbPanel").droppable(thumbDroppable); $("#gMicroThumbPanel").selectable(selectable); diff --git a/modules/organize/js/organize_init.js b/modules/organize/js/organize_init.js index ed036fdb..30bc78dd 100644 --- a/modules/organize/js/organize_init.js +++ b/modules/organize/js/organize_init.js @@ -17,7 +17,7 @@ $("document").ready(function() { zIndex: 75 }); - //showLoading("#gDialog"); + //$.gallery_show_loading("#gDialog"); $.get(href, function(data) { $("#gDialog").html(data); diff --git a/modules/server_add/js/server_add.js b/modules/server_add/js/server_add.js index 989555cc..3348de4b 100644 --- a/modules/server_add/js/server_add.js +++ b/modules/server_add/js/server_add.js @@ -4,11 +4,9 @@ function select_file(li) { $(li).toggleClass("selected"); if ($("#gServerAdd span.selected").length) { - $("#gServerAddAddButton").enable(true); - $("#gServerAddAddButton").removeClass("ui-state-disabled"); + $("#gServerAddAddButton").enable(true).removeClass("ui-state-disabled"); } else { - $("#gServerAddAddButton").enable(false); - $("#gServerAddAddButton").addClass("ui-state-disabled"); + $("#gServerAddAddButton").enable(false).addClass("ui-state-disabled"); } } diff --git a/modules/server_add/views/server_add_tree_dialog.html.php b/modules/server_add/views/server_add_tree_dialog.html.php index 21952849..5c5dfd0f 100644 --- a/modules/server_add/views/server_add_tree_dialog.html.php +++ b/modules/server_add/views/server_add_tree_dialog.html.php @@ -34,7 +34,7 @@ <?= t("Add") ?> </button> - <button class="ui-state-default ui-corner-all" onclick="closeDialog(); window.location.reload();"> + <button id="gServerCloseButton" class="ui-state-default ui-corner-all"> <?= t("Close") ?> </button> </span> @@ -48,6 +48,9 @@ progressbar("value", 0); $("#gProgress").slideDown("fast", function() { start_add() }); }); + $("#gServerCloseButton").click(function(event) { + $("#gDialog").dialog("close"); + }); }); </script> diff --git a/modules/tag/js/tag.js b/modules/tag/js/tag.js index 765c2a35..61ac73f4 100644 --- a/modules/tag/js/tag.js +++ b/modules/tag/js/tag.js @@ -23,7 +23,7 @@ function closeEditInPlaceForms() { $("#gRenameTagForm").parent().html($("#gRenameTagForm").parent().data("revert")); li.height(""); $(".gEditable", li).bind("click", editInPlace); - $(".gDialogLink", li).bind("click", handleDialogEvent); + $(".gDialogLink", li).gallery_dialog(); } } diff --git a/modules/user/helpers/user_theme.php b/modules/user/helpers/user_theme.php index c5351f8e..8de2d248 100644 --- a/modules/user/helpers/user_theme.php +++ b/modules/user/helpers/user_theme.php @@ -19,14 +19,10 @@ */ class user_theme_Core { static function header_top($theme) { - $view = new View("login.html"); - $view->user = user::active(); - return $view->render(); - } - - static function admin_head($theme) { - if (strpos(Router::$current_uri, "admin/users") !== false) { - $theme->script("gallery.panel.js"); + if ($theme->page_type != "login") { + $view = new View("login.html"); + $view->user = user::active(); + return $view->render(); } } } diff --git a/modules/user/views/admin_users.html.php b/modules/user/views/admin_users.html.php index 542b8b8b..9bd4c068 100644 --- a/modules/user/views/admin_users.html.php +++ b/modules/user/views/admin_users.html.php @@ -28,7 +28,7 @@ {}, function(data) { $("#group-" + group_id).html(data); - $("#group-" + group_id + " .gDialogLink").bind("click", handleDialogEvent); + $("#group-" + group_id + " .gDialogLink").gallery_dialog(); }); } diff --git a/themes/admin_default/js/ui.init.js b/themes/admin_default/js/ui.init.js index 3f062a27..e52f0c4c 100644 --- a/themes/admin_default/js/ui.init.js +++ b/themes/admin_default/js/ui.init.js @@ -1,5 +1,4 @@ $(document).ready(function(){ - // Initialize Superfish menus $("#gSiteAdminMenu ul.gMenu").addClass("sf-menu"); $("ul.gMenu").addClass("sf-menu"); @@ -15,23 +14,17 @@ $(document).ready(function(){ $("#gSiteAdminMenu").css("display", "block"); // Initialize status message effects - $("#gMessage li").showMessage(); + $("#gMessage li").gallery_show_message(); // Initialize modal dialogs - var dialogLinks = $(".gDialogLink"); - for (var i=0; i < dialogLinks.length; i++) { - $(dialogLinks[i]).bind("click", handleDialogEvent); - } + $(".gDialogLink").gallery_dialog(); // Initialize panels - var panelLinks = $(".gPanelLink"); - for (i=0; i<panelLinks.length; i++) { - $(panelLinks[i]).bind("click", handlePanelEvent); - } + $(".gPanelLink").gallery_panel(); if ($("#gPhotoStream").length) { // Vertically align thumbs in photostream - $(".gItem").vAlign(); + $(".gItem").gallery_valign(); } // Apply jQuery UI button css to submit inputs diff --git a/themes/default/js/ui.init.js b/themes/default/js/ui.init.js index b3c1d514..2fc0dc75 100644 --- a/themes/default/js/ui.init.js +++ b/themes/default/js/ui.init.js @@ -29,14 +29,11 @@ $(document).ready(function() { $("#gSiteMenu").css("display", "block"); // Initialize status message effects - $("#gMessage li").showMessage(); + $("#gMessage li").gallery_show_message(); // Initialize dialogs $("#gLoginLink").addClass("gDialogLink"); - var dialogLinks = $(".gDialogLink"); - for (var i=0; i < dialogLinks.length; i++) { - $(dialogLinks[i]).bind("click", handleDialogEvent); - } + $(".gDialogLink").gallery_dialog(); // Initialize view menu if ($("#gViewMenu").length) { @@ -55,7 +52,10 @@ $(document).ready(function() { // Album view only if ($("#gAlbumGrid").length) { // Vertical align thumbnails/metadata in album grid - $(".gItem").vAlign(); + $(".gItem").gallery_valign(); + $(".gQuick").ajaxStop(function(){ + $(".gItem").gallery_valign(); + }); } // Photo/Item item view only diff --git a/themes/default/views/photo.html.php b/themes/default/views/photo.html.php index cf8bebdd..453417dc 100644 --- a/themes/default/views/photo.html.php +++ b/themes/default/views/photo.html.php @@ -5,7 +5,7 @@ <script> $(document).ready(function() { $(".gFullSizeLink").click(function() { - show_full_size("<?= $theme->item()->file_url() ?>", "<?= $theme->item()->width ?>", "<?= $theme->item()->height ?>"); + $.gallery_show_full_size("<?= $theme->item()->file_url() ?>", "<?= $theme->item()->width ?>", "<?= $theme->item()->height ?>"); return false; }); }); |