diff options
author | Steven Wittens <steven@10.no-reply.drupal.org> | 2005-05-25 06:03:18 +0000 |
---|---|---|
committer | Steven Wittens <steven@10.no-reply.drupal.org> | 2005-05-25 06:03:18 +0000 |
commit | 6be2c61896c9afe79ad8398c2a851df99e072e7e (patch) | |
tree | 93de416a3c691168ecf9f6d85a2963a3103f1691 /modules | |
parent | 753bc588d9e8a04ba626d272f1eb246fc802f794 (diff) | |
download | brdo-6be2c61896c9afe79ad8398c2a851df99e072e7e.tar.gz brdo-6be2c61896c9afe79ad8398c2a851df99e072e7e.tar.bz2 |
- #20809: User-configurable, per-theme, optional favicons.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/system.module | 30 | ||||
-rw-r--r-- | modules/system/system.module | 30 |
2 files changed, 54 insertions, 6 deletions
diff --git a/modules/system.module b/modules/system.module index d9f675517..495a669d1 100644 --- a/modules/system.module +++ b/modules/system.module @@ -633,6 +633,19 @@ function system_theme_settings($key = '') { } } + // Check for a new uploaded favicon, and use that instead. + if ($file = file_check_upload('favicon_upload')) { + $parts = pathinfo($file->filename); + $filename = ($key) ? str_replace('/', '_', $key) . '_favicon.' . $parts['extension'] : 'favicon.' . $parts['extension']; + + if ($file = file_save_upload('favicon_upload', $filename, 1)) { + $settings['default_favicon'] = 0; + $settings['favicon_path'] = $file->filepath; + + // Update the variable table with the new settings so that they take effect immediately. + variable_set($var, $settings); + } + } $form = ''; @@ -643,10 +656,20 @@ function system_theme_settings($key = '') { 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); + $form .= form_group(t('Logo image settings'), $group); + } + + // Icon settings + if ((!$key) || in_array('toggle_favicon', $features)) { + $group = t('Your shortcut icon or \'favicon\' is displayed in the address bar and bookmarks of most browsers.'); + $group .= form_checkbox(t('Use the default shortcut icon.'), "$var][default_favicon", 1, $settings['default_favicon'], t('Check here if you want the theme to use the default shortcut icon.')); + $group .= form_textfield(t('Path to custom icon'), "$var][favicon_path", $settings['favicon_path'], 50, 128, t('The path to the image file you would like to use as your custom shortcut icon.')); + + file_check_directory(variable_get('file_directory_path', 'files'), FILE_CREATE_DIRECTORY, 'file_directory_path'); + $group .= form_file(t('Upload icon image'), 'favicon_upload', 40, t("If you don't have direct file access to the server, use this field to upload your shortcut icon.")); + $form .= form_group(t('Shortcut icon settings'), $group); } // System wide only settings. @@ -709,7 +732,8 @@ function system_theme_settings($key = '') { 'toggle_secondary_links' => t('Secondary links'), 'toggle_node_user_picture' => t('User pictures in posts'), 'toggle_comment_user_picture' => t('User pictures in comments'), - 'toggle_search' => t('Search box')); + 'toggle_search' => t('Search box'), + 'toggle_favicon' => t('Shortcut icon')); foreach ($toggles as $name => $title) { if ((!$key) || in_array($name, $features)) { diff --git a/modules/system/system.module b/modules/system/system.module index d9f675517..495a669d1 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -633,6 +633,19 @@ function system_theme_settings($key = '') { } } + // Check for a new uploaded favicon, and use that instead. + if ($file = file_check_upload('favicon_upload')) { + $parts = pathinfo($file->filename); + $filename = ($key) ? str_replace('/', '_', $key) . '_favicon.' . $parts['extension'] : 'favicon.' . $parts['extension']; + + if ($file = file_save_upload('favicon_upload', $filename, 1)) { + $settings['default_favicon'] = 0; + $settings['favicon_path'] = $file->filepath; + + // Update the variable table with the new settings so that they take effect immediately. + variable_set($var, $settings); + } + } $form = ''; @@ -643,10 +656,20 @@ function system_theme_settings($key = '') { 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); + $form .= form_group(t('Logo image settings'), $group); + } + + // Icon settings + if ((!$key) || in_array('toggle_favicon', $features)) { + $group = t('Your shortcut icon or \'favicon\' is displayed in the address bar and bookmarks of most browsers.'); + $group .= form_checkbox(t('Use the default shortcut icon.'), "$var][default_favicon", 1, $settings['default_favicon'], t('Check here if you want the theme to use the default shortcut icon.')); + $group .= form_textfield(t('Path to custom icon'), "$var][favicon_path", $settings['favicon_path'], 50, 128, t('The path to the image file you would like to use as your custom shortcut icon.')); + + file_check_directory(variable_get('file_directory_path', 'files'), FILE_CREATE_DIRECTORY, 'file_directory_path'); + $group .= form_file(t('Upload icon image'), 'favicon_upload', 40, t("If you don't have direct file access to the server, use this field to upload your shortcut icon.")); + $form .= form_group(t('Shortcut icon settings'), $group); } // System wide only settings. @@ -709,7 +732,8 @@ function system_theme_settings($key = '') { 'toggle_secondary_links' => t('Secondary links'), 'toggle_node_user_picture' => t('User pictures in posts'), 'toggle_comment_user_picture' => t('User pictures in comments'), - 'toggle_search' => t('Search box')); + 'toggle_search' => t('Search box'), + 'toggle_favicon' => t('Shortcut icon')); foreach ($toggles as $name => $title) { if ((!$key) || in_array($name, $features)) { |