[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/audio/views/handlers/ -> audio_handler_field_player.inc (source)

   1  <?php
   2  
   3  /**
   4   * Show a embedded player for an audio file
   5   */
   6  class audio_handler_field_player extends views_handler_field {
   7    function allow_advanced_render() {
   8      return FALSE;
   9    }
  10  
  11    function option_definition() {
  12      $options = parent::option_definition();
  13  
  14      $players = array_keys(audio_get_players('names'));
  15      $options['player'] = array('default' => $players[0], 'translatable' => FALSE);
  16  
  17      return $options;
  18    }
  19  
  20    /**
  21     * Provide link to the page being visited.
  22     */
  23    function options_form(&$form, &$form_state) {
  24      parent::options_form($form, $form_state);
  25      
  26      $players = audio_get_players('names');
  27      $options = array();
  28      foreach ($players as $name => $player) {
  29        $options[$name] = $player['title'];
  30      }
  31      
  32      $form['player'] = array(
  33        '#title' => t('Select a player'),
  34        '#type' => 'select',
  35        '#options' => $options,
  36        '#default_value' => $this->options['player'],
  37      );
  38    }
  39  
  40    function render($values) {
  41      // Don't bother doing a node_load() if there's not a node and file id.
  42      if (!empty($values->{$this->aliases['nid']}) && !empty($values->{$this->aliases['fid']})) {
  43        $node = node_load($values->{$this->aliases['nid']});
  44        return audio_get_node_player($node, $this->options['player']);
  45      }
  46    }
  47  }


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