- Patch #266246 by David Strauss: added smart defaults for system_settings_form().
parent
f80c618427
commit
bdbd0dffe5
|
@ -805,7 +805,7 @@ function blogapi_admin_settings() {
|
|||
);
|
||||
}
|
||||
|
||||
return system_settings_form($form);
|
||||
return system_settings_form($form, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -31,7 +31,7 @@ function book_admin_settings() {
|
|||
$form['book_allowed_types'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Allowed book outline types'),
|
||||
'#default_value' => variable_get('book_allowed_types', array('book')),
|
||||
'#default_value' => array('book'),
|
||||
'#options' => $types,
|
||||
'#description' => t('Select content types which users with the %add-perm permission will be allowed to add to the book hierarchy. Users with the %outline-perm permission can add all content types.', array('%add-perm' => t('add content to books'), '%outline-perm' => t('administer book outlines'))),
|
||||
'#required' => TRUE,
|
||||
|
@ -39,7 +39,7 @@ function book_admin_settings() {
|
|||
$form['book_child_type'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Default child page type'),
|
||||
'#default_value' => variable_get('book_child_type', 'book'),
|
||||
'#default_value' => 'book',
|
||||
'#options' => $types,
|
||||
'#description' => t('The content type for the %add-child link must be one of those selected as an allowed book outline type.', array('%add-child' => t('Add child page'))),
|
||||
'#required' => TRUE,
|
||||
|
@ -47,7 +47,7 @@ function book_admin_settings() {
|
|||
$form['array_filter'] = array('#type' => 'value', '#value' => TRUE);
|
||||
$form['#validate'][] = 'book_admin_settings_validate';
|
||||
|
||||
return system_settings_form($form);
|
||||
return system_settings_form($form, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -146,20 +146,20 @@ function contact_admin_delete_submit($form, &$form_state) {
|
|||
function contact_admin_settings() {
|
||||
$form['contact_form_information'] = array('#type' => 'textarea',
|
||||
'#title' => t('Additional information'),
|
||||
'#default_value' => variable_get('contact_form_information', t('You can leave a message using the contact form below.')),
|
||||
'#default_value' => t('You can leave a message using the contact form below.'),
|
||||
'#description' => t('Information to show on the <a href="@form">contact page</a>. Can be anything from submission guidelines to your postal address or telephone number.', array('@form' => url('contact'))),
|
||||
);
|
||||
$form['contact_hourly_threshold'] = array('#type' => 'select',
|
||||
'#title' => t('Hourly threshold'),
|
||||
'#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50)),
|
||||
'#default_value' => variable_get('contact_hourly_threshold', 3),
|
||||
'#default_value' => 3,
|
||||
'#description' => t('The maximum number of contact form submissions a user can perform per hour.'),
|
||||
);
|
||||
$form['contact_default_status'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Enable personal contact form by default'),
|
||||
'#default_value' => variable_get('contact_default_status', 1),
|
||||
'#default_value' => 1,
|
||||
'#description' => t('Default status of the personal contact form for new users.'),
|
||||
);
|
||||
return system_settings_form($form);
|
||||
return system_settings_form($form, TRUE);
|
||||
}
|
||||
|
|
|
@ -16,12 +16,12 @@ function dblog_admin_settings() {
|
|||
$form['dblog_row_limit'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Discard log entries above the following row limit'),
|
||||
'#default_value' => variable_get('dblog_row_limit', 1000),
|
||||
'#default_value' => 1000,
|
||||
'#options' => drupal_map_assoc(array(100, 1000, 10000, 100000, 1000000)),
|
||||
'#description' => t('The maximum number of rows to keep in the database log. Older entries will be automatically discarded. (Requires a correctly configured <a href="@cron">cron maintenance task</a>.)', array('@cron' => url('admin/reports/status')))
|
||||
);
|
||||
|
||||
return system_settings_form($form);
|
||||
return system_settings_form($form, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -324,7 +324,7 @@ function filter_admin_configure(&$form_state, $format) {
|
|||
}
|
||||
|
||||
if (!empty($form)) {
|
||||
$form = system_settings_form($form);
|
||||
$form = system_settings_form($form, TRUE);
|
||||
}
|
||||
else {
|
||||
$form['error'] = array('#markup' => t('No settings are available.'));
|
||||
|
|
|
@ -191,25 +191,25 @@ function forum_admin_settings() {
|
|||
$number = drupal_map_assoc(array(5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100, 150, 200, 250, 300, 350, 400, 500));
|
||||
$form['forum_hot_topic'] = array('#type' => 'select',
|
||||
'#title' => t('Hot topic threshold'),
|
||||
'#default_value' => variable_get('forum_hot_topic', 15),
|
||||
'#default_value' => 15,
|
||||
'#options' => $number,
|
||||
'#description' => t('The number of posts a topic must have to be considered "hot".'),
|
||||
);
|
||||
$number = drupal_map_assoc(array(10, 25, 50, 75, 100));
|
||||
$form['forum_per_page'] = array('#type' => 'select',
|
||||
'#title' => t('Topics per page'),
|
||||
'#default_value' => variable_get('forum_per_page', 25),
|
||||
'#default_value' => 25,
|
||||
'#options' => $number,
|
||||
'#description' => t('Default number of forum topics displayed per page.'),
|
||||
);
|
||||
$forder = array(1 => t('Date - newest first'), 2 => t('Date - oldest first'), 3 => t('Posts - most active first'), 4 => t('Posts - least active first'));
|
||||
$form['forum_order'] = array('#type' => 'radios',
|
||||
'#title' => t('Default order'),
|
||||
'#default_value' => variable_get('forum_order', '1'),
|
||||
'#default_value' => '1',
|
||||
'#options' => $forder,
|
||||
'#description' => t('Default display order for topics.'),
|
||||
);
|
||||
return system_settings_form($form);
|
||||
return system_settings_form($form, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -607,7 +607,7 @@ function menu_configure() {
|
|||
$form['menu_default_node_menu'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Default menu for content'),
|
||||
'#default_value' => variable_get('menu_default_node_menu', 'main-menu'),
|
||||
'#default_value' => 'main-menu',
|
||||
'#options' => $menu_options,
|
||||
'#description' => t('Choose the menu to be the default in the menu options in the content authoring form.'),
|
||||
);
|
||||
|
@ -627,11 +627,11 @@ function menu_configure() {
|
|||
$form["menu_secondary_links_source"] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Source for the Secondary links'),
|
||||
'#default_value' => variable_get('menu_secondary_links_source', 'secondary-menu'),
|
||||
'#default_value' => 'secondary-menu',
|
||||
'#options' => $secondary_options,
|
||||
'#tree' => FALSE,
|
||||
'#description' => t("Select the source for the Secondary links. An advanced option allows you to use the same source for both Main links (currently %main) and Secondary links: if your source menu has two levels of hierarchy, the top level menu links will appear in the Main links, and the children of the active link will appear in the Secondary links." , array('%main' => $main_options[$main])),
|
||||
);
|
||||
|
||||
return system_settings_form($form);
|
||||
return system_settings_form($form, TRUE);
|
||||
}
|
||||
|
|
|
@ -30,12 +30,14 @@ function node_configure() {
|
|||
}
|
||||
|
||||
$form['default_nodes_main'] = array(
|
||||
'#type' => 'select', '#title' => t('Number of posts on main page'), '#default_value' => variable_get('default_nodes_main', 10),
|
||||
'#type' => 'select', '#title' => t('Number of posts on main page'),
|
||||
'#default_value' => 10,
|
||||
'#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
|
||||
'#description' => t('The default maximum number of posts to display per page on overview pages such as the main page.')
|
||||
);
|
||||
$form['teaser_length'] = array(
|
||||
'#type' => 'select', '#title' => t('Length of trimmed posts'), '#default_value' => variable_get('teaser_length', 600),
|
||||
'#type' => 'select', '#title' => t('Length of trimmed posts'),
|
||||
'#default_value' => 600,
|
||||
'#options' => drupal_map_assoc(array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000), '_node_characters'),
|
||||
'#description' => t("The maximum number of characters used in the trimmed version of a post. Drupal will use this setting to determine at which offset long posts should be trimmed. The trimmed version of a post is typically used as a teaser when displaying the post on the main page, in XML feeds, etc. To disable teasers, set to 'Unlimited' . Note that this setting will only affect new or updated content and will not affect existing teasers.")
|
||||
);
|
||||
|
@ -43,12 +45,12 @@ function node_configure() {
|
|||
$form['node_preview'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Preview post'),
|
||||
'#default_value' => variable_get('node_preview', 0),
|
||||
'#default_value' => 0,
|
||||
'#options' => array(t('Optional'), t('Required')),
|
||||
'#description' => t('Must users preview posts before submitting?'),
|
||||
);
|
||||
|
||||
return system_settings_form($form);
|
||||
return system_settings_form($form, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -53,19 +53,45 @@ function search_admin_settings() {
|
|||
$items = drupal_map_assoc(array(10, 20, 50, 100, 200, 500));
|
||||
|
||||
// Indexing throttle:
|
||||
$form['indexing_throttle'] = array('#type' => 'fieldset', '#title' => t('Indexing throttle'));
|
||||
$form['indexing_throttle']['search_cron_limit'] = array('#type' => 'select', '#title' => t('Number of items to index per cron run'), '#default_value' => variable_get('search_cron_limit', 100), '#options' => $items, '#description' => t('The maximum number of items indexed in each pass of a <a href="@cron">cron maintenance task</a>. If necessary, reduce the number of items to prevent timeouts and memory errors while indexing.', array('@cron' => url('admin/reports/status'))));
|
||||
$form['indexing_throttle'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Indexing throttle')
|
||||
);
|
||||
$form['indexing_throttle']['search_cron_limit'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Number of items to index per cron run'),
|
||||
'#default_value' => 100,
|
||||
'#options' => $items,
|
||||
'#description' => t('The maximum number of items indexed in each pass of a <a href="@cron">cron maintenance task</a>. If necessary, reduce the number of items to prevent timeouts and memory errors while indexing.', array('@cron' => url('admin/reports/status')))
|
||||
);
|
||||
// Indexing settings:
|
||||
$form['indexing_settings'] = array('#type' => 'fieldset', '#title' => t('Indexing settings'));
|
||||
$form['indexing_settings']['info'] = array('#markup' => t('<p><em>Changing the settings below will cause the site index to be rebuilt. The search index is not cleared but systematically updated to reflect the new settings. Searching will continue to work but new content won\'t be indexed until all existing content has been re-indexed.</em></p><p><em>The default settings should be appropriate for the majority of sites.</em></p>'));
|
||||
$form['indexing_settings']['minimum_word_size'] = array('#type' => 'textfield', '#title' => t('Minimum word length to index'), '#default_value' => variable_get('minimum_word_size', 3), '#size' => 5, '#maxlength' => 3, '#description' => t('The number of characters a word has to be to be indexed. A lower setting means better search result ranking, but also a larger database. Each search query must contain at least one keyword that is this size (or longer).'));
|
||||
$form['indexing_settings']['overlap_cjk'] = array('#type' => 'checkbox', '#title' => t('Simple CJK handling'), '#default_value' => variable_get('overlap_cjk', TRUE), '#description' => t('Whether to apply a simple Chinese/Japanese/Korean tokenizer based on overlapping sequences. Turn this off if you want to use an external preprocessor for this instead. Does not affect other languages.'));
|
||||
$form['indexing_settings'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Indexing settings')
|
||||
);
|
||||
$form['indexing_settings']['info'] = array(
|
||||
'#markup' => t('<p><em>Changing the settings below will cause the site index to be rebuilt. The search index is not cleared but systematically updated to reflect the new settings. Searching will continue to work but new content won\'t be indexed until all existing content has been re-indexed.</em></p><p><em>The default settings should be appropriate for the majority of sites.</em></p>')
|
||||
);
|
||||
$form['indexing_settings']['minimum_word_size'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Minimum word length to index'),
|
||||
'#default_value' => 3,
|
||||
'#size' => 5,
|
||||
'#maxlength' => 3,
|
||||
'#description' => t('The number of characters a word has to be to be indexed. A lower setting means better search result ranking, but also a larger database. Each search query must contain at least one keyword that is this size (or longer).')
|
||||
);
|
||||
$form['indexing_settings']['overlap_cjk'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Simple CJK handling'),
|
||||
'#default_value' => TRUE,
|
||||
'#description' => t('Whether to apply a simple Chinese/Japanese/Korean tokenizer based on overlapping sequences. Turn this off if you want to use an external preprocessor for this instead. Does not affect other languages.')
|
||||
);
|
||||
|
||||
$form['#validate'] = array('search_admin_settings_validate');
|
||||
|
||||
// Per module settings
|
||||
$form = array_merge($form, module_invoke_all('search', 'admin'));
|
||||
return system_settings_form($form);
|
||||
return system_settings_form($form, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -189,14 +189,14 @@ function statistics_access_logging_settings() {
|
|||
$form['access']['statistics_enable_access_log'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Enable access log'),
|
||||
'#default_value' => variable_get('statistics_enable_access_log', 0),
|
||||
'#default_value' => 0,
|
||||
'#options' => $options,
|
||||
'#description' => t('Log each page access. Required for referrer statistics.'));
|
||||
$period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');
|
||||
$form['access']['statistics_flush_accesslog_timer'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Discard access logs older than'),
|
||||
'#default_value' => variable_get('statistics_flush_accesslog_timer', 259200),
|
||||
'#default_value' => 259200,
|
||||
'#options' => $period,
|
||||
'#description' => t('Older access log entries (including referrer statistics) will be automatically discarded. (Requires a correctly configured <a href="@cron">cron maintenance task</a>.)', array('@cron' => url('admin/reports/status'))));
|
||||
|
||||
|
@ -207,9 +207,9 @@ function statistics_access_logging_settings() {
|
|||
$form['content']['statistics_count_content_views'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Count content views'),
|
||||
'#default_value' => variable_get('statistics_count_content_views', 0),
|
||||
'#default_value' => 0,
|
||||
'#options' => $options,
|
||||
'#description' => t('Increment a counter each time content is viewed.'));
|
||||
|
||||
return system_settings_form($form);
|
||||
return system_settings_form($form, TRUE);
|
||||
}
|
||||
|
|
|
@ -41,12 +41,12 @@ function syslog_admin_settings() {
|
|||
$form['syslog_facility'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Send events to this syslog facility'),
|
||||
'#default_value' => variable_get('syslog_facility', DEFAULT_SYSLOG_FACILITY),
|
||||
'#default_value' => DEFAULT_SYSLOG_FACILITY,
|
||||
'#options' => syslog_facility_list(),
|
||||
'#description' => t('Select the syslog facility code under which Drupal\'s messages should be sent. On UNIX/Linux systems, Drupal can flag its messages with the code LOG_LOCAL0 through LOG_LOCAL7; for Microsoft Windows, all messages are flagged with the code LOG_USER. Depending on the system configuration, syslog and other logging tools use this code to identify or filter Drupal messages from within the entire system log. For more information on syslog, see <a href="@syslog_help">Syslog help</a>.', array(
|
||||
'@syslog_help' => url('admin/help/syslog'))),
|
||||
);
|
||||
return system_settings_form($form);
|
||||
return system_settings_form($form, TRUE);
|
||||
}
|
||||
|
||||
function syslog_facility_list() {
|
||||
|
|
|
@ -153,18 +153,18 @@ function system_admin_theme_settings() {
|
|||
'#options' => $options,
|
||||
'#title' => t('Administration theme'),
|
||||
'#description' => t('Choose which theme the administration pages should display in. If you choose "System default" the administration pages will use the same theme as the rest of the site.'),
|
||||
'#default_value' => variable_get('admin_theme', '0'),
|
||||
'#default_value' => '0',
|
||||
);
|
||||
|
||||
$form['node_admin_theme'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Use administration theme for content editing'),
|
||||
'#description' => t('Use the administration theme when editing existing posts or creating new ones.'),
|
||||
'#default_value' => variable_get('node_admin_theme', '0'),
|
||||
'#default_value' => '0',
|
||||
);
|
||||
|
||||
$form['#submit'][] = 'system_admin_theme_submit';
|
||||
return system_settings_form($form);
|
||||
return system_settings_form($form, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -496,7 +496,7 @@ function system_theme_settings(&$form_state, $key = '') {
|
|||
}
|
||||
$form['#attributes'] = array('enctype' => 'multipart/form-data');
|
||||
|
||||
$form = system_settings_form($form);
|
||||
$form = system_settings_form($form, FALSE);
|
||||
// We don't want to call system_settings_form_submit(), so change #submit.
|
||||
$form['#submit'] = array('system_theme_settings_submit');
|
||||
return $form;
|
||||
|
@ -1177,46 +1177,46 @@ function system_site_information_settings() {
|
|||
$form['site_name'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Name'),
|
||||
'#default_value' => variable_get('site_name', 'Drupal'),
|
||||
'#default_value' => 'Drupal',
|
||||
'#description' => t('The name of this website.'),
|
||||
'#required' => TRUE
|
||||
);
|
||||
$form['site_mail'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('E-mail address'),
|
||||
'#default_value' => variable_get('site_mail', ini_get('sendmail_from')),
|
||||
'#default_value' => ini_get('sendmail_from'),
|
||||
'#description' => t("The <em>From</em> address in automated e-mails sent during registration and new password requests, and other notifications. (Use an address ending in your site's domain to help prevent this e-mail being flagged as spam.)"),
|
||||
'#required' => TRUE,
|
||||
);
|
||||
$form['site_slogan'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Slogan'),
|
||||
'#default_value' => variable_get('site_slogan', ''),
|
||||
'#default_value' => '',
|
||||
'#description' => t("Your site's motto, tag line, or catchphrase (often displayed alongside the title of the site).")
|
||||
);
|
||||
$form['site_mission'] = array(
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('Mission'),
|
||||
'#default_value' => variable_get('site_mission', ''),
|
||||
'#default_value' => '',
|
||||
'#description' => t("Your site's mission or focus statement (often prominently displayed on the front page).")
|
||||
);
|
||||
$form['site_footer'] = array(
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('Footer message'),
|
||||
'#default_value' => variable_get('site_footer', ''),
|
||||
'#default_value' => '',
|
||||
'#description' => t('This text will be displayed at the bottom of each page. Useful for adding a copyright notice to your pages.')
|
||||
);
|
||||
$form['anonymous'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Anonymous user'),
|
||||
'#default_value' => variable_get('anonymous', t('Anonymous')),
|
||||
'#default_value' => t('Anonymous'),
|
||||
'#description' => t('The name used to indicate anonymous users.'),
|
||||
'#required' => TRUE,
|
||||
);
|
||||
$form['site_frontpage'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Default front page'),
|
||||
'#default_value' => variable_get('site_frontpage', 'node'),
|
||||
'#default_value' => 'node',
|
||||
'#size' => 40,
|
||||
'#description' => t('The home page displays content from this relative URL. If unsure, specify "node".'),
|
||||
'#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
|
||||
|
@ -1224,7 +1224,7 @@ function system_site_information_settings() {
|
|||
);
|
||||
$form['#validate'][] = 'system_site_information_settings_validate';
|
||||
|
||||
return system_settings_form($form);
|
||||
return system_settings_form($form, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1258,7 +1258,7 @@ function system_error_reporting_settings() {
|
|||
$form['site_403'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Default 403 (access denied) page'),
|
||||
'#default_value' => variable_get('site_403', ''),
|
||||
'#default_value' => '',
|
||||
'#size' => 40,
|
||||
'#description' => t('This page is displayed when the requested document is denied to the current user. If unsure, specify nothing.'),
|
||||
'#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=')
|
||||
|
@ -1267,19 +1267,20 @@ function system_error_reporting_settings() {
|
|||
$form['site_404'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Default 404 (not found) page'),
|
||||
'#default_value' => variable_get('site_404', ''),
|
||||
'#default_value' => '',
|
||||
'#size' => 40,
|
||||
'#description' => t('This page is displayed when no other content matches the requested document. If unsure, specify nothing.'),
|
||||
'#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=')
|
||||
);
|
||||
|
||||
$form['error_level'] = array(
|
||||
'#type' => 'select', '#title' => t('Error reporting'), '#default_value' => variable_get('error_level', 1),
|
||||
'#type' => 'select', '#title' => t('Error reporting'),
|
||||
'#default_value' => 1,
|
||||
'#options' => array(t('Write errors to the log'), t('Write errors to the log and to the screen')),
|
||||
'#description' => t('Specify where Drupal, PHP and SQL errors are logged. While it is recommended that a site running in a production environment write errors to the log only, in a development or testing environment it may be helpful to write errors both to the log and to the screen.')
|
||||
);
|
||||
|
||||
return system_settings_form($form);
|
||||
return system_settings_form($form, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1399,7 +1400,7 @@ function system_performance_settings() {
|
|||
$form['#submit'][] = 'drupal_clear_css_cache';
|
||||
$form['#submit'][] = 'drupal_clear_js_cache';
|
||||
|
||||
return system_settings_form($form);
|
||||
return system_settings_form($form, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1441,12 +1442,12 @@ function system_file_system_settings() {
|
|||
$form['file_downloads'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Download method'),
|
||||
'#default_value' => variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC),
|
||||
'#default_value' => FILE_DOWNLOADS_PUBLIC,
|
||||
'#options' => array(FILE_DOWNLOADS_PUBLIC => t('Public - files are available using HTTP directly.'), FILE_DOWNLOADS_PRIVATE => t('Private - files are transferred by Drupal.')),
|
||||
'#description' => t('Choose the <em>Public download</em> method unless you wish to enforce fine-grained access controls over file downloads. Changing the download method will modify all download paths and may cause unexpected problems on an existing site.')
|
||||
);
|
||||
|
||||
return system_settings_form($form);
|
||||
return system_settings_form($form, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1461,7 +1462,7 @@ function system_image_toolkit_settings() {
|
|||
$form['image_toolkit'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Select an image processing toolkit'),
|
||||
'#default_value' => variable_get('image_toolkit', image_get_toolkit()),
|
||||
'#default_value' => image_get_toolkit(),
|
||||
'#options' => $toolkits_available
|
||||
);
|
||||
}
|
||||
|
@ -1471,7 +1472,7 @@ function system_image_toolkit_settings() {
|
|||
|
||||
$form['image_toolkit_settings'] = image_toolkit_invoke('settings');
|
||||
|
||||
return system_settings_form($form);
|
||||
return system_settings_form($form, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1485,19 +1486,19 @@ function system_rss_feeds_settings() {
|
|||
$form['feed_default_items'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Number of items in each feed'),
|
||||
'#default_value' => variable_get('feed_default_items', 10),
|
||||
'#default_value' => 10,
|
||||
'#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
|
||||
'#description' => t('Default number of items to include in each feed.')
|
||||
);
|
||||
$form['feed_item_length'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Feed content'),
|
||||
'#default_value' => variable_get('feed_item_length', 'teaser'),
|
||||
'#default_value' => 'teaser',
|
||||
'#options' => array('title' => t('Titles only'), 'teaser' => t('Titles plus teaser'), 'fulltext' => t('Full text')),
|
||||
'#description' => t('Global setting for the default display of content items in each feed.')
|
||||
);
|
||||
|
||||
return system_settings_form($form);
|
||||
return system_settings_form($form, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1670,7 +1671,7 @@ function system_date_time_settings() {
|
|||
'#description' => t('A user-defined long date format. See the <a href="@url">PHP manual</a> for available options. This format is currently set to display as <span>%date</span>.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date(REQUEST_TIME, 'custom', $default_long_custom))),
|
||||
);
|
||||
|
||||
$form = system_settings_form($form);
|
||||
$form = system_settings_form($form, FALSE);
|
||||
// We will call system_settings_form_submit() manually, so remove it for now.
|
||||
unset($form['#submit']);
|
||||
return $form;
|
||||
|
@ -1711,7 +1712,7 @@ function system_site_maintenance_settings() {
|
|||
$form['site_offline'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Site status'),
|
||||
'#default_value' => variable_get('site_offline', 0),
|
||||
'#default_value' => 0,
|
||||
'#options' => array(t('Online'), t('Offline')),
|
||||
'#description' => t('When set to "Online", all visitors will be able to browse your site normally. When set to "Offline", only users with the "administer site configuration" permission will be able to access your site to perform maintenance; all other visitors will see the site offline message configured below. Authorized users can log in during "Offline" mode directly via the <a href="@user-login">user login</a> page.', array('@user-login' => url('user'))),
|
||||
);
|
||||
|
@ -1719,11 +1720,11 @@ function system_site_maintenance_settings() {
|
|||
$form['site_offline_message'] = array(
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('Site offline message'),
|
||||
'#default_value' => variable_get('site_offline_message', t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal')))),
|
||||
'#default_value' => t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal'))),
|
||||
'#description' => t('Message to show visitors when the site is in offline mode.')
|
||||
);
|
||||
|
||||
return system_settings_form($form);
|
||||
return system_settings_form($form, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1736,7 +1737,7 @@ function system_clean_url_settings() {
|
|||
$form['clean_url'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Clean URLs'),
|
||||
'#default_value' => variable_get('clean_url', 0),
|
||||
'#default_value' => 0,
|
||||
'#options' => array(t('Disabled'), t('Enabled')),
|
||||
'#description' => t('This option makes Drupal emit "clean" URLs (i.e. without <code>?q=</code> in the URL).'),
|
||||
);
|
||||
|
@ -1756,7 +1757,7 @@ function system_clean_url_settings() {
|
|||
}
|
||||
}
|
||||
|
||||
return system_settings_form($form);
|
||||
return system_settings_form($form, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1284,6 +1284,24 @@ function system_initialize_theme_blocks($theme) {
|
|||
}
|
||||
}
|
||||
|
||||
function _system_settings_form_automatic_defaults($form) {
|
||||
// Get an array of all non-property keys
|
||||
$keys = element_children($form);
|
||||
|
||||
foreach ($keys as $key) {
|
||||
// If the property (key) '#default_value' exists, replace it.
|
||||
if (array_key_exists('#default_value', $form[$key])) {
|
||||
$form[$key]['#default_value'] = variable_get($key, $form[$key]['#default_value']);
|
||||
}
|
||||
else {
|
||||
// Recurse through child elements
|
||||
$form[$key] = _system_settings_form_automatic_defaults($form[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add default buttons to a form and set its prefix.
|
||||
*
|
||||
|
@ -1294,10 +1312,14 @@ function system_initialize_theme_blocks($theme) {
|
|||
* @return
|
||||
* The form structure.
|
||||
*/
|
||||
function system_settings_form($form) {
|
||||
function system_settings_form($form, $automatic_defaults = TRUE) {
|
||||
$form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration') );
|
||||
$form['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset to defaults') );
|
||||
|
||||
if ($automatic_defaults) {
|
||||
$form = _system_settings_form_automatic_defaults($form);
|
||||
}
|
||||
|
||||
if (!empty($_POST) && form_get_errors()) {
|
||||
drupal_set_message(t('The settings have not been saved because of the errors.'), 'error');
|
||||
}
|
||||
|
|
|
@ -718,3 +718,82 @@ class SystemBlockTestCase extends DrupalWebTestCase {
|
|||
|
||||
}
|
||||
|
||||
class SystemSettingsForm extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo().
|
||||
*/
|
||||
function getInfo() {
|
||||
return array(
|
||||
'name' => t('System setting forms'),
|
||||
'description' => t('Tests correctness of system_settings_form() processing.'),
|
||||
'group' => t('System')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of setUp().
|
||||
*/
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
variable_set('system_settings_form_test', TRUE);
|
||||
variable_set('system_settings_form_test_4', TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset page title.
|
||||
*/
|
||||
function tearDown() {
|
||||
variable_del('system_settings_form_test');
|
||||
variable_del('system_settings_form_test_4');
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the handling of automatic defaults in systems_settings_form().
|
||||
*/
|
||||
function testAutomaticDefaults() {
|
||||
$form = array();
|
||||
|
||||
$form['system_settings_form_test'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => FALSE,
|
||||
);
|
||||
|
||||
$form['system_settings_form_test_2'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => FALSE,
|
||||
);
|
||||
|
||||
$form['system_settings_form_test_3'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => TRUE,
|
||||
);
|
||||
|
||||
$form['has_children']['system_settings_form_test_4'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => FALSE,
|
||||
);
|
||||
|
||||
$form['has_children']['system_settings_form_test_5'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => TRUE,
|
||||
);
|
||||
|
||||
$automatic = system_settings_form($form, FALSE);
|
||||
$this->assertFalse($automatic['system_settings_form_test']['#default_value']);
|
||||
$this->assertFalse($automatic['system_settings_form_test_2']['#default_value']);
|
||||
$this->assertTrue($automatic['system_settings_form_test_3']['#default_value']);
|
||||
$this->assertFalse($automatic['has_children']['system_settings_form_test_4']['#default_value']);
|
||||
$this->assertTrue($automatic['has_children']['system_settings_form_test_5']['#default_value']);
|
||||
|
||||
|
||||
$no_automatic = system_settings_form($form);
|
||||
$this->assertTrue($no_automatic['system_settings_form_test']['#default_value']);
|
||||
$this->assertFalse($no_automatic['system_settings_form_test_2']['#default_value']);
|
||||
$this->assertTrue($no_automatic['system_settings_form_test_3']['#default_value']);
|
||||
$this->assertTrue($no_automatic['has_children']['system_settings_form_test_4']['#default_value']);
|
||||
$this->assertTrue($no_automatic['has_children']['system_settings_form_test_5']['#default_value']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ function update_settings() {
|
|||
'#description' => t('If there are updates available of Drupal core or any of your installed modules and themes, your site will print an error message on the <a href="@status_report">status report</a>, the <a href="@modules_page">modules page</a>, and the <a href="@themes_page">themes page</a>. You can choose to only see these error messages if a security update is available, or to be notified about any newer versions.', array('@status_report' => url('admin/reports/status'), '@modules_page' => url('admin/build/modules'), '@themes_page' => url('admin/build/themes')))
|
||||
);
|
||||
|
||||
$form = system_settings_form($form);
|
||||
$form = system_settings_form($form, FALSE);
|
||||
// Custom validation callback for the email notification setting.
|
||||
$form['#validate'][] = 'update_settings_validate';
|
||||
// We need to call our own submit callback first, not the one from
|
||||
|
|
|
@ -148,5 +148,5 @@ function upload_admin_settings() {
|
|||
|
||||
$form['#validate'] = array('upload_admin_settings_validate');
|
||||
|
||||
return system_settings_form($form);
|
||||
return system_settings_form($form, FALSE);
|
||||
}
|
||||
|
|
|
@ -526,7 +526,7 @@ function user_admin_settings() {
|
|||
'#description' => t("This text is displayed at the picture upload form in addition to the default guidelines. It's useful for helping or instructing your users."),
|
||||
);
|
||||
|
||||
return system_settings_form($form);
|
||||
return system_settings_form($form, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue