You are here

function atom_reference_field_diff_view in Scald: Media Management made easy 7

Diff field callback for parsing atom_reference field comparative values.

File

modules/fields/atom_reference/atom_reference.module, line 479
Defines a new field type, allowing to directly reference Scald Atoms from a node.

Code

function atom_reference_field_diff_view($items, $context) {
  $instance = $context['instance'];
  $settings = $context['settings'];
  $diff_items = array();
  foreach ($items as $delta => $item) {
    if (!isset($item['atom'])) {
      continue;
    }
    $diff_items[$delta] = $item['atom']->title;
    if ($settings['show_id'] || $settings['show_type']) {
      $diff_items[$delta] .= ' (';
    }
    if ($settings['show_type']) {
      $diff_items[$delta] .= t('!type', array(
        '!type' => ucfirst($item['atom']->type),
      ));
    }
    if ($settings['show_id']) {
      if ($settings['show_type']) {
        $diff_items[$delta] .= ', ';
      }
      $diff_items[$delta] .= t('@entity_name ID: !id', array(
        '@entity_name' => $settings['entity_title'],
        '!id' => $item['atom']->sid,
      ));
    }
    if ($settings['show_id'] || $settings['show_type']) {
      $diff_items[$delta] .= ')';
    }
  }
  return $diff_items;
}