You are here

private function lightgallery_style_plugin::conf_get_field_sources in Lightgallery 7

Fetches field options for all fields definied in view.

Return value

type

2 calls to lightgallery_style_plugin::conf_get_field_sources()
lightgallery_style_plugin::options_form in views/lightgallery_style_plugin.inc
Adds Lightgallery configuration form options.
lightgallery_style_plugin::render_fields in views/lightgallery_style_plugin.inc
Renders the view fields.

File

views/lightgallery_style_plugin.inc, line 399
Contains the lightgallery style plugin.

Class

lightgallery_style_plugin
Style plugin to render views as lightgallery instance.

Code

private function conf_get_field_sources() {
  $view = $this->view;
  $options = array(
    'field_options_images' => array(),
    'field_options_images_type' => array(),
    'field_options' => array(),
  );
  $field_handlers = $this->display->handler
    ->get_handlers('field');
  if (!empty($view->base_table) && $view->base_table == 'file_managed') {
    $options['field_options_images_type']['file_base'] = 'file_base';
  }
  $field_labels = $this->display->handler
    ->get_field_labels();

  // Get the label for each field.
  foreach ($field_handlers as $field => $handler) {
    $name = $field_labels[$field];

    // Separate image fields from non-image fields. For image fields we can
    // work with fids and fields of type image or file.
    if (isset($handler->field) && $handler->field == 'fid') {
      $options['field_options_images'][$field] = $name;
      $options['field_options_images_type'][$field] = 'file_id_field';
    }
    elseif (isset($handler->field_info['type']) && ($handler->field_info['type'] == 'image' || $handler->field_info['type'] == 'file')) {
      $options['field_options_images'][$field] = $name;
      $options['field_options_images_type'][$field] = 'file_field';
    }
    else {
      $options['field_options'][$field] = $name;
    }
  }
  return $options;
}