summaryrefslogtreecommitdiff
path: root/modules/gallery
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery')
-rw-r--r--modules/gallery/controllers/admin_graphics.php2
-rw-r--r--modules/gallery/helpers/item.php14
-rw-r--r--modules/gallery/models/item.php9
3 files changed, 16 insertions, 9 deletions
diff --git a/modules/gallery/controllers/admin_graphics.php b/modules/gallery/controllers/admin_graphics.php
index 565ee1b0..c59dd38e 100644
--- a/modules/gallery/controllers/admin_graphics.php
+++ b/modules/gallery/controllers/admin_graphics.php
@@ -32,7 +32,7 @@ class Admin_Graphics_Controller extends Admin_Controller {
if ($toolkit_id != module::get_var("gallery", "graphics_toolkit")) {
$tk = graphics::detect_toolkits();
module::set_var("gallery", "graphics_toolkit", $toolkit_id);
- module::set_var("gallery", "graphics_toolkit_path", dirname($tk->$toolkit_id->dir));
+ module::set_var("gallery", "graphics_toolkit_path", $tk->$toolkit_id->dir);
site_status::clear("missing_graphics_toolkit");
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index 80c25862..5504dc95 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -137,4 +137,18 @@ class item_Core {
$group->submit("")->value(t("Delete"));
return $form;
}
+
+ /**
+ * Get the next weight value
+ */
+ static function get_max_weight() {
+ // Guard against an empty result when we create the first item. It's unfortunate that we
+ // have to check this every time.
+ // @todo: figure out a better way to bootstrap the weight.
+ $result = Database::instance()
+ ->select("weight")->from("items")
+ ->orderby("weight", "desc")->limit(1)
+ ->get()->current();
+ return ($result ? $result->weight : 0) + 1;
+ }
} \ No newline at end of file
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index c4b9826f..7a3a2ba7 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -351,14 +351,7 @@ class Item_Model extends ORM_MPTT {
$this->updated = time();
if (!$this->loaded) {
$this->created = $this->updated;
- // Guard against an empty result when we create the first item. It's unfortunate that we
- // have to check this every time.
- // @todo: figure out a better way to bootstrap the weight.
- $result = Database::instance()
- ->select("weight")->from("items")
- ->orderby("weight", "desc")->limit(1)
- ->get()->current();
- $this->weight = ($result ? $result->weight : 0) + 1;
+ $this->weight = item::get_max_weight();
} else {
$send_event = 1;
}