summaryrefslogtreecommitdiff
path: root/core/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'core/helpers')
-rw-r--r--core/helpers/core_installer.php25
-rw-r--r--core/helpers/core_menu.php9
-rw-r--r--core/helpers/graphics.php48
3 files changed, 78 insertions, 4 deletions
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;
+ }
}