You are here

function features_feature_diff in Features 6

Same name and namespace in other branches
  1. 7.2 features.admin.inc \features_feature_diff()
  2. 7 features.admin.inc \features_feature_diff()

Page callback to display the differences between what's in code and what is in the db.

Parameters

$feature: A loaded feature object to display differences for.

$component: Optional: specific component to display differences for. If excluded, all components are used.

Return value

Themed display of what is different.

1 string reference to 'features_feature_diff'
features_menu in ./features.module
Implementation of hook_menu().

File

./features.admin.inc, line 725

Code

function features_feature_diff($feature, $component = NULL) {
  drupal_add_css(drupal_get_path('module', 'features') . '/features.css');
  module_load_include('inc', 'features', 'features.export');
  $overrides = features_detect_overrides($feature);
  $output = '';
  if (!empty($overrides)) {

    // Filter overrides down to specified component.
    if (isset($component) && isset($overrides[$component])) {
      $overrides = array(
        $component => $overrides[$component],
      );
    }
    module_load_include('php', 'diff', 'DiffEngine');
    $formatter = new DrupalDiffFormatter();
    $rows = array();
    foreach ($overrides as $component => $items) {
      $diff = new Diff(explode("\n", $items['default']), explode("\n", $items['normal']));
      $rows[] = array(
        array(
          'data' => $component,
          'colspan' => 4,
          'header' => TRUE,
        ),
      );
      $rows = array_merge($rows, $formatter
        ->format($diff));
    }
    $header = array(
      array(
        'data' => t('Default'),
        'colspan' => 2,
      ),
      array(
        'data' => t('Overrides'),
        'colspan' => 2,
      ),
    );
    $output .= theme('diff_table', $header, $rows, array(
      'class' => 'diff features-diff',
    ));
  }
  else {
    $output = "<div class='features-empty'>" . t('No changes have been made to this feature.') . "</div>";
  }
  $output = "<div class='features-comparison'>{$output}</div>";
  return $output;
}