diff options
author | Dries Buytaert <dries@buytaert.net> | 2004-09-21 18:33:51 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2004-09-21 18:33:51 +0000 |
commit | 1a91e6e1bc2128ba2a07e3c0879824c2bee4f57d (patch) | |
tree | 7e612b72bbceac44646dda681ea992598949a3d4 /modules | |
parent | f8080719f2be5763af02fd42b32e762012895d8d (diff) | |
download | brdo-1a91e6e1bc2128ba2a07e3c0879824c2bee4f57d.tar.gz brdo-1a91e6e1bc2128ba2a07e3c0879824c2bee4f57d.tar.bz2 |
- Patch #10730 by Adrian: made it possible to upload a logo.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/system.module | 32 | ||||
-rw-r--r-- | modules/system/system.module | 32 |
2 files changed, 62 insertions, 2 deletions
diff --git a/modules/system.module b/modules/system.module index bbe918570..e5dbb0554 100644 --- a/modules/system.module +++ b/modules/system.module @@ -588,6 +588,7 @@ function system_site_settings($module = NULL) { */ function system_theme_settings() { system_settings_save(); + // Default settings are defined in _theme_settings() in includes/theme.inc $key = str_replace('.', '/', arg(3)); if ($key) { @@ -601,13 +602,39 @@ function system_theme_settings() { $var = 'theme_settings'; } + // Check for a new uploaded logo, and use that instead. + if ($file = file_check_upload('logo_upload')) { + if (in_array($file->filemime, array('image/jpeg', 'image/gif', 'image/png'))) { + $parts = pathinfo($file->filename); + $filename = ($key) ? str_replace('/', '_', $key) . '_logo.' . $parts['extension'] : 'logo.' . $parts['extension']; + + if ($file = file_save_upload('logo_upload', $filename, 1)) { + $settings['default_logo'] = 0; + $settings['logo_path'] = $file->filepath; + + // Update the variable table with the new settings so that they take effect immediately. + variable_set($var, $settings); + } + } + else { + form_set_error('file_upload', t('Only JPEG, PNG and GIF images are allowed to be used as logos.')); + } + } + + $form = ''; // Logo settings if ((!$key) || in_array('logo', $features)) { $group = form_checkbox(t('Use the default logo'), "$var][default_logo", 1, $settings['default_logo'], t('Check here if you want the theme to use the logo supplied with it.')); $group .= form_textfield(t('Path to custom logo'), "$var][logo_path", $settings['logo_path'], 50, 60, t('The path to the file you would like to use as your logo file instead of the default logo.')); + + file_check_directory(variable_get('file_directory_path', 'files'), FILE_CREATE_DIRECTORY, 'file_directory_path'); + $group .= form_file(t('Upload logo image'), 'logo_upload', 40, t("If you don't have direct file access to the server, use this field to upload your logo.")); + $group .= form_button(t('Upload'), 'fileop'); + $form = form_group(t('Logo image settings'), $group); + } // System wide only settings. @@ -659,8 +686,11 @@ function system_theme_settings() { } } } + $form .= form_submit(t('Save configuration')); + $form .= form_submit(t('Reset to defaults')); + + print theme('page', form($form, 'post', null, array('enctype' => 'multipart/form-data'))); - print theme('page', system_settings_form($form)); } ?> diff --git a/modules/system/system.module b/modules/system/system.module index bbe918570..e5dbb0554 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -588,6 +588,7 @@ function system_site_settings($module = NULL) { */ function system_theme_settings() { system_settings_save(); + // Default settings are defined in _theme_settings() in includes/theme.inc $key = str_replace('.', '/', arg(3)); if ($key) { @@ -601,13 +602,39 @@ function system_theme_settings() { $var = 'theme_settings'; } + // Check for a new uploaded logo, and use that instead. + if ($file = file_check_upload('logo_upload')) { + if (in_array($file->filemime, array('image/jpeg', 'image/gif', 'image/png'))) { + $parts = pathinfo($file->filename); + $filename = ($key) ? str_replace('/', '_', $key) . '_logo.' . $parts['extension'] : 'logo.' . $parts['extension']; + + if ($file = file_save_upload('logo_upload', $filename, 1)) { + $settings['default_logo'] = 0; + $settings['logo_path'] = $file->filepath; + + // Update the variable table with the new settings so that they take effect immediately. + variable_set($var, $settings); + } + } + else { + form_set_error('file_upload', t('Only JPEG, PNG and GIF images are allowed to be used as logos.')); + } + } + + $form = ''; // Logo settings if ((!$key) || in_array('logo', $features)) { $group = form_checkbox(t('Use the default logo'), "$var][default_logo", 1, $settings['default_logo'], t('Check here if you want the theme to use the logo supplied with it.')); $group .= form_textfield(t('Path to custom logo'), "$var][logo_path", $settings['logo_path'], 50, 60, t('The path to the file you would like to use as your logo file instead of the default logo.')); + + file_check_directory(variable_get('file_directory_path', 'files'), FILE_CREATE_DIRECTORY, 'file_directory_path'); + $group .= form_file(t('Upload logo image'), 'logo_upload', 40, t("If you don't have direct file access to the server, use this field to upload your logo.")); + $group .= form_button(t('Upload'), 'fileop'); + $form = form_group(t('Logo image settings'), $group); + } // System wide only settings. @@ -659,8 +686,11 @@ function system_theme_settings() { } } } + $form .= form_submit(t('Save configuration')); + $form .= form_submit(t('Reset to defaults')); + + print theme('page', form($form, 'post', null, array('enctype' => 'multipart/form-data'))); - print theme('page', system_settings_form($form)); } ?> |