Same name and namespace in other branches
- 4.7.x modules/system.module \system_theme_settings()
- 5.x modules/system/system.module \system_theme_settings()
- 6.x modules/system/system.admin.inc \system_theme_settings()
- 7.x modules/system/system.admin.inc \system_theme_settings()
Menu callback; display theme configuration for entire site and individual themes.
1 string reference to 'system_theme_settings'
- system_menu in modules/
system.module - Implementation of hook_menu().
File
- modules/
system.module, line 611 - Configuration system that lets administrators modify the workings of the site.
Code
function system_theme_settings($key = '') {
// Default settings are defined in theme_get_settings() in includes/theme.inc
if ($key) {
$settings = theme_get_settings($key);
$var = str_replace('/', '_', 'theme_' . $key . '_settings');
$themes = system_theme_data();
$features = function_exists($themes[$key]->prefix . '_features') ? call_user_func($themes[$key]->prefix . '_features') : array();
}
else {
$settings = theme_get_settings('');
$var = 'theme_settings';
}
// Check for a new uploaded logo, and use that instead.
if ($file = file_check_upload('logo_upload')) {
if ($info = image_get_info($file->filepath)) {
$parts = pathinfo($file->filename);
$filename = $key ? str_replace('/', '_', $key) . '_logo.' . $parts['extension'] : 'logo.' . $parts['extension'];
if ($file = file_save_upload('logo_upload', $filename, 1)) {
$_POST['edit'][$var]['default_logo'] = 0;
$_POST['edit'][$var]['logo_path'] = $file->filepath;
}
}
else {
form_set_error('file_upload', t('Only JPEG, PNG and GIF images are allowed to be used as logos.'));
}
}
system_settings_save();
$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, 128, t('The path to the file you would like to use as your logo file instead of the default logo.'));
$directory_path = variable_get('file_directory_path', 'files');
file_check_directory($directory_path, 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.
if (!$key) {
// Menu settings
$group = form_textarea(t('Primary links'), "{$var}][primary_links", $settings['primary_links'], 70, 8, t('The HTML code for the primary links.'));
$group .= form_textarea(t('Secondary links'), "{$var}][secondary_links", $settings['secondary_links'], 70, 8, t('The HTML code for the secondary links.'));
$form .= form_group(t('Menu Settings'), $group, t('Customize the menus that are displayed at the top and/or bottom of the page. This configuration screen is only available in the site wide display configuration.'));
// Toggle node display.
$node_list = module_invoke('node', 'list');
if ($node_list) {
$group = '';
foreach (node_list() as $type) {
$group .= form_checkbox(node_invoke($type, 'node_name'), "{$var}][toggle_node_info_{$type}", 1, $settings["toggle_node_info_{$type}"]);
}
$form .= form_group(t('Display post information on'), $group, t('Enable or disable the "submitted by Username on date" text when displaying posts of the above type'));
}
}
$group = '';
// Toggle settings
$toggles = array(
'toggle_name' => t('Site name'),
'toggle_slogan' => t('Site slogan'),
'toggle_mission' => t('Mission statement'),
'toggle_primary_links' => t('Primary links'),
'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'),
);
foreach ($toggles as $name => $title) {
if (!$key || in_array($name, $features)) {
// disable search box if search.module is disabled
$group .= form_checkbox($title, "{$var}][{$name}", 1, $settings[$name], NULL, !module_exist('search') && $name == 'toggle_search' ? array(
'disabled' => 'disabled',
) : NULL);
}
}
if ($group) {
$form .= form_group(t('Toggle display'), $group, t('Enable or disable the display of certain page elements.'));
}
if ($key) {
// Template-specific settings
$function = $themes[$key]->prefix . '_settings';
if (function_exists($function)) {
$group = $function();
if ($themes[$key]->template) {
// file is a template or a style of a template
$form .= form_group(t('Engine-specific settings'), $group, t('These settings only exist for all the templates and styles based on the %engine theme engine.', array(
'%engine' => $themes[$key]->prefix,
)));
}
else {
// file is a theme or a style of a theme
$form .= form_group(t('Theme-specific settings'), $group, t('These settings only exist for the %theme theme and all the styles based on it.', array(
'%theme' => $themes[$key]->prefix,
)));
}
}
}
$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',
)));
}