function diff_diffs_show in Diff 6.2
Same name and namespace in other branches
- 5.2 diff.module \diff_diffs_show()
- 5 diff.module \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.
$remove_markup: Strip markup before doing the diff
1 string reference to 'diff_diffs_show'
- diff_menu in ./
diff.module - Implementation of hook_menu().
File
- ./
diff.pages.inc, line 158 - Menu callbacks for hook_menu().
Code
function diff_diffs_show($node, $old_vid, $new_vid, $remove_markup = NULL) {
// Set same title as on the 'Revisions' tab for consistency
drupal_set_title(t('Revisions for %title', array(
'%title' => $node->title,
)));
$node_revisions = node_revision_list($node);
$old_node = node_load($node->nid, $old_vid);
$new_node = node_load($node->nid, $new_vid);
// Set default for remove markup if not set
if ($remove_markup == NULL) {
$remove_markup = variable_get('remove_markup_default_' . $node->type, FALSE);
}
// 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,
),
);
if ($remove_markup) {
$show_hide_markup_link = l(t('Hide/Show Markup'), 'node/' . $node->nid . '/revisions/view/' . $old_vid . '/' . $new_vid . '/0');
}
else {
$show_hide_markup_link = l(t('Hide/Show Markup'), 'node/' . $node->nid . '/revisions/view/' . $old_vid . '/' . $new_vid . '/1');
}
$rows[] = array(
array(
'data' => $show_hide_markup_link,
'class' => 'diff-prevlink',
'colspan' => 4,
),
);
$rows = array_merge($rows, _diff_body_rows($old_node, $new_node, $remove_markup));
$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;
}