summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-07-08 01:08:15 +0000
committerDries Buytaert <dries@buytaert.net>2008-07-08 01:08:15 +0000
commitffdfefebbccc2a7fedfec541f05f1c770e2bcc01 (patch)
tree0f30b2f6bb8085e61fc1862e321b5cf98a7636a3
parenta4883506e3064c1acf554d118ccf8a2ef09ad8d6 (diff)
downloadbrdo-ffdfefebbccc2a7fedfec541f05f1c770e2bcc01.tar.gz
brdo-ffdfefebbccc2a7fedfec541f05f1c770e2bcc01.tar.bz2
- Patch #270508 by paul.levvik and pwolanin: usability improvement: image toolkits should not have to be copied.
-rw-r--r--includes/bootstrap.inc2
-rw-r--r--includes/image.inc31
-rw-r--r--modules/system/image.gd.inc (renamed from includes/image.gd.inc)0
-rw-r--r--modules/system/system.info1
-rw-r--r--modules/system/system.module7
5 files changed, 25 insertions, 16 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 626b87405..63f704a1d 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -1175,7 +1175,7 @@ function ip_address($reset = false) {
if (!isset($ip_address) || $reset) {
$ip_address = $_SERVER['REMOTE_ADDR'];
-
+
if (variable_get('reverse_proxy', 0)) {
if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
// If an array of known reverse proxy IPs is provided, then trust
diff --git a/includes/image.inc b/includes/image.inc
index d86b62b01..44eca9f3c 100644
--- a/includes/image.inc
+++ b/includes/image.inc
@@ -21,11 +21,13 @@
* from this problem, but it requires the ISP to have installed additional
* software.
*
- * Image toolkits are installed by copying the image.ToolkitName.inc file into
- * Drupal's includes directory. The toolkit must then be enabled using the
- * admin/settings/image-toolkit form.
+ * Image toolkits are discovered based on the associated module's
+ * hook_image_toolkits. Additionally the image toolkit include file
+ * must be identified in the files array in the module.info file. The
+ * toolkit must then be enabled using the admin/settings/image-toolkit
+ * form.
*
- * Only one toolkit maybe selected at a time. If a module author wishes to call
+ * Only one toolkit may be selected at a time. If a module author wishes to call
* a specific toolkit they can check that it is installed by calling
* image_get_available_toolkits(), and then calling its functions directly.
*/
@@ -37,18 +39,17 @@
* An array of toolkit name => descriptive title.
*/
function image_get_available_toolkits() {
- $toolkits = file_scan_directory('includes', 'image\..*\.inc$');
+ // hook_image_toolkits returns an array of toolkit names.
+ $toolkits = module_invoke_all('image_toolkits');
$output = array();
- foreach ($toolkits as $file => $toolkit) {
- include_once "./$file";
- $function = str_replace('.', '_', $toolkit->name) . '_info';
- if (function_exists($function)) {
+ foreach ($toolkits as $name) {
+ $function = 'image_' . $name . '_info';
+ if (drupal_function_exists($function)) {
$info = $function();
$output[$info['name']] = $info['title'];
}
}
-
return $output;
}
@@ -63,11 +64,11 @@ function image_get_toolkit() {
if (!$toolkit) {
$toolkit = variable_get('image_toolkit', 'gd');
- $toolkit_file = './includes/image.' . $toolkit . '.inc';
- if (isset($toolkit) && file_exists($toolkit_file)) {
- include_once $toolkit_file;
+ if (isset($toolkit) &&
+ drupal_function_exists("image_" . $toolkit . "_resize")) {
}
- elseif (!image_gd_check_settings()) {
+ elseif (!drupal_function_exists("image_gd_check_settings") ||
+ !image_gd_check_settings()) {
$toolkit = FALSE;
}
}
@@ -88,7 +89,7 @@ function image_get_toolkit() {
function image_toolkit_invoke($method, $params = array()) {
if ($toolkit = image_get_toolkit()) {
$function = 'image_' . $toolkit . '_' . $method;
- if (function_exists($function)) {
+ if (drupal_function_exists($function)) {
return call_user_func_array($function, $params);
}
else {
diff --git a/includes/image.gd.inc b/modules/system/image.gd.inc
index ab26371f6..ab26371f6 100644
--- a/includes/image.gd.inc
+++ b/modules/system/image.gd.inc
diff --git a/modules/system/system.info b/modules/system/system.info
index 649436908..983331437 100644
--- a/modules/system/system.info
+++ b/modules/system/system.info
@@ -6,3 +6,4 @@ version = VERSION
core = 7.x
files[] = system.module
files[] = system.admin.inc
+files[] = image.gd.inc
diff --git a/modules/system/system.module b/modules/system/system.module
index b34c39f55..b1e5d2897 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -2105,3 +2105,10 @@ function theme_meta_generator_html($version = VERSION) {
function theme_meta_generator_header($version = VERSION) {
drupal_set_header('X-Generator: Drupal ' . $version . ' (http://drupal.org)');
}
+
+/**
+ * Implementation of hook_image_toolkits().
+ */
+function system_image_toolkits() {
+ return array('gd');
+}