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

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

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


Revision 1.5 - (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.4: +4 -4 lines
File MIME type: text/x-php
Corrected all errors registered by Coder module in preperation for D6 port
1 <?php
2 // $Id: dailymotion.inc,v 1.4 2008/04/29 20:32:01 aaron Exp $
3
4 define('VIDEO_CCK_DAILYMOTION_MAIN_URL', 'http://www.dailymotion.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_dailymotion_info() {
18 $name = t('Dailymotion');
19 $features = array(
20 array(t('Autoplay'), t('Yes'), ''),
21 array(t('RSS Attachment'), t('No'), ''),
22 array(t('Thumbnails'), t('No'), t('')),
23 );
24 return array(
25 'provider' => 'dailymotion',
26 'name' => $name,
27 'url' => VIDEO_CCK_DAILYMOTION_MAIN_URL,
28 'settings_description' => t('These settings specifically affect videos displayed from !dailymotion. You can learn more about its !api here.', array('!dailymotion' => l($name, VIDEO_CCK_DAILYMOTION_MAIN_URL, array('target' => '_blank')), '!api' => l(t('API'), VIDEO_CCK_DAILYMOTION_API_INFO, 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['dailymotion'])
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_dailymotion_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_dailymotion_extract($embed = '') {
55 // http://www.dailymotion.com/us/cluster/news/featured/video/x3xk8v_primary-smackdown-obama-girl-return_fun
56 // http://www.dailymotion.com/barelypolitical/video/x3xk8v_primary-smackdown-obama-girl-return_fun
57 // http://www.dailymotion.com/barelypolitical/video/x3xk8v
58 // <div><object width="420" height="252"><param name="movie" value="http://www.dailymotion.com/swf/x3xk8v" /></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.dailymotion.com/swf/x3xk8v" type="application/x-shockwave-flash" width="420" height="252" allowFullScreen="true" allowScriptAccess="always"></embed></object><br /><b><a href="http://www.dailymotion.com/video/x3xk8v_primary-smackdown-obama-girl-return_fun">Primary Smackdown: Obama Girl Returns</a></b><br /><i>Uploaded by <a href="http://www.dailymotion.com/BarelyPolitical">BarelyPolitical</a></i></div>
59 // <div><object width="420" height="252"><param name="movie" value="http://www.dailymotion.com/swf/x3xk8v"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.dailymotion.com/swf/x3xk8v" type="application/x-shockwave-flash" width="420" height="252" allowFullScreen="true" allowScriptAccess="always"></embed></object><br /><b><a href="http://www.dailymotion.com/video/x3xk8v_primary-smackdown-obama-girl-return_fun">Primary Smackdown: Obama Girl Returns</a></b><br /><i>Uploaded by <a href="http://www.dailymotion.com/BarelyPolitical">BarelyPolitical</a></i></div>
60 // if (preg_match('@dailymotion\.com@i', $embed, $matches)) {
61 // if (preg_match('@/([^/_]+)_@i', $embed, $matches)) {
62 // return $matches[0];
63 // }
64 // }
65 if (preg_match('@dailymotion\.com/swf/([^"\&]+)@i', $embed, $matches)) {
66 return $matches[1];
67 }
68 if (preg_match('@dailymotion\.com@i', $embed, $matches)) {
69 if (preg_match('@/([^/_]+)_@i', $embed, $matches)) {
70 return $matches[1];
71 }
72 }
73 return array();
74 }
75
76 /**
77 * hook video_cck_PROVIDER_embedded_link($video_code)
78 * returns a link to view the video at the provider's site
79 * @param $video_code
80 * the string containing the video to watch
81 * @return
82 * a string containing the URL to view the video at the original provider's site
83 */
84 function video_cck_dailymotion_embedded_link($video_code) {
85 return 'http://www.dailymotion.com/swf/'. $video_code;
86 }
87
88 /**
89 * the embedded flash displaying the dailymotion video
90 */
91 function theme_video_cck_dailymotion_flash($embed, $width, $height, $autoplay) {
92 if ($embed) {
93 if ($autoplay) {
94 $autoplay_value = '&autoStart=1';
95 }
96 $output .= " <object type=\"application/x-shockwave-flash\" height=\"$height\" width=\"$width\" data=\"http://www.dailymotion.com/swf/$embed". $autoplay_value ."\" id=\"VideoPlayback\">
97 <param name=\"movie\" value=\"http://www.dailymotion.com/swf/$embed". $autoplay_value ."\" />
98 <param name=\"allowScriptAcess\" value=\"always\" />
99 <param name=\"allowFullScreen\" value=\"true\" />
100 <param name=\"quality\" value=\"best\" />
101 <param name=\"bgcolor\" value=\"#FFFFFF\" />
102 <param name=\"scale\" value=\"noScale\" />
103 <param name=\"salign\" value=\"TL\" />
104 <param name=\"FlashVars\" value=\"playerMode=embedded$autoplay_value\" />
105 <param name=\"wmode\" value=\"transparent\" />
106 </object>\n";
107 }
108 return $output;
109 }
110
111 /**
112 * hook video_cck_PROVIDER_thumbnail
113 * returns the external url for a thumbnail of a specific video
114 * TODO: make the args: ($embed, $field, $item), with $field/$item provided if we need it, but otherwise simplifying things
115 * @param $field
116 * the field of the requesting node
117 * @param $item
118 * the actual content of the field from the requesting node
119 * @return
120 * a URL pointing to the thumbnail
121 */
122 function video_cck_dailymotion_thumbnail($field, $item, $formatter, $node, $width, $height) {
123 return 'http://www.dailymotion.com/thumbnail/160x120/video/'. $item['value'];
124 }
125
126 /**
127 * hook video_cck_PROVIDER_video
128 * this actually displays the full/normal-sized video we want, usually on the default page view
129 * @param $embed
130 * the video code for the video to embed
131 * @param $width
132 * the width to display the video
133 * @param $height
134 * the height to display the video
135 * @param $field
136 * the field info from the requesting node
137 * @param $item
138 * the actual content from the field
139 * @return
140 * the html of the embedded video
141 */
142 function video_cck_dailymotion_video($embed, $width, $height, $field, $item, $autoplay) {
143 $output = theme('video_cck_dailymotion_flash', $embed, $width, $height, $autoplay);
144 return $output;
145 }
146
147 /**
148 * hook video_cck_PROVIDER_video
149 * this actually displays the preview-sized video we want, commonly for the teaser
150 * @param $embed
151 * the video code for the video to embed
152 * @param $width
153 * the width to display the video
154 * @param $height
155 * the height to display the video
156 * @param $field
157 * the field info from the requesting node
158 * @param $item
159 * the actual content from the field
160 * @return
161 * the html of the embedded video
162 */
163 function video_cck_dailymotion_preview($embed, $width, $height, $field, $item, $autoplay) {
164 $output = theme('video_cck_dailymotion_flash', $embed, $width, $height, $autoplay);
165 return $output;
166 }

  ViewVC Help
Powered by ViewVC 1.1.2