? diff-code.patch ? mw_165.patch ? modules/node/node.diff.inc ? modules/node/node.pages-diff.inc ? sites/all/modules ? sites/default/files ? sites/default/settings.php Index: modules/node/content_types.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/content_types.inc,v retrieving revision 1.57 diff -u -p -r1.57 content_types.inc --- modules/node/content_types.inc 16 Jul 2008 21:59:27 -0000 1.57 +++ modules/node/content_types.inc 30 Sep 2008 08:14:05 -0000 @@ -138,6 +138,11 @@ function node_type_form(&$form_state, $t '#options' => drupal_map_assoc(array(0, 10, 25, 50, 75, 100, 125, 150, 175, 200)), '#description' => t('The minimum number of words for the body field to be considered valid for this content type. This can be useful to rule out submissions that do not meet the site\'s standards, such as short test posts.') ); + $form['submission']['node_show_preview_changes'] = array( + '#type' => 'checkbox', + '#title' => t('Show %preview_changes button on edit form', array('%preview_changes' => t('Preview changes'))), + '#default_value' => variable_get('node_show_preview_changes_'. $form['#node_type']->type, FALSE), + ); $form['submission']['help'] = array( '#type' => 'textarea', '#title' => t('Explanation or submission guidelines'), Index: modules/node/node.css =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.css,v retrieving revision 1.5 diff -u -p -r1.5 node.css --- modules/node/node.css 25 Jan 2008 21:21:44 -0000 1.5 +++ modules/node/node.css 30 Sep 2008 08:14:05 -0000 @@ -42,3 +42,60 @@ td.revision-current { .terms-inline { display: inline; } + +/* Diff styles */ +table.diff { + border-spacing: 4px; + margin-bottom: 20px; + table-layout: fixed; + width: 100%; +} +table.diff tr.even, table.diff tr.odd { + background-color: inherit; + border: none; +} +td.diff-prevlink { + text-align: left; +} +td.diff-nextlink { + text-align: right; +} +td.diff-section-title, div.diff-section-title { + background-color: #f0f0ff; + font-size: 0.83em; + font-weight: bold; + padding: 0.1em 1em; +} +td.diff-deletedline { + background-color: #ffa; + width: 50%; +} +td.diff-addedline { + background-color: #afa; + width: 50%; +} +td.diff-context { + background-color: #fafafa; +} +span.diffchange { + color: #f00; + font-weight: bold; +} + +table.diff col.diff-marker { + width: 1.4em; +} +table.diff col.diff-content { + width: 50%; +} +table.diff th { + padding-right: inherit; +} +table.diff td div { + overflow: auto; + padding: 0.1ex 0.5em; + word-wrap: break-word; +} +table.diff td { + padding: 0.1ex 0.4em; +} \ No newline at end of file Index: modules/node/node.info =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.info,v retrieving revision 1.6 diff -u -p -r1.6 node.info --- modules/node/node.info 6 May 2008 12:18:48 -0000 1.6 +++ modules/node/node.info 30 Sep 2008 08:14:05 -0000 @@ -8,3 +8,4 @@ files[] = node.module files[] = content_types.inc files[] = node.admin.inc files[] = node.pages.inc +files[] = node.pages-diff.inc Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.978 diff -u -p -r1.978 node.module --- modules/node/node.module 27 Sep 2008 19:47:43 -0000 1.978 +++ modules/node/node.module 30 Sep 2008 08:14:07 -0000 @@ -135,6 +135,23 @@ function node_theme() { 'node_submitted' => array( 'arguments' => array('node' => NULL), ), + 'node_revisions_overview' => array( + 'arguments' => array('form' => NULL), + 'file' => 'node.pages-diff.inc', + ), + 'diff_header_line' => array( + 'arguments' => array('lineno' => NULL), + 'file' => 'node.pages-diff.inc', + ), + 'diff_content_line' => array( + 'arguments' => array('line' => NULL), + 'file' => 'node.pages-diff.inc', + ), + 'diff_empty_line' => array( + 'arguments' => array('line' => NULL), + 'file' => 'node.pages-diff.inc', + ), + ); } @@ -1609,8 +1626,8 @@ function node_menu() { 'type' => MENU_CALLBACK); $items['node/%node/revisions'] = array( 'title' => 'Revisions', - 'page callback' => 'node_revision_overview', - 'page arguments' => array(1), + 'page callback' => 'drupal_get_form', + 'page arguments' => array('node_revisions_overview', 1), 'access callback' => '_node_revision_access', 'access arguments' => array(1), 'weight' => 2, @@ -1625,6 +1642,22 @@ function node_menu() { 'access arguments' => array(1), 'type' => MENU_CALLBACK, ); + $items['node/%node/revisions/view/%/%'] = array( + 'title' => 'View differences', + 'page callback' => 'node_diffs_show', + 'page arguments' => array(1, 4, 5), + 'type' => MENU_CALLBACK, + 'access callback' => '_node_revision_access', + 'access arguments' => array(1), + ); + $items['node/%node/revisions/view/latest'] = array( + 'title' => 'View differences', + 'page callback' => 'node_diff_latest', + 'page arguments' => array(1), + 'type' => MENU_CALLBACK, + 'access callback' => '_node_revision_access', + 'access arguments' => array(1), + ); $items['node/%node/revisions/%/revert'] = array( 'title' => 'Revert to earlier revision', 'load arguments' => array(3), @@ -1960,7 +1993,6 @@ function node_form_alter(&$form, $form_s ); } - $form['#validate'][] = 'node_search_validate'; } } @@ -2879,3 +2911,29 @@ function node_list_permissions($type) { return $perms; } + +/** + * Implementation of hook_diff() - body and title fields. + */ +function node_diff(&$old_node, &$new_node) { + + $result = array(); + $type = node_get_types('type', $new_node); + $result['title'] = array( + '#name' => $type->title_label, + '#old' => array($old_node->title), + '#new' => array($new_node->title), + '#weight' => -5, + '#format' => array( + 'show_header' => FALSE, + ) + ); + if ($type->has_body) { + $result['body'] = array( + '#name' => $type->body_label, + '#old' => explode("\n", $old_node->body), + '#new' => explode("\n", $new_node->body), + ); + } + return $result; +} Index: modules/node/node.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.pages.inc,v retrieving revision 1.39 diff -u -p -r1.39 node.pages.inc --- modules/node/node.pages.inc 27 Sep 2008 20:37:00 -0000 1.39 +++ modules/node/node.pages.inc 30 Sep 2008 08:14:08 -0000 @@ -248,6 +248,15 @@ function node_form(&$form_state, $node) '#weight' => 10, '#submit' => array('node_form_build_preview'), ); + // Add a 'Preview changes' button on the node edit form. + if (variable_get('node_show_preview_changes_'. $node->type, FALSE) && !empty($node->nid)) { + $form['buttons']['preview_changes'] = array( + '#type' => 'submit', + '#value' => t('Preview changes'), + '#weight' => 13, + '#submit' => array('node_form_preview_changes_submit') + ); + } if (!empty($node->nid) && node_access('delete', $node)) { $form['buttons']['delete'] = array( '#type' => 'submit', @@ -501,51 +510,6 @@ function node_delete_confirm_submit($for } /** - * Generate an overview table of older revisions of a node. - */ -function node_revision_overview($node) { - drupal_set_title(t('Revisions for %title', array('%title' => $node->title))); - - $header = array(t('Revision'), array('data' => t('Operations'), 'colspan' => 2)); - - $revisions = node_revision_list($node); - - $rows = array(); - $revert_permission = FALSE; - if ((user_access('revert revisions') || user_access('administer nodes')) && node_access('update', $node)) { - $revert_permission = TRUE; - } - $delete_permission = FALSE; - if ((user_access('delete revisions') || user_access('administer nodes')) && node_access('delete', $node)) { - $delete_permission = TRUE; - } - foreach ($revisions as $revision) { - $row = array(); - $operations = array(); - - if ($revision->current_vid > 0) { - $row[] = array('data' => t('!date by !username', array('!date' => l(format_date($revision->timestamp, 'small'), "node/$node->nid"), '!username' => theme('username', $revision))) - . (($revision->log != '') ? '

' . filter_xss($revision->log) . '

' : ''), - 'class' => 'revision-current'); - $operations[] = array('data' => theme('placeholder', t('current revision')), 'class' => 'revision-current', 'colspan' => 2); - } - else { - $row[] = t('!date by !username', array('!date' => l(format_date($revision->timestamp, 'small'), "node/$node->nid/revisions/$revision->vid/view"), '!username' => theme('username', $revision))) - . (($revision->log != '') ? '

' . filter_xss($revision->log) . '

' : ''); - if ($revert_permission) { - $operations[] = l(t('revert'), "node/$node->nid/revisions/$revision->vid/revert"); - } - if ($delete_permission) { - $operations[] = l(t('delete'), "node/$node->nid/revisions/$revision->vid/delete"); - } - } - $rows[] = array_merge($row, $operations); - } - - return theme('table', $header, $rows); -} - -/** * Ask for confirmation of the reversion to prevent against CSRF attacks. */ function node_revision_revert_confirm($form_state, $node_revision) { Index: modules/taxonomy/taxonomy.module =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v retrieving revision 1.430 diff -u -p -r1.430 taxonomy.module --- modules/taxonomy/taxonomy.module 27 Sep 2008 20:37:01 -0000 1.430 +++ modules/taxonomy/taxonomy.module 30 Sep 2008 08:14:09 -0000 @@ -1351,3 +1351,56 @@ function taxonomy_hook_info() { ), ); } + +/** + * Implementation of hook_diff(). + */ +function taxonomy_diff(&$old_node, &$new_node) { + $result = array(); + //dsm($old_node);dsm($new_node); + // TODO: make taxonomy by category not only by whole taxonomy? + $old_taxonomy = array(); + $new_taxonomy = array(); + if (isset($old_node->taxonomy) && $old_node->taxonomy) { + foreach ($old_node->taxonomy as $term) { + $old_taxonomy[] = $term->name; + } + } + if (isset($new_node->taxonomy) && $new_node->taxonomy) { + foreach ($new_node->taxonomy as $id => $entry) { + if (is_array($entry)) { + // During editing the taxonomy is built up as a list of vocabulary ids as keys + // and a list of term ids per array entry. + if (is_numeric($id)) { + foreach ($entry as $tid) { + $term = taxonomy_get_term($tid); + $new_taxonomy[] = $term->name; + } + } + else { + // If the id is not numeric than it has to be 'tags' which denotes freetagging + // vocabularies. These are stored as an array which map the vocabulary id to + // a string of terms. + foreach ($entry as $taglist) { + $new_taxonomy = array_merge($new_taxonomy, drupal_explode_tags($taglist)); + } + } + } + else { + // Not during editing the taxonomy list is a list of terms. + $term = taxonomy_get_term($id); + $new_taxonomy[] = $term->name; + } + } + } + $result['taxonomy'] = array( + '#name' => t('Taxonomy'), + '#old' => $old_taxonomy, + '#new' => $new_taxonomy, + '#weight' => -3, + '#format' => array( + 'show_header' => FALSE, + ) + ); + return $result; +} Index: modules/upload/upload.module =================================================================== RCS file: /cvs/drupal/drupal/modules/upload/upload.module,v retrieving revision 1.207 diff -u -p -r1.207 upload.module --- modules/upload/upload.module 27 Sep 2008 20:37:01 -0000 1.207 +++ modules/upload/upload.module 30 Sep 2008 08:14:09 -0000 @@ -634,3 +634,44 @@ function upload_js() { print drupal_to_js(array('status' => TRUE, 'data' => $output)); exit; } + +/** + * Implementation of hook_diff() for file attachments. + */ +function upload_diff(&$old_node, &$new_node) { + $result = array(); + $old_files = array(); + if (isset($old_node->files)) { + foreach ($old_node->files as $file) { + $old_files[] = $file->filename; + } + } + $new_files = array(); + if (isset($new_node->files)) { + foreach ($new_node->files as $key => $file) { + if (is_array($file)) { + // During editing the files are stored as arrays, not objects. + if ($file['remove']) { + // It looks better if a blank line is inserted for removed files. + $new_files[] = ''; + } + else { + $new_files[] = $file['filename']; + } + } + else { + $new_files[] = $file->filename; + } + } + } + $result['attachments'] = array( + '#name' => t('Attachments'), + '#old' => $old_files, + '#new' => $new_files, + '#weight' => 30, + '#format' => array( + 'show_header' => FALSE, + ) + ); + return $result; +} \ No newline at end of file