You are here

function nodeblock_get_view_modes in Nodeblock 7

Getting view modes.

Checks for all available View Modes, then checks which are available for the given content type.

3 calls to nodeblock_get_view_modes()
nodeblock_block_configure in ./nodeblock.module
Implements hook_block_configure().
nodeblock_form_node_form_alter in ./nodeblock.module
Implements hook_form_node_form_alter().
nodeblock_form_node_type_form_alter in ./nodeblock.module
Implements hook_form_node_type_form_alter().

File

./nodeblock.module, line 950
Enables use of specified node types as custom blocks.

Code

function nodeblock_get_view_modes($type) {
  $entity_info = entity_get_info('node');
  $view_modes = field_view_mode_settings('node', $type);
  $options = array();
  $options_dis = array();
  if (!empty($entity_info['view modes'])) {
    foreach ($entity_info['view modes'] as $mode => $settings) {
      if (!empty($view_modes[$mode]['custom_settings'])) {
        $options[$mode] = $settings['label'];
      }
      else {
        $str = t('Disabled');
        $options_dis[$mode] = $settings['label'] . ' (' . $str . ')';
      }
    }
  }
  if (empty($options)) {
    $options = array(
      'node_block_default' => t('Default'),
      'teaser' => t('Teaser'),
      'full' => t('Full node'),
    );
  }
  $options += $options_dis;
  return $options;
}