You are here

getid3_handler_field_tags.inc in getID3() 7

A special handler that renders ID3 tags attached to a file.

File

includes/getid3_handler_field_tags.inc
View source
<?php

/**
 * @file
 * A special handler that renders ID3 tags attached to a file.
 */

/**
 * Render a field as a readable value in hours, minutes, and seconds.
 *
 * @ingroup views_field_handlers
 */
class getid3_handler_field_tags extends views_handler_field {
  function option_definition() {
    $options = parent::option_definition();
    $default = reset(array_keys(getid3_tags()));
    $options['tag'] = array(
      'tag' => $default,
      'required' => TRUE,
      'translatable' => TRUE,
    );
    return $options;
  }
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $form['relationship']['#weight'] = -2;
    $form['tag'] = array(
      '#type' => 'select',
      '#title' => t('ID3 tag'),
      '#required' => TRUE,
      '#default_value' => $this->options['tag'],
      '#options' => getid3_tags(),
      '#description' => t('Select the tag to be rendered. If needing multiple tags, add another ID3 tags field.'),
      '#weight' => -1,
    );
  }
  function render($values) {
    $value = unserialize($values->{$this->field_alias});
    $tag = $this->options['tag'];
    if (isset($value[$tag])) {
      return check_plain($value[$tag]);
    }
  }

}

Classes

Namesort descending Description
getid3_handler_field_tags Render a field as a readable value in hours, minutes, and seconds.