function context_groups_add_regions_to_table in Context groups 8
Same name and namespace in other branches
- 8.2 includes/context_groups_ui.inc \context_groups_add_regions_to_table()
Add regions to Context reaction table.
Parameters
array $table: Context reaction table.
array $regions: Regions of currently selected theme.
array $context_blocks: Blocks added to the context.
Return value
array Return array of regions, where we can drag/drop groups/blocks.
1 call to context_groups_add_regions_to_table()
- context_groups_reaction_ui_display_form_alter in includes/
context_groups_ui.inc - Alter the reaction table display.
File
- includes/
context_groups_ui.inc, line 291 - Altering display for reaction table.
Code
function context_groups_add_regions_to_table(array &$table, array $regions, array $context_blocks) {
$region_keys = array_keys($regions);
if (!$table) {
return FALSE;
}
$drag_regions = [];
foreach (Element::children($table) as $child) {
$region_name = str_replace('region-', '', $child);
// Add draggable region, unset region element from original reaction table.
if (in_array($region_name, $region_keys)) {
$drag_regions[$child] = [
'title' => $table[$child]['title']['#markup'],
];
$table[$child]['#attributes']['data-region'] = $child;
unset($table[$child]);
}
// Context block element.
if (in_array($child, $context_blocks)) {
$table[$child]['#attributes']['data-region'] = 'region-' . $table[$child]['region']['#default_value'];
}
$table[$child]['#region_callback'] = 'context_groups_region_callback';
}
$table['#regions'] = $drag_regions;
return $drag_regions;
}