Projet

Général

Profil

Paste
Télécharger (20,6 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / diff / diff.pages.inc @ 661d64c9

1
<?php
2

    
3
/**
4
 * @file
5
 * Menu callbacks for hook_menu().
6
 */
7

    
8
/**
9
 * Menu callback - show latest diff for a given node.
10
 */
11
function diff_latest($node) {
12
  $revisions = node_revision_list($node);
13
  if (count($revisions) < 2 || !diff_node_revision_access($node, 'view')) {
14
    drupal_goto('node/' . $node->nid);
15
  }
16
  $new = array_shift($revisions);
17
  $old = array_shift($revisions);
18
  drupal_goto("node/{$node->nid}/revisions/view/{$old->vid}/{$new->vid}");
19
}
20

    
21
/**
22
 * Menu callback - an overview table of older revisions.
23
 *
24
 * Generate an overview table of older revisions of a node and provide
25
 * an input form to select two revisions for a comparison.
26
 */
27
function diff_diffs_overview($node) {
28
  drupal_set_title(t('Revisions for %title', array('%title' => $node->title)), PASS_THROUGH);
29
  return drupal_get_form('diff_node_revisions', $node);
30
}
31

    
32
/**
33
 * Input form to select two revisions.
34
 */
35
function diff_node_revisions($form, $form_state, $node) {
36
  $form['nid'] = array(
37
    '#type' => 'hidden',
38
    '#value' => $node->nid,
39
  );
40

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

    
44
  if ($revision_count > REVISION_LIST_SIZE) {
45
    // If the list of revisions is longer than the number shown on one page
46
    // split the array.
47
    $page = isset($_GET['page']) ? $_GET['page'] : '0';
48
    $revision_chunks = array_chunk($revision_list, REVISION_LIST_SIZE);
49
    $revisions = $revision_chunks[$page];
50
    // Set up global pager variables as would 'pager_query' do.
51
    // These variables are then used in the theme('pager') call later.
52
    global $pager_page_array, $pager_total, $pager_total_items;
53
    $pager_total_items[0] = $revision_count;
54
    $pager_total[0] = ceil($revision_count / REVISION_LIST_SIZE);
55
    $pager_page_array[0] = max(0, min($page, ((int) $pager_total[0]) - 1));
56
  }
57
  else {
58
    $revisions = $revision_list;
59
  }
60

    
61
  $revert_permission = FALSE;
62
  if ((user_access('revert revisions') || user_access('administer nodes')) && node_access('update', $node)) {
63
    $revert_permission = TRUE;
64
  }
65
  $delete_permission = FALSE;
66
  if ((user_access('delete revisions') || user_access('administer nodes')) && node_access('delete', $node)) {
67
    $delete_permission = TRUE;
68
  }
69

    
70
  foreach ($revisions as $revision) {
71
    $operations = array();
72
    $revision_ids[$revision->vid] = '';
73

    
74
    $revision_log = ($revision->log != '') ? '<p class="revision-log">' . filter_xss($revision->log) . '</p>' : '';
75
    if ($revision->current_vid > 0) {
76
      $form['info'][$revision->vid] = array(
77
        '#markup' => t('!date by !username', array(
78
          '!date' => l(format_date($revision->timestamp, 'small'), "node/$node->nid"),
79
          '!username' => theme('username', array('account' => $revision)))) . $revision_log,
80
        '#revision' => $revision,
81
      );
82
    }
83
    else {
84
      $diff_date = l(format_date($revision->timestamp, 'small'), "node/$node->nid/revisions/$revision->vid/view");
85
      $form['info'][$revision->vid] = array(
86
        '#markup' => t('!date by !username', array(
87
          '!date' => $diff_date,
88
          '!username' => theme('username', array('account' => $revision)))
89
        ) . $revision_log,
90
        '#revision' => $revision,
91
      );
92
      if ($revert_permission) {
93
        $operations[] = array(
94
          '#markup' => l(t('Revert'), "node/$node->nid/revisions/$revision->vid/revert"),
95
        );
96
      }
97
      if ($delete_permission) {
98
        $operations[] = array(
99
          '#markup' => l(t('Delete'), "node/$node->nid/revisions/$revision->vid/delete"),
100
        );
101
      }
102
      // Set a dummy, even if the user has no permission for the other
103
      // operations, so that we can check if the operations array is
104
      // empty to know if the row denotes the current revision.
105
      $operations[] = array();
106
    }
107
    $form['operations'][$revision->vid] = $operations;
108

    
109
  }
110
  $new_vid = key($revision_ids);
111
  next($revision_ids);
112
  $old_vid = key($revision_ids);
113
  $form['diff']['old'] = array(
114
    '#type' => 'radios',
115
    '#options' => $revision_ids,
116
    '#default_value' => $old_vid,
117
  );
118
  $form['diff']['new'] = array(
119
    '#type' => 'radios',
120
    '#options' => $revision_ids,
121
    '#default_value' => $new_vid,
122
  );
123

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

    
126
  if ($revision_count > REVISION_LIST_SIZE) {
127
    $form['#suffix'] = theme('pager');
128
  }
129
  $form['#attached'] = diff_build_attachments(TRUE);
130
  return $form;
131
}
132

    
133
/**
134
 * Validation for input form to select two revisions.
135
 */
136
function diff_node_revisions_validate($form, &$form_state) {
137
  $old_vid = $form_state['values']['old'];
138
  $new_vid = $form_state['values']['new'];
139
  if ($old_vid == $new_vid || !$old_vid || !$new_vid) {
140
    form_set_error('diff', t('Select different revisions to compare.'));
141
  }
142
}
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

    
157
/**
158
 * Create a comparison for the node between versions 'old_vid' and 'new_vid'.
159
 *
160
 * @param object $node
161
 *   Node on which to perform comparison.
162
 * @param int $old_vid
163
 *   Version ID of the old revision.
164
 * @param int $new_vid
165
 *   Version ID of the new revision.
166
 */
167
function diff_diffs_show($node, $old_vid, $new_vid, $state = NULL) {
168
  // Attaches the CSS.
169
  $build['#attached'] = diff_build_attachments();
170

    
171
  $default_state = variable_get('diff_default_state_node', 'raw');
172
  if (empty($state)) {
173
    $state = $default_state;
174
  }
175
  $state = str_replace('-', '_', $state);
176
  if (!array_key_exists($state, diff_available_states())) {
177
    $state = $default_state;
178
  }
179

    
180
  // Same title as the 'Revisions' tab. Blocked by non-page requests.
181
  if (node_is_page($node)) {
182
    drupal_set_title(t('Revisions for %title', array('%title' => $node->title)), PASS_THROUGH);
183
  }
184
  $node_revisions = node_revision_list($node);
185

    
186
  $old_node = node_load($node->nid, $old_vid);
187
  $new_node = node_load($node->nid, $new_vid);
188

    
189
  // Generate table header (date, username, log message).
190
  $old_header = t('!date by !username', array(
191
    '!date' => l(format_date($old_node->revision_timestamp), "node/$node->nid/revisions/$old_node->vid/view", array('absolute' => 1)),
192
    '!username' => theme('username', array('account' => $node_revisions[$old_vid])),
193
  ));
194
  $new_header = t('!date by !username', array(
195
    '!date' => l(format_date($new_node->revision_timestamp), "node/$node->nid/revisions/$new_node->vid/view", array('absolute' => 1)),
196
    '!username' => theme('username', array('account' => $node_revisions[$new_vid])),
197
  ));
198

    
199
  $old_log = $old_node->log != '' ? '<p class="revision-log">' . filter_xss($old_node->log) . '</p>' : '';
200
  $new_log = $new_node->log != '' ? '<p class="revision-log">' . filter_xss($new_node->log) . '</p>' : '';
201

    
202
  // Generate previous diff/next diff links.
203
  $nav_suffix = ($default_state != $state) ? '/' . str_replace('_', '-', $state) : '';
204
  $next_vid = _diff_get_next_vid($node_revisions, $new_vid);
205
  if ($next_vid) {
206
    $next_link = l(t('Next difference >'), 'node/' . $node->nid . '/revisions/view/' . $new_vid . '/' . $next_vid . $nav_suffix, array('absolute' => 1));
207
  }
208
  else {
209
    $next_link = '';
210
  }
211
  $prev_vid = _diff_get_previous_vid($node_revisions, $old_vid);
212
  if ($prev_vid) {
213
    $prev_link = l(t('< Previous difference'), 'node/' . $node->nid . '/revisions/view/' . $prev_vid . '/' . $old_vid . $nav_suffix, array('absolute' => 1));
214
  }
215
  else {
216
    $prev_link = '';
217
  }
218

    
219
  $header = _diff_default_header($old_header, $new_header);
220
  $rows = array();
221
  if ($old_log || $new_log) {
222
    $rows['logs'] = array(
223
      array(
224
        'data' => $old_log,
225
        'colspan' => 2,
226
      ),
227
      array(
228
        'data' => $new_log,
229
        'colspan' => 2,
230
      ),
231
    );
232
  }
233
  $rows['navigation'] = array(
234
    array(
235
      'data' => $prev_link,
236
      'class' => array('diff-prevlink'),
237
      'colspan' => 2,
238
    ),
239
    array(
240
      'data' => $next_link,
241
      'class' => array('diff-nextlink'),
242
      'colspan' => 2,
243
    ),
244
  );
245

    
246
  $links = array();
247
  foreach (diff_available_states('node') as $alternative_state => $label) {
248
    if ($alternative_state == $state) {
249
      // @todo: Should we show both or just alternatives?
250
    }
251
    $links[$alternative_state] = array(
252
      'title' => $label,
253
      'href' => "node/{$node->nid}/revisions/view/{$old_vid}/{$new_vid}" . ($alternative_state == $default_state ? '' : '/' . str_replace('_', '-', $alternative_state)),
254
    );
255
  }
256
  if (count($links) > 1) {
257
    $state_links = theme('links', array(
258
      'links' => $links,
259
      'attributes' => array('class' => array('links', 'inline')),
260
    ));
261
    $rows['states'] = array(
262
      array(
263
        'data' => $state_links,
264
        'class' => 'diff-links',
265
        'colspan' => 4,
266
      ),
267
    );
268
  }
269
  $rows = array_merge($rows, _diff_body_rows($old_node, $new_node, $state));
270

    
271
  $build['diff_table'] = array(
272
    '#theme' => 'table__diff__standard',
273
    '#header' => $header,
274
    '#rows' => $rows,
275
    '#attributes' => array('class' => array('diff')),
276
    '#colgroups' => _diff_default_cols(),
277
    '#sticky' => FALSE,
278
  );
279

    
280
  // Allow users to hide or set the display mode of the preview.
281
  if (node_is_page($node) && $view_mode = variable_get('diff_view_mode_preview_node_' . $new_node->type, 'full')) {
282
    $header = '';
283
    if ($node->vid == $new_vid) {
284
      $header .= '<div class="diff-section-title">' . t('Current revision:') . '</div>';
285
    }
286
    else {
287
      $header .= '<div class="diff-section-title">' . t('Revision of @new_date:', array('@new_date' => format_date($new_node->revision_timestamp))) . '</div>';
288
    }
289
    $build['diff_preview']['header']['#markup'] = $header;
290
    // Don't include node links or comments when viewing the diff.
291
    $build['diff_preview']['content'] = function_exists('entity_view') ? entity_view('node', array($new_node), $view_mode) : node_view($new_node, $view_mode);
292
    if (isset($build['diff_preview']['content']['links'])) {
293
      unset($build['diff_preview']['content']['links']);
294
    }
295
    if (isset($build['diff_preview']['content']['comments'])) {
296
      unset($build['diff_preview']['content']['comments']);
297
    }
298
  }
299
  return $build;
300
}
301

    
302
/**
303
 * Creates an array of rows which represent the difference between two entities.
304
 *
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.
311
 */
312
function diff_entity_body_rows($entity_type, $left_entity, $right_entity, $context = array()) {
313
  // This is an unique index only, so no need for drupal_static().
314
  static $table_row_counter = 0;
315

    
316
  if ($theme = variable_get('diff_theme', 'default')) {
317
    drupal_add_css(drupal_get_path('module', 'diff') . "/css/diff.{$theme}.css");
318
  }
319

    
320
  $rows = array();
321
  $any_visible_change = FALSE;
322
  $context += array(
323
    'entity_type' => $entity_type,
324
    'states' => array('raw'),
325
    'view_mode' => 'diff_standard',
326
  );
327
  $state = current($context['states']);
328

    
329
  $entity_diffs = diff_compare_entities($left_entity, $right_entity, $context);
330

    
331
  // Track line numbers between multiple diffs.
332
  $line_stats = array(
333
    'counter' => array('x' => 0, 'y' => 0),
334
    'offset' => array('x' => 0, 'y' => 0),
335
  );
336

    
337
  // Render diffs for each.
338
  foreach ($entity_diffs as $entity_diff) {
339
    $show_header = !empty($entity_diff['#name']);
340
    // These are field level settings.
341
    if ($show_header && isset($entity_diff['#settings']['show_header'])) {
342
      $show_header = $show_header && $entity_diff['#settings']['show_header'];
343
    }
344

    
345
    // Line counting and line header options.
346
    if (empty($entity_diff['#settings']['line_counter'])) {
347
      $line_counter = FALSE;
348
    }
349
    else {
350
      $line_counter = $entity_diff['#settings']['line_counter'];
351
    }
352
    // Every call to 'line' resets the counters.
353
    if ($line_counter) {
354
      $line_stats['counter']['x'] = 0;
355
      $line_stats['counter']['y'] = 0;
356
      if ($line_counter == 'line' && 0) {
357
        $line_stats['offset']['x'] = 0;
358
        $line_stats['offset']['y'] = 0;
359
      }
360
      $line_stats_ref = $line_stats;
361
    }
362
    else {
363
      $line_stats_ref = NULL;
364
    }
365

    
366
    list($left, $right) = diff_extract_state($entity_diff, $state);
367
    if ($entity_diff_rows = diff_get_rows($left, $right, $line_counter && $line_counter != 'hidden', $line_stats_ref)) {
368
      if ($line_counter && $line_counter != 'line') {
369
        $line_stats['offset']['x'] += $line_stats_ref['counter']['x'];
370
        $line_stats['offset']['y'] += $line_stats_ref['counter']['y'];
371
      }
372
      if ($show_header) {
373
        $rows['diff-header-' . $table_row_counter++] = array(
374
          array(
375
            'data' => t('Changes to %name', array('%name' => $entity_diff['#name'])),
376
            'class' => 'diff-section-title',
377
            'colspan' => 4,
378
          ),
379
        );
380
      }
381
      // To avoid passing counter to the Diff engine, index rows manually here
382
      // to allow modules to interact with the table. i.e. no array_merge().
383
      foreach ($entity_diff_rows as $row) {
384
        $rows['diff-row-' . $table_row_counter++] = $row;
385
      }
386
      $any_visible_change = TRUE;
387
    }
388
  }
389
  if (!$any_visible_change) {
390
    $rows['diff-empty-' . $table_row_counter++] = array(
391
      array(
392
        'data' => t('No visible changes'),
393
        'class' => 'diff-section-title',
394
        'colspan' => 4,
395
      ),
396
    );
397
  }
398
  return $rows;
399
}
400

    
401
/**
402
 * Creates an array of rows which represent the difference between nodes.
403
 *
404
 * @param object $old_node
405
 *   Node for comparison which will be displayed on the left side.
406
 * @param object $new_node
407
 *   Node for comparison which will be displayed on the right side.
408
 * @param bool $state
409
 *   The state to render for the diff.
410
 */
411
function _diff_body_rows($old_node, $new_node, $state = 'raw') {
412
  $context = array(
413
    'states' => array($state),
414
    'view_mode' => 'diff_standard',
415
  );
416
  return diff_entity_body_rows('node', $old_node, $new_node, $context);
417
}
418

    
419
/**
420
 * Generic callback to compare two entities.
421
 */
422
function diff_compare_entities($left_entity, $right_entity, $context) {
423
  $entity_type = $context['entity_type'];
424
  list(, , $bundle) = entity_extract_ids($entity_type, $right_entity);
425
  $context['bundle'] = $bundle;
426
  $context['old_entity'] = $left_entity;
427
  $context['new_entity'] = $right_entity;
428
  $context += array(
429
    'states' => array('raw'),
430
    'view_mode' => FALSE,
431
    'language' => LANGUAGE_NONE,
432
  );
433

    
434
  $diff = module_invoke_all('entity_diff', $left_entity, $right_entity, $context);
435

    
436
  // Allow other modules to interact directly with the results.
437
  drupal_alter('entity_diff', $diff, $context);
438

    
439
  // We start off assuming all form elements are in the correct order.
440
  $diff['#sorted'] = TRUE;
441

    
442
  // Field rows. Recurse through all child elements.
443
  $count = 0;
444
  foreach (element_children($diff) as $key) {
445
    if (!isset($diff[$key]['#states'])) {
446
      $diff[$key]['#states'] = array();
447
    }
448

    
449
    // Ensure that the element follows the new #states format.
450
    if (isset($diff[$key]['#old'])) {
451
      $diff[$key]['#states']['raw']['#old'] = $diff[$key]['#old'];
452
      unset($diff[$key]['#old']);
453
    }
454
    if (isset($diff[$key]['#new'])) {
455
      $diff[$key]['#states']['raw']['#new'] = $diff[$key]['#new'];
456
      unset($diff[$key]['#new']);
457
    }
458

    
459
    // If requested, we can convert the .
460
    foreach (array('raw', 'rendered') as $state) {
461
      if (in_array($state . '_plain', $context['states'])) {
462
        diff_markdown_state($diff[$key], $state);
463
      }
464
    }
465

    
466
    // Assign a decimal placeholder weight to preserve original array order.
467
    if (!isset($diff[$key]['#weight'])) {
468
      $diff[$key]['#weight'] = $count / 1000;
469
    }
470
    else {
471
      // If one child element has a weight then we will need to sort later.
472
      unset($diff['#sorted']);
473
    }
474
    $count++;
475
  }
476

    
477
  // One of the children has a #weight.
478
  if (!isset($diff['#sorted'])) {
479
    uasort($diff, 'element_sort');
480
  }
481
  else {
482
    unset($diff['#sorted']);
483
  }
484

    
485
  // Process the array and get line counts per field.
486
  array_walk($diff, 'diff_process_state_lines');
487

    
488
  return $diff;
489
}
490

    
491
/**
492
 * Helper function to get line counts per field.
493
 */
494
function diff_process_state_lines(&$diff, $key) {
495
  foreach ($diff['#states'] as $state => $data) {
496
    if (isset($data['#old'])) {
497
      if (is_string($data['#old'])) {
498
        $diff['#states'][$state]['#old'] = explode("\n", $data['#old']);
499
      }
500
      $diff['#states'][$state]['#count_old'] = count($diff['#states'][$state]['#old']);
501
    }
502
    else {
503
      $diff['#states'][$state]['#count_old'] = 0;
504
    }
505
    if (isset($data['#new'])) {
506
      if (is_string($data['#new'])) {
507
        $diff['#states'][$state]['#new'] = explode("\n", $data['#new']);
508
      }
509
      $diff['#states'][$state]['#count_new'] = count($diff['#states'][$state]['#new']);
510
    }
511
    else {
512
      $diff['#states'][$state]['#count_new'] = 0;
513
    }
514
  }
515
}
516

    
517
/**
518
 * Helper function to render plain states from the corresponding raw state.
519
 *
520
 * @param array $diff
521
 *   The Diff Engine output array.
522
 * @param string $state
523
 *   The state to markdown.
524
 */
525
function diff_markdown_state(&$diff, $state) {
526
  list($plain_old, $plain_new) = diff_extract_state($diff, $state . '_plain');
527
  list($old, $new) = diff_extract_state($diff, $state);
528
  $markdown = FALSE;
529
  if (isset($diff['#settings']) && !empty($diff['#settings']['markdown'])) {
530
    if (function_exists($diff['#settings']['markdown'])) {
531
      $markdown = $diff['#settings']['markdown'];
532
    }
533
  }
534

    
535
  if (!isset($plain_old) && isset($old)) {
536
    $diff['#states'][$state . '_plain']['#old'] = _diff_apply_markdown($markdown, $old);
537
  }
538
  if (!isset($plain_new) && isset($new)) {
539
    $diff['#states'][$state . '_plain']['#new'] = _diff_apply_markdown($markdown, $new);
540
  }
541
}
542

    
543
/**
544
 * Helper function to clear newlines from the content.
545
 */
546
function _diff_apply_markdown($markdown, $items) {
547
  if (!$markdown) {
548
    return $items;
549
  }
550
  if (is_array($items)) {
551
    $items = array_map($markdown, $items);
552
    foreach ($items as &$item) {
553
      $item = trim($item, "\n");
554
    }
555
    return $items;
556
  }
557
  else {
558
    return trim($markdown($items), "\n");
559
  }
560
}
561

    
562
/**
563
 * Get the entry in the revisions list after $vid.
564
 *
565
 * @param array $node_revisions
566
 *   Array of node revision IDs in descending order.
567
 * @param int $vid
568
 *   Version ID to look for.
569
 *
570
 * @return bool|int
571
 *   Returns FALSE if $vid is the last entry.
572
 */
573
function _diff_get_next_vid($node_revisions, $vid) {
574
  $previous = NULL;
575
  foreach ($node_revisions as $revision) {
576
    if ($revision->vid == $vid) {
577
      return ($previous ? $previous->vid : FALSE);
578
    }
579
    $previous = $revision;
580
  }
581
  return FALSE;
582
}
583

    
584
/**
585
 * Get the entry in the revision list before $vid.
586
 *
587
 * @param array $node_revisions
588
 *   Array of node revision IDs in descending order.
589
 * @param int $vid
590
 *   Version ID to look for.
591
 *
592
 * @return bool|int
593
 *   Returns FALSE if $vid is the first entry.
594
 */
595
function _diff_get_previous_vid($node_revisions, $vid) {
596
  $previous = NULL;
597
  foreach ($node_revisions as $revision) {
598
    if ($previous && $previous->vid == $vid) {
599
      return $revision->vid;
600
    }
601
    $previous = $revision;
602
  }
603
  return FALSE;
604
}
605

    
606
/**
607
 * Helper function to create default 'cols' array for diff table.
608
 */
609
function _diff_default_cols() {
610
  return array(
611
    array(
612
      array(
613
        'class' => 'diff-marker',
614
      ),
615
      array(
616
        'class' => 'diff-content',
617
      ),
618
      array(
619
        'class' => 'diff-marker',
620
      ),
621
      array(
622
        'class' => 'diff-content',
623
      ),
624
    ),
625
  );
626
}
627

    
628
/**
629
 * Helper function to create default 'header' array for diff table.
630
 */
631
function _diff_default_header($old_header = '', $new_header = '') {
632
  return array(
633
    array(
634
      'data' => $old_header,
635
      'colspan' => 2,
636
    ),
637
    array(
638
      'data' => $new_header,
639
      'colspan' => 2,
640
    ),
641
  );
642
}
643

    
644
/**
645
 * Show the inline diff for a given node, vid.
646
 *
647
 * If vid = 0 or no previous vid exists for the given revision returns the
648
 * normally rendered content of the specified revision.
649
 */
650
function diff_inline_show($node, $vid = 0, $metadata = TRUE) {
651
  $new_node = $vid ? node_load($node->nid, $vid) : clone $node;
652
  node_build_content($new_node);
653
  $new = drupal_render($new_node->content);
654

    
655
  $old = $vid ? _diff_get_previous_vid(node_revision_list($node), $vid) : 0;
656
  if ($old) {
657
    $old_node = node_load($node->nid, $old);
658
    node_build_content($old_node);
659
    $old = drupal_render($old_node->content);
660
    $output = $metadata ? theme('diff_inline_metadata', array('node' => $new_node)) : '';
661
    $output .= diff_get_inline($old, $new);
662
    return $output;
663
  }
664
  return $new;
665
}