function uniqueness_form_alter in Uniqueness 6
Same name and namespace in other branches
- 7 uniqueness.module \uniqueness_form_alter()
Implementation of hook_form_alter().
File
- ./
uniqueness.module, line 98 - uniqueness.module
Code
function uniqueness_form_alter(&$form, $form_state, $form_id) {
// Select node types to search for similarites.
if ($form_id == 'node_type_form') {
// @todo put this in submission form settings
$form['uniqueness'] = array(
'#type' => 'fieldset',
'#title' => t('Uniqueness settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['uniqueness']['uniqueness_type'] = array(
'#type' => 'checkboxes',
'#title' => t('Provide uniqueness search'),
'#options' => array(
UNIQUENESS_ADD_NODE => t('When adding a new node of this content type'),
UNIQUENESS_EDIT_NODE => t('When editing an existing node of this content type'),
),
'#description' => t('Shows similar content when adding or editing content to help avoid duplication.'),
'#default_value' => variable_get('uniqueness_type_' . $form['#node_type']->type, array()),
);
}
elseif (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] . '_node_form' == $form_id) {
$type = $form['type']['#value'];
$op = empty($form['#node']->nid) ? UNIQUENESS_ADD_NODE : UNIQUENESS_EDIT_NODE;
_uniqueness_widget_store(array(
'type' => $type,
'op' => $op,
));
// Save the content type and operation for later use
if (user_access('use uniqueness widget') && in_array($op, variable_get('uniqueness_type_' . $type, array()))) {
// Add our javascript.
_uniqueness_add_search_javascript($type, $form['nid']['#value']);
// Embed inline widget if enabled.
if (uniqueness_widget_enabled(UNIQUENESS_WIDGET_INLINE)) {
$form['uniqueness'] = array(
'#type' => 'fieldset',
'#title' => filter_xss_admin(variable_get('uniqueness_default_title', t('Related content'))),
'#collapsible' => 1,
'#collapsed' => 0,
'#weight' => $form['title']['#weight'] + 1,
);
$form['uniqueness']['uniqueness_type'] = array(
'#type' => 'item',
'#title' => '',
);
$form['uniqueness']['uniqueness_type']['#value'] = uniqueness_widget_content();
}
// Add our submit handler.
$form['#submit'][] = '_uniqueness_node_add_submit';
}
}
}