function diff_form_alter in Diff 6.2
Same name and namespace in other branches
- 5.2 diff.module \diff_form_alter()
- 5 diff.module \diff_form_alter()
- 6 diff.module \diff_form_alter()
- 7.2 diff.module \diff_form_alter()
Implementation of hook_form_alter().
File
- ./
diff.module, line 146 - Provides functionality to show a diff between two node revisions.
Code
function diff_form_alter(&$form, $form_state, $form_id) {
if (isset($form['type']['#value']) && $form['type']['#value'] . '_node_form' == $form_id) {
// Add a 'View changes' button on the node edit form.
if (variable_get('show_preview_changes_' . $form['type']['#value'], TRUE) && $form['nid']['#value'] > 0) {
$form['buttons']['preview_changes'] = array(
'#type' => 'submit',
'#value' => t('View changes'),
'#weight' => 12,
'#submit' => array(
'diff_node_form_build_preview_changes',
),
);
}
}
elseif ($form_id == 'node_type_form' && isset($form['identity']['type'])) {
// Node type edit form.
// Add checkbox to activate 'View changes' button per node type.
$form['workflow']['diff'] = array(
'#title' => t('Diff'),
'#type' => 'item',
'#tree' => FALSE,
);
$form['workflow']['diff']['show_preview_changes'] = array(
'#type' => 'checkbox',
'#title' => t('Show %preview_changes button on node edit form', array(
'%preview_changes' => t('View changes'),
)),
'#weight' => 10,
'#default_value' => variable_get('show_preview_changes_' . $form['#node_type']->type, TRUE),
);
$form['workflow']['diff']['remove_markup_default'] = array(
'#type' => 'checkbox',
'#title' => t('Remove markup by default when comparing body text'),
'#weight' => 10,
'#default_value' => variable_get('remove_markup_default_' . $form['#node_type']->type, FALSE),
);
$form['workflow']['diff']['show_diff_inline'] = array(
'#type' => 'checkbox',
'#title' => t('Show diffs inline for this content type'),
'#description' => t("You must enable the 'Inline diff' block to use this feature"),
'#weight' => 10,
'#default_value' => variable_get('show_diff_inline_' . $form['#node_type']->type, FALSE),
);
$form['workflow']['diff']['enable_revisions_page'] = array(
'#type' => 'checkbox',
'#title' => t('Enable the %revisions page for this content type', array(
'%revisions' => t('Revisions'),
)),
'#weight' => 11,
'#default_value' => variable_get('enable_revisions_page_' . $form['#node_type']->type, TRUE),
);
}
}