function diff_diffs_show in Diff 6
Same name and namespace in other branches
- 5.2 diff.module \diff_diffs_show()
- 5 diff.module \diff_diffs_show()
- 6.2 diff.pages.inc \diff_diffs_show()
- 7.3 diff.pages.inc \diff_diffs_show()
- 7.2 diff.pages.inc \diff_diffs_show()
Create output string for a comparison of 'node' between versions 'old_vid' and 'new_vid'.
Parameters
$node: Node on which to perform comparison
$old_vid: Version ID of the old revision.
$new_vid: Version ID of the new revision.
1 string reference to 'diff_diffs_show'
- diff_menu in ./
diff.module - Implementation of hook_menu() The menu path 'node/$nid/revisions' is overriden with 'diff_diffs'.
File
- ./
diff.module, line 236 - Provides functionality to show a diff between two node revisions.
Code
function diff_diffs_show(&$node, $old_vid, $new_vid) {
// Set same title as on the 'Revisions' tab for consistency
drupal_set_title(t('Revisions for %title', array(
'%title' => $node->title,
)));
$lame_revisions = node_revision_list($node);
foreach ($lame_revisions as $revision) {
$node_revisions[$revision->vid] = $revision;
}
$old_node = node_load($node->nid, $old_vid);
$new_node = node_load($node->nid, $new_vid);
// Generate table header (date, username, logmessage).
$old_header = t('!date by !username', array(
'!date' => l(format_date($old_node->revision_timestamp), "node/{$node->nid}/revisions/{$old_node->vid}/view"),
'!username' => theme('username', $node_revisions[$old_vid]),
));
$new_header = t('!date by !username', array(
'!date' => l(format_date($new_node->revision_timestamp), "node/{$node->nid}/revisions/{$new_node->vid}/view"),
'!username' => theme('username', $node_revisions[$new_vid]),
));
$old_log = $old_node->log != '' ? '<p class="revision-log">' . filter_xss($old_node->log) . '</p>' : '';
$new_log = $new_node->log != '' ? '<p class="revision-log">' . filter_xss($new_node->log) . '</p>' : '';
// Generate previous diff/next diff links.
$next_vid = _diff_get_next_vid($node_revisions, $new_vid);
if ($next_vid) {
$next_link = l(t('next diff >'), 'node/' . $node->nid . '/revisions/view/' . $new_vid . '/' . $next_vid);
}
else {
$next_link = '';
}
$prev_vid = _diff_get_previous_vid($node_revisions, $old_vid);
if ($prev_vid) {
$prev_link = l(t('< previous diff'), 'node/' . $node->nid . '/revisions/view/' . $prev_vid . '/' . $old_vid);
}
else {
$prev_link = '';
}
$cols = _diff_default_cols();
$header = _diff_default_header($old_header, $new_header);
$rows = array();
if ($old_log || $new_log) {
$rows[] = array(
array(
'data' => $old_log,
'colspan' => 2,
),
array(
'data' => $new_log,
'colspan' => 2,
),
);
}
$rows[] = array(
array(
'data' => $prev_link,
'class' => 'diff-prevlink',
'colspan' => 2,
),
array(
'data' => $next_link,
'class' => 'diff-nextlink',
'colspan' => 2,
),
);
$rows = array_merge($rows, _diff_body_rows($old_node, $new_node));
$output = theme('diff_table', $header, $rows, array(
'class' => 'diff',
), NULL, $cols);
if ($node->vid == $new_vid) {
$output .= '<div class="diff-section-title">' . t('Current revision:') . '</div>';
}
else {
$output .= '<div class="diff-section-title">' . t('Revision of !new_date:', array(
'!new_date' => format_date($new_node->revision_timestamp),
)) . '</div>';
}
// Don't include node links (final argument) when viewing the diff.
$output .= node_view($new_node, FALSE, FALSE, FALSE);
return $output;
}