You are here

function mediafront_handler_field_player::render in MediaFront 7

Same name and namespace in other branches
  1. 6.2 views/mediafront_handler_field_player.inc \mediafront_handler_field_player::render()
  2. 6 views/mediafront_handler_field_player.inc \mediafront_handler_field_player::render()

Render the field.

Parameters

array $values: The values retrieved from the database.

Overrides views_handler_field::render

File

views/mediafront_handler_field_player.inc, line 138

Class

mediafront_handler_field_player
Field handler to provide simple renderer that turns a URL into a clickable link.

Code

function render($values) {
  $options = array(
    'intro' => $this->options['intro'],
    'commercial' => $this->options['commercial'],
    'prereel' => $this->options['prereel'],
    'media' => $this->options['media'],
    'postreel' => $this->options['postreel'],
    'preview' => $this->options['preview'],
  );
  $node = new stdClass();
  $node->mediafiles = array(
    'media' => array(),
    'images' => array(
      'image' => '',
    ),
  );
  foreach (array_filter($options) as $type => $value) {
    if (isset($this->view->field[$value])) {
      $field = $this->view->field[$value];

      // Different processing if it is an image.
      if ($field->field_info['type'] == 'image') {
        $entity = clone $values->_field_data[$field->field_alias]['entity'];
        $entity_type = $values->_field_data[$field->field_alias]['entity_type'];
        $langcode = $field
          ->field_language($entity_type);
        $value = file_create_url($entity->{$value}[$langcode][0]['uri']);
      }
      else {

        // Render the media field.
        $value = $this
          ->renderField($values, $field);
      }
      if ($type == 'preview') {
        $node->mediafiles['images']['image'] = $value;
      }
      else {
        $node->mediafiles['media'][$type] = $value;
      }
    }
  }
  return theme('mediafront_field', array(
    'entity' => $node,
    'preset' => $this->options['preset'],
  ));
}