function pathauto_settings_form in Pathauto 6.2
Same name and namespace in other branches
- 7 pathauto.admin.inc \pathauto_settings_form()
Form builder; Configure the Pathauto settings.
See also
1 string reference to 'pathauto_settings_form'
- pathauto_menu in ./
pathauto.module - Implements hook_menu().
File
- ./
pathauto.admin.inc, line 93 - Admin page callbacks for the Pathauto module.
Code
function pathauto_settings_form() {
module_load_include('inc', 'pathauto');
$form['pathauto_verbose'] = array(
'#type' => 'checkbox',
'#title' => t('Verbose'),
'#default_value' => variable_get('pathauto_verbose', FALSE),
'#description' => t('Display alias changes (except during bulk updates).'),
);
$form['pathauto_separator'] = array(
'#type' => 'textfield',
'#title' => t('Separator'),
'#size' => 1,
'#maxlength' => 1,
'#default_value' => variable_get('pathauto_separator', '-'),
'#description' => t('Character used to separate words in titles. This will replace any spaces and punctuation characters. Using a space or + character can cause unexpected results.'),
);
$form['pathauto_case'] = array(
'#type' => 'radios',
'#title' => t('Character case'),
'#default_value' => variable_get('pathauto_case', PATHAUTO_CASE_LOWER),
'#options' => array(
PATHAUTO_CASE_LEAVE_ASIS => t('Leave case the same as source token values.'),
PATHAUTO_CASE_LOWER => t('Change to lower case'),
),
);
$max_length = _pathauto_get_schema_alias_maxlength();
$form['pathauto_max_length'] = array(
'#type' => 'textfield',
'#title' => t('Maximum alias length'),
'#size' => 3,
'#maxlength' => 3,
'#default_value' => variable_get('pathauto_max_length', 100),
'#min_value' => 1,
'#max_value' => $max_length,
'#description' => t('Maximum length of aliases to generate. 100 is the recommended length. @max is the maximum possible length. See <a href="@pathauto-help">Pathauto help</a> for details.', array(
'@pathauto-help' => url('admin/help/pathauto'),
'@max' => $max_length,
)),
'#element_validate' => array(
'_pathauto_validate_numeric_element',
),
);
$form['pathauto_max_component_length'] = array(
'#type' => 'textfield',
'#title' => t('Maximum component length'),
'#size' => 3,
'#maxlength' => 3,
'#default_value' => variable_get('pathauto_max_component_length', 100),
'#min_value' => 1,
'#max_value' => $max_length,
'#description' => t('Maximum text length of any component in the alias (e.g., [title]). 100 is the recommended length. @max is the maximum possible length. See <a href="@pathauto-help">Pathauto help</a> for details.', array(
'@pathauto-help' => url('admin/help/pathauto'),
'@max' => $max_length,
)),
'#element_validate' => array(
'_pathauto_validate_numeric_element',
),
);
$form['pathauto_update_action'] = array(
'#type' => 'radios',
'#title' => t('Update action'),
'#default_value' => variable_get('pathauto_update_action', PATHAUTO_UPDATE_ACTION_DELETE),
'#options' => array(
PATHAUTO_UPDATE_ACTION_NO_NEW => t('Do nothing. Leave the old alias intact.'),
PATHAUTO_UPDATE_ACTION_LEAVE => t('Create a new alias. Leave the existing alias functioning.'),
PATHAUTO_UPDATE_ACTION_DELETE => t('Create a new alias. Delete the old alias.'),
PATHAUTO_UPDATE_ACTION_REDIRECT => t('Create a new alias. Redirect from old alias.'),
),
'#description' => t('What should Pathauto do when updating an existing content item which already has an alias?'),
);
if (!module_exists('path_redirect')) {
// Remove the redirection option if Path redirect is not enabled.
unset($form['pathauto_update_action']['#options'][PATHAUTO_UPDATE_ACTION_REDIRECT]);
if (variable_get('pathauto_update_action', NULL) == PATHAUTO_UPDATE_ACTION_REDIRECT) {
// Fix the current update action variable as well.
variable_set('pathauto_update_action', PATHAUTO_UPDATE_ACTION_DELETE);
}
}
$form['pathauto_transliterate'] = array(
'#type' => 'checkbox',
'#title' => t('Transliterate prior to creating alias'),
'#default_value' => variable_get('pathauto_transliterate', FALSE),
'#description' => t('When a pattern includes certain characters (such as those with accents) should Pathauto attempt to transliterate them into the US-ASCII alphabet? Transliteration is handled by the Transliteration module.'),
);
if (!module_exists('transliteration')) {
// Remove the redirection option if Transliteration is not enabled.
$form['pathauto_transliterate']['#access'] = FALSE;
variable_set('pathauto_transliterate', FALSE);
}
$form['pathauto_reduce_ascii'] = array(
'#type' => 'checkbox',
'#title' => t('Reduce strings to letters and numbers'),
'#default_value' => variable_get('pathauto_reduce_ascii', FALSE),
'#description' => t('Filters the new alias to only letters and numbers found in the ASCII-96 set.'),
);
$form['pathauto_ignore_words'] = array(
'#type' => 'textarea',
'#title' => t('Strings to Remove'),
'#default_value' => variable_get('pathauto_ignore_words', PATHAUTO_IGNORE_WORDS),
'#description' => t('Words to strip out of the URL alias, separated by commas. Do not use this to remove punctuation.'),
'#wysiwyg' => FALSE,
);
$form['punctuation'] = array(
'#type' => 'fieldset',
'#title' => t('Punctuation'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$punctuation = pathauto_punctuation_chars();
foreach ($punctuation as $name => $details) {
$details['default'] = PATHAUTO_PUNCTUATION_REMOVE;
if ($details['value'] == variable_get('pathauto_separator', '-')) {
$details['default'] = PATHAUTO_PUNCTUATION_REPLACE;
}
$form['punctuation']['pathauto_punctuation_' . $name] = array(
'#type' => 'select',
'#title' => $details['name'] . ' (<code>' . check_plain($details['value']) . '</code>)',
'#default_value' => variable_get('pathauto_punctuation_' . $name, $details['default']),
'#options' => array(
PATHAUTO_PUNCTUATION_REMOVE => t('Remove'),
PATHAUTO_PUNCTUATION_REPLACE => t('Replace by separator'),
PATHAUTO_PUNCTUATION_DO_NOTHING => t('No action (do not replace)'),
),
);
}
return system_settings_form($form);
}