From f1c223d55d51b7bf493da800e2f7e5e9cb5d1042 Mon Sep 17 00:00:00 2001 From: Luke Last Date: Tue, 25 Oct 2005 00:20:44 +0000 Subject: RSS DTV support by Uwe Hermann. Also some other small fixes. --- video.module | 77 ++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 60 insertions(+), 17 deletions(-) diff --git a/video.module b/video.module index e66eff5..d0a2ce2 100644 --- a/video.module +++ b/video.module @@ -74,13 +74,13 @@ ALTER TABLE video ADD custom_field_6 text NULL default NULL; function video_help($section = 'admin/help#video') { switch ($section) { case 'admin/help#video': - $output = '

'. t('The video module(4.7 or with backport patch to 4.6) allows users to post video content to their site. The emergence of portable phones with video capture capabilities has made video capture ubiquitos. Video logging, or vlogging as medium for personal video broadcasting has proven to be popular and is following the blogging, and podcasting phenomenas. Videos are useful for creative collaboration among community members. If community members can not meet in person videos of meetings are valuable for enhancing the interaction between community members.', array('%elink-en-wikipedia-org' => 'http://en.wikipedia.org/wiki/Vlog')) .'

'; - $output .= '

'. t('The video module can be administered to flash player settings. There are a number of page and menu links which can be added to play and download video content on the site. Other configurable options include counts of plays and downloads. Multi-file downloads can also be configured to play. You can add file extensions that the flash video player should handle. There are also up to six custom fields and a group name which can be added.') .'

'; + $output = '

' . t('The video module (4.7 or with backport patch to 4.6) allows users to post video content to their site. The emergence of portable phones with video capture capabilities has made video capture ubiquitous. Video logging, or vlogging as a medium for personal video broadcasting has proven to be popular and is following the blogging, and podcasting phenomena\'s. Videos are useful for creative collaboration among community members. If community members can not meet in person videos of meetings are valuable for enhancing the interaction between community members.', array('%elink-en-wikipedia-org' => 'http://en.wikipedia.org/wiki/Vlog')) . '

'; + $output .= '

' . t('The video module can be administered to flash player settings. There are a number of page and menu links which can be added to play and download video content on the site. Other configurable options include play and download counters. Multi-file downloads can also be configured under settings. There are also up to six custom fields and a group name which can be added.') . '

'; $output .= t('

You can:

', array('%admin-block' => url('admin/block'), '%node-add-video' => url('node/add/video'), '%admin-settings-video' => url('admin/settings/video'))); $output .= '

'. t('For more information please read the configuration and customization handbook Video page.', array('%video' => 'http://www.drupal.org/handbook/modules/video/')) .'

'; @@ -101,7 +101,6 @@ function video_help($section = 'admin/help#video') { $help .= '
  • ' . t('Multi-file download folder') . '
  • '; $help .= '
  • ' . t('Show files in "play" folder') . '
  • '; return $help; - break; } } @@ -115,8 +114,6 @@ function video_help($section = 'admin/help#video') { * array of menu information */ function video_menu($may_cache) { - global $user; - if ($may_cache) { $items[] = array('path' => 'video', 'title' => t('videos'), 'callback' => 'video_page', @@ -191,7 +188,7 @@ function video_link($type, $node = NULL) { $link .= ($display_download_link == 1) ? ' ' . t('or') . ' ' : ' | '; } if ($display_download_link == 1) { - $link .= l(t('download'), "node/$node->nid/download", array('class' => 'outgoing', 'title' => t('visit %link', array('%link' => $node->title)))); + $link .= l(t('download'), "node/$node->nid/download", array('class' => 'outgoing', 'title' => t('download %link', array('%link' => $node->title)))); $link .= ' | '; } if ($display_playtime == 1) { @@ -221,7 +218,6 @@ function video_link($type, $node = NULL) { * string HTML output */ function video_page() { - global $user; $output = ''; if (arg(1) != 'help') { //We are not reading help so output a list of recent video nodes. $result = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'video' AND n.status = 1 ORDER BY n.created DESC"), variable_get('default_nodes_main', 10)); @@ -335,12 +331,30 @@ function video_access($op, $node) { switch($op) { case 'view': return $node->status; // see book.module for reference - case 'create': return user_access('create video'); } } +/** + * Implementation of hook_nodeapi(). + * We use this to append tags to the RSS feeds Drupal generates. + */ +function video_nodeapi($node, $op, $arg) { + switch ($op) { + case 'rss item': + if ($node->type == 'video') { + $attributes['url'] = _video_get_fileurl($node->vidfile) . basename($node->vidfile); + $attributes['length'] = $node->size; + $mime_type = _video_get_mime_type($node); + if ($mime_type) { + $attributes['type'] = $mime_type; + } + return array(array('key' => 'enclosure', 'attributes' => $attributes)); + } + } +} + /** * Hook, displays the contents of the node form page for creating and editing nodes. * @@ -350,7 +364,7 @@ function video_access($op, $node) { * @return * string value of form content */ -function video_form(&$node) { +function video_form($node) { $output = ''; $output .= form_textfield(t('Video File'), 'vidfile', $node->vidfile, 60, 65535, t('Put here the video file path. You can use either relative to the drupal root directory (something/video.mov) or absolute (http://www.example.com/videos/videos.mov). Windows Media currently requires a fully qualified URL to function. Flash movies may not play with spaces in the path or filename. To add youtube.com videos enter the video ID. If your video was at (http://www.youtube.com/watch.php?v=aBM4QYXPf-s) you would enter (aBM4QYXPf-s). ') . l(t('More information.'), 'video/help#videofile') . ($error['vidfile'] ? $error['vidfile'] : ''), NULL, TRUE); $output .= form_textfield(t('Video Size x'), 'videox', $node->videox, 4, 4, t('Horizontal video pixel size.'), null, true); @@ -442,7 +456,7 @@ function video_update(&$node) { * @param $node * object */ -function video_delete(&$node) { +function video_delete($node) { db_query("DELETE FROM {video} WHERE nid = '%s'", $node->nid); cache_clear_all("video:blogmarks:block"); } @@ -777,7 +791,7 @@ function video_view(&$node, $teaser = FALSE, $page = FALSE) { * @return * string of content to display */ -function theme_video_play_flash(&$node) { +function theme_video_play_flash($node) { $loader_location = variable_get('video_flvplayerloader', 'Player.swf'); $skin_location = variable_get('video_flvplayerskin', 'modules/video/FLVPlayer_Skin.swf'); $skin_location = substr($skin_location, 0, strlen($skin_location) - 4); @@ -806,7 +820,7 @@ function theme_video_play_flash(&$node) { * @return * string of content to display */ -function theme_video_play_quicktime(&$node) { +function theme_video_play_quicktime($node) { $height = $node->videoy + 16; //Increase the height to accommodate the player controls on the bottom. $output = ' @@ -946,7 +960,7 @@ function _theme_video_format_play(&$output, $url, $title, $link_text) { * @return * string of content to display */ -function theme_video_view(&$node) { +function theme_video_view($node) { //Adds the custom fields. $group_title = variable_get('video_customfieldtitle', ''); //Title of the custom fields. $title1 = variable_get('video_customfield1', ''); @@ -1139,7 +1153,7 @@ function _video_scandir($dir) { * @return * integer bytes */ -function _video_size2bytes(&$node) { +function _video_size2bytes($node) { if (!empty($node->size)) { switch ($node->size_format) { case 'Kb': // KiloBits @@ -1252,3 +1266,32 @@ function _video_page_goto($id, $type = 'video') { } return false; } + +/** + * Returns the correct mime-type for the video. Returns false if the + * mime-type cannot be detected. + */ +function _video_get_mime_type($node) { + switch (_video_get_filetype($node->vidfile)) { + case 'mov': + return 'video/quicktime'; + break; + case 'rm': + return 'application/vnd.rn-realmedia'; + break; + case 'flv': + return 'flv-application/octet-stream'; + break; + case 'wmv': + return 'video/x-ms-wmv'; + break; + case 'youtube': + // We can't support this properly, so return false. + return false; + break; + default: + // We couldn't detect the mime-type, so return false. + return false; + break; + } +} -- cgit v1.2.3