You are here

function _audio_js_get_items_info in audio.js 7

Returns url and label for give item.

1 call to _audio_js_get_items_info()
audio_js_field_formatter_view in ./audio_js.module
Implements hook_field_formatter_view().

File

./audio_js.module, line 284
This is the main script for the audio.js module. It merely contains the implementation of hooks invoked by Drupal core.

Code

function _audio_js_get_items_info($type, $instance, $item) {
  $file = array();
  switch ($type) {
    case 'audio_js':
      if (!empty($item['uri'])) {
        $file['url'] = file_create_url($item['uri']);

        // If the description is available use that, else use the filename.
        $file['label'] = !empty($item['description']) ? check_plain($item['description']) : $item['filename'];
      }
      else {
        $file['url'] = '';
        $file['label'] = 'Song ' . $delta;
      }
      break;
    case 'audio_js_link':
      if (!empty($item['url'])) {
        $file['url'] = $item['url'];
        $link_title = $instance['settings']['title'];
        if ($link_title == 'value' || $link_title == 'required') {
          $file['label'] = $item['title'];
        }
        else {
          $file_parts = pathinfo($item['title']);
          $file['label'] = $file_parts['filename'];
        }
      }
      else {
        $file['url'] = '';
        $file['label'] = 'Song ' . $delta;
      }
      break;
  }
  return $file;
}