function diff_node_form_add_changes in Diff 5.2
Same name and namespace in other branches
- 5 diff.module \diff_node_form_add_changes()
Callback for node edit form to add the 'Preview changes' output.
1 string reference to 'diff_node_form_add_changes'
- diff_form_alter in ./
diff.module - Implementation of hook_form_alter(). Used to add a 'Preview changes' button on the node edit form.
File
- ./
diff.module, line 583
Code
function diff_node_form_add_changes($form) {
global $form_values;
$op = isset($form_values['op']) ? $form_values['op'] : '';
if ($op == t('Preview changes')) {
// Diff module expects node as object, thus $form_values is cast to an object.
$node = (object) $form_values;
// Create diff of old node and edited node
$rows = _diff_body_rows(node_load($form_values['nid']), $node);
$cols = array(
array(
array(
'class' => 'diff-marker',
),
array(
'class' => 'diff-content',
),
array(
'class' => 'diff-marker',
),
array(
'class' => 'diff-content',
),
),
);
$changes = theme('diff_table', array(), $rows, array(
'class' => 'diff',
), NULL, $cols);
// Prepend diff to edit form
$form['#prefix'] = isset($form['#prefix']) ? $changes . $form['#prefix'] : $changes;
}
return $form;
}