/[drupal]/contributions/modules/emfield/contrib/video_cck/providers/tudou.inc
ViewVC logotype

Contents of /contributions/modules/emfield/contrib/video_cck/providers/tudou.inc

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


Revision 1.3 - (show annotations) (download) (as text)
Mon May 12 04:10:54 2008 UTC (18 months, 2 weeks ago) by alexua
Branch: MAIN
CVS Tags: DRUPAL-5--1-3, HEAD
Changes since 1.2: +2 -2 lines
File MIME type: text/x-php
Corrected all errors registered by Coder module in preperation for D6 port
1 <?php
2 // $Id: tudou.inc,v 1.2 2008/03/03 22:22:59 aaron Exp $
3
4 define('VIDEO_CCK_TUDOU_MAIN_URL', 'http://www.tudou.com/');
5
6 /**
7 * hook video_cck_PROVIDER_info
8 * this returns information relevant to a specific 3rd party video provider
9 * @return
10 * an array of strings requested by various admin and other forms
11 * 'name' => the translated name of the provider
12 * 'url' => the url to the main page for the provider
13 * 'settings_description' => a description of the provider that will be posted in the admin settings form
14 * 'supported_features' => an array of rows describing the state of certain supported features by the provider.
15 * These will be rendered in a table, with the columns being 'Feature', 'Supported', 'Notes'.
16 */
17 function video_cck_tudou_info() {
18 $name = t('Tudou');
19 $features = array(
20 array(t('Autoplay'), t('No'), ''),
21 array(t('RSS Attachment'), t('No'), ''),
22 array(t('Thumbnails'), t('No'), t('')),
23 );
24 return array(
25 'provider' => 'tudou',
26 'name' => $name,
27 'url' => VIDEO_CCK_TUDOU_MAIN_URL,
28 'settings_description' => t('These settings specifically affect videos displayed from !tudou.', array('!tudou' => l($name, VIDEO_CCK_TUDOU_MAIN_URL, array('target' => '_blank')))),
29 'supported_features' => $features,
30 );
31 }
32
33 /**
34 * hook video_cck_PROVIDER_settings
35 * this should return a subform to be added to the video_cck_settings() admin settings page.
36 * note that a form field will already be provided, at $form['PROVIDER'] (such as $form['tudou'])
37 * so if you want specific provider settings within that field, you can add the elements to that form field.
38 */
39 function video_cck_tudou_settings() {
40 $form = array();
41 return $form;
42 }
43
44 /**
45 * hook video_cck_PROVIDER_extract
46 * this is called to extract the video code from a pasted URL or embed code.
47 * @param $embed
48 * an optional string with the pasted URL or embed code
49 * @return
50 * either an array of regex expressions to be tested, or a string with the video code to be used
51 * if the hook tests the code itself, it should return either the string of the video code (if matched), or an empty array.
52 * otherwise, the calling function will handle testing the embed code against each regex string in the returned array.
53 */
54 function video_cck_tudou_extract($embed = '') {
55 // http://www.tudou.com/programs/view/uprLNXyEGpc/
56 // <object width="400" height="300"><param name="movie" value="http://www.tudou.com/v/uprLNXyEGpc"></param><param name="allowScriptAccess" value="always"></param><param name="wmode" value="transparent"></param><embed src="http://www.tudou.com/v/uprLNXyEGpc" type="application/x-shockwave-flash" width="400" height="300" allowFullScreen="true" wmode="transparent" allowScriptAccess="always"></embed></object>
57 return array(
58 '@tudou\.com/programs/view/([^"\&/]+)@i',
59 '@value="http\://www\.tudou\.com/v/([^"\&/]+)@i'
60 );
61 }
62
63 /**
64 * hook video_cck_PROVIDER_embedded_link($video_code)
65 * returns a link to view the video at the provider's site
66 * @param $video_code
67 * the string containing the video to watch
68 * @return
69 * a string containing the URL to view the video at the original provider's site
70 */
71 function video_cck_tudou_embedded_link($video_code) {
72 return 'http://www.tudou.com/programs/view/'. $video_code;
73 }
74
75 /**
76 * the embedded flash displaying the tudou video
77 */
78 function theme_video_cck_tudou_flash($embed, $width, $height, $autoplay) {
79 if ($embed) {
80 $output .= "
81 <object width=\"$width\" height=\"$height\">
82 <param name=\"movie\" value=\"http://www.tudou.com/v/$embed\"></param>
83 <param name=\"allowScriptAccess\" value=\"always\"></param>
84 <param name=\"wmode\" value=\"transparent\"></param>
85 <embed src=\"http://www.tudou.com/v/$embed\" type=\"application/x-shockwave-flash\" width=\"$width\" height=\"$height\" allowFullScreen=\"true\" wmode=\"transparent\" allowScriptAccess=\"always\"></embed>
86 </object>
87 ";
88 }
89 return $output;
90 }
91
92 /**
93 * hook video_cck_PROVIDER_thumbnail
94 * returns the external url for a thumbnail of a specific video
95 * TODO: make the args: ($embed, $field, $item), with $field/$item provided if we need it, but otherwise simplifying things
96 * @param $field
97 * the field of the requesting node
98 * @param $item
99 * the actual content of the field from the requesting node
100 * @return
101 * a URL pointing to the thumbnail
102 */
103 function video_cck_tudou_thumbnail($field, $item, $formatter, $node, $width, $height) {
104 }
105
106 /**
107 * hook video_cck_PROVIDER_video
108 * this actually displays the full/normal-sized video we want, usually on the default page view
109 * @param $embed
110 * the video code for the video to embed
111 * @param $width
112 * the width to display the video
113 * @param $height
114 * the height to display the video
115 * @param $field
116 * the field info from the requesting node
117 * @param $item
118 * the actual content from the field
119 * @return
120 * the html of the embedded video
121 */
122 function video_cck_tudou_video($embed, $width, $height, $field, $item, $autoplay) {
123 $output = theme('video_cck_tudou_flash', $embed, $width, $height, $autoplay);
124 return $output;
125 }
126
127 /**
128 * hook video_cck_PROVIDER_video
129 * this actually displays the preview-sized video we want, commonly for the teaser
130 * @param $embed
131 * the video code for the video to embed
132 * @param $width
133 * the width to display the video
134 * @param $height
135 * the height to display the video
136 * @param $field
137 * the field info from the requesting node
138 * @param $item
139 * the actual content from the field
140 * @return
141 * the html of the embedded video
142 */
143 function video_cck_tudou_preview($embed, $width, $height, $field, $item, $autoplay) {
144 $output = theme('video_cck_tudou_flash', $embed, $width, $height, $autoplay);
145 return $output;
146 }

  ViewVC Help
Powered by ViewVC 1.1.2