function features_feature_diff in Features 7
Same name and namespace in other branches
- 6 features.admin.inc \features_feature_diff()
- 7.2 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 - Implements hook_menu().
File
- ./
features.admin.inc, line 786 - @todo.
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('inc', 'diff', 'diff.engine');
$formatter = new DrupalDiffFormatter();
$rows = array();
foreach ($overrides as $component => $items) {
$rows[] = array(
array(
'data' => $component,
'colspan' => 4,
'header' => TRUE,
),
);
$diff = new Diff(explode("\n", $items['default']), explode("\n", $items['normal']));
$rows = array_merge($rows, $formatter
->format($diff));
}
$header = array(
array(
'data' => t('Default'),
'colspan' => 2,
),
array(
'data' => t('Overrides'),
'colspan' => 2,
),
);
$output .= theme('table', array(
'header' => $header,
'rows' => $rows,
'attributes' => array(
'class' => array(
'diff',
'features-diff',
),
),
));
}
else {
$output = "<div class='features-empty'>" . t('No changes have been made to this feature.') . "</div>";
}
$output = array(
'page' => array(
'#markup' => "<div class='features-comparison'>{$output}</div>",
),
);
return $output;
}