diff --git a/3.0/modules/custom_albums/helpers/custom_albums_event.php b/3.0/modules/custom_albums/helpers/custom_albums_event.php new file mode 100644 index 00000000..b8dbe5aa --- /dev/null +++ b/3.0/modules/custom_albums/helpers/custom_albums_event.php @@ -0,0 +1,64 @@ +is_album()) { + $albumCustom = ORM::factory("custom_album")->where("album_id", "=", $item->id)->find(); + + $thumbdata = $form->edit_item->group("custom_album")->label("Custom Album"); + + if ($albumCustom->loaded()) { + $thumbdata->input("thumbsize")->label(t("Thumbnail size (in pixels)"))->value($albumCustom->thumb_size); + } else { + $thumbdata->input("thumbsize")->label(t("Thumbnail size (in pixels)")); + } + } + } + + static function item_edit_form_completed($item, $form) { + if ($item->is_album()) { + $thumbChanged = false; + + if ($form->edit_item->custom_album->thumbsize->value == "") { + db::build() + ->delete("custom_album") + ->where("album_id", "=", $item->id) + ->execute(); + } else { + $albumCustom = ORM::factory("custom_album")->where("album_id", "=", $item->id)->find(); + if (!$albumCustom->loaded()) { + $albumCustom->album_id = $item->id; + } + $albumCustom->thumb_size = $form->edit_item->custom_album->thumbsize->value; + $albumCustom->save(); + + $thumbChanged = true; + } + + if ($thumbChanged) { + db::build() + ->update("items") + ->set("thumb_dirty", 1) + ->where("parent_id", "=", $item->id) + ->execute(); + } + } + } +} diff --git a/3.0/modules/custom_albums/helpers/custom_albums_graphics.php b/3.0/modules/custom_albums/helpers/custom_albums_graphics.php new file mode 100644 index 00000000..5fa6cd49 --- /dev/null +++ b/3.0/modules/custom_albums/helpers/custom_albums_graphics.php @@ -0,0 +1,57 @@ +where("album_id", "=", $options["parent_id"])->find(); + +/* + $dims = getimagesize($input_file); + if (max($dims[0], $dims[1]) < min($options["width"], $options["height"])) { + // Image would get upscaled; do nothing + copy($input_file, $output_file); + } else { + $image = Image::factory($input_file) + ->resize($options["width"], $options["height"], $options["master"]) + ->quality(module::get_var("gallery", "image_quality")); + if (graphics::can("sharpen")) { + $image->sharpen(module::get_var("gallery", "image_sharpen")); + } + $image->save($output_file); + } +*/ + module::event("graphics_resize_completed", $input_file, $output_file, $options); + } +} diff --git a/3.0/modules/custom_albums/helpers/custom_albums_installer.php b/3.0/modules/custom_albums/helpers/custom_albums_installer.php new file mode 100644 index 00000000..477b70e0 --- /dev/null +++ b/3.0/modules/custom_albums/helpers/custom_albums_installer.php @@ -0,0 +1,54 @@ + 0, "height" => 0, "master" => Image::AUTO), + 200); + graphics::add_rule( + "gallery", "resize", "custom_albums::resize", + array("width" => 0, "height" => 0, "master" => Image::AUTO), + 200); + + // Create a table to store custom album info in. + $db = Database::instance(); + + $db->query( + "CREATE TABLE IF NOT EXISTS {custom_albums} ( + `id` int(9) NOT NULL auto_increment, + `album_id` int(9) NOT NULL, + `thumb_size` int(9) NOT NULL, + PRIMARY KEY (`id`), + KEY `album_id` (`album_id`,`id`) + ) DEFAULT CHARSET=utf8;" + ); + + module::set_version("custom_albums", 1); + } + + static function uninstall() { + // Delete the custom album table before uninstalling. + $db = Database::instance(); + $db->query("DROP TABLE IF EXISTS {custom_albums};"); + module::delete("custom_albums"); + } +} diff --git a/3.0/modules/custom_albums/models/custom_album.php b/3.0/modules/custom_albums/models/custom_album.php new file mode 100644 index 00000000..56dc8661 --- /dev/null +++ b/3.0/modules/custom_albums/models/custom_album.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/3.0/modules/custom_albums/module.info b/3.0/modules/custom_albums/module.info new file mode 100644 index 00000000..1161c533 --- /dev/null +++ b/3.0/modules/custom_albums/module.info @@ -0,0 +1,3 @@ +name = "Custom Albums" +description = "Lets you set custom thumbnail sizes for albums" +version = 1