function domain_301_redirect_admin_form in Domain 301 Redirect 7
Admin form for configuring Domain 301 Redirect.
1 string reference to 'domain_301_redirect_admin_form'
- domain_301_redirect_menu in ./
domain_301_redirect.module - Implements hook_menu().
File
- ./
domain_301_redirect.admin.inc, line 11 - Administrative pages for the Domain 301 Redirect module.
Code
function domain_301_redirect_admin_form($form_state) {
$disabled_by_check = variable_get('domain_301_redirect_disabled_by_check', false);
$enabled = variable_get('domain_301_redirect_enabled', 0);
// Warn the user if the redirect was disabled by cron.
if (!$enabled && $disabled_by_check) {
$domain = variable_get('domain_301_redirect_domain', '');
$last_checked = variable_get('domain_301_redirect_last_checked', 0);
drupal_set_message(t('Redirects have been disabled by cron because the domain was not available at: %date.', array(
'%date' => format_date($last_checked),
)), 'warning');
}
$form['domain_301_redirect_enabled'] = array(
'#type' => 'radios',
'#title' => t('Status'),
'#description' => t('Enable this setting to start 301 redirects to the domain below for all other domains.'),
'#options' => array(
1 => t('Enabled'),
0 => t('Disabled'),
),
'#default_value' => variable_get('domain_301_redirect_enabled', 0),
);
$form['domain_301_redirect_domain'] = array(
'#type' => 'textfield',
'#title' => t('Domain'),
'#description' => t('This is the domain that all other domains that point to this site will be 301 redirected to. This value should also include the scheme (http or https). E.g. http://www.testsite.com'),
'#default_value' => variable_get('domain_301_redirect_domain', ''),
);
$form['domain_301_redirect_check_period'] = array(
'#type' => 'select',
'#title' => t('Domain Check'),
'#description' => t('This option selects the period between domain validation checks. If the Domain no longer points to this site, Domain 301 Redirection will be disabled.'),
'#options' => array(
0 => t('Disabled'),
3600 => t('1 hour'),
7200 => t('2 hours'),
10800 => t('3 hours'),
21600 => t('6 hours'),
43200 => t('12 hours'),
86400 => t('1 day'),
),
'#default_value' => variable_get('domain_301_redirect_check_period', 60 * 60 * 3),
);
$form['domain_301_redirect_domain_check_retries'] = array(
'#type' => 'select',
'#title' => t('Domain retries'),
'#description' => t('Number of times to check domain availability before disabling redirects.'),
'#options' => array(
1 => 1,
2 => 2,
3 => 3,
),
'#default_value' => variable_get('domain_301_redirect_domain_check_retries', 3),
);
$form['domain_301_redirect_domain_check_reenable'] = array(
'#type' => 'checkbox',
'#title' => t('Re-enable domain redirection'),
'#description' => t('Turn domain redirection on when the domain becomes available.'),
'#default_value' => variable_get('domain_301_redirect_domain_check_reenable', true),
);
// Per-path configuration settings to apply the redirect to specific paths.
$form['applicability']['path'] = array(
'#type' => 'fieldset',
'#title' => t('Pages'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#weight' => 0,
);
$options = array(
BLOCK_VISIBILITY_NOTLISTED => t('All pages except those listed'),
BLOCK_VISIBILITY_LISTED => t('Only the listed pages'),
);
$description = t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array(
'%blog' => 'blog',
'%blog-wildcard' => 'blog/*',
'%front' => '<front>',
));
$title = t('Pages');
$form['applicability']['path']['domain_301_redirect_applicability'] = array(
'#type' => 'radios',
'#title' => t('Redirect on specific pages'),
'#options' => $options,
'#default_value' => variable_get('domain_301_redirect_applicability', BLOCK_VISIBILITY_NOTLISTED),
);
$form['applicability']['path']['domain_301_redirect_pages'] = array(
'#type' => 'textarea',
'#title' => '<span class="element-invisible">' . $title . '</span>',
'#default_value' => variable_get('domain_301_redirect_pages'),
'#description' => $description,
);
return system_settings_form($form);
}