You are here

class scald_views_handler_field_representation in Scald: Media Management made easy 6

Same name and namespace in other branches
  1. 7 includes/scald_views_handler_field_representation.inc \scald_views_handler_field_representation

@file Provides a field containing the representation of an atom, in a choosen context.

Hierarchy

Expanded class hierarchy of scald_views_handler_field_representation

1 string reference to 'scald_views_handler_field_representation'
scald_views_data in includes/scald.views.inc
@file Provides support for the Views module.

File

includes/scald_views_handler_field_representation.inc, line 7
Provides a field containing the representation of an atom, in a choosen context.

View source
class scald_views_handler_field_representation extends views_handler_field {

  /**
   * Renders the atom according in the context specified in the option form.
   */
  function render($values) {
    $sid = $values->{$this->field_alias};
    return scald_render($sid, $this->options['context']);
  }

  /**
   * Add a default context to the option definition.
   */
  function option_definition() {
    $options = parent::option_definition();
    $options['context'] = array(
      'default' => 'sdl_library_item',
    );
    return $options;
  }

  /**
   * Allow to choose in which context the atom should be rendered.
   */
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $scald_config = variable_get('scald_config', 0);
    foreach ($scald_config->contexts as $name => $context) {
      $options[$name] = $name;
    }
    $form['context'] = array(
      '#type' => 'select',
      '#title' => t('Context'),
      '#default_value' => $this->options['context'],
      '#description' => t('The context in which the atom should be rendered.'),
      '#options' => $options,
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
scald_views_handler_field_representation::options_form function Allow to choose in which context the atom should be rendered.
scald_views_handler_field_representation::option_definition function Add a default context to the option definition.
scald_views_handler_field_representation::render function Renders the atom according in the context specified in the option form.