function nat_settings_form in Node Auto Term [NAT] 5
Same name and namespace in other branches
- 6.2 nat.admin.inc \nat_settings_form()
- 6 nat.admin.inc \nat_settings_form()
- 7.2 nat.admin.inc \nat_settings_form()
- 7 nat.admin.inc \nat_settings_form()
Menu callback: NAT module settings form.
1 string reference to 'nat_settings_form'
- nat_menu in ./
nat.module - Implementation of hook_menu().
File
- ./
nat.module, line 197 - NAT - node auto term - is a helper module that automatically creates a term using the same title as a node.
Code
function nat_settings_form() {
$types = node_get_types();
$vocabularies = _nat_get_vocabularies();
if (empty($vocabularies)) {
drupal_set_message(t('The NAT module requires at least one vocabulary to be defined.'), 'error');
drupal_goto('admin/content/taxonomy');
}
$nat_config = _nat_variable_get();
foreach ($types as $type => $type_object) {
$collapsed = !isset($nat_config['types'][$type]) || empty($nat_config['types'][$type]);
$form['nat_' . $type] = array(
'#type' => 'fieldset',
'#title' => check_plain($type_object->name),
'#collapsible' => TRUE,
'#collapsed' => $collapsed,
);
$form['nat_' . $type][$type] = array(
'#type' => 'select',
'#title' => t('Vocabularies'),
'#options' => $vocabularies,
'#default_value' => isset($nat_config['types'][$type]) ? $nat_config['types'][$type] : array(),
'#multiple' => TRUE,
'#description' => t('Creating a node of type %type will automatically create a term in any selected vocabularies.', array(
'%type' => $type,
)),
'#parents' => array(
'types',
$type,
),
);
$form['nat_' . $type]['body_' . $type] = array(
'#type' => 'checkbox',
'#title' => t('Associate node body with term description.'),
'#default_value' => isset($nat_config['body'][$type]) ? $nat_config['body'][$type] : 0,
'#parents' => array(
'body',
$type,
),
);
$form['nat_' . $type]['delete_' . $type] = array(
'#type' => 'checkbox',
'#title' => t('Delete associated term if a node is deleted.'),
'#default_value' => isset($nat_config['delete'][$type]) ? $nat_config['delete'][$type] : 0,
'#parents' => array(
'delete',
$type,
),
);
$form['nat_' . $type]['related_' . $type] = array(
'#type' => 'checkbox',
'#title' => t('Allow users to define synonyms and related terms when they create and edit nodes.'),
'#default_value' => isset($nat_config['related'][$type]) ? $nat_config['related'][$type] : 0,
'#parents' => array(
'related',
$type,
),
);
$form['nat_' . $type]['node_links_' . $type] = array(
'#type' => 'checkbox',
'#title' => t('Make NAT terms in %type node views point to the associated node rather than the taxonomy page.', array(
'%type' => $type,
)),
'#default_value' => isset($nat_config['node_links'][$type]) ? $nat_config['node_links'][$type] : 0,
'#parents' => array(
'node_links',
$type,
),
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
return $form;
}