function diff_diffs_show in Diff 5
Same name and namespace in other branches
- 5.2 diff.module \diff_diffs_show()
- 6.2 diff.pages.inc \diff_diffs_show()
- 6 diff.module \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 call to diff_diffs_show()
- diff_diffs in ./
diff.module - Menu callback for diff related activities.
File
- ./
diff.module, line 293
Code
function diff_diffs_show(&$node, $old_vid, $new_vid) {
$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 = '';
}
// display table
$output .= '<table class="diff">';
$output .= '<col class="diff-marker" /><col class="diff-content" /><col class="diff-marker" /><col class="diff-content" />';
$output .= '<thead><tr><th></th><th>' . $old_header . '</th><th></th><th>' . $new_header . '</th></tr></thead>';
if ($new_log || $old_log) {
$output .= '<tr><td></td><td>' . $old_log . '</td><td></td><td>' . $new_log . '</td></tr>';
}
$output .= '<tr><td></td><td class="diff-prevlink">' . $prev_link . '</td><td></td><td class="diff-nextlink">' . $next_link . '</td></tr>';
$output .= _diff_table_body($old_node, $new_node);
$output .= '</table>';
$output .= '<hr/>';
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;
}