function context_ui_editor in Context 6.3
Same name and namespace in other branches
- 7.3 context_ui/context_ui.module \context_ui_editor()
Inline context editor form.
1 string reference to 'context_ui_editor'
- context_ui_block in context_ui/
context_ui.module - Implementation of hook_block().
File
- context_ui/
context_ui.module, line 108
Code
function context_ui_editor($form_state, $contexts) {
$form = array(
'#attributes' => array(
'class' => 'context-editor',
),
'#theme' => array(
'context_ui_editor',
),
'editables' => array(
'#type' => 'markup',
),
'contexts' => array(
'#tree' => TRUE,
),
'buttons' => array(
'#tree' => FALSE,
),
);
$items = array();
$form_context = array();
ksort($contexts);
foreach ($contexts as $context) {
$edit = l(t('Edit'), $_GET['q'], array(
'fragment' => $context->name,
'attributes' => array(
'class' => 'edit',
),
));
$done = l(t('Done'), $_GET['q'], array(
'fragment' => $context->name,
'attributes' => array(
'class' => 'done',
),
));
$items[] = array(
'data' => "<div class='label'>" . (empty($context->description) ? $context->name : check_plain($context->description)) . "</div><div class='links'>{$edit} {$done}</div>",
'class' => 'context-editable clear-block',
'id' => "context-editable-trigger-{$context->name}",
);
$form_context = array(
'#tree' => TRUE,
'#type' => module_exists('admin') ? 'admin_panes' : NULL,
'context' => array(
'#type' => 'value',
'#value' => $context,
),
);
// Edit context conditions.
foreach (array_keys(context_conditions()) as $condition) {
$plugin = context_get_plugin('condition', $condition);
if (method_exists($plugin, 'editor_form') && ($plugin_form = $plugin
->editor_form($context))) {
$form_context['condition'][$condition] = $plugin_form;
}
}
if (count(element_children($form_context['condition']))) {
$form_context['condition']['#title'] = t('Conditions');
$form_context['condition']['#type'] = 'item';
$form_context['condition']['#description'] = t('This context is active when any of the selected conditions are true.');
}
// Edit context reactions.
foreach (array_keys(context_reactions()) as $reaction) {
$plugin = context_get_plugin('reaction', $reaction);
if (method_exists($plugin, 'editor_form') && ($plugin_form = $plugin
->editor_form($context))) {
$form_context["reaction-{$reaction}"] = $plugin_form + array(
'#title' => $plugin->title,
);
}
}
// Add to main form.
$form['contexts'][$context->name] = $form_context;
}
// Display editable contexts in list.
$form['editables']['#value'] = theme('item_list', $items);
// Buttons.
$form['buttons']['save'] = array(
'#type' => 'submit',
'#value' => t('Save changes'),
'#submit' => array(
'context_ui_editor_submit',
),
);
$form['buttons']['cancel'] = array(
'#type' => 'submit',
'#value' => t('Cancel'),
'#submit' => array(
'context_ui_editor_cancel',
),
);
return $form;
}