You are here

public function JuiceboxFormatterViewsStyle::confGetFieldSources in Juicebox HTML5 Responsive Image Galleries 7.2

Utility to determine which view fields can be used for image data.

This method will extract a list of fields that can be used as "sources" for a Juicebox gallery along with other useful field information.

Return value

array An associative array containing a breakdown of field data that can be referenced by other build methods, including:

  • field_options_image: An associative array, keyed by field id, of fields that can be used as Juicebox gallery image sources.
  • field_options_image_type: An associative array, keyed by field id, of field "types" for all fields listed in 'field_options_image' above.
  • field_options: An associative array, keyed by field id, of fields that cannot be used as Juicebox gallery image sources, but may be useful for other purposes (text and caption sorces, etc.)

See also

JuiceboxFormatterViewStyle::getItems()

2 calls to JuiceboxFormatterViewsStyle::confGetFieldSources()
JuiceboxFormatterViewsStyle::getItems in plugins/JuiceboxFormatterViewsStyle.inc
Utility to get the item arrays that contain image data from view rows.
JuiceboxFormatterViewsStyle::options_form in plugins/JuiceboxFormatterViewsStyle.inc
Define plugin options form.

File

plugins/JuiceboxFormatterViewsStyle.inc, line 345
Contains the Juicebox views style plugin.

Class

JuiceboxFormatterViewsStyle
Style plugin to render each item in a views list.

Code

public function confGetFieldSources() {
  $view = $this->view;
  $options = array(
    'field_options_images' => array(),
    'field_options_images_type' => array(),
    'field_options' => array(),
  );
  $field_handlers = $view->display_handler->display->handler
    ->get_handlers('field');

  // If we have a "file" based view we MIGHT be able to use the base row ids
  // from the view as fids. This only appears to work when some modules, like
  // File Entity, are installed which ensure the fid is listed for each row.
  // Because this option cannot be used universally it is OBSOLETE as of
  // 7.x-2.x-beta6. So we list "file_base" in the "field_options_images_type"
  // array, but NOT in the "field_options_images" array. This should ensure we
  // don't break galleries that already use this option, but remove it from
  // the source picklists going forward.
  if (!empty($view->base_table) && $view->base_table == 'file_managed') {
    $options['field_options_images_type']['file_base'] = 'file_base';
  }

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

    // 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;
}