Skip to content

Instantly share code, notes, and snippets.

@zeropaper
Created September 27, 2011 11:10
Show Gist options
  • Save zeropaper/1244831 to your computer and use it in GitHub Desktop.
Save zeropaper/1244831 to your computer and use it in GitHub Desktop.
A simple theming function override to display the generated .info file for the features module
<?php
/**
* Implements hook_theme_registry_alter()
*/
function YOURMODULENAME_theme_registry_alter(&$items) {
$items['features_components']['function'] = 'YOURMODULENAME_features_components';
}
/**
* Theme a set of features export components.
*/
function YOURMODULENAME_features_components($info, $sources = array()) {
$output = '';
$rows = array();
$components = features_get_components();
if (!empty($info['features']) || !empty($info['dependencies']) || !empty($sources)) {
$export = array_unique(array_merge(
array_keys($info['features']),
array_keys($sources),
array('dependencies')
));
foreach ($export as $component) {
if ($component === 'dependencies') {
$feature_items = isset($info[$component]) ? $info[$component] : array();
}
else {
$feature_items = isset($info['features'][$component]) ? $info['features'][$component] : array();
}
$source_items = isset($sources[$component]) ? $sources[$component] : array();
if (!empty($feature_items) || !empty($source_items)) {
$rows[] = array(array(
'data' => isset($components[$component]['name']) ? $components[$component]['name'] : $component,
'header' => TRUE
));
$rows[] = array(array(
'data' => theme('features_component_list', $feature_items, $source_items),
'class' => 'component'
));
}
}
module_load_include('inc', 'features', 'features.export');
features_include();
$form_state = array();
$submitted = $_POST;
if ($form = form_get_cache($submitted['form_build_id'], $form_state)) {
$export_ready = features_export_prepare($info, $form['info']['module_name']['#default_value']);
$output .= '<div><label>'. t('Info file content') .'</label><textarea rows="4" style="display:block; width: 100%;">'. features_export_info($export_ready) .'</textarea></div>';
}
$output .= theme('table', array(), $rows);
$output .= theme('features_component_key');
}
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment