You are here

function mediafront_handler_field_player::renderField in MediaFront 6

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

File

views/mediafront_handler_field_player.inc, line 118

Class

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

Code

function renderField($values, $fieldObj) {

  // We're down to a single node here, so we can retrieve the actual field
  // definition for the node type being considered.
  $field = content_fields($fieldObj->content_field['field_name'], $values->{$fieldObj->aliases['type']});

  // If the field does not appear in the node type, then we have no value
  // to display, and can just return.
  if (empty($field)) {
    return '';
  }
  $options = $fieldObj->options;
  $db_info = content_database_info($field);

  // Build a pseudo-node from the retrieved values.
  $node = drupal_clone($values);
  $node->type = $values->{$fieldObj->aliases['type']};
  $node->nid = $values->{$fieldObj->aliases['nid']};
  $node->vid = $values->{$fieldObj->aliases['vid']};
  $node->build_mode = NODE_BUILD_NORMAL;
  $item = array();
  foreach ($db_info['columns'] as $column => $attributes) {
    $item[$column] = $values->{$fieldObj->aliases[$attributes['column']]};
  }
  $item['#delta'] = $field['multiple'] ? $values->{$fieldObj->aliases['delta']} : 0;

  // Render items.
  $formatter_name = $options['format'];
  if ($formatter = _content_get_formatter($formatter_name, $field['type'])) {
    if (content_handle('formatter', 'multiple values', $formatter) == CONTENT_HANDLE_CORE) {

      // Single-value formatter.
      $output = content_format($field, $item, $formatter_name, $node);
    }
    else {

      // Multiple values formatter - we actually have only one value to display.
      $output = content_format($field, array(
        $item,
      ), $formatter_name, $node);
    }
    return $fieldObj
      ->render_link($output, $values);
  }
  return '';
}