diff options
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r-- | modules/gallery/helpers/MY_num.php | 14 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_block.php | 25 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_installer.php | 13 | ||||
-rw-r--r-- | modules/gallery/helpers/graphics.php | 21 | ||||
-rw-r--r-- | modules/gallery/helpers/module.php | 2 |
5 files changed, 62 insertions, 13 deletions
diff --git a/modules/gallery/helpers/MY_num.php b/modules/gallery/helpers/MY_num.php index 9787044c..842a2ee3 100644 --- a/modules/gallery/helpers/MY_num.php +++ b/modules/gallery/helpers/MY_num.php @@ -37,4 +37,18 @@ class num extends num_Core { return $val; } + + /** + * Convert a size value as accepted by PHP's shorthand to bytes. + * ref: http://us2.php.net/manual/en/function.ini-get.php + * ref: http://us2.php.net/manual/en/faq.using.php#faq.using.shorthandbytes + */ + static function convert_to_human_readable($num) { + foreach (array("G" => 1e9, "M" => 1e6, "K" => 1e3) as $k => $v) { + if ($num > $v) { + $num = round($num / $v) . $k; + } + } + return $num; + } } diff --git a/modules/gallery/helpers/gallery_block.php b/modules/gallery/helpers/gallery_block.php index 0ba7c936..49d16246 100644 --- a/modules/gallery/helpers/gallery_block.php +++ b/modules/gallery/helpers/gallery_block.php @@ -82,9 +82,13 @@ class gallery_block_Core { break; case "block_adder": - $block->css_id = "g-block-adder"; - $block->title = t("Dashboard content"); - $block->content = gallery_block::get_add_block_form(); + if ($form = gallery_block::get_add_block_form()) { + $block->css_id = "g-block-adder"; + $block->title = t("Dashboard content"); + $block->content = $form; + } else { + $block = ""; + } break; case "language": @@ -118,11 +122,22 @@ class gallery_block_Core { } static function get_add_block_form() { + $available_blocks = block_manager::get_available_admin_blocks(); + + $active = array(); + foreach (array_merge(block_manager::get_active("dashboard_sidebar"), + block_manager::get_active("dashboard_center")) as $b) { + unset($available_blocks[implode(":", $b)]); + } + + if (!$available_blocks) { + return; + } + $form = new Forge("admin/dashboard/add_block", "", "post", array("id" => "g-add-dashboard-block-form")); $group = $form->group("add_block")->label(t("Add Block")); - $group->dropdown("id")->label(t("Available Blocks")) - ->options(block_manager::get_available_admin_blocks()); + $group->dropdown("id")->label(t("Available blocks"))->options($available_blocks); $group->submit("center")->value(t("Add to center")); $group->submit("sidebar")->value(t("Add to sidebar")); return $form; diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index 83c5ed71..7a9af402 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -311,9 +311,9 @@ class gallery_installer { module::set_var("gallery", "email_header_separator", serialize("\n")); module::set_var("gallery", "show_user_profiles_to", "registered_users"); module::set_var("gallery", "extra_binary_paths", "/usr/local/bin:/opt/local/bin:/opt/bin"); - module::set_var("gallery", "timezone", Kohana::config("locale.timezone")); + module::set_var("gallery", "timezone", null); - module::set_version("gallery", 48); + module::set_version("gallery", 49); } static function upgrade($version) { @@ -685,11 +685,12 @@ class gallery_installer { module::set_version("gallery", $version = 47); } - if ($version == 47) { + if ($version == 47 || $version == 48) { // Add configuration variable to set timezone. Defaults to the currently - // used timezone (from PHP configuration). - module::set_var("gallery", "timezone", Kohana::config("locale.timezone")); - module::set_version("gallery", $version = 48); + // used timezone (from PHP configuration). Note that in v48 we werew + // setting this value incorrectly, so we're going to stomp this value for v49. + module::set_var("gallery", "timezone", null); + module::set_version("gallery", $version = 49); } } diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index 04501132..8d8853b0 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -316,7 +316,7 @@ class graphics_Core { // ImageMagick & GraphicsMagick $magick_kits = array( "imagemagick" => array( - "name" => "ImageMagick", "binary" => "convert", "version" => "convert -v", + "name" => "ImageMagick", "binary" => "convert", "version" => "convert -version", "version_regex" => "/Version: \S+ (\S+)/"), "graphicsmagick" => array( "name" => "GraphicsMagick", "binary" => "gm", "version" => "gm version", @@ -423,4 +423,23 @@ class graphics_Core { return true; } + + /** + * Return the max file size that this graphics toolkit can handle. + */ + static function max_filesize() { + if (module::get_var("gallery", "graphics_toolkit") == "gd") { + $memory_limit = trim(ini_get("memory_limit")); + $memory_limit_bytes = num::convert_to_bytes($memory_limit); + + // GD expands images in memory and uses 4 bytes of RAM for every byte + // in the file. + $max_filesize = $memory_limit_bytes / 4; + $max_filesize_human_readable = num::convert_to_human_readable($max_filesize); + return array($max_filesize, $max_filesize_human_readable); + } + + // Some arbitrarily large size + return array(1000000000, "1G"); + } } diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index 37f7f68a..4b7d4a5f 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -101,7 +101,7 @@ class module_Core { $m->locked = false; if ($m->active && $m->version != $m->code_version) { - site_status::warning(t("Some of your modules are out of date. <a href=\"%upgrader_url\">Upgrade now!</a>", array("upgrader_url" => url::site("upgrader"))), "upgrade_now"); + site_status::warning(t("Some of your modules are out of date. <a href=\"%upgrader_url\">Upgrade now!</a>", array("upgrader_url" => url::abs_site("upgrader"))), "upgrade_now"); } } |