summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/controllers/admin_graphics.php48
-rw-r--r--core/helpers/core_installer.php25
-rw-r--r--core/helpers/core_menu.php9
-rw-r--r--core/helpers/graphics.php48
-rw-r--r--core/libraries/Admin_View.php2
-rw-r--r--core/views/admin_graphics.html.php92
6 files changed, 219 insertions, 5 deletions
diff --git a/core/controllers/admin_graphics.php b/core/controllers/admin_graphics.php
new file mode 100644
index 00000000..e6e42672
--- /dev/null
+++ b/core/controllers/admin_graphics.php
@@ -0,0 +1,48 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2008 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 Admin_Graphics_Controller extends Admin_Controller {
+ public function index() {
+ $view = new Admin_View("admin.html");
+ $view->content = new View("admin_graphics.html");
+ $view->content->tk = new ArrayObject(graphics::detect_toolkits(), ArrayObject::ARRAY_AS_PROPS);
+ $view->content->active = module::get_var("core", "graphics_toolkit");
+ print $view;
+ }
+
+ public function save() {
+ access::verify_csrf();
+ $toolkit = $this->input->post("graphics_toolkit");
+ if ($toolkit != module::get_var("core", "graphics_toolkit")) {
+ module::set_var("core", "graphics_toolkit", $toolkit);
+
+ $toolkit_info = graphics::detect_toolkits();
+ if ($toolkit == "graphicsmagick" || $toolkit == "imagemagick") {
+ module::set_var("core", "graphics_toolkit_path", $toolkit_info[$toolkit]);
+ }
+
+ site_status::clear("missing_graphics_toolkit");
+ message::success(_("Updated Graphics Toolkit"));
+ log::success("graphics", sprintf(_("Changed graphics toolkit to %s"), $toolkit));
+ }
+
+ url::redirect("admin/graphics");
+ }
+}
+
diff --git a/core/helpers/core_installer.php b/core/helpers/core_installer.php
index d1904181..e720bfb3 100644
--- a/core/helpers/core_installer.php
+++ b/core/helpers/core_installer.php
@@ -185,6 +185,24 @@ class core_installer {
array("width" => 640, "height" => 480, "master" => Image::AUTO),
100);
+ // Detect a graphics toolkit
+ $toolkits = graphics::detect_toolkits();
+ foreach (array("imagemagick", "graphicsmagick", "gd") as $tk) {
+ if ($toolkits[$tk]) {
+ module::set_var("core", "graphics_toolkit", $tk);
+ if ($tk != "gd") {
+ module::set_var("core", "graphics_toolkit_path", $toolkits[$tk]);
+ }
+ break;
+ }
+ }
+ if (!module::get_var("core", "graphics_toolkit")) {
+ site_status::warning(
+ sprintf(_("Graphics toolkit missing! Please %schoose a toolkit%s."),
+ "<a href=\"" . url::site("admin/graphics") . "\">", "</a>"),
+ "missing_graphics_toolkit");
+ }
+
module::set_version("core", 1);
}
}
@@ -193,9 +211,14 @@ class core_installer {
$db = Database::instance();
$db->query("DROP TABLE IF EXISTS `access_caches`;");
$db->query("DROP TABLE IF EXISTS `access_intents`;");
- $db->query("DROP TABLE IF EXISTS `permissions`;");
+ $db->query("DROP TABLE IF EXISTS `graphics_rules`;");
$db->query("DROP TABLE IF EXISTS `items`;");
+ $db->query("DROP TABLE IF EXISTS `logs`;");
+ $db->query("DROP TABLE IF EXISTS `messages`;");
$db->query("DROP TABLE IF EXISTS `modules`;");
+ $db->query("DROP TABLE IF EXISTS `permissions`;");
+ $db->query("DROP TABLE IF EXISTS `sessions`;");
+ $db->query("DROP TABLE IF EXISTS `tasks`;");
$db->query("DROP TABLE IF EXISTS `vars`;");
system("/bin/rm -rf " . VARPATH . "albums");
system("/bin/rm -rf " . VARPATH . "resizes");
diff --git a/core/helpers/core_menu.php b/core/helpers/core_menu.php
index d6f7bc56..68d6c7d9 100644
--- a/core/helpers/core_menu.php
+++ b/core/helpers/core_menu.php
@@ -73,10 +73,13 @@ class core_menu_Core {
->id("dashboard")
->label(_("Dashboard"))
->url(url::site("admin")))
- ->append(Menu::factory("link")
- ->id("general_settings")
+ ->append(Menu::factory("submenu")
+ ->id("general_settings_menu")
->label(_("General Settings"))
- ->url("#"))
+ ->append(Menu::factory("link")
+ ->id("graphics_toolkits")
+ ->label(_("Graphics"))
+ ->url(url::site("admin/graphics"))))
->append(Menu::factory("link")
->id("modules")
->label(_("Modules"))
diff --git a/core/helpers/graphics.php b/core/helpers/graphics.php
index e64a9c6d..85f86863 100644
--- a/core/helpers/graphics.php
+++ b/core/helpers/graphics.php
@@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class graphics_Core {
+ private static $init;
+
/**
* Add a new graphics rule.
*
@@ -126,6 +128,10 @@ class graphics_Core {
* @param array $options
*/
public static function resize($input_file, $output_file, $options) {
+ if (!self::$init) {
+ self::init_toolkit();
+ }
+
Image::factory($input_file)
->resize($options["width"], $options["height"], $options["master"])
->save($output_file);
@@ -141,6 +147,10 @@ class graphics_Core {
* @param array $options
*/
public static function composite($input_file, $output_file, $options) {
+ if (!self::$init) {
+ self::init_toolkit();
+ }
+
list ($width, $height) = getimagesize($input_file);
list ($w_width, $w_height) = getimagesize($options["file"]);
@@ -240,4 +250,42 @@ class graphics_Core {
site_status::clear("graphics_dirty");
}
}
+
+ /**
+ * Detect which graphics toolkits are available on this system. Return an array of key value
+ * pairs where the key is one of gd, imagemagick, graphicsmagick and the value is information
+ * about that toolkit. For GD we return the version string, and for ImageMagick and
+ * GraphicsMagick we return the path to the directory containing the appropriate binaries.
+ */
+ public static function detect_toolkits() {
+ $gd_info = gd_info();
+ return array("gd" => $gd_info["GD Version"],
+ "imagemagick" => dirname(exec("which convert")),
+ "graphicsmagick" => dirname(exec("which gm")));
+ }
+
+ /**
+ * Choose which driver the Kohana Image library uses.
+ */
+ public static function init_toolkit() {
+ switch(module::get_var("core", "graphics_toolkit")) {
+ case "gd":
+ Kohana::config_set("image.driver", "GD");
+ break;
+
+ case "imagemagick":
+ Kohana::config_set("image.driver", "ImageMagick");
+ Kohana::config_set(
+ "image.params.directory", module::get_var("core", "graphics_toolkit_path"));
+ break;
+
+ case "graphicsmagick":
+ Kohana::config_set("image.driver", "GraphicsMagick");
+ Kohana::config_set(
+ "image.params.directory", module::get_var("core", "graphics_toolkit_path"));
+ break;
+ }
+
+ self::$init = 1;
+ }
}
diff --git a/core/libraries/Admin_View.php b/core/libraries/Admin_View.php
index 803b8942..332be596 100644
--- a/core/libraries/Admin_View.php
+++ b/core/libraries/Admin_View.php
@@ -62,7 +62,7 @@ class Admin_View_Core extends View {
}
/**
- * Print out any site wide status information. This is for admins only.
+ * Print out any site wide status information.
*/
public function site_status() {
return site_status::get();
diff --git a/core/views/admin_graphics.html.php b/core/views/admin_graphics.html.php
new file mode 100644
index 00000000..9d1f49a8
--- /dev/null
+++ b/core/views/admin_graphics.html.php
@@ -0,0 +1,92 @@
+<? defined("SYSPATH") or die("No direct script access."); ?>
+<div id="gGraphics">
+ <h1> <?= _("Graphics Settings") ?> </h1>
+ <p>
+ <?= _("Gallery needs a graphics toolkit in order to manipulate your photos. Please choose one from the list below.") ?>
+ </p>
+
+ <form method="post" action="<?= url::site("admin/graphics/save") ?>">
+ <?= access::csrf_form_field() ?>
+ <h2> <?= _("Graphics Toolkits") ?> </h2>
+ <table>
+ <tr>
+ <td valign="top" style="width: 100px">
+ <center>
+ <input type="radio" name="graphics_toolkit" value="gd"
+ <? if (!$tk->gd): ?> disabled="disabled" <? endif ?>
+ <? if ($active == "gd"): ?> checked="checked" <? endif ?>
+ >
+ </center>
+ </td>
+ <td>
+ <h3> <?= _("GD") ?> </h3>
+ <p>
+ <? printf(_("The GD graphics library is an extension to PHP commonly installed most webservers. Please refer to the %sGD website%s for more information."), "<a href=\"http://www.boutell.com/gd/\">", "</a>") ?>
+ </p>
+ <? if ($tk->gd): ?>
+ <p class="gSuccess">
+ <? printf(_("You have GD version %s."), $tk->gd) ?>
+ </p>
+ <? else: ?>
+ <p class="gInfo">
+ <?= _("You do not have GD installed.") ?>
+ </p>
+ <? endif ?>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top" style="width: 100px">
+ <center>
+ <input type="radio" name="graphics_toolkit" value="imagemagick"
+ <? if (!$tk->imagemagick): ?> disabled="disabled" <? endif ?>
+ <? if ($active == "imagemagick"): ?> checked="checked" <? endif ?>
+ >
+ </center>
+ </td>
+ <td>
+ <h3> <?= _("ImageMagick") ?> </h3>
+ <p>
+ <? printf(_("ImageMagick is a standalone graphics program available on most Linux systems. Please refer to the %sImageMagick website%s for more information."), "<a href=\"http://www.imagemagick.org/\">", "</a>") ?>
+ </p>
+ <? if ($tk->imagemagick): ?>
+ <p class="gSuccess">
+ <? printf(_("You have ImageMagick installed in %s"), $tk->imagemagick) ?>
+ </p>
+ <? else: ?>
+ <p class="gInfo">
+ <?= _("ImageMagick is not available on your system.") ?>
+ </p>
+ <? endif ?>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top" style="width: 100px">
+ <center>
+ <input type="radio" name="graphics_toolkit" value="graphicsmagick"
+ <? if (!$tk->graphicsmagick): ?> disabled="disabled" <? endif ?>
+ <? if ($active == "graphicsmagick"): ?> checked="checked" <? endif ?>
+ >
+ </center>
+ </td>
+ <td>
+ <h3> <?= _("GraphicsMagick") ?> </h3>
+ <p>
+ <? printf(_("GraphicsMagick is a standalone graphics program available on most Linux systems. Please refer to the %sGraphicsMagick website%s for more information."), "<a href=\"http://www.graphicsmagick.org/\">", "</a>") ?>
+ </p>
+ <? if ($tk->graphicsmagick): ?>
+ <p class="gSuccess">
+ <? printf(_("You have GraphicsMagick installed in %s"), $tk->graphicsmagick) ?>
+ </p>
+ <? else: ?>
+ <p class="gInfo">
+ <?= _("GraphicsMagick is not available on your system.") ?>
+ </p>
+ <? endif ?>
+ </td>
+ </tr>
+ </table>
+ <input type="submit" value="<?= _("Save") ?>"/>
+ </form>
+</div>