Initial checkin of custom albums (not working)
This commit is contained in:
parent
6c29c8229a
commit
9f24bc9df6
64
3.0/modules/custom_albums/helpers/custom_albums_event.php
Normal file
64
3.0/modules/custom_albums/helpers/custom_albums_event.php
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2010 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class custom_albums_event_Core {
|
||||||
|
static function item_edit_form($item, $form) {
|
||||||
|
if ($item->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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
57
3.0/modules/custom_albums/helpers/custom_albums_graphics.php
Normal file
57
3.0/modules/custom_albums/helpers/custom_albums_graphics.php
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2010 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class custom_albums_graphics_Core {
|
||||||
|
/**
|
||||||
|
* Resize an image. Valid options are width, height and master. Master is one of the Image
|
||||||
|
* master dimension constants.
|
||||||
|
*
|
||||||
|
* @param string $input_file
|
||||||
|
* @param string $output_file
|
||||||
|
* @param array $options
|
||||||
|
*/
|
||||||
|
static function resize($input_file, $output_file, $options) {
|
||||||
|
graphics::init_toolkit();
|
||||||
|
|
||||||
|
module::event("graphics_resize", $input_file, $output_file, $options);
|
||||||
|
|
||||||
|
if (@filesize($input_file) == 0) {
|
||||||
|
throw new Exception("@todo EMPTY_INPUT_FILE");
|
||||||
|
}
|
||||||
|
|
||||||
|
$albumCustom = ORM::factory("custom_album")->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);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2010 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class custom_albums_installer {
|
||||||
|
static function install() {
|
||||||
|
// Add rules for generating our thumbnails and resizes
|
||||||
|
graphics::add_rule(
|
||||||
|
"gallery", "thumb", "custom_albums::resize",
|
||||||
|
array("width" => 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");
|
||||||
|
}
|
||||||
|
}
|
5
3.0/modules/custom_albums/models/custom_album.php
Normal file
5
3.0/modules/custom_albums/models/custom_album.php
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
class Custom_Album_Model extends ORM
|
||||||
|
{
|
||||||
|
}
|
||||||
|
?>
|
3
3.0/modules/custom_albums/module.info
Normal file
3
3.0/modules/custom_albums/module.info
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name = "Custom Albums"
|
||||||
|
description = "Lets you set custom thumbnail sizes for albums"
|
||||||
|
version = 1
|
Reference in New Issue
Block a user