summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/gallery.dialog.js87
-rw-r--r--modules/comment/helpers/comment_installer.php13
-rw-r--r--modules/gallery/js/quick.js2
-rw-r--r--modules/gallery/views/after_install.html.php2
-rw-r--r--modules/search/helpers/search_event.php5
-rw-r--r--modules/tag/models/tag.php48
-rw-r--r--themes/default/views/movie.html.php29
7 files changed, 125 insertions, 61 deletions
diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js
index e3597eab..6c2993fd 100644
--- a/lib/gallery.dialog.js
+++ b/lib/gallery.dialog.js
@@ -2,56 +2,53 @@
$.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>';
-
- $("body").append(eDialog);
+ if (!self.options.immediate) {
+ this.element.click(function(event) {
+ event.preventDefault();
+ self._show($(event.currentTarget).attr("href"));
+ return false;
+ });
+ } else {
+ self._show(this.element.attr("href"));
+ }
+ },
- if (!self.options.close) {
- self.options.close = self.close_dialog;
- }
- $("#gDialog").dialog(self.options);
+ _show: function(sHref) {
+ var self = this;
+ var eDialog = '<div id="gDialog"></div>';
- $("#gDialog").gallery_show_loading();
+ $("body").append(eDialog);
- $.get(sHref, function(data) {
- $("#gDialog").html(data).gallery_show_loading();
+ if (!self.options.close) {
+ self.options.close = self.close_dialog;
+ }
+ $("#gDialog").dialog(self.options);
- if ($("#gDialog form").length) {
- self._trigger("form_loaded", null, $("#gDialog form"));
- }
- self._layout();
+ $("#gDialog").gallery_show_loading();
- $("#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) {
+ $("#gDialog").html(data).gallery_show_loading();
- if ($("#gDialog form").length) {
- self._ajaxify_dialog();
- }
- });
- $("#gDialog").dialog("option", "self", self);
- return false;
- });
- },
+ if ($("#gDialog form").length) {
+ self._trigger("form_loaded", null, $("#gDialog form"));
+ }
+ self._layout();
- 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();
+ if ($("#gDialog form").length) {
+ self._ajaxify_dialog();
+ }
+ });
+ $("#gDialog").dialog("option", "self", self);
},
_layout: function() {
@@ -97,7 +94,11 @@
close_dialog: function (event, ui) {
var self = $("#gDialog").dialog("option", "self");
- self.destroy();
+ if ($("#gDialog form").length) {
+ self._trigger("form_closing", null, $("#gDialog form"));
+ }
+ self._trigger("dialog_closing", null, $("#gDialog"));
+ $("#gDialog").dialog("destroy").remove();
},
_ajaxify_dialog: function() {
diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php
index f54913c3..edf2427c 100644
--- a/modules/comment/helpers/comment_installer.php
+++ b/modules/comment/helpers/comment_installer.php
@@ -52,8 +52,8 @@ class comment_installer {
}
static function upgrade($version) {
+ $db = Database::instance();
if ($version == 1) {
- $db = Database::instance();
$db->query("ALTER TABLE {comments} CHANGE `state` `state` varchar(15) default 'unpublished'");
module::set_version("comment", 2);
}
@@ -61,9 +61,16 @@ class comment_installer {
static function uninstall() {
$db = Database::instance();
- $sql = "SELECT `item_id` FROM {comments}";
- module::event("item_related_update_batch", $sql);
+ // Notify listeners that we're deleting some data. This is probably going to be very
+ // inefficient for large uninstalls, and we could make it better by doing things like passing
+ // a SQL fragment through so that the listeners could use subselects. But by using a single,
+ // simple event API we lighten the load on module developers.
+ foreach (ORM::factory("item")
+ ->join("comments", "items.id", "comments.item_id")
+ ->find_all() as $item) {
+ module::event("item_related_update", $item);
+ }
$db->query("DROP TABLE IF EXISTS {comments};");
}
}
diff --git a/modules/gallery/js/quick.js b/modules/gallery/js/quick.js
index fda6470f..dfa61c20 100644
--- a/modules/gallery/js/quick.js
+++ b/modules/gallery/js/quick.js
@@ -46,7 +46,7 @@ var quick_do = function(cont, pane, img) {
return false;
}
if (pane.hasClass("gDialogLink")) {
- openDialog(pane);
+ $(pane).gallery_dialog({immediate: 1});
} else {
img.css("opacity", "0.1");
cont.addClass("gLoadingLarge");
diff --git a/modules/gallery/views/after_install.html.php b/modules/gallery/views/after_install.html.php
index bfce46f0..41e600fb 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").gallery_dialog();
+ $("#gAfterInstallChangePasswordLink").gallery_dialog({immediate: true});
</script>
</p>
diff --git a/modules/search/helpers/search_event.php b/modules/search/helpers/search_event.php
index b65763af..836bbe15 100644
--- a/modules/search/helpers/search_event.php
+++ b/modules/search/helpers/search_event.php
@@ -35,9 +35,4 @@ class search_event_Core {
static function item_related_update($item) {
search::update($item);
}
-
- static function item_related_update_batch($sql) {
- $db = Database::instance();
- $db->query("UPDATE {search_records} SET `dirty` = 1 WHERE item_id IN ($sql)");
- }
}
diff --git a/modules/tag/models/tag.php b/modules/tag/models/tag.php
index e910a8ee..d9488e1c 100644
--- a/modules/tag/models/tag.php
+++ b/modules/tag/models/tag.php
@@ -54,4 +54,52 @@ class Tag_Model extends ORM {
}
return $model->count_all();
}
+
+ /**
+ * Overload ORM::save() to trigger an item_related_update event for all items that are related
+ * to this tag. Since items can be added or removed as part of the save, we need to trigger an
+ * event for the union of all related items before and after the save.
+ */
+ public function save() {
+ $db = Database::instance();
+ $related_item_ids = array();
+ foreach ($db->getwhere("items_tags", array("tag_id" => $this->id)) as $row) {
+ $related_item_ids[$row->item_id] = 1;
+ }
+
+ $result = parent::save();
+
+ foreach ($db->getwhere("items_tags", array("tag_id" => $this->id)) as $row) {
+ $related_item_ids[$row->item_id] = 1;
+ }
+
+ if ($related_item_ids) {
+ foreach (ORM::factory("item")->in("id", array_keys($related_item_ids))->find_all() as $item) {
+ module::event("item_related_update", $item);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Overload ORM::delete() to trigger an item_related_update event for all items that are
+ * related to this tag.
+ */
+ public function delete() {
+ $related_item_ids = array();
+ $db = Database::Instance();
+ foreach ($db->getwhere("items_tags", array("tag_id" => $this->id)) as $row) {
+ $related_item_ids[$row->item_id] = 1;
+ }
+
+ $result = parent::delete();
+
+ if ($related_item_ids) {
+ foreach (ORM::factory("item")->in("id", array_keys($related_item_ids))->find_all() as $item) {
+ module::event("item_related_update", $item);
+ }
+ }
+ return $result;
+ }
} \ No newline at end of file
diff --git a/themes/default/views/movie.html.php b/themes/default/views/movie.html.php
index 66c80ded..c90a370c 100644
--- a/themes/default/views/movie.html.php
+++ b/themes/default/views/movie.html.php
@@ -2,16 +2,29 @@
<div id="gItem">
<?= $theme->photo_top() ?>
- <ul id="gPager">
- <li><?= t("%position of %total", array("position" => $position, "total" => $sibling_count)) ?></li>
- <? if ($previous_item): ?>
- <li><span class="ui-icon ui-icon-seek-prev"></span><a href="<?= $previous_item->url() ?>"><?= t("previous") ?></a></li>
- <? endif ?>
- <? if ($next_item): ?>
- <li><a href="<?= $next_item->url() ?>"><?= t("next") ?></a><span class="ui-icon ui-icon-seek-next"></span></li>
- <? endif ?>
+ <ul class="gPager">
+ <li>
+ <? if ($previous_item): ?>
+ <a href="<?= $previous_item->url() ?>" class="gButtonLink ui-icon-left ui-state-default ui-corner-all">
+ <span class="ui-icon ui-icon-triangle-1-w"></span><?= t("previous") ?></a>
+ <? else: ?>
+ <a class="gButtonLink ui-icon-left ui-state-disabled ui-corner-all">
+ <span class="ui-icon ui-icon-triangle-1-w"></span><?= t("previous") ?></a>
+ <? endif; ?>
+ </li>
+ <li class="gInfo"><?= t("%position of %total", array("position" => $position, "total" => $sibling_count)) ?></li>
+ <li class="txtright">
+ <? if ($next_item): ?>
+ <a href="<?= $next_item->url() ?>" class="gButtonLink ui-icon-right ui-state-default ui-corner-all">
+ <span class="ui-icon ui-icon-triangle-1-e"></span><?= t("next") ?></a>
+ <? else: ?>
+ <a class="gButtonLink ui-icon-right ui-state-disabled ui-corner-all">
+ <span class="ui-icon ui-icon-triangle-1-e"></span><?= t("next") ?></a>
+ <? endif ?>
+ </li>
</ul>
+
<?= $item->movie_img(array("class" => "gMovie", "id" => "gMovieId-{$item->id}")) ?>
<div id="gInfo">