/[drupal]/contributions/modules/audio/contrib/feeds/audio_feeds_views.inc
ViewVC logotype

Diff of /contributions/modules/audio/contrib/feeds/audio_feeds_views.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.9 by drewish, Mon Aug 27 23:23:54 2007 UTC revision 1.10 by drewish, Sun May 25 17:21:27 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: audio_feeds_views.inc,v 1.8 2007/08/03 02:41:13 drewish Exp $  // $Id: audio_feeds_views.inc,v 1.9 2007/08/27 23:23:54 drewish Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 13  function audio_feeds_views_style_plugins Line 13  function audio_feeds_views_style_plugins
13      'theme' => 'audio_feeds_views_xspf',      'theme' => 'audio_feeds_views_xspf',
14      'summary_theme' => 'views_summary',      'summary_theme' => 'views_summary',
15    );    );
16   return $items;    return $items;
17  }  }
18    
19  /**  /**
# Line 21  function audio_feeds_views_style_plugins Line 21  function audio_feeds_views_style_plugins
21   */   */
22  function theme_audio_feeds_views_xspf($view, $nodes, $type) {  function theme_audio_feeds_views_xspf($view, $nodes, $type) {
23    if (isset($_GET['xspf'])) {    if (isset($_GET['xspf'])) {
24      return audio_feeds_views_prepare_xspf(views_get_title($view, $type), url($view->real_url, null, null, true), $nodes);      return audio_feeds_views_prepare_xspf(views_get_title($view, $type), url($view->real_url, array('absolute' => true)), $nodes);
25    }    }
26    elseif (isset($_GET['m3u'])) {    elseif (isset($_GET['m3u'])) {
27      return theme('audio_feeds_views_m3u', $view, $nodes, $type);      return theme('audio_feeds_views_m3u', $view, $nodes, $type);
# Line 41  function theme_audio_feeds_views_xspf($v Line 41  function theme_audio_feeds_views_xspf($v
41        }        }
42      }      }
43      $filters = $query_string ? audio_feeds_query_string_encode($query_string) .'%26xspf' : 'xspf';      $filters = $query_string ? audio_feeds_query_string_encode($query_string) .'%26xspf' : 'xspf';
44      $playlist_url = url($view->real_url, $filters, NULL, TRUE);      $playlist_url = url($view->real_url, array('query' => $filters, 'absolute' => TRUE));
45      $output = theme($player['theme_xspf'], $playlist_url);      $output = theme($player['theme_xspf'], $playlist_url);
46      $output .= theme('audio_feeds_views_links', $view, $query_string);      $output .= theme('audio_feeds_views_links', $view, $query_string);
47      return $output;      return $output;
# Line 55  function audio_feeds_views_prepare_xspf( Line 55  function audio_feeds_views_prepare_xspf(
55    global $base_url;    global $base_url;
56    
57    // prepare feed metadata    // prepare feed metadata
58    $metadata = array('title' => $title,    $metadata = array(
59                      'author' => $base_url,      'title' => $title,
60                      'link' => $base_url,      'author' => $base_url,
61                      'feed_url' => $url      'link' => $base_url,
62                      );      'feed_url' => $url
63      );
64    
65    // prepare feed items    // prepare feed items
66    foreach ($nodes as $n) {    foreach ($nodes as $n) {
67    $audio = node_load($n->nid);      $audio = node_load($n->nid);
68    // use the first image uploaded as the included image if it exists      // use the first image uploaded as the included image if it exists
69    $image = is_array($audio->audio_images) ? current($audio->audio_images) : '';      $image = is_array($audio->audio_images) ? current($audio->audio_images) : '';
70    $items[] = array('title' => $audio->audio_tags['title'] ? $audio->audio_tags['title'] : $audio->title,      $items[] = array(
71                     'author' => $audio->audio_tags['artist'],        'title' => $audio->audio_tags['title'] ? $audio->audio_tags['title'] : $audio->title,
72                     'album' => $audio->audio_tags['album'],        'author' => $audio->audio_tags['artist'],
73                     'duration' => $audio->audio_file['playtime'],        'album' => $audio->audio_tags['album'],
74                     'link' => url('node/'.$audio->nid, NULL, NULL, TRUE),        'duration' => $audio->audio_file['playtime'],
75                     'image' => $image ? array('url' => $base_url .'/'. $image['filepath']) : '',        'link' => url('node/'. $audio->nid, array('absolute' => TRUE)),
76                     'enclosure' => array('url' => $audio->url_play)        'image' => $image ? array('url' => $base_url .'/'. $image['filepath']) : '',
77                     );        'enclosure' => array('url' => $audio->url_play)
78        );
79    }    }
80    audio_feeds_generate_xspf($items, $metadata);    audio_feeds_generate_xspf($items, $metadata);
81  }  }
# Line 98  function audio_feeds_views_prepare_m3u($ Line 99  function audio_feeds_views_prepare_m3u($
99    // prepare feed items    // prepare feed items
100    foreach ($nodes as $n) {    foreach ($nodes as $n) {
101      $audio = node_load($n->nid);      $audio = node_load($n->nid);
102      $items[] = array('title' => $audio->audio_tags['title'] ? $audio->audio_tags['title'] : $audio->title,      $items[] = array(
103                       'author' => $audio->audio_tags['artist'],        'title' => $audio->audio_tags['title'] ? $audio->audio_tags['title'] : $audio->title,
104                       'duration' => $audio->audio_file['playtime'],        'author' => $audio->audio_tags['artist'],
105                       'enclosure' => array('url' => $audio->url_play)        'duration' => $audio->audio_file['playtime'],
106                       );        'enclosure' => array('url' => $audio->url_play)
107        );
108    }    }
109    audio_feeds_generate_m3u($items, $metadata);    audio_feeds_generate_m3u($items, $metadata);
110  }  }
# Line 126  function audio_feeds_views_prepare_pls($ Line 128  function audio_feeds_views_prepare_pls($
128    // prepare feed items    // prepare feed items
129    foreach ($nodes as $n) {    foreach ($nodes as $n) {
130      $audio = node_load($n->nid);      $audio = node_load($n->nid);
131      $items[] = array('title' => $audio->audio_tags['title'] ? $audio->audio_tags['title'] : $audio->title,      $items[] = array(
132                       'author' => $audio->audio_tags['artist'],        'title' => $audio->audio_tags['title'] ? $audio->audio_tags['title'] : $audio->title,
133                       'duration' => $audio->audio_file['playtime'],        'author' => $audio->audio_tags['artist'],
134                       'enclosure' => array('url' => $audio->url_play)        'duration' => $audio->audio_file['playtime'],
135                       );        'enclosure' => array('url' => $audio->url_play)
136        );
137    }    }
138    audio_feeds_generate_pls($items, $metadata);    audio_feeds_generate_pls($items, $metadata);
139  }  }
# Line 145  function theme_audio_feeds_views_links($ Line 148  function theme_audio_feeds_views_links($
148    
149    $links = array();    $links = array();
150    $links['m3u']['title'] = t('m3u');    $links['m3u']['title'] = t('m3u');
151    $links['m3u']['href'] = url($view->real_url, $m3u_filter, null, true);    $links['m3u']['href'] = url($view->real_url, array('query' => $m3u_filter, 'absolute' => true));
152    $links['pls']['title'] = t('pls');    $links['pls']['title'] = t('pls');
153    $links['pls']['href'] = url($view->real_url, $pls_filter, null, true);    $links['pls']['href'] = url($view->real_url, array('query' => $pls_filter, 'absolute' => true));
154    $links['xspf']['title'] = t('xspf');    $links['xspf']['title'] = t('xspf');
155    $links['xspf']['href'] = url($view->real_url, $xspf_filter, null, true);    $links['xspf']['href'] = url($view->real_url, array('query' => $xspf_filter, 'absolute' => true));
156    return theme('links', $links);    return theme('links', $links);
157  }  }
158    
# Line 160  function audio_feeds_views_default_views Line 163  function audio_feeds_views_default_views
163    $view = new stdClass();    $view = new stdClass();
164    $view->name = 'audio_feeds';    $view->name = 'audio_feeds';
165    $view->description = 'Audio XSPF Player';    $view->description = 'Audio XSPF Player';
166    $view->access = array (    $view->access = array(
167      0 => '1',      0 => '1',
168      1 => '2',      1 => '2',
169    );    );
# Line 177  function audio_feeds_views_default_views Line 180  function audio_feeds_views_default_views
180    $view->url = 'audio/listen';    $view->url = 'audio/listen';
181    $view->use_pager = FALSE;    $view->use_pager = FALSE;
182    $view->nodes_per_page = '15';    $view->nodes_per_page = '15';
183    $view->sort = array (    $view->sort = array(
184      array (      array(
185        'tablename' => 'node',        'tablename' => 'node',
186        'field' => 'created',        'field' => 'created',
187        'sortorder' => 'DESC',        'sortorder' => 'DESC',
188        'options' => 'normal',        'options' => 'normal',
189      ),      ),
190    );    );
191    $view->argument = array (    $view->argument = array(
192      array (      array(
193        'type' => 'rss_feed',        'type' => 'rss_feed',
194        'argdefault' => '2',        'argdefault' => '2',
195        'title' => '',        'title' => '',
# Line 195  function audio_feeds_views_default_views Line 198  function audio_feeds_views_default_views
198        'wildcard_substitution' => '',        'wildcard_substitution' => '',
199      ),      ),
200    );    );
201    $view->field = array (    $view->field = array(
202      array (      array(
203        'tablename' => 'node',        'tablename' => 'node',
204        'field' => 'title',        'field' => 'title',
205        'label' => '',        'label' => '',
# Line 204  function audio_feeds_views_default_views Line 207  function audio_feeds_views_default_views
207        'options' => 'link',        'options' => 'link',
208      ),      ),
209    );    );
210    $view->filter = array (    $view->filter = array(
211      array (      array(
212        'tablename' => 'node',        'tablename' => 'node',
213        'field' => 'type',        'field' => 'type',
214        'operator' => 'OR',        'operator' => 'OR',
215        'options' => '',        'options' => '',
216        'value' => array (        'value' => array(
217            0 => 'audio',            0 => 'audio',
218          ),          ),
219      ),      ),
220      array (      array(
221        'tablename' => 'node',        'tablename' => 'node',
222        'field' => 'status',        'field' => 'status',
223        'operator' => '=',        'operator' => '=',

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.3