/[drupal]/contributions/modules/ffpc/ffpc_plugin_row_podcast.inc
ViewVC logotype

Contents of /contributions/modules/ffpc/ffpc_plugin_row_podcast.inc

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


Revision 1.6 - (show annotations) (download) (as text)
Tue Dec 30 21:40:27 2008 UTC (10 months, 3 weeks ago) by mfer
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +5 -5 lines
File MIME type: text/x-php
#328649 by grendzy: The guid in a feed needs to be unique. Updated to use the filepath which works with private files. Some feed readers judge if an item is unique by the guid.
1 <?php
2 class ffpc_plugin_row_podcast extends views_plugin_row_node_rss {
3
4 function render($row) {
5 // For the most part, this code is taken from node_feed() in node.module
6 global $base_url;
7
8 $item_length = $this->options['item_length'];
9 if ($item_length == 'default') {
10 $item_length = variable_get('feed_item_length', 'teaser');
11 }
12
13 if (empty($this->view->style_plugin->namespaces)) {
14 $this->view->style_plugin->namespaces['xmlns:itunes'] = 'http://www.itunes.com/dtds/podcast-1.0.dtd';
15 }
16
17 // Load the specified node:
18 $item = node_load($row->nid);
19 $item->build_mode = NODE_BUILD_RSS;
20 $item->link = url("node/$row->nid", array('absolute' => TRUE));
21
22 if ($item_length != 'title') {
23 $teaser = ($item_length == 'teaser') ? TRUE : FALSE;
24
25 // Filter and prepare node teaser
26 if (node_hook($item, 'view')) {
27 $item = node_invoke($item, 'view', $teaser, FALSE);
28 }
29 else {
30 $item = node_prepare($item, $teaser);
31 }
32
33 // Allow modules to change $node->teaser before viewing.
34 node_invoke_nodeapi($item, 'view', $teaser, FALSE);
35 }
36
37 // Allow modules to add additional item fields and/or modify $item
38 $extra = node_invoke_nodeapi($item, 'rss item');
39 $extra = array_merge($extra,
40 array(
41 array('key' => 'pubDate', 'value' => gmdate('r', $item->created)),
42 // The author should be an email address. Need to add this in.
43 //array('key' => 'author', 'value' => $item->name),
44 )
45 );
46 foreach ($extra as $element) {
47 if (isset($element['namespace'])) {
48 $this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $element['namespace']);
49 }
50 }
51
52 // Prepare the item description
53 switch ($item_length) {
54 case 'fulltext':
55 $item_text = $item->body;
56 break;
57 case 'teaser':
58 $item_text = $item->teaser;
59 if (!empty($item->readmore)) {
60 $item_text .= '<p>' . l(t('read more'), 'node/' . $item->nid, array('absolute' => TRUE, 'attributes' => array('target' => '_blank'))) . '</p>';
61 }
62 break;
63 case 'title':
64 $item_text = '';
65 break;
66 }
67
68 $stripped_item_text = strip_tags($item_text);
69
70 if (strlen($stripped_item_text) > 255) {
71 $item_subtitle = substr($stripped_item_text, 0, 252) .'...';
72 }
73 else {
74 $item_subtitle = $stripped_item_text;
75 }
76
77 if (!getid3_load(TRUE)) {
78 return NULL;
79 }
80 $getid3 = new getID3;
81 foreach ( $this->view->field as $id => $field ) {
82 foreach ( $item->{$field->content_field['field_name']} as $file ) {
83 $info = $getid3->analyze($file['filepath']);
84 $file_extra = array();
85 $file_extra[] = array(
86 'key' => 'enclosure',
87 'attributes' => array(
88 'url' => url( $file['filepath'], array('absolute'=>TRUE) ),
89 'length' => $file['filesize'],
90 'type' => $file['filemime'],
91 ),
92 );
93 $file_extra[] = array(
94 'key' => 'itunes:duration',
95 'value' => $info['playtime_string'],
96 );
97 $file_extra[] = array(
98 'key' => 'itunes:author',
99 'value' => $info['tags']['id3v2']['artist'][0],
100 );
101
102 $file_extra[] = array(
103 'key' => 'itunes:subtitle',
104 'value' => str_replace('&amp;', '&', $item_subtitle),
105 );
106 $file_extra[] = array(
107 'key' => 'itunes:summary',
108 'value' => str_replace('&amp;', '&', $stripped_item_text),
109 );
110 $file_extra[] = array(
111 'key' => 'guid',
112 'value' => file_create_url($file['filepath']),
113 'attributes' => array('isPermaLink' => 'false'),
114 );
115 $file_extra = array_merge($extra, $file_extra);
116 /*
117 * The following function takes title, link, description and then
118 * all additional XML elements. For the title we'll use the node
119 * title. Link serves no real purpose in a podcast. Description
120 * is overridden by the extra "subtitle" tag but we'll keep it for
121 * completeness with RSS and use the node teaser.
122 */
123 $output .= format_rss_item($item->title, $item->link, $item_text, $file_extra );
124 }
125 }
126 return $output;
127 }
128 }

  ViewVC Help
Powered by ViewVC 1.1.2