You are here

function mefibs_get_exposed_items in MEFIBS - More exposed forms in blocks 7

Same name and namespace in other branches
  1. 8 mefibs.module \mefibs_get_exposed_items()

Retrieve all exposed fields of a given type (filter, sort).

Parameters

object $view: A fully loaded views object.

Return value

array Array containing the internal names of exposed elements.

2 calls to mefibs_get_exposed_items()
mefibs_bef_mefibs_elements_alter in modules/mefibs_bef/mefibs_bef.module
Implements hook_mefibs_elements_alter().
mefibs_get_expected_items_for_exposed_form_block in ./mefibs.module
Retrieve the elements that should go into an additional form.

File

./mefibs.module, line 848
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_exposed_items($view) {
  static $exposed_items;
  if (!isset($exposed_items[$view->current_display])) {
    $items = array(
      'filter' => array(),
      'sort' => array(),
      'other' => array(),
    );
    foreach (array(
      'sort',
      'filter',
    ) as $type) {
      $handlers = $view->display_handler
        ->get_handlers($type);
      foreach ($handlers as $handler) {
        if ($handler->options['exposed'] && in_array($type, array(
          'filter',
          'sort',
        ))) {
          if ($type == 'filter') {
            $expose_info = $handler->options['expose'];
            $identifier = $expose_info['identifier'];
            if ($handler->options['is_grouped']) {
              $identifier = $handler->options['group_info']['identifier'];
            }
            $items[$type][$identifier] = $handler->options['id'];
            if ($expose_info['use_operator']) {
              $items[$type][$expose_info['operator']] = $expose_info['operator_id'];
            }
          }
          else {
            $items[$type][] = $handler->options['id'];
          }
        }
      }
    }
    $pager = $view->display_handler
      ->get_plugin('pager');
    if ($pager
      ->items_per_page_exposed()) {
      $items['other'][] = 'items_per_page';
    }
    if ($pager
      ->offset_exposed()) {
      $items['other'][] = 'offset';
    }
    $exposed_items[$view->current_display] = $items;
  }
  return $exposed_items[$view->current_display];
}