summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/theme.inc17
-rw-r--r--misc/favicon.ico (renamed from favicon.ico)bin8430 -> 8430 bytes
-rw-r--r--modules/system.module30
-rw-r--r--modules/system/system.module30
-rw-r--r--themes/chameleon/chameleon.theme5
-rw-r--r--themes/engines/phptemplate/phptemplate.engine10
6 files changed, 82 insertions, 10 deletions
diff --git a/includes/theme.inc b/includes/theme.inc
index 0de03afe3..53e7b38b6 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -216,7 +216,10 @@ function theme_get_settings($key = NULL) {
'mission' => '',
'default_logo' => 1,
'logo_path' => '',
+ 'default_favicon' => 1,
+ 'favicon_path' => '',
'toggle_logo' => 1,
+ 'toggle_favicon' => 1,
'toggle_name' => 1,
'toggle_search' => 1,
'toggle_slogan' => 0,
@@ -289,6 +292,20 @@ function theme_get_setting($setting_name, $refresh = FALSE) {
}
}
+ if ($settings['toggle_favicon']) {
+ if ($settings['default_favicon']) {
+ if (file_exists($favicon = dirname($theme_object->filename) .'/favicon.ico')) {
+ $settings['favicon'] = $favicon;
+ }
+ else {
+ $settings['favicon'] = 'misc/favicon.ico';
+ }
+ }
+ elseif ($settings['favicon_path']) {
+ $settings['favicon'] = $settings['favicon_path'];
+ }
+ }
+
foreach (array('primary', 'secondary') as $type) {
// Get the data to populate the textfields, if the variable is not an array .. try to parse the old-style link format.
$value = $settings[$type . '_links'];
diff --git a/favicon.ico b/misc/favicon.ico
index 18e2d52f9..18e2d52f9 100644
--- a/favicon.ico
+++ b/misc/favicon.ico
Binary files differ
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)) {
diff --git a/themes/chameleon/chameleon.theme b/themes/chameleon/chameleon.theme
index 563103c74..a0f60a6ed 100644
--- a/themes/chameleon/chameleon.theme
+++ b/themes/chameleon/chameleon.theme
@@ -9,6 +9,7 @@
function chameleon_features() {
return array(
'logo',
+ 'toggle_favicon',
'toggle_name',
'toggle_slogan',
'toggle_primary_links',
@@ -18,6 +19,10 @@ function chameleon_features() {
function chameleon_page($content) {
$language = $GLOBALS['locale'];
+ if (theme_get_setting('toggle_favicon')) {
+ drupal_set_html_head('<link rel="shortcut icon" href="'. check_url(theme_get_setting('favicon')) .'" type="image/x-icon" />');
+ }
+
$title = drupal_get_title();
$output = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
diff --git a/themes/engines/phptemplate/phptemplate.engine b/themes/engines/phptemplate/phptemplate.engine
index 11561716f..310d4e68d 100644
--- a/themes/engines/phptemplate/phptemplate.engine
+++ b/themes/engines/phptemplate/phptemplate.engine
@@ -93,6 +93,7 @@ function _phptemplate_default_variables($hook, $variables) {
function phptemplate_features() {
return array(
'logo',
+ 'toggle_favicon',
'toggle_name',
'toggle_search',
'toggle_slogan',
@@ -110,15 +111,16 @@ function phptemplate_features() {
function phptemplate_page($content) {
/* Set title and breadcrumb to declared values */
- if (file_exists(path_to_theme() . '/favicon.ico')) {
- drupal_set_html_head("<link rel=\"shortcut icon\" href=\"" . path_to_theme() . "/favicon.ico\" />\n");
- }
-
if ($_GET['q'] == variable_get('site_frontpage', 'node')) {
$mission = theme_get_setting('mission');
$frontpage = true;
}
+ /* Add favicon */
+ if (theme_get_setting('toggle_favicon')) {
+ drupal_set_html_head('<link rel="shortcut icon" href="'. check_url(theme_get_setting('favicon')) .'" type="image/x-icon" />');
+ }
+
/**
* Populate sidebars.
*/