function context_ui_export in Context 6
Same name and namespace in other branches
- 5 context_ui/context_ui_admin.inc \context_ui_export()
- 6.2 context_ui/context_ui.admin.inc \context_ui_export()
Provides a form with an exported context definition for use in modules.
Parameters
$cid: A context id.
Return value
A FormAPI array.
1 string reference to 'context_ui_export'
- context_ui_menu in context_ui/
context_ui.module - Implementation of hook_menu().
File
- context_ui/
context_ui.admin.inc, line 534
Code
function context_ui_export(&$form_state, $context) {
drupal_set_title(t('Export %title', array(
'%title' => $context->value,
)));
// 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;
// clear out empty associations
foreach ($context as $key => $item) {
if (context_empty($item)) {
unset($context[$key]);
}
}
// clean up blocks
if (!empty($context['block'])) {
foreach ($context['block'] as $bid => $block) {
unset($block->bid);
$context['block'][$bid] = (array) $block;
}
}
// build the form
$form = array();
$form['export'] = array(
'#type' => 'textarea',
'#rows' => 24,
'#value' => $context,
'#theme' => 'context_ui_export_form',
);
return $form;
}