function features_export_components_json in Features 7.2
Page callback for 'features/ajaxcallback/%'.
Parameters
string $feature_name: Path fragment specifying the feature being exported.
1 string reference to 'features_export_components_json'
- features_menu in ./
features.module - Implements hook_menu().
File
- ./
features.admin.inc, line 833 - Forms for Features admin screens.
Code
function features_export_components_json($feature_name) {
module_load_include('inc', 'features', 'features.export');
$export = array(
'features' => array(),
);
if (!empty($_POST['items'])) {
$excluded = !empty($_POST['excluded']) ? $_POST['excluded'] : array();
$stub = array();
foreach ($_POST['items'] as $key) {
preg_match('/^([^\\[]+)(\\[.+\\])?\\[(.+)\\]\\[(.+)\\]$/', $key, $matches);
if (!empty($matches[1]) && !empty($matches[4])) {
$component = $matches[1];
$item = features_dom_decode($matches[4]);
if (empty($stub[$component])) {
$stub[$component] = array(
$item,
);
}
else {
$stub[$component] = array_merge($stub[$component], array(
$item,
));
}
}
}
$stub['dependencies'] = isset($stub['dependencies']) ? $stub['dependencies'] : array();
$export = features_populate(array(
'features' => $stub,
'dependencies' => $stub['dependencies'],
), $feature_name);
$export['features']['dependencies'] = $export['dependencies'];
// Uncheck any detected item that is in the excluded list.
foreach ($export['features'] as $component => $value) {
foreach ($value as $key => $item) {
$clean_key = features_dom_encode($key);
if ($key != $clean_key) {
// Need to move key to a cleankey for javascript.
$export['features'][$component][$clean_key] = $export['features'][$component][$key];
unset($export['features'][$component][$key]);
}
if (isset($excluded[$component][$key])) {
$export['features'][$component][$clean_key] = FALSE;
}
}
}
}
print drupal_json_encode($export['features']);
}