[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/audio/ -> audio.theme.inc (source)

   1  <?php
   2  // $Id: audio.theme.inc,v 1.3 2008/12/22 08:47:39 drewish Exp $
   3  
   4  /**
   5   * Format the teaser for an audio node.
   6   */
   7  function theme_audio_teaser($node) {
   8    $format = variable_get('audio_teaser_format', '[audio-player]<br />[audio-length]');
   9    return token_replace($format, 'node', $node);
  10  }
  11  
  12  /**
  13   * Format the audio node for display
  14   */
  15  function theme_audio_display($node) {
  16    $items = array();
  17    if ($player = audio_get_node_player($node)) {
  18      $items[] = $player;
  19    }
  20    foreach (audio_get_tag_settings() as $tag => $setting) {
  21      if (!$setting['hidden'] && isset($node->audio_tags[$tag])) {
  22        $items[] = '<strong>'. t(ucwords(str_replace('_', ' ', $tag))) .':</strong> '
  23          . theme('audio_format_tag', $tag, $node->audio_tags[$tag], $setting);
  24      }
  25    }
  26    $items[] = '<strong>'. t('Length') .':</strong> '. theme('audio_format_filelength', $node->audio);
  27    $items[] = '<strong>'. t('Format') .':</strong> '. theme('audio_format_fileformat', $node->audio);
  28  
  29    $output = "<div class='audio-node block'>\n";
  30    // give audio_image.module (or a theme) a chance to display the images.
  31    if (isset($node->audio_images)) {
  32      $output .= theme('audio_images', $node->audio_images);
  33    }
  34    $output .= theme('item_list', $items, NULL, 'ul', array('class' => 'audio-info'));
  35    $output .= "</div>\n";
  36  
  37    return $output ;
  38  }
  39  
  40  /**
  41   * Format a metadata tag.
  42   */
  43  function theme_audio_format_tag($tag, $value, $setting) {
  44    if ($setting['browsable']) {
  45      return l($value, "audio/by/$tag/". audio_clean_tag($value));
  46    }
  47    else {
  48      switch ($tag) {
  49        // url tags
  50        case 'url_file':
  51        case 'url_artist':
  52        case 'url_source':
  53        case 'url_station':
  54          return '<a href="'. check_url($value) .'" title="'. $tag .'">'. check_plain($value) .'</a>';
  55  
  56        default:
  57          return check_plain($value);
  58      }
  59    }
  60  }
  61  
  62  /**
  63   * Return a string describing the node's file size and play time.
  64   *
  65   * @param $fileinfo
  66   *   Audio node's audio array.
  67   */
  68  function theme_audio_format_filelength($fileinfo) {
  69    $args['@filesize'] = format_size(isset($fileinfo['file']->filesize) ? $fileinfo['file']->filesize : 0);
  70    if (empty($fileinfo['playtime'])) {
  71      return t('@filesize', $args);
  72    }
  73    else {
  74      $args['@playtime'] = $fileinfo['playtime'];
  75      return t('@playtime minutes (@filesize)', $args);
  76    }
  77  }
  78  
  79  /**
  80   * Return a string describing the node's file information.
  81   *
  82   * @param $fileinfo
  83   *   Audio node's audioinfo array.
  84   */
  85  function theme_audio_format_fileformat($fileinfo) {
  86    $format = '';
  87    $args = array();
  88    if (!empty($fileinfo['format'])) {
  89      $format .= '@format ';
  90      $args['@format'] = check_plain(drupal_strtoupper($fileinfo['format']));
  91    }
  92    if (!empty($fileinfo['channel_mode'])) {
  93      $format .= '@channel_mode ';
  94      $args['@channel_mode'] = check_plain(drupal_ucfirst($fileinfo['channel_mode']));
  95    }
  96    if (!empty($fileinfo['sample_rate'])) {
  97      $format .= '@sampleratekHz ';
  98      $args['@samplerate'] = (integer) ($fileinfo['sample_rate'] / 1000);
  99    }
 100    if (!empty($fileinfo['bitrate'])) {
 101      $format .= '@bitrateKbps ';
 102      $args['@bitrate'] = (integer) ($fileinfo['bitrate'] / 1000);
 103  
 104      if (!empty($fileinfo['bitrate_mode'])) {
 105        $format .= '(@bitrate_mode)';
 106        $args['@bitrate_mode'] = check_plain(drupal_strtoupper($fileinfo['bitrate_mode']));
 107      }
 108    }
 109    return strtr($format, $args);
 110  }
 111  


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7