You are here

public function context_condition_entity_view_mode::condition_form in Context entity field 7

Condition form.

Overrides context_condition::condition_form

File

plugins/context_condition_entity_view_mode.inc, line 22
Implement context condiction class for entity view mode.

Class

context_condition_entity_view_mode
Expose entity view mode as a context condition.

Code

public function condition_form($context) {
  $form = array();
  $defaults = $this
    ->fetch_from_context($context, 'values');
  $entity_types = array();
  foreach (entity_get_info() as $entity_type_name => $entity_type) {
    foreach ($entity_type['view modes'] as $view_mode => $value) {
      $entity_types[$entity_type_name . '|' . $view_mode] = $entity_type['label'] . ' - ' . $value['label'];
    }
  }
  $form['entity_type'] = array(
    '#title' => t('Entity type'),
    '#type' => 'checkboxes',
    '#options' => $entity_types,
    '#description' => t('Select entity type to check'),
    '#default_value' => isset($defaults['entity_type']) ? unserialize($defaults['entity_type']) : array(),
  );
  return $form;
}