function mefibs_get_expected_items_for_exposed_form_block in MEFIBS - More exposed forms in blocks 8
Same name and namespace in other branches
- 7 mefibs.module \mefibs_get_expected_items_for_exposed_form_block()
Retrieve the elements that should go into the additional form.
Parameters
object $view: A fully loaded views object.
string $block_id:
string $item_type:
Return value
array An array of view specific unique names of the elements for the additional form.
5 calls to mefibs_get_expected_items_for_exposed_form_block()
- MefibsDisplayExtender::buildOptionsForm in lib/
Drupal/ mefibs/ Plugin/ views/ display_extender/ MefibsDisplayExtender.php - Provide a form to edit options for this plugin.
- MefibsDisplayExtender::hideExposedFormItems in lib/
Drupal/ mefibs/ Plugin/ views/ display_extender/ MefibsDisplayExtender.php - Hide form elements that should not show up for the given block id.
- MefibsDisplayExtender::preExecute in lib/
Drupal/ mefibs/ Plugin/ views/ display_extender/ MefibsDisplayExtender.php - Set up any variables on the view prior to execution.
- MefibsDisplayExtender::setDefaultValues in lib/
Drupal/ mefibs/ Plugin/ views/ display_extender/ MefibsDisplayExtender.php - Set default values for the exposed items of a block.
- theme_mefibs_views_ui_block_list in ./
mefibs.theme.inc - Theme the block listing in the mefibs config form in views ui.
File
- ./
mefibs.module, line 358 - Primarily Drupal hooks and global API functions to manipulate views and to provide an additional block with an exposed filter form.
Code
function mefibs_get_expected_items_for_exposed_form_block($view, $block_id) {
$display_id = $view->current_display;
$display = $view
->getDisplay($display_id);
$mefibs_options = $view
->getDisplay()
->getOption('mefibs');
$elements = array(
'filter' => array(),
'sort' => array(),
'other' => array(),
);
$exposed_items = mefibs_get_exposed_items($display);
foreach (array(
'filter',
'other',
) as $type) {
foreach ($exposed_items[$type] as $key => $item) {
if (!isset($mefibs_options[$display_id][$type])) {
continue;
}
$type_def = $mefibs_options[$display_id][$type];
// Filters can have exposed operators so in case this is an operator we
// build a special base name without the attached '_op'.
$is_operator = strrpos($item, '_op') == strlen($item) - 3;
$base = $is_operator ? substr($item, 0, strlen($item) - 3) : $item;
// Check for normal items and operators in special block.
if (isset($type_def[$base]) && $block_id == $type_def[$base]) {
$elements[$type][$key] = $item;
}
elseif (!isset($type_def[$item]) && $block_id == 'default') {
$elements[$type][$key] = $item;
}
}
}
if (isset($mefibs_options[$display_id]['sort_block']) && $mefibs_options[$display_id]['sort_block'] == $block_id) {
$elements['sort'] = $exposed_items['sort'];
}
$context = array(
'view' => clone $view,
'display_id' => $display_id,
'block_id' => $block_id,
'type' => 'expected_items',
);
drupal_alter('mefibs_elements', $elements, $context);
return $elements;
}