{$key})) { if (is_array($context->{$key})) { foreach ($context->{$key} as $item) { $pipe[$key][$item] = $item; } } else { $item = $context->{$key}; $pipe[$key][$item] = $item; } } } // Special pipe for blocks if (!empty($context->block)) { foreach ($context->block as $block) { $block = (array) $block; $bid = "{$block['module']}-{$block['delta']}"; $pipe['block'][$bid] = $bid; } } } } return $pipe; } /** * Implementation of hook_features_export_render() */ function context_features_export_render($module = 'foo', $data) { $code = array(); $code[] = ' $items = array();'; $code[] = ''; foreach ($data as $identifier) { $contexts = context_enabled_contexts(); $context = $contexts[$identifier]; // prune system specific information and cast for Drupal's AOP (array oriented programming) $prune = array('cid', 'status', 'system', 'type'); foreach ($prune as $key) { if (isset($context->{$key})) { unset($context->{$key}); } } $context = (array) $context; // clean up blocks if (!empty($context['block'])) { foreach ($context['block'] as $bid => $block) { unset($block->bid); $context['block'][$bid] = (array) $block; } } $code[] = ' $items[] = '. context_var_export($context, ' ') .';'; } $code[] = ' return $items;'; $code = implode("\n", $code); return array('context_default_contexts' => $code); }