You are here

function slick_get_view_modes in Slick Carousel 7.2

A helper function to return view modes for a form.

Parameters

string $entity_type: The entity type to use with entity_get_info($entity_type) or entity_get_info($field['settings']['target_type']).

bool $exclude: If TRUE, then exclude some view modes, such as: 'rss', 'search_index', 'search_result', 'print', 'token'.

Return value

array An array of available view modes, excluding some.

1 call to slick_get_view_modes()
_slick_fields_field_formatter_settings_form in slick_fields/includes/slick_fields.formatters.admin.inc
Off-loaded hook_field_formatter_settings_form().

File

includes/slick.admin.inc, line 319
Contains optional functions called only if needed by admin pages.

Code

function slick_get_view_modes($entity_type, $exclude = TRUE) {
  $view_mode_options =& drupal_static(__FUNCTION__);
  if (!isset($view_mode_options)) {
    $view_mode_options = array(
      'default' => t('Default'),
    );
    $view_mode_excludes = array(
      'rss',
      'search_index',
      'search_result',
      'print',
      'token',
      'preview',
      'wysiwyg',
    );
    $entity_info = entity_get_info($entity_type);
    if (!empty($entity_info['view modes'])) {
      foreach ($entity_info['view modes'] as $view_mode => $view_mode_settings) {
        if ($exclude && in_array($view_mode, $view_mode_excludes)) {
          continue;
        }
        $view_mode_options[$view_mode] = $view_mode_settings['label'];
      }
    }
  }
  return $view_mode_options;
}