function features_feature_diff in Features 7.2
Same name and namespace in other branches
- 6 features.admin.inc \features_feature_diff()
- 7 features.admin.inc \features_feature_diff()
Page callback for 'admin/structure/features/%feature/diff'.
Shows the differences between what's in code and what is in the db.
Parameters
\stdClass $feature: A loaded feature object to display differences for.
string $component: (optional) Specific component to display differences for. If excluded, all components are used.
Return value
array Render element showing the difference between code and db.
Throws
\Exception Exception theoretically thrown in theme().
1 string reference to 'features_feature_diff'
- features_menu in ./
features.module - Implements hook_menu().
File
- ./
features.admin.inc, line 1570 - Forms for Features admin screens.
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');
drupal_set_title($feature->info['name']);
$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;
}