function word_link_admin_settings in Word Link 7
Same name and namespace in other branches
- 8 word_link.admin.inc \word_link_admin_settings()
- 7.2 word_link.admin.inc \word_link_admin_settings()
Form builder for a settings page.
1 string reference to 'word_link_admin_settings'
- word_link_menu in ./
word_link.module - Implements hook_menu().
File
- ./
word_link.admin.inc, line 11 - Administrative pages for the Word Link module.
Code
function word_link_admin_settings() {
$form['#tree'] = TRUE;
$form['word_link_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Settings'),
'#collapsible' => FALSE,
);
$form['word_link_settings']['word_link_node_types'] = array(
'#type' => 'fieldset',
'#title' => t('Node types'),
'#description' => t('Choose the fields into which Word Link will automatically insert links.'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
// Get all node types.
$node_types = node_type_get_names();
$type_defaults = variable_get('word_link_node_types', array());
foreach ($type_defaults as $content => $type) {
$types = array();
foreach ($type['fields'] as $name => $field) {
if (!is_array($field)) {
$types[$field] = $field;
}
else {
foreach ($field as $fc_field) {
$types[$name . '__' . $fc_field] = $name . '__' . $fc_field;
}
}
}
$type_defaults[$content]['fields'] = isset($types) ? $types : array();
}
foreach ($node_types as $type => $name) {
$fields = word_link_get_node_fields($type);
if (!empty($fields)) {
if (module_exists('comment')) {
$fields['comments'] = t('Comments');
}
$default_values = isset($type_defaults[$type]['fields']) ? $type_defaults[$type]['fields'] : array();
$default_values = is_array($default_values) ? array_filter($default_values) : array();
$form['word_link_settings']['word_link_node_types'][$type] = array(
'#type' => 'fieldset',
'#title' => $name,
'#collapsible' => TRUE,
'#collapsed' => empty($default_values),
);
$form['word_link_settings']['word_link_node_types'][$type]['fields'] = array(
'#type' => 'select',
'#options' => $fields,
'#multiple' => TRUE,
'#tree' => TRUE,
'#default_value' => $default_values,
);
}
}
$form['word_link_settings']['word_link_css'] = array(
'#type' => 'checkbox',
'#title' => t('Add default CSS'),
'#description' => t('If turned on default CSS from module will be added.'),
'#default_value' => variable_get('word_link_css', 1),
);
$form['word_link_settings']['word_link_highlight'] = array(
'#type' => 'checkbox',
'#title' => t('Highlight words.'),
'#description' => t('Highlight found words instead of replace it to links.'),
'#default_value' => variable_get('word_link_highlight', 0),
);
$form['word_link_settings']['word_link_limit'] = array(
'#type' => 'textfield',
'#size' => 5,
'#maxlenghth' => 3,
'#title' => t('Convert limit'),
'#description' => t('Set the maxium instances that will be converted. Use 0 if you want all instances in the node to be converted.'),
'#default_value' => variable_get('word_link_limit', 0),
);
$form['word_link_settings']['word_link_tags_except'] = array(
'#type' => 'textfield',
'#title' => t('Disallowed HTML tags'),
'#description' => t('A list of HTML tags that will be ignored. Never enter here tags that are not text. E.g. @tags.', array(
'@tags' => '<img>',
)),
'#default_value' => variable_get('word_link_tags_except', '<h1> <h2> <h3> <h4> <h5> <h6>'),
);
$form['word_link_add_form']['save'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}