Merge remote branch 'upstream/master'
This commit is contained in:
commit
d10945106a
37
3.0/modules/albumtree/helpers/albumtree_block.php
Normal file
37
3.0/modules/albumtree/helpers/albumtree_block.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?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 albumtree_block_Core {
|
||||
static function get_site_list() {
|
||||
return array("albumtree" => t("Album tree"));
|
||||
}
|
||||
|
||||
static function get($block_id) {
|
||||
$block = new Block();
|
||||
switch ($block_id) {
|
||||
case "albumtree":
|
||||
$block->css_id = "g-albumtree";
|
||||
$block->title = t("Album Tree");
|
||||
$block->content = new View("albumtree_block.html");
|
||||
$block->content->root = item::root();
|
||||
break;
|
||||
}
|
||||
return $block;
|
||||
}
|
||||
}
|
3
3.0/modules/albumtree/module.info
Normal file
3
3.0/modules/albumtree/module.info
Normal file
@ -0,0 +1,3 @@
|
||||
name = "Album Tree"
|
||||
description = "Provides a block in the sidebar with quick links to all other albums."
|
||||
version = 1
|
24
3.0/modules/albumtree/views/albumtree_block.html.php
Normal file
24
3.0/modules/albumtree/views/albumtree_block.html.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<select onchange="window.location='<?= url::site("items/__ID__")?>'.replace('__ID__', this.value)">
|
||||
<? // We'll keep track of the list of items that we want to display in a stack ?>
|
||||
<? $stack = array(array(0, $root)) ?>
|
||||
|
||||
<? // While there are still items to show, pick the next one and show it ?>
|
||||
<? while ($stack): ?>
|
||||
<? list($level, $album) = array_pop($stack) ?>
|
||||
<option value="<?= $album->id ?>"><?= str_repeat(" ", $level) ?><?= $album->title ?></option>
|
||||
|
||||
<? // Then take all of that album's children and put them next on the stack. ?>
|
||||
<? $tmp = array(); ?>
|
||||
<? foreach ($album->children(null, null, array(array("type", "=", "album"))) as $child): ?>
|
||||
<? $tmp[] = array($level + 1, $child) ?>
|
||||
<? endforeach ?>
|
||||
|
||||
<? // Since we'll pull them off the stack in the opposite order that we put them on, ?>
|
||||
<? // and the order that we put them on is the order in which we want to display them, ?>
|
||||
<? // We need to reverse the order of the children on the stack ?>
|
||||
<? if ($tmp): ?>
|
||||
<? $stack = array_merge($stack, array_reverse($tmp)) ?>
|
||||
<? endif ?>
|
||||
<? endwhile ?>
|
||||
</select>
|
@ -0,0 +1,72 @@
|
||||
<?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 rectangle_thumbs_graphics_Core {
|
||||
/**
|
||||
* Crop the input image so that it matches the aspect ratio specified in the
|
||||
* rectangle_thumbs.aspect_ratio module setting. Focus on the center of the image and crop out
|
||||
* the biggest piece that we can.
|
||||
*
|
||||
* @param string $input_file
|
||||
* @param string $output_file
|
||||
* @param array $options
|
||||
*/
|
||||
static function crop_to_aspect_ratio($input_file, $output_file, $options) {
|
||||
graphics::init_toolkit();
|
||||
|
||||
if (@filesize($input_file) == 0) {
|
||||
throw new Exception("@todo EMPTY_INPUT_FILE");
|
||||
}
|
||||
|
||||
list ($desired_width, $desired_height) =
|
||||
explode(":", module::get_var("rectangle_thumbs", "aspect_ratio"));
|
||||
$desired_ratio = $desired_width / $desired_height;
|
||||
|
||||
// Crop the largest rectangular section we can out of the original image. Start with a
|
||||
// rectangular section that's guaranteed to be too large, then shrink it horizontally to just
|
||||
// barely fit. If it's still too tall vertically, shrink both dimensions proportionally until
|
||||
// the horizontal edge fits as well.
|
||||
$dims = getimagesize($input_file);
|
||||
if ($desired_ratio == 1) {
|
||||
$new_width = $new_height = min($dims[0], $dims[1]);
|
||||
} else if ($desired_ratio < 1) {
|
||||
list ($new_width, $new_height) = array($dims[0], $dims[0] / $desired_ratio);
|
||||
} else {
|
||||
list ($new_width, $new_height) = array($dims[1] * $desired_ratio, $dims[1]);
|
||||
}
|
||||
|
||||
if ($new_width > $dims[0]) {
|
||||
// Too wide, scale it down
|
||||
list ($new_width, $new_height) = array($dims[0], $dims[0] / $desired_ratio);
|
||||
}
|
||||
|
||||
if ($new_height > $dims[1]) {
|
||||
// Too tall, scale it down some more
|
||||
$new_width = min($dims[0], $dims[1] * $desired_ratio);
|
||||
$new_height = $new_width / $desired_ratio;
|
||||
}
|
||||
$new_width = round($new_width);
|
||||
$new_height = round($new_height);
|
||||
|
||||
Image::factory($input_file)
|
||||
->crop($new_width, $new_height)
|
||||
->quality(module::get_var("gallery", "image_quality"))
|
||||
->save($output_file);
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
<?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 rectangle_thumbs_installer {
|
||||
static function install() {
|
||||
// Insert a rule into the thumbnail generation pipeline that converts the source image to the
|
||||
// right aspect ratio such that when we resize it down, it comes out to the right dimensions.
|
||||
graphics::add_rule(
|
||||
"rectangle_thumbs", "thumb", "rectangle_thumbs_graphics::crop_to_aspect_ratio", array(), 50);
|
||||
module::set_var("rectangle_thumbs", "aspect_ratio", "3:1");
|
||||
module::set_version("rectangle_thumbs", 1);
|
||||
}
|
||||
}
|
3
3.0/modules/rectangle_thumbs/module.info
Normal file
3
3.0/modules/rectangle_thumbs/module.info
Normal file
@ -0,0 +1,3 @@
|
||||
name = "Rectangle Thumbnails"
|
||||
description = "Force all thumbnails to be a specific rectangular aspect ratio"
|
||||
version = 1
|
37
3.1/modules/albumtree/helpers/albumtree_block.php
Normal file
37
3.1/modules/albumtree/helpers/albumtree_block.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?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 albumtree_block_Core {
|
||||
static function get_site_list() {
|
||||
return array("albumtree" => t("Album tree"));
|
||||
}
|
||||
|
||||
static function get($block_id) {
|
||||
$block = new Block();
|
||||
switch ($block_id) {
|
||||
case "albumtree":
|
||||
$block->css_id = "g-albumtree";
|
||||
$block->title = t("Album Tree");
|
||||
$block->content = new View("albumtree_block.html");
|
||||
$block->content->root = item::root();
|
||||
break;
|
||||
}
|
||||
return $block;
|
||||
}
|
||||
}
|
3
3.1/modules/albumtree/module.info
Normal file
3
3.1/modules/albumtree/module.info
Normal file
@ -0,0 +1,3 @@
|
||||
name = "Album Tree"
|
||||
description = "Provides a block in the sidebar with quick links to all other albums."
|
||||
version = 1
|
24
3.1/modules/albumtree/views/albumtree_block.html.php
Normal file
24
3.1/modules/albumtree/views/albumtree_block.html.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<select onchange="window.location='<?= url::site("items/__ID__")?>'.replace('__ID__', this.value)">
|
||||
<? // We'll keep track of the list of items that we want to display in a stack ?>
|
||||
<? $stack = array(array(0, $root)) ?>
|
||||
|
||||
<? // While there are still items to show, pick the next one and show it ?>
|
||||
<? while ($stack): ?>
|
||||
<? list($level, $album) = array_pop($stack) ?>
|
||||
<option value="<?= $album->id ?>"><?= str_repeat(" ", $level) ?><?= $album->title ?></option>
|
||||
|
||||
<? // Then take all of that album's children and put them next on the stack. ?>
|
||||
<? $tmp = array(); ?>
|
||||
<? foreach ($album->children(null, null, array(array("type", "=", "album"))) as $child): ?>
|
||||
<? $tmp[] = array($level + 1, $child) ?>
|
||||
<? endforeach ?>
|
||||
|
||||
<? // Since we'll pull them off the stack in the opposite order that we put them on, ?>
|
||||
<? // and the order that we put them on is the order in which we want to display them, ?>
|
||||
<? // We need to reverse the order of the children on the stack ?>
|
||||
<? if ($tmp): ?>
|
||||
<? $stack = array_merge($stack, array_reverse($tmp)) ?>
|
||||
<? endif ?>
|
||||
<? endwhile ?>
|
||||
</select>
|
@ -0,0 +1,72 @@
|
||||
<?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 rectangle_thumbs_graphics_Core {
|
||||
/**
|
||||
* Crop the input image so that it matches the aspect ratio specified in the
|
||||
* rectangle_thumbs.aspect_ratio module setting. Focus on the center of the image and crop out
|
||||
* the biggest piece that we can.
|
||||
*
|
||||
* @param string $input_file
|
||||
* @param string $output_file
|
||||
* @param array $options
|
||||
*/
|
||||
static function crop_to_aspect_ratio($input_file, $output_file, $options) {
|
||||
graphics::init_toolkit();
|
||||
|
||||
if (@filesize($input_file) == 0) {
|
||||
throw new Exception("@todo EMPTY_INPUT_FILE");
|
||||
}
|
||||
|
||||
list ($desired_width, $desired_height) =
|
||||
explode(":", module::get_var("rectangle_thumbs", "aspect_ratio"));
|
||||
$desired_ratio = $desired_width / $desired_height;
|
||||
|
||||
// Crop the largest rectangular section we can out of the original image. Start with a
|
||||
// rectangular section that's guaranteed to be too large, then shrink it horizontally to just
|
||||
// barely fit. If it's still too tall vertically, shrink both dimensions proportionally until
|
||||
// the horizontal edge fits as well.
|
||||
$dims = getimagesize($input_file);
|
||||
if ($desired_ratio == 1) {
|
||||
$new_width = $new_height = min($dims[0], $dims[1]);
|
||||
} else if ($desired_ratio < 1) {
|
||||
list ($new_width, $new_height) = array($dims[0], $dims[0] / $desired_ratio);
|
||||
} else {
|
||||
list ($new_width, $new_height) = array($dims[1] * $desired_ratio, $dims[1]);
|
||||
}
|
||||
|
||||
if ($new_width > $dims[0]) {
|
||||
// Too wide, scale it down
|
||||
list ($new_width, $new_height) = array($dims[0], $dims[0] / $desired_ratio);
|
||||
}
|
||||
|
||||
if ($new_height > $dims[1]) {
|
||||
// Too tall, scale it down some more
|
||||
$new_width = min($dims[0], $dims[1] * $desired_ratio);
|
||||
$new_height = $new_width / $desired_ratio;
|
||||
}
|
||||
$new_width = round($new_width);
|
||||
$new_height = round($new_height);
|
||||
|
||||
Image::factory($input_file)
|
||||
->crop($new_width, $new_height)
|
||||
->quality(module::get_var("gallery", "image_quality"))
|
||||
->save($output_file);
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
<?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 rectangle_thumbs_installer {
|
||||
static function install() {
|
||||
// Insert a rule into the thumbnail generation pipeline that converts the source image to the
|
||||
// right aspect ratio such that when we resize it down, it comes out to the right dimensions.
|
||||
graphics::add_rule(
|
||||
"rectangle_thumbs", "thumb", "rectangle_thumbs_graphics::crop_to_aspect_ratio", array(), 50);
|
||||
module::set_var("rectangle_thumbs", "aspect_ratio", "3:1");
|
||||
module::set_version("rectangle_thumbs", 1);
|
||||
}
|
||||
}
|
3
3.1/modules/rectangle_thumbs/module.info
Normal file
3
3.1/modules/rectangle_thumbs/module.info
Normal file
@ -0,0 +1,3 @@
|
||||
name = "Rectangle Thumbnails"
|
||||
description = "Force all thumbnails to be a specific rectangular aspect ratio"
|
||||
version = 1
|
Reference in New Issue
Block a user