function spaces_dashboard_editor in Spaces 6.3
Same name and namespace in other branches
- 7.3 spaces_dashboard/spaces_dashboard.module \spaces_dashboard_editor()
- 7 spaces_dashboard/spaces_dashboard.module \spaces_dashboard_editor()
Form builder: spaces dashboard editor. Clones and overrides form built by context_ui_editor().
1 string reference to 'spaces_dashboard_editor'
- spaces_dashboard_block in spaces_dashboard/
spaces_dashboard.module - Implementation of hook_block().
File
- spaces_dashboard/
spaces_dashboard.module, line 302
Code
function spaces_dashboard_editor(&$form_state, $contexts) {
$form = array();
if ($context = context_get('spaces', 'dashboard')) {
context_set('spaces_dashboard', 'form_build', TRUE);
// Clone the context_ui_editor form and make some changes.
$form = context_ui_editor($form_state, $contexts);
unset($form['contexts'][$context]['#type']);
// Hide conditions.
$form['contexts'][$context]['condition']['#access'] = FALSE;
// Hide reactions other than blocks.
foreach (array_keys(context_reactions()) as $reaction) {
if ($reaction !== 'block' && isset($form['contexts'][$context]["reaction-{$reaction}"])) {
$form['contexts'][$context]["reaction-{$reaction}"]['#access'] = FALSE;
}
}
// Alter allowed layouts
if (module_exists('context_layouts')) {
$layouts = variable_get('spaces_dashboard_layouts', array());
if (!empty($layouts) && isset($form['contexts'][$context]['reaction-block']['layout'])) {
$layouts = array_filter($layouts);
$layouts[0] = 1;
$form['contexts'][$context]['reaction-block']['layout']['layout']['#options'] = array_intersect_key($form['contexts'][$context]['reaction-block']['layout']['layout']['#options'], $layouts);
}
}
// We need to call this alter manually against our form.
if (module_exists('spaces') && ($space = spaces_get_space())) {
spaces_form_context_ui_editor_alter($form, $form_state);
}
}
return $form;
}