Projet

Général

Profil

Révision 661d64c9

Ajouté par Assos Assos il y a plus de 7 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/diff/CHANGELOG.txt
1

  
2
CHANGELOG for Diff 7.x-2.0+13-dev to 7.x-3.x
3
============================================
4

  
5
1) System variable names have been changed
6
------------------------------------------
7

  
8
Considerable changes have occurred.
9

  
10
2) hook_diff() was removed
11
--------------------------
12

  
13
This has been replaced by hook_entity_diff() as of Diff 7.x-3.x.
14

  
15
3) Field diffs are handled independently by Diff and the field module
16
---------------------------------------------------------------------
17

  
18
Field modules SHOULD NOT implement hook_entity_diff().
19

  
20
This is complicated and costly in terms of performance.
21

  
22
Two new field callbacks are defined to handle these.
23

  
24
  a) MODULE_field_diff_view_prepare()
25

  
26
  Optional: If you need to load data, use MODULE_field_diff_view_prepare().
27

  
28
  b) MODULE_field_diff_view()
29

  
30
  Recommended: You should implement this to generate the compared data.
31

  
32
If there is no corresponding hook for a field, the field comparison will try
33
to guess the value using $item['safe_value'] or $item['value'] properties.
34

  
35
If you need to make this configurable, there are two additional hooks:
36

  
37
  c) MODULE_field_diff_default_options($field_type)
38
  
39
  You should define any additioal settings here. This shares a global namespace
40
  of the diff module, so you can overwrite core Diff settings here too.
41
  
42
  In saying that, take care not to accidentially do this.
43
  
44
  d) MODULE_field_diff_options_form($field_type, $settings)
45
  
46
  This is where you insert Form API elements to configure your option settings.
47

  
48
4) Field diffs are now configurable
49
-----------------------------------
50

  
51
Each field type defined by core have configurable settings to control the
52
rendering of the comparison.
53

  
54
  a) Global configuration
55

  
56
  An administration page has been added to handle field type default settings.
57
  
58
  This is the preferred way to configure field settings are these are global to
59
  all fields of this type.
60

  
61
  b) View mode display options
62

  
63
  The display "Diff comparison" is used to control the fields that are displayed 
64
  when comparing different revisions.
65

  
66
  The following is a walk-through on how you would configure the Basic page
67
  (page) content types field configuration.
68

  
69
  - Enable "Diff comparison" custom view mode
70

  
71
    Navigate to admin/structure/types/manage/page/display and look at the
72
    Custom Display Settings for this view mode. Check and save.
73

  
74
  - Configure the display
75

  
76
    After Saving this page, a new tab appears "Diff comparison", click this or
77
    navigate directly to admin/structure/types/manage/page/display/diff_standard
78

  
79
    - You can hide or show the fields that you want to display when doing 
80
      comparisons.
81
    - If the field has no inbuilt diff support, then the renderred field items
82
      will be compared.
83

  
84
5) Standard comparison preview / Inline diff view setting
85
---------------------------------------------------------
86

  
87
You can set the view modes used to compare the rendered node. This can be found
88
in the Diff settings in the Content Type settings page.
89

  
90
6) Optional CSS and new Boxes styles
91
------------------------------------
92

  
93
This takes the styles from WikiPedia to really spice up the diff page.
94

  
95
7) Optional JScript extras
96
--------------------------
97

  
98
This spices up the revision checkboxes on the revisions page.
99

  
100
8) Simple past revision token support
101
-------------------------------------
102

  
103
Use-case, email notifications when content has changes. If these support tokens,
104
then you can embed Diffs into these emails.
105

  
106
9) Extensive string review
107
--------------------------
108
See http://drupal.org/node/1785742
109

  
110

  
111
10) Inline block settings changes
112
---------------------------------
113
The inline block settings are now in the block configuration page.
114

  
115
11) And much more...
116
--------------------
117

  
118
The complete change log follows:
119

  
120
Diff 7.x-2.x
121
    o #888680 by Deciphered, Alan D.: Allow modules to interact via drupal_alter()
122
    o #1280892 by Alan D., crea: Diff should track the variables that it defines
123
    o #1304658 by Alan D., kari.kaariainen: Remove links and comments from the comparison preview
124
    o #1122206 by binford2k, Alan D.: Notices thrown by DiffEngine::process_chunk()
125
    o #1175064 by zilverdistel, Alan D.: Provide variables for leading and trailing context
126
    o #1673864 by Alan D.: Allow users to bypass the admin theme when viewing comparisons
127
    o #1673876 by Alan D.: Use Drupal autoloading for classes
128
    o #1673856 by Alan D.: Use hook_form_BASE_FORM_ID_alter() rather than hook_form_alter()
129
    o #1673856 by Alan D.: Normalise line endings
130
    o #114308 by Alan D.: add jQuery for hiding radios that shouldn't show diffs
131
    o #1688840 by Alan D.: Enable new JScript behaviour by default
132
    o #372957 by erykmynn, JuliaKM, lsrzj, andrew_rs, alexpott, et al: HTML Strip for Diff, WYSIWYG Friendly
133
      (This was refactored in the 7.x-3.x branch from the commited 7.x-2.x code)    
134
    o #521212 by Alan D., blakehall: Make diff comparison page themable
135
    o #1671484 by Alan D.: Show number of lines changed on revisions page
136
    o #114699 by smokris, Alan D.: Diff module should support Token
137
    o #372957 by c31ck: display either Hide or Show based on what clicking it will do at any time (HTML Strip for Diff)
138
      This was altered for the 7.x-3.x branch.
139
    o #1807510 & #1825202: Simplify Diff administration
140
    o #1812162 by mitchell, Alan D.: 'Highlight changes' block appears on edit form
141

  
142
    Node to Entity changes
143
    ----------------------
144
    These are roughly tracked in the meta issue #1365750 Generalize API and Integrate with core field types
145

  
146
    o (no issue) by Alan D.: Use entity specific system variables.
147
    o (no issue) by Alan D.: View mode code, new hooks, new API. Massive patch!
148

  
149
    Resolves:
150
    o #248778: Taxonomy diff
151
    o #1550698: Diff of "select from list" fields shows change in key, not change in value
152
    o #1458814: File (and image) field support
153
    o #1418760: Optional setting to honour the display settings
154
    o #1347316: Selectable view mode for inline diffs and "Current revision" display view mode
155
    o #1458906: Improve performances (of existing 7.x-2.x field rendering)
156
    o #1424162: Diff in Taxonomy term description
157
    o #1211282: Image diff support
158

  
159
The following patches will be posted in the corresponding project queues once
160
the 7.x-3.x branch is released:
161
    o #1595702 by Alan D., mbilbille: Support of field collection module
162
    o #1350604 by Alan D., johaziel: Datetime diff
163
    o (no issue) by Alan D.: Email field Diff support
164
    o (no issue) by Alan D.: Countries Diff support
165
    o (no issue) by Alan D.: Name field Diff support
166
    o (no issue) by Alan D.: Link field Diff support
drupal7/sites/all/modules/diff/DiffEngine.php
41 41
class _DiffOp_Copy extends _DiffOp {
42 42
  var $type = 'copy';
43 43

  
44
  function _DiffOp_Copy($orig, $closing = FALSE) {
44
  function __construct($orig, $closing = FALSE) {
45 45
    if (!is_array($closing)) {
46 46
      $closing = $orig;
47 47
    }
......
62 62
class _DiffOp_Delete extends _DiffOp {
63 63
  var $type = 'delete';
64 64

  
65
  function _DiffOp_Delete($lines) {
65
  function __construct($lines) {
66 66
    $this->orig = $lines;
67 67
    $this->closing = FALSE;
68 68
  }
......
80 80
class _DiffOp_Add extends _DiffOp {
81 81
  var $type = 'add';
82 82

  
83
  function _DiffOp_Add($lines) {
83
  function __construct($lines) {
84 84
    $this->closing = $lines;
85 85
    $this->orig = FALSE;
86 86
  }
......
98 98
class _DiffOp_Change extends _DiffOp {
99 99
  var $type = 'change';
100 100

  
101
  function _DiffOp_Change($orig, $closing) {
101
  function __construct($orig, $closing) {
102 102
    $this->orig = $orig;
103 103
    $this->closing = $closing;
104 104
  }
......
215 215
      // Find deletes & adds.
216 216
      $delete = array();
217 217
      while ($xi < $n_from && $this->xchanged[$xi]) {
218
        $delete[] = $from_lines[$xi++];
218
        $_fl = $from_lines[$xi++];
219
        if (strlen($_fl)) {
220
          $delete[] = $_fl;
221
        }
219 222
      }
220 223
      $add = array();
221 224
      while ($yi < $n_to && $this->ychanged[$yi]) {
222
        $add[] = $to_lines[$yi++];
225
        $_tl = $to_lines[$yi++];
226
        if (strlen($_tl)) {
227
          $add[] = $_tl;
228
        }
223 229
      }
224 230
      if ($delete && $add) {
225 231
        $edits[] = new _DiffOp_Change($delete, $add);
......
576 582
   *      (Typically these are lines from a file.)
577 583
   * @param $to_lines array An array of strings.
578 584
   */
579
  function Diff($from_lines, $to_lines) {
585
  function __construct($from_lines, $to_lines) {
580 586
    $eng = new _DiffEngine;
581 587
    $this->edits = $eng->diff($from_lines, $to_lines);
582 588
    //$this->_check($from_lines, $to_lines);
......
735 741
   * @param $mapped_to_lines array This array should
736 742
   *  have the same number of elements as $to_lines.
737 743
   */
738
  function MappedDiff($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines) {
739

  
744
  function __construct($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines) {
740 745
    assert(sizeof($from_lines) == sizeof($mapped_from_lines));
741 746
    assert(sizeof($to_lines) == sizeof($mapped_to_lines));
742 747

  
743
    $this->Diff($mapped_from_lines, $mapped_to_lines);
748
    parent::__construct($mapped_from_lines, $mapped_to_lines);
744 749

  
745 750
    $xi = $yi = 0;
746 751
    for ($i = 0; $i < sizeof($this->edits); $i++) {
......
950 955
 * @subpackage DifferenceEngine
951 956
 */
952 957
class _HWLDF_WordAccumulator {
953
  function _HWLDF_WordAccumulator() {
958
  function __construct() {
954 959
    $this->_lines = array();
955 960
    $this->_line = '';
956 961
    $this->_group = '';
......
1016 1021
    return 10000;
1017 1022
  }
1018 1023

  
1019
  function WordLevelDiff($orig_lines, $closing_lines) {
1024
  function __construct($orig_lines, $closing_lines) {
1020 1025
    list($orig_words, $orig_stripped) = $this->_split($orig_lines);
1021 1026
    list($closing_words, $closing_stripped) = $this->_split($closing_lines);
1022 1027

  
1023
    $this->MappedDiff($orig_words, $closing_words, $orig_stripped, $closing_stripped);
1028
    parent::__construct($orig_words, $closing_words, $orig_stripped, $closing_stripped);
1024 1029
  }
1025 1030

  
1026 1031
  function _split($lines) {
......
1095 1100
    'offset' => array('x' => 0, 'y' => 0),
1096 1101
  );
1097 1102

  
1098
  function DrupalDiffFormatter() {
1103
  function __construct() {
1099 1104
    $this->leading_context_lines = variable_get('diff_context_lines_leading', 2);
1100 1105
    $this->trailing_context_lines = variable_get('diff_context_lines_trailing', 2);
1101 1106
  }
drupal7/sites/all/modules/diff/css/diff.boxes.css
1

  
2
html.js .diff-js-hidden { display: none; }
1
html.js .diff-js-hidden {
2
  display: none;
3
}
3 4

  
4 5
/* Reset as many core themes as possible */
5 6
table.diff {
......
8 9
  border: 0 none;
9 10
  width: 98%;
10 11
  border-spacing: 5px;
11
  table-layout: fixed ;
12
  table-layout: fixed;
12 13
  border-collapse: separate;
13 14
}
14 15
table.diff tr td:last-child {
......
24 25
  border-spacing: 4px;
25 26
  padding: 4px 8px;
26 27
}
27
table.diff tr, table.diff tr.even {
28
table.diff tr,
29
table.diff tr.even {
28 30
  background: none;
29 31
}
30
table.diff tr th, table.diff tr th a, table.diff tr th a:hover {
32
table.diff tr th,
33
table.diff tr th a,
34
table.diff tr th a:hover {
31 35
  color: inherit;
32 36
  font-weight: bold;
33 37
}
......
37 41
  border-style: none;
38 42
  background: transparent;
39 43
}
40
table.diff th a { display: inline; }
44
table.diff th a {
45
  display: inline;
46
}
41 47

  
42 48
/* Main theming */
43
table.diff, td.diff-number {
44
  background-color: white
49
table.diff,
50
td.diff-number {
51
  background-color: white;
45 52
}
46 53

  
47 54
table.diff td.diff-lineno {
48
  font-weight: bold
55
  font-weight: bold;
49 56
}
50 57

  
51
table.diff td.diff-addedline, table.diff td.diff-deletedline, table.diff td.diff-context {
58
table.diff td.diff-addedline,
59
table.diff td.diff-deletedline,
60
table.diff td.diff-context {
52 61
  font-size: 88%;
53 62
  vertical-align: top;
54 63
  white-space: -moz-pre-wrap;
55
  white-space: pre-wrap
64
  white-space: pre-wrap;
56 65
}
57 66

  
58
table.diff td.diff-addedline, table.diff td.diff-deletedline {
67
table.diff td.diff-addedline,
68
table.diff td.diff-deletedline {
59 69
  border-style: solid;
60 70
  border-width: 1px 1px 1px 4px;
61
  border-radius: 0.33em
71
  border-radius: 0.33em;
62 72
}
63 73

  
64 74
table.diff td.diff-context {
......
76 86
}
77 87

  
78 88
table.diff td.diff-deletedline {
79
  border-color: #ffe49c
89
  border-color: #ffe49c;
80 90
}
81 91

  
82 92
.diffchange {
83 93
  font-weight: bold;
84
  text-decoration: none
94
  text-decoration: none;
85 95
}
86 96

  
87
table.diff td.diff-addedline .diffchange, table.diff td.diff-deletedline .diffchange {
97
table.diff td.diff-addedline .diffchange,
98
table.diff td.diff-deletedline .diffchange {
88 99
  border-radius: 0.33em;
89
  padding: 0.25em 0
100
  padding: 0.25em 0;
90 101
}
91 102

  
92 103
table.diff td.diff-addedline .diffchange {
93
  background: #d8ecff
104
  background: #d8ecff;
94 105
}
95 106

  
96 107
table.diff td.diff-deletedline .diffchange {
97
  background: #feeec8
108
  background: #feeec8;
98 109
}
99 110

  
100 111
table.diff table.diff td {
101
  padding: 0.33em 0.66em
112
  padding: 0.33em 0.66em;
102 113
}
103 114

  
104 115
table.diff td.diff-marker {
105 116
  width: 2%;
106 117
  text-align: right;
107 118
  font-weight: bold;
108
  font-size: 1.25em  
119
  font-size: 1.25em;
109 120
}
110 121

  
111 122
table.diff col.diff-content {
112
  width: 48%
123
  width: 48%;
113 124
}
114 125

  
115 126
table.diff table.diff td div {
116 127
  word-wrap: break-word;
117
  overflow: auto
128
  overflow: auto;
118 129
}
119 130
td.diff-prevlink {
120 131
  text-align: left;
......
122 133
td.diff-nextlink {
123 134
  text-align: right;
124 135
}
136

  
137
table.diff-revisions tr.revision-published td {
138
  background-color: #aaffaa;
139
}
drupal7/sites/all/modules/diff/css/diff.default.css
1

  
2
html.js .diff-js-hidden { display: none; }
1
html.js .diff-js-hidden {
2
  display: none;
3
}
3 4

  
4 5
/**
5 6
 * Inline diff metadata
6 7
 */
7 8
.diff-inline-metadata {
8
  padding:4px;
9
  border:1px solid #ddd;
10
  background:#fff;
11
  margin:0px 0px 10px;
9
  padding: 4px;
10
  border: 1px solid #ddd;
11
  background: #fff;
12
  margin: 0 0 10px;
12 13
}
13 14

  
14
.diff-inline-legend { font-size:11px; }
15
.diff-inline-legend {
16
  font-size: 11px;
17
}
15 18

  
16 19
.diff-inline-legend span,
17
.diff-inline-legend label { margin-right:5px; }
20
.diff-inline-legend label {
21
  margin-right: 5px;
22
}
18 23

  
19 24
/**
20 25
 * Inline diff markup
21 26
 */
22
span.diff-deleted { color:#ccc; }
23
span.diff-deleted img { border: solid 2px #ccc; }
24
span.diff-changed { background:#ffb; }
25
span.diff-changed img { border:solid 2px #ffb; }
26
span.diff-added { background:#cfc; }
27
span.diff-added img { border: solid 2px #cfc; }
27
span.diff-deleted {
28
  color: #ccc;
29
}
30
span.diff-deleted img {
31
  border: solid 2px #ccc;
32
}
33
span.diff-changed {
34
  background: #ffb;
35
}
36
span.diff-changed img {
37
  border: solid 2px #ffb;
38
}
39
span.diff-added {
40
  background: #cfc;
41
}
42
span.diff-added img {
43
  border: solid 2px #cfc;
44
}
28 45

  
29 46
/**
30 47
 * Traditional split diff theming
......
35 52
  table-layout: fixed;
36 53
  width: 100%;
37 54
}
38
table.diff tr.even, table.diff tr.odd {
55
table.diff tr.even,
56
table.diff tr.odd {
39 57
  background-color: inherit;
40 58
  border: none;
41 59
}
......
45 63
td.diff-nextlink {
46 64
  text-align: right;
47 65
}
48
td.diff-section-title, div.diff-section-title {
66
td.diff-section-title,
67
div.diff-section-title {
49 68
  background-color: #f0f0ff;
50 69
  font-size: 0.83em;
51 70
  font-weight: bold;
......
84 103
table.diff td {
85 104
  padding: 0.1ex 0.4em;
86 105
}
106

  
107
table.diff-revisions tr.revision-published td {
108
  background-color: #aaffaa;
109
}
drupal7/sites/all/modules/diff/diff.admin.inc
20 20
    '#empty_option' => t('- None -'),
21 21
    '#description' => t('Alter the CSS used when displaying diff results.'),
22 22
  );
23
  $form['diff_default_state_node'] = array(
24
    '#type' => 'select',
25
    '#title' => t('Diff default state'),
26
    '#default_value' => variable_get('diff_default_state_node', 'raw'),
27
    '#options' => array(
28
      'raw' => t('HTML view'),
29
      'raw_plain' => t('Plain view'),
30
    ),
31
    '#empty_option' => t('- None -'),
32
    '#description' => t('Default display to show when viewing a diff, html tags in diffed result or as plain text.'),
33
  );
34 23
  $form['diff_radio_behavior'] = array(
35 24
    '#type' => 'select',
36 25
    '#title' => t('Diff radio behavior'),
......
68 57
function diff_admin_global_entity_settings($form, $form_state, $entity_type) {
69 58
  $entity_info = entity_get_info($entity_type);
70 59
  drupal_set_title(t('Diff settings for %entity_label entities', array('%entity_label' => $entity_info['label'])), PASS_THROUGH);
60

  
61
  if ($options = module_invoke_all('entity_diff_options', $entity_type)) {
62
    $form['diff_additional_options_' . $entity_type] = array(
63
      '#type' => 'checkboxes',
64
      '#title' => t('Property options'),
65
      '#default_value' => variable_get('diff_additional_options_' . $entity_type, array()),
66
      '#options' => $options,
67
    );
68
  }
69
  else {
70
    $form['diff_additional_options_' . $entity_type] = array(
71
      '#type' => 'value',
72
      '#value' => array(),
73
    );
74
  }
75

  
71 76
  $form['diff_show_header_' . $entity_type] = array(
72 77
    '#type' => 'checkbox',
73
    '#title' => t('Show entity label header'),
78
    '#title' => t('Show entity label row header'),
74 79
    '#default_value' => variable_get('diff_show_header_' . $entity_type, 1),
75 80
  );
81
  if (user_access('administer permissions')) {
82
    $admin_link = l(t('View the administration theme'), 'admin/people/permissions', array('fragment' => 'edit-view-the-administration-theme'));
83
  }
84
  else {
85
    $admin_link = t('View the administration theme');
86
  }
76 87
  $form['diff_admin_path_' . $entity_type] = array(
77 88
    '#type' => 'checkbox',
78
    '#title' => t('Treat diff pages as administrative'),
79
    '#description' => t('Diff pages are treated as administrative pages by default, although it is up to each module to enforce this and to implement this optional setting.'),
89
    '#title' => t('Use administration theme'),
90
    '#description' => t('This option will enable users with the <em>!link</em> permission to use the admin theme when doing comparisons.', array('!link' => $admin_link)),
80 91
    '#default_value' => variable_get('diff_admin_path_' . $entity_type, 1),
81 92
  );
93
  $form['diff_default_state_' . $entity_type] = array(
94
    '#type' => 'select',
95
    '#title' => t('Diff default state'),
96
    '#default_value' => variable_get('diff_default_state_' . $entity_type, 'raw'),
97
    '#options' => array(
98
      'raw' => t('HTML view'),
99
      'raw_plain' => t('Plain view'),
100
    ),
101
    '#empty_option' => t('- None -'),
102
    '#description' => t('Default display to show when viewing a diff, html tags in diffed result or as plain text.'),
103
  );
82 104
  return system_settings_form($form);
83 105
}
84 106

  
drupal7/sites/all/modules/diff/diff.api.php
11 11
 */
12 12

  
13 13
/**
14
 * Allow modules to provide a comparison about entities.
14
 * Allow modules to provide a comparison about entity properties.
15 15
 *
16 16
 * @param object $old_entity
17 17
 *   The older entity revision.
18
 *
18 19
 * @param object $new_entity
19 20
 *   The newer entity revision.
21
 *
20 22
 * @param array $context
21 23
 *   An associative array containing:
22 24
 *   - entity_type: The entity type; e.g., 'node' or 'user'.
23
 *   - view_mode: The view mode to use. Defaults to FALSE.
25
 *   - old_entity: The older entity.
26
 *   - new_entity: The newer entity.
27
 *   - view_mode: The view mode to use. Defaults to FALSE. If no view mode is
28
 *                given, the recommended fallback view mode is 'default'.
29
 *   - states: An array of view states. These could be one of:
30
 *     - raw: The raw value of the diff, the classic 7.x-2.x view.
31
 *     - rendered: The rendered HTML as determined by the view mode. Only
32
 *                 return markup for this state if the value is normally shown
33
 *                 by this view mode. The user will most likely be able to see
34
 *                 the raw or raw_plain state, so this is optional.
35
 *
36
 *                 The rendering state is a work in progress.
37
 *
38
 *     Conditionally, you can get these states, but setting these will override
39
 *     the user selectable markdown method.
40
 *
41
 *     - raw_plain: As raw, but text should be markdowned.
42
 *     - rendered_plain: As rendered, but text should be markdowned.
24 43
 *
25 44
 * @return array
26 45
 *   An associative array of values keyed by the entity property.
27 46
 *
28
 * @todo
29
 *   Investiagate options and document these.
47
 *   This is effectively an unnested Form API-like structure.
48
 *
49
 *   States are returned as follows:
50
 *
51
 *   $results['line'] = array(
52
 *     '#name' => t('Line'),
53
 *     '#states' => array(
54
 *       'raw' => array(
55
 *         '#old' => '<p class="line">This was the old line number [tag].</p>',
56
 *         '#new' => '<p class="line">This is the new line [tag].</p>',
57
 *       ),
58
 *       'rendered' => array(
59
 *         '#old' => '<p class="line">This was the old line number <span class="line-number">57</span>.</p>',
60
 *         '#new' => '<p class="line">This is the new line <span class="line-number">57</span>.</p>',
61
 *       ),
62
 *     ),
63
 *   );
64
 *
65
 *   For backwards compatibility, no changes are required to support states,
66
 *   but it is recommended to provide a better UI for end users.
67
 *
68
 *   For example, the following example is equivalent to returning the raw
69
 *   state from the example above.
70
 *
71
 *   $results['line'] = array(
72
 *     '#name' => t('Line'),
73
 *     '#old' => '<p class="line">This was the old line number [tag].</p>',
74
 *     '#new' => '<p class="line">This is the new line [tag].</p>',
75
 *   );
30 76
 */
31 77
function hook_entity_diff($old_entity, $new_entity, $context) {
78
  $results = array();
79

  
32 80
  if ($context['entity_type'] == 'node') {
33 81
    $type = node_type_get_type($new_entity);
34
    $result['title'] = array(
82
    $results['title'] = array(
35 83
      '#name' => $type->title_label,
36 84
      '#old' => array($old_entity->title),
37 85
      '#new' => array($new_entity->title),
......
41 89
      ),
42 90
    );
43 91
  }
92

  
93
  return $results;
44 94
}
45 95

  
46 96
/**
......
57 107
 *
58 108
 * @see hook_entity_diff()
59 109
 */
60
function hook_entity_diff_alter($entity_diffs, $context) {
110
function hook_entity_diff_alter(&$entity_diffs, $context) {
61 111
}
62 112

  
63 113
/**
drupal7/sites/all/modules/diff/diff.css
1

  
2
html.js .diff-js-hidden { display:none; }
1
html.js .diff-js-hidden {
2
  display:none;
3
}
3 4

  
4 5
/**
5 6
 * Inline diff metadata
6 7
 */
7 8
.diff-inline-metadata {
8
  padding:4px;
9
  border:1px solid #ddd;
10
  background:#fff;
11
  margin:0px 0px 10px;
12
  }
13

  
14
.diff-inline-legend { font-size:11px; }
9
  padding: 4px;
10
  border: 1px solid #ddd;
11
  background: #fff;
12
  margin: 0 0 10px;
13
}
15 14

  
15
.diff-inline-legend {
16
  font-size: 11px;
17
}
16 18
.diff-inline-legend span,
17
.diff-inline-legend label { margin-right:5px; }
19
.diff-inline-legend label {
20
  margin-right: 5px;
21
}
18 22

  
19 23
/**
20 24
 * Inline diff markup
21 25
 */
22
span.diff-deleted { color:#ccc; }
23
span.diff-deleted img { border: solid 2px #ccc; }
24
span.diff-changed { background:#ffb; }
25
span.diff-changed img { border:solid 2px #ffb; }
26
span.diff-added { background:#cfc; }
27
span.diff-added img { border: solid 2px #cfc; }
26
span.diff-deleted {
27
  color: #ccc;
28
}
29
span.diff-deleted img {
30
  border: solid 2px #ccc;
31
}
32
span.diff-changed {
33
  background: #ffb;
34
}
35
span.diff-changed img {
36
  border: solid 2px #ffb;
37
}
38
span.diff-added {
39
  background: #cfc;
40
}
41
span.diff-added img {
42
  border: solid 2px #cfc;
43
}
28 44

  
29 45
/**
30 46
 * Traditional split diff theming
......
35 51
  table-layout: fixed;
36 52
  width: 100%;
37 53
}
38
table.diff tr.even, table.diff tr.odd {
54
table.diff tr.even,
55
table.diff tr.odd {
39 56
  background-color: inherit;
40 57
  border: none;
41 58
}
......
45 62
td.diff-nextlink {
46 63
  text-align: right;
47 64
}
48
td.diff-section-title, div.diff-section-title {
65
td.diff-section-title,
66
div.diff-section-title {
49 67
  background-color: #f0f0ff;
50 68
  font-size: 0.83em;
51 69
  font-weight: bold;
drupal7/sites/all/modules/diff/diff.diff.inc
12 12
 *
13 13
 * This manually invokes hook_diff() to avoid a function name clash with the
14 14
 * PHP 5 (>= 5.3.0) date_diff() function or the Dates modules implementation.
15
 *
16
 * @param object $old_entity
17
 *   The older node revision.
18
 * @param object $new_entity
19
 *   The newer node revision.
20
 * @param array $context
21
 *   An associative array containing:
22
 *   - entity_type: The entity type; e.g., 'node' or 'user'.
23
 *   - old_entity: The older entity.
24
 *   - new_entity: The newer entity.
25
 *   - view_mode: The view mode to use. Defaults to FALSE.
26 15
 */
27 16
function diff_entity_diff($old_entity, $new_entity, $context) {
28 17
  $return = array();
......
52 41
 *   - old_entity: The older entity.
53 42
 *   - new_entity: The newer entity.
54 43
 *   - view_mode: The view mode to use. Defaults to FALSE.
44
 * @param string $default_langcode
45
 *   (optional) Language code to force comparison in.
55 46
 *
56 47
 * @return array
57 48
 *   An associative array of values keyed by the field name and delta value.
58 49
 */
59
function diff_entity_fields_diff($old_entity, $new_entity, $context) {
50
function diff_entity_fields_diff($old_entity, $new_entity, $context, $default_langcode = NULL) {
60 51
  $result = array();
61 52

  
62 53
  $entity_type = $context['entity_type'];
......
65 56
  $field_context = $context;
66 57

  
67 58
  $actual_mode = FALSE;
68
  list(,, $bundle_name) = entity_extract_ids($entity_type, $new_entity);
59
  list(, , $bundle_name) = entity_extract_ids($entity_type, $new_entity);
69 60
  $instances = field_info_instances($entity_type, $bundle_name);
70 61

  
71 62
  // Some fields piggy back the display settings, so we need to fake these by
......
98 89

  
99 90
    // We provide a loose check on the field access.
100 91
    if (field_access('view', $field, $entity_type) || field_access('edit', $field, $entity_type)) {
101
      $langcode = field_language($entity_type, $new_entity, $field_name);
92
      $langcode = $default_langcode ? $default_langcode : field_language($entity_type, $new_entity, $field_name);
102 93

  
103 94
      $field_context['language'] = $langcode;
104 95
      $field_context['field'] = $field;
......
136 127
        $func = 'diff_field_diff_view';
137 128
      }
138 129

  
130
      // Copy the static ID cache to ensure this is the same for each comparison.
131
      $original_html_ids = drupal_static('drupal_html_id');
132
      $html_ids = &drupal_static('drupal_html_id');
133

  
139 134
      // These callbacks should be independent of revision.
140 135
      $old_context = $field_context;
141 136
      $old_context['entity'] = $old_entity;
142 137
      $old_values = $func($old_items, $old_context);
138

  
139
      // Restores the ID cache to the original.
140
      $html_ids = $original_html_ids;
141

  
143 142
      $new_context = $field_context;
144 143
      $new_context['entity'] = $new_entity;
145 144
      $new_values = $func($new_items, $new_context);
......
200 199
 *   An array of strings representing the value, keyed by delta index.
201 200
 */
202 201
function diff_field_diff_view($items, $context) {
202
  // Prevent unnecessary rendering of the field. This also prevents issues
203
  // where field_view_field() will use a language fallback for display that
204
  // may not match the requested diff comparison language.
205
  if (!$items) {
206
    return array();
207
  }
208

  
203 209
  $diff_items = array();
204
   $entity = clone $context['entity'];
205
   $langcode = field_language($context['entity_type'], $entity, $context['field']['field_name']);
206
   $view_mode = empty($context['view_mode']) ? 'diff_standard' : $context['view_mode'];
207
   $element = field_view_field($context['entity_type'], $entity, $context['field']['field_name'], $view_mode, $langcode);
208

  
209
   foreach (element_children($element) as $delta) {
210
     $diff_items[$delta] = drupal_render($element[$delta]);
211
   }
210
  $entity = clone $context['entity'];
211
  $langcode = field_language($context['entity_type'], $entity, $context['field']['field_name']);
212
  $view_mode = empty($context['view_mode']) ? 'diff_standard' : $context['view_mode'];
213
  $element = field_view_field($context['entity_type'], $entity, $context['field']['field_name'], $view_mode, $langcode);
214

  
215
  foreach (element_children($element) as $delta) {
216
    $diff_items[$delta] = drupal_render($element[$delta]);
217
  }
212 218
  return $diff_items;
213 219
}
214 220

  
215 221
/**
216 222
 * Helper function to get the settings for a given field or formatter.
217 223
 *
218
 * @param array $context
224
 * @param array $field_context
219 225
 *   This will get the settings for a field.
220 226
 *   - field (required): The field that the items belong to.
221 227
 *   - entity: The entity that we are looking up.
......
274 280
    ),
275 281
  );
276 282

  
277
  /*
278
This would be cool, but to do anything else than inline with the text appears
279
to be very hard, requiring a refactoring of both the modules API but also the
280
DiffFormatter and Diff classes. Diff 8.x-4.x maybe.
281

  
282
  $subform['show_delta'] = array(
283
    '#type' => 'checkbox',
284
    '#title' => t('Show delta values'),
285
    '#default_value' => $settings['show_delta'],
286
  );
287
  $subform['delta_format'] = array(
288
    '#type' => 'radios',
289
    '#title' => t('Delta insertion method'),
290
    '#default_value' => $settings['delta_format'],
291
    '#options' => array(
292
      'inline' => t('Prefix to item'),
293
      'row' => t('Individual row'),
294
    ),
295
    '#states' => array(
296
      'invisible' => array(
297
        "input[id$='show-delta']" => array('checked' => FALSE),
298
      ),
299
    ),
300
  );
301
  */
302 283
}
303 284

  
304 285
/**
......
323 304
    'markdown' => function_exists($func) ? '' : 'drupal_html_to_text',
324 305
    'line_counter' => '',
325 306
    'show_header' => 1,
326
    // Can we? This seems too hard to track in the DiffFormatter as all we
327
    // have is a string or an array of strings.
328
    //'show_delta' => 0,
329
    //'delta_format' => 'row',
330 307
  );
308

  
331 309
  return $settings;
332 310
}
333 311

  
drupal7/sites/all/modules/diff/diff.info
1 1
name = Diff
2 2
description = Show differences between content revisions.
3 3
core = 7.x
4
configure = admin/config/content/diff
4 5

  
5 6
files[] = DiffEngine.php
6 7

  
7
; Information added by drupal.org packaging script on 2012-11-13
8
version = "7.x-3.2"
8
; Information added by Drupal.org packaging script on 2016-12-20
9
version = "7.x-3.3"
9 10
core = "7.x"
10 11
project = "diff"
11
datestamp = "1352784357"
12
datestamp = "1482211686"
12 13

  
drupal7/sites/all/modules/diff/diff.install
5 5
 * Provides uninstallation functions.
6 6
 */
7 7

  
8
/**
9
 * Implements hook_install().
10
 */
11
function diff_install() {
12
  user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('diff view changes'));
13
  user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('diff view changes'));
14
}
15

  
8 16
/**
9 17
 * Implements hook_uninstall().
10 18
 */
......
16 24
    'diff_view_mode_',
17 25
    'diff_admin_path_',
18 26
    'diff_default_state_',
27
    'diff_additional_options_',
19 28
  );
20 29
  foreach ($prefixes as $prefix) {
21 30
    db_delete('variable')
......
55 64
  }
56 65
}
57 66

  
58
/**
59
 * Removed diff_update_7301().
60
 */
61

  
62
/**
63
 * Removed diff_update_7302().
64
 */
65

  
66 67
/**
67 68
 * Renames some internal settings names.
68 69
 */
69 70
function diff_update_7303() {
70
  // Get current values
71
  // Get current values.
71 72
  $radio = variable_get('diff_script_revisioning', 'simple');
72 73
  $leading = variable_get('diff_leading_context_lines', 2);
73 74
  $trailing = variable_get('diff_trailing_context_lines', 2);
74
  // Create new variable names
75
  // Create new variable names.
75 76
  variable_set('diff_radio_behavior', $radio);
76 77
  variable_set('diff_context_lines_leading', $leading);
77 78
  variable_set('diff_context_lines_trailing', $trailing);
78
  // Delete old variables
79
  // Delete old variables.
79 80
  variable_del('diff_script_revisioning');
80 81
  variable_del('diff_leading_context_lines');
81 82
  variable_del('diff_trailing_context_lines');
......
88 89
  // This is now always applied to text fields.
89 90
  variable_del('diff_normalise_text');
90 91

  
91
  // Merge the content type settings for the inline diff block into a single variable.
92
  // diff_update_7300() - show_diff_inline_TYPE to diff_show_diff_inline_node_TYPE
92
  // Merge the content type settings for the inline diff block into a single
93
  // variable.
93 94
  $node_types = array_keys(node_type_get_types());
94 95
  $enabled_types = array();
95 96
  foreach ($node_types as $node_type) {
......
122 123
      ->condition('name', db_like('diff_view_mode_inline_') . '%', 'LIKE')
123 124
      ->execute();
124 125
}
126

  
127
/**
128
 * Sets the optional additional node properties to render so that the title
129
 * still shows by default when doing node comparisons.
130
 */
131
function diff_update_7306() {
132
  variable_set('diff_additional_options_node', array('title' => 'title'));
133
}
134

  
135
/**
136
 * Grants access to the Diff "View Changes" button permission to all users.
137
 */
138
function diff_update_7307() {
139
  user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('diff view changes'));
140
  user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('diff view changes'));
141
}
drupal7/sites/all/modules/diff/diff.module
39 39
    case 'admin/help#diff':
40 40
      $output = '<p>' . t('The Diff module replaces the normal <em>Revisions</em> node tab. Diff enhances the listing of revisions with an option to view the differences between any two content revisions. Access to this feature is controlled with the <em>View revisions</em> permission. The feature can be disabled for an entire content type on the content type configuration page. Diff also provides an optional <em>View changes</em> button while editing a node.') . '</p>';
41 41
      return $output;
42

  
42 43
    case 'node/%/revisions/%/view':
43 44
      // The translated strings should match node_help('node/%/revisions').
44 45
      return '<p>' . t('Revisions allow you to track differences between multiple versions of your content, and revert back to older versions.') . '</p>';
46

  
45 47
    case 'node/%/revisions/view/%/%':
46 48
      return '<p>' . t('Comparing two revisions:') . '</p>';
49

  
47 50
  }
48 51
}
49 52

  
......
104 107
    'page callback' => 'diff_latest',
105 108
    'page arguments' => array(1),
106 109
    'type' => MENU_LOCAL_TASK,
107
    'access callback' => 'diff_node_revision_access',
108
    'access arguments' => array(1),
110
    'access arguments' => array('access content'),
109 111
    'tab_parent' => 'node/%/revisions/view',
110 112
    'file' => 'diff.pages.inc',
111 113
  );
......
152 154
  );
153 155

  
154 156
  $items['admin/config/content/diff/entities/node'] = array(
155
    'title' => 'Node',
157
    'title' => 'Nodes',
158
    'description' => 'Node comparison settings.',
156 159
    'type' => MENU_DEFAULT_LOCAL_TASK,
157 160
    'weight' => -10,
158 161
  );
162
  $items['admin/config/content/diff/entities/user'] = array(
163
    'title' => 'Users',
164
    'description' => 'User diff settings.',
165
    'file' => 'diff.admin.inc',
166
    'page callback' => 'drupal_get_form',
167
    'page arguments' => array('diff_admin_global_entity_settings', 'user'),
168
    'access arguments' => array('administer site configuration'),
169
    'type' => MENU_LOCAL_TASK,
170
  );
159 171

  
160 172
  return $items;
161 173
}
......
197 209
  return $may_revision_this_type && _node_revision_access($node, $op);
198 210
}
199 211

  
212
/**
213
 * Implements hook_permission().
214
 */
215
function diff_permission() {
216
  return array(
217
    'diff view changes' => array(
218
      'title' => t('Access %view button', array('%view' => t('View changes'))),
219
      'description' => t('Controls access to the %view button when editing content.', array('%view' => t('View changes'))),
220
    ),
221
  );
222
}
223

  
200 224
/**
201 225
 * Implements hook_hook_info().
202 226
 */
......
238 262
  }
239 263
}
240 264

  
265
/**
266
 * Returns a list of all the existing revision numbers.
267
 *
268
 * Clone of node_revision_list() with revision status included. This would be
269
 * an additional join in Drupal 8.x to the {node_field_revision} table.
270
 *
271
 * @param object $node
272
 *   The node object.
273
 *
274
 * @return array
275
 *   An associative array keyed by node revision number.
276
 */
277
function diff_node_revision_list($node) {
278
  $revisions = array();
279
  $result = db_query('SELECT r.vid, r.title, r.log, r.uid, n.vid AS current_vid, r.status AS status, r.timestamp, u.name FROM {node_revision} r LEFT JOIN {node} n ON n.vid = r.vid INNER JOIN {users} u ON u.uid = r.uid WHERE r.nid = :nid ORDER BY r.vid DESC', array(':nid' => $node->nid));
280
  foreach ($result as $revision) {
281
    $revisions[$revision->vid] = $revision;
282
  }
283

  
284
  return $revisions;
285
}
286

  
241 287
/**
242 288
 * Implements hook_block_info().
243 289
 */
......
287 333
    $enabled_types = variable_get('diff_show_diff_inline_node_bundles', array());
288 334
    if (!empty($enabled_types[$node->type])) {
289 335
      $block = array();
290
      $revisions = node_revision_list($node);
336
      $revisions = diff_node_revision_list($node);
291 337
      if (count($revisions) > 1) {
292 338
        $block['subject'] = t('Highlight changes');
293 339
        $block['content'] = drupal_get_form('diff_inline_form', $node, $revisions);
......
302 348
 */
303 349
function diff_node_view_alter(&$build) {
304 350
  $node = $build['#node'];
305
  if (user_access('view revisions') && in_array($node->type, variable_get('diff_show_diff_inline_node_bundles', array()))) {
351
  if (user_access('view revisions') && in_array($node->type, variable_get('diff_show_diff_inline_node_bundles', array()), TRUE)) {
306 352
    // Ugly but cheap way to check that we are viewing a node's revision page.
307 353
    if (arg(2) === 'revisions' && arg(3) === $node->vid) {
308 354
      module_load_include('inc', 'diff', 'diff.pages');
......
320 366
function diff_form_node_form_alter(&$form, $form_state) {
321 367
  // Add a 'View changes' button on the node edit form.
322 368
  $node = $form['#node'];
323
  if (variable_get('diff_show_preview_changes_node_' . $node->type, TRUE) && !empty($node->nid)) {
369
  if (variable_get('diff_show_preview_changes_node_' . $node->type, TRUE)
370
      && user_access('diff view changes')
371
      && !empty($node->nid)) {
324 372
    $form['actions']['preview_changes'] = array(
325 373
      '#type' => 'submit',
326 374
      '#value' => t('View changes'),
......
347 395
      '#title' => t('Show <em>View changes</em> button on node edit form'),
348 396
      '#weight' => 10,
349 397
      '#default_value' => variable_get('diff_show_preview_changes_node_' . $type->type, TRUE),
398
      '#description' => t('You can refine access using the "!perm" permission.', array(
399
        '!perm' => t('Access %view button', array('%view' => t('View changes'))),
400
      )),
350 401
    );
351 402
    $form['diff']['diff_enable_revisions_page_node'] = array(
352 403
      '#type' => 'checkbox',
......
430 481
  $changes = theme('table__diff__preview', array(
431 482
    'header' => $header,
432 483
    'rows' => $rows,
433
    'attributes' => array('class' => 'diff'),
484
    'attributes' => array('class' => array('diff')),
434 485
    'colgroups' => _diff_default_cols(),
435 486
    'sticky' => FALSE,
436 487
  ));
......
440 491
  $form_state['rebuild'] = TRUE;
441 492
}
442 493

  
494
/**
495
 * Implementation of hook_features_pipe_COMPONENT_alter().
496
 */
497
function diff_features_pipe_node_alter(&$pipe, $data, $export) {
498
  if (!empty($data)) {
499
    $variables = array(
500
      'diff_show_preview_changes_node',
501
      'diff_enable_revisions_page_node',
502
      'diff_view_mode_preview_node',
503
    );
504
    foreach ($data as $node_type) {
505
      foreach ($variables as $variable_name) {
506
        $pipe['variable'][] = $variable_name . '_' . $node_type;
507
      }
508
    }
509
  }
510
}
511

  
443 512
/**
444 513
 * Implements hook_theme().
445 514
 */
......
483 552
 *   The source string to compare from.
484 553
 * @param string $b
485 554
 *   The target string to compare to.
486
 * @param boolean $show_header
555
 * @param bool $show_header
487 556
 *   Display diff context headers. For example, "Line x".
488 557
 * @param array $line_stats
489 558
 *   This structure tracks line numbers across multiple calls to DiffFormatter.
......
621 690
  }
622 691
  return $attachments;
623 692
}
693

  
694
/**
695
 * Implements hook_entity_diff() on behalf of the Node module.
696
 */
697
function node_entity_diff($old_node, $new_node, $context) {
698
  $result = array();
699
  if ($context['entity_type'] == 'node') {
700
    module_load_include('inc', 'diff', 'includes/node');
701
    $options = variable_get('diff_additional_options_node', array('title' => 'title'));
702
    foreach (node_entity_diff_options('node') as $key => $option_label) {
703
      if (!empty($options[$key])) {
704
        $func = '_node_entity_diff_additional_options_' . $key;
705
        $result[$key] = $func($old_node, $new_node, $context);
706
      }
707
    }
708
  }
709
  return $result;
710
}
711

  
712
/**
713
 * Implements hook_entity_diff_options() on behalf of the Node module.
714
 */
715
function node_entity_diff_options($entity_type) {
716
  if ($entity_type == 'node') {
717
    $options = array(
718
      'title' => t('Title field'),
719
      // Author field is either the owner or revision creator, neither capture
720
      // a change in the author field.
721
      'author' => t('Author'),
722
      'revision_author' => t('Revision author'),
723
      'type' => t('Node type'),
724
      'publishing_flags' => t('Publishing options'),
725
      // More fields that currently can not be tracked.
726
      'created' => t('Created date'),
727
      'changed' => t('Updated date'),
728
      'revision_timestamp' => t('Revision timestamp'),
729
    );
730
    if (module_exists('comment')) {
731
      $options['comment'] = t('Comment setting');
732
    }
733
    return $options;
734
  }
735
}
736

  
737
/**
738
 * Implements hook_entity_diff() on behalf of the User module.
739
 */
740
function user_entity_diff($old_user, $new_user, $context) {
741
  $result = array();
742
  if ($context['entity_type'] == 'user') {
743
    module_load_include('inc', 'diff', 'includes/user');
744
    $options = variable_get('diff_additional_options_user', array(
745
      'name' => 'name',
746
      'mail' => 'mail',
747
      'status' => 'status',
748
    ));
749
    foreach (user_entity_diff_options('user') as $key => $option_label) {
750
      if (!empty($options[$key])) {
751
        $func = '_user_entity_diff_additional_options_' . $key;
752
        $result[$key] = $func($old_user, $new_user, $context);
753
      }
754
    }
755
  }
756
  return $result;
757
}
758

  
759
/**
760
 * Implements hook_entity_diff_options() on behalf of the User module.
761
 */
762
function user_entity_diff_options($entity_type) {
763
  if ($entity_type == 'user') {
764
    $options = array(
765
      'name' => t('Username'),
766
      'mail' => t('E-mail address'),
767
      'roles' => t('Roles'),
768
      'status' => t('Status'),
769
      'timezone' => t('Time zone'),
770
      'password' => t('Password Hash'),
771
    );
772
    return $options;
773
  }
774
}
drupal7/sites/all/modules/diff/diff.pages.inc
10 10
 */
11 11
function diff_latest($node) {
12 12
  $revisions = node_revision_list($node);
13
  if (count($revisions) < 2 || !diff_node_revision_access($node, 'view')) {
14
    drupal_goto('node/' . $node->nid);
15
  }
13 16
  $new = array_shift($revisions);
14 17
  $old = array_shift($revisions);
15 18
  drupal_goto("node/{$node->nid}/revisions/view/{$old->vid}/{$new->vid}");
......
35 38
    '#value' => $node->nid,
36 39
  );
37 40

  
38
  $revision_list = node_revision_list($node);
41
  $revision_list = diff_node_revision_list($node);
42
  $revision_count = count($revision_list);
39 43

  
40
  if (count($revision_list) > REVISION_LIST_SIZE) {
44
  if ($revision_count > REVISION_LIST_SIZE) {
41 45
    // If the list of revisions is longer than the number shown on one page
42 46
    // split the array.
43 47
    $page = isset($_GET['page']) ? $_GET['page'] : '0';
44
    $revision_chunks = array_chunk(node_revision_list($node), REVISION_LIST_SIZE);
48
    $revision_chunks = array_chunk($revision_list, REVISION_LIST_SIZE);
45 49
    $revisions = $revision_chunks[$page];
46 50
    // Set up global pager variables as would 'pager_query' do.
47 51
    // These variables are then used in the theme('pager') call later.
48 52
    global $pager_page_array, $pager_total, $pager_total_items;
49
    $pager_total_items[0] = count($revision_list);
50
    $pager_total[0] = ceil(count($revision_list) / REVISION_LIST_SIZE);
53
    $pager_total_items[0] = $revision_count;
54
    $pager_total[0] = ceil($revision_count / REVISION_LIST_SIZE);
51 55
    $pager_page_array[0] = max(0, min($page, ((int) $pager_total[0]) - 1));
52 56
  }
53 57
  else {
......
73 77
        '#markup' => t('!date by !username', array(
74 78
          '!date' => l(format_date($revision->timestamp, 'small'), "node/$node->nid"),
75 79
          '!username' => theme('username', array('account' => $revision)))) . $revision_log,
80
        '#revision' => $revision,
76 81
      );
77 82
    }
78 83
    else {
......
82 87
          '!date' => $diff_date,
83 88
          '!username' => theme('username', array('account' => $revision)))
84 89
        ) . $revision_log,
90
        '#revision' => $revision,
85 91
      );
86 92
      if ($revert_permission) {
87 93
        $operations[] = array(
......
117 123

  
118 124
  $form['submit'] = array('#type' => 'submit', '#value' => t('Compare'));
119 125

  
120
  if (count($revision_list) > REVISION_LIST_SIZE) {
126
  if ($revision_count > REVISION_LIST_SIZE) {
121 127
    $form['#suffix'] = theme('pager');
122 128
  }
123 129
  $form['#attached'] = diff_build_attachments(TRUE);
124 130
  return $form;
125 131
}
126 132

  
127
/**
128
 * Submit code for input form to select two revisions.
129
 */
130
function diff_node_revisions_submit($form, &$form_state) {
131
  // The ids are ordered so the old revision is always on the left.
132
  $old_vid = min($form_state['values']['old'], $form_state['values']['new']);
133
  $new_vid = max($form_state['values']['old'], $form_state['values']['new']);
134
  $form_state['redirect'] = 'node/' . $form_state['values']['nid'] . '/revisions/view/' . $old_vid . '/' . $new_vid;
135
}
136

  
137 133
/**
138 134
 * Validation for input form to select two revisions.
139 135
 */
......
145 141
  }
146 142
}
147 143

  
144
/**
145
 * Submit code for input form to select two revisions.
146
 */
147
function diff_node_revisions_submit($form, &$form_state) {
148
  // The ids are ordered so the old revision is always on the left.
149
  $old_vid = min($form_state['values']['old'], $form_state['values']['new']);
150
  $new_vid = max($form_state['values']['old'], $form_state['values']['new']);
151
  if (isset($_GET['destination'])) {
152
    unset($_GET['destination']);
153
  }
154
  $form_state['redirect'] = 'node/' . $form_state['values']['nid'] . '/revisions/view/' . $old_vid . '/' . $new_vid;
155
}
156

  
148 157
/**
149 158
 * Create a comparison for the node between versions 'old_vid' and 'new_vid'.
150 159
 *
151 160
 * @param object $node
152
 *   Node on which to perform comparison
153
 * @param integer $old_vid
161
 *   Node on which to perform comparison.
162
 * @param int $old_vid
154 163
 *   Version ID of the old revision.
155
 * @param integer $new_vid
164
 * @param int $new_vid
156 165
 *   Version ID of the new revision.
157 166
 */
158 167
function diff_diffs_show($node, $old_vid, $new_vid, $state = NULL) {
......
161 170

  
162 171
  $default_state = variable_get('diff_default_state_node', 'raw');
163 172
  if (empty($state)) {
164
  	$state = $default_state;
173
    $state = $default_state;
165 174
  }
166 175
  $state = str_replace('-', '_', $state);
167 176
  if (!array_key_exists($state, diff_available_states())) {
......
279 288
    }
280 289
    $build['diff_preview']['header']['#markup'] = $header;
281 290
    // Don't include node links or comments when viewing the diff.
282
    $build['diff_preview']['content'] = node_view($new_node, $view_mode);
291
    $build['diff_preview']['content'] = function_exists('entity_view') ? entity_view('node', array($new_node), $view_mode) : node_view($new_node, $view_mode);
283 292
    if (isset($build['diff_preview']['content']['links'])) {
284 293
      unset($build['diff_preview']['content']['links']);
285 294
    }
......
291 300
}
292 301

  
293 302
/**
294
 * Creates an array of rows which represent the difference between nodes.
303
 * Creates an array of rows which represent the difference between two entities.
295 304
 *
296
 * @param object $old_node
297
 *   Node for comparison which will be displayed on the left side.
298
 * @param object $new_node
299
 *   Node for comparison which will be displayed on the right side.
300
 * @param boolean $state
301
 *   The state to render for the diff.
305
 * @param object $left_entity
306
 *   Entity for comparison which will be displayed on the left side.
307
 * @param object $right_entity
308
 *   Entity for comparison which will be displayed on the right side.
309
 * @param array $context
310
 *   The context used to render the diff.
302 311
 */
303
function _diff_body_rows($old_node, $new_node, $state = 'raw') {
312
function diff_entity_body_rows($entity_type, $left_entity, $right_entity, $context = array()) {
304 313
  // This is an unique index only, so no need for drupal_static().
305 314
  static $table_row_counter = 0;
306 315

  
307 316
  if ($theme = variable_get('diff_theme', 'default')) {
308 317
    drupal_add_css(drupal_get_path('module', 'diff') . "/css/diff.{$theme}.css");
309 318
  }
310
  module_load_include('inc', 'diff', 'includes/node');
311 319

  
312 320
  $rows = array();
313 321
  $any_visible_change = FALSE;
314
  $context = array(
315
    'entity_type' => 'node',
316
    'states' => array($state),
322
  $context += array(
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff