function context_ui_bulk_export in Context 6.2
Same name and namespace in other branches
- 6 context_ui/context_ui.admin.inc \context_ui_bulk_export()
Export multiple contexts
1 string reference to 'context_ui_bulk_export'
- context_ui_menu in context_ui/
context_ui.module - Implementation of hook_menu().
File
- context_ui/
context_ui.admin.inc, line 691
Code
function context_ui_bulk_export(&$form_state) {
$form = array();
$contexts = context_contexts();
if (isset($form_state['storage']['module_name'])) {
$code = "function " . $form_state['storage']['module_name'] . "_context_default_contexts() {\n";
if (isset($form_state['storage']['contexts']) && is_array($form_state['storage']['contexts'])) {
foreach ($form_state['storage']['contexts'] as $id) {
$context = (array) $contexts[$id];
unset($context['cid']);
$code .= ' $items[] = ' . context_var_export($context, ' ') . ";\n\n";
}
}
$code .= " return \$items;\n}";
$form['code'] = array(
'#type' => 'textarea',
'#title' => t('Code'),
'#description' => t('Put this in your module\'s .module file.'),
'#cols' => 60,
'#rows' => 30,
'#value' => $code,
'#default_value' => $code,
);
}
else {
$form['#contexts'] = $contexts;
$form['checkboxes']['#tree'] = TRUE;
foreach ($contexts as $context) {
$form['checkboxes']["{$context->namespace}-{$context->attribute}-{$context->value}"] = array(
'#title' => $context->value,
'#type' => 'checkbox',
);
}
$form['module_name'] = array(
'#type' => 'textfield',
'#title' => t('Module Name'),
'#description' => t('The name of the module for which to generate the hook.'),
'#size' => 40,
'#maxlength' => 255,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Export'),
);
$form['#theme'] = 'context_ui_bulk_export_table';
}
return $form;
}