function content_diff in Content Construction Kit (CCK) 6
Same name and namespace in other branches
- 6.3 includes/content.diff.inc \content_diff()
- 6.2 includes/content.diff.inc \content_diff()
Implementation of hook_diff()
1 string reference to 'content_diff'
- content_init in ./
content.module - Implementation of hook_init().
File
- includes/
content.diff.inc, line 13 - hook_diff() implementations for CCK (especially fields).
Code
function content_diff(&$old_node, &$new_node) {
$result = array();
$cck_info = content_types($new_node->type);
if ($cck_info) {
foreach ($cck_info['fields'] as $field) {
$old_values = array();
$new_values = array();
switch ($field['type']) {
case 'nodereference':
if (isset($old_node->{$field}['field_name'])) {
$old_values = _cck_nodereference_diff_values($old_node, $field);
}
if (isset($new_node->{$field}['field_name'])) {
$new_values = _cck_nodereference_diff_values($new_node, $field);
}
break;
case 'userreference':
if (isset($old_node->{$field}['field_name'])) {
$old_values = _cck_userreference_diff_values($old_node, $field);
}
if (isset($new_node->{$field}['field_name'])) {
$new_values = _cck_userreference_diff_values($new_node, $field);
}
break;
case 'number_integer':
case 'text':
if (isset($old_node->{$field}['field_name'])) {
$old_values = _cck_text_diff_values($old_node, $field);
}
if (isset($new_node->{$field}['field_name'])) {
$new_values = _cck_text_diff_values($new_node, $field);
}
break;
case 'link':
if (isset($old_node->{$field}['field_name'])) {
$old_values = _cck_link_diff_values($old_node, $field);
}
if (isset($new_node->{$field}['field_name'])) {
$new_values = _cck_link_diff_values($new_node, $field);
}
break;
}
$result[$field['field_name']] = array(
'#name' => $field['widget']['label'],
'#old' => $old_values,
'#new' => $new_values,
'#weight' => $field['widget']['weight'],
'#format' => array(
'show_header' => false,
),
);
}
}
return $result;
}