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

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

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


Revision 1.4 - (show annotations) (download) (as text)
Fri Feb 20 03:21:22 2009 UTC (9 months, 1 week ago) by aaron
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +3 -8 lines
File MIME type: text/x-php
 * #345515 - Vimeo thumbnail feature not working (aaron).
1 <?php
2 // $Id: vimeo.inc,v 1.3 2008/05/12 04:10:54 alexua Exp $
3
4 define('VIDEO_CCK_VIMEO_MAIN_URL', 'http://www.vimeo.com/');
5 define('VIDEO_CCK_VIMEO_API_INFO', 'http://vimeo.com/api');
6 define('VIDEO_CCK_VIMEO_COLOR_DEFAULT', '#01AAEA');
7
8 /**
9 * hook video_cck_PROVIDER_info
10 * this returns information relevant to a specific 3rd party video provider
11 * @return
12 * an array of strings requested by various admin and other forms
13 * 'name' => the translated name of the provider
14 * 'url' => the url to the main page for the provider
15 * 'settings_description' => a description of the provider that will be posted in the admin settings form
16 * 'supported_features' => an array of rows describing the state of certain supported features by the provider.
17 * These will be rendered in a table, with the columns being 'Feature', 'Supported', 'Notes'.
18 */
19 function video_cck_vimeo_info() {
20 $name = t('Vimeo');
21 $features = array(
22 array(t('Custom player color'), t('Yes'), t('You may customize the player\'s skin by choosing your own color.')),
23 array(t('Thumbnails'), t('Yes'), t('You may select the size of thumbnail to request from Vimeo.')),
24 array(t('Full screen mode'), t('Yes'), t('You may customize the player to enable or disable full screen playback. Full screen mode is enabled by default.')),
25 );
26 return array(
27 'provider' => 'vimeo',
28 'name' => $name,
29 'url' => VIDEO_CCK_VIMEO_MAIN_URL,
30 'settings_description' => t('These settings specifically affect videos displayed from !provider. You can learn more about its !api here.', array('!provider' => l($name, VIDEO_CCK_VIMEO_MAIN_URL, array('target' => '_blank')), '!api' => l(t('API'), VIDEO_CCK_VIMEO_API_INFO, array('target' => '_blank')))),
31 'supported_features' => $features,
32 );
33 }
34
35 /**
36 * hook video_cck_PROVIDER_settings
37 * this should return a subform to be added to the video_cck_settings() admin settings page.
38 * note that a form field will already be provided, at $form['PROVIDER'] (such as $form['vimeo'])
39 * so if you want specific provider settings within that field, you can add the elements to that form field.
40 */
41 function video_cck_vimeo_settings() {
42 $form['vimeo']['color'] = array(
43 '#type' => 'fieldset',
44 '#title' => t('Embedded video player color'),
45 '#description' => t('If allowed, this color, in hexidecimal form (#RRGGBB), will be used to change the skin of the Vimeo player.'),
46 '#collapsible' => true,
47 '#collapsed' => true,
48 );
49 $form['vimeo']['color']['video_cck_vimeo_color_override'] = array(
50 '#type' => 'checkbox',
51 '#title' => t('Override player color'),
52 '#default_value' => variable_get('video_cck_vimeo_color_override', FALSE),
53 );
54 $form['vimeo']['color']['video_cck_vimeo_color'] = array(
55 '#type' => 'textfield',
56 '#title' => t('Color'),
57 '#default_value' => variable_get('video_cck_vimeo_color', VIDEO_CCK_VIMEO_COLOR_DEFAULT),
58 );
59 $form['vimeo']['player_options'] = array(
60 '#type' => 'fieldset',
61 '#title' => t('Embedded video player options'),
62 '#collapsible' => true,
63 '#collapsed' => true,
64 );
65 $form['vimeo']['player_options']['video_cck_vimeo_on_screen_info'] = array(
66 '#type' => 'checkboxes',
67 '#title' => t('On-screen info'),
68 '#default_value' => variable_get('video_cck_vimeo_on_screen_info', array('portrait', 'title', 'byline')),
69 '#options' => array(
70 'portrait' => t('Show video author\'s portrait'),
71 'title' => t('Show video title'),
72 'byline' => t('Show byline'),
73 ),
74 '#description' => t('Provide additional video information on the Vimeo player.'),
75 );
76 $form['vimeo']['player_options']['video_cck_vimeo_full_screen'] = array(
77 '#type' => 'checkbox',
78 '#title' => t('Allow fullscreen'),
79 '#default_value' => variable_get('video_cck_vimeo_full_screen', 1),
80 '#description' => t('Allow users to view video using the entire computer screen.'),
81 );
82 $form['vimeo']['video_cck_vimeo_api_key'] = array(
83 '#type' => 'textfield',
84 '#title' => t('Vimeo API Key'),
85 '#default_value' => variable_get('video_cck_vimeo_api_key', ''),
86 );
87 $form['vimeo']['video_cck_vimeo_api_secret'] = array(
88 '#type' => 'textfield',
89 '#title' => t('Vimeo API Shared Secret'),
90 '#default_value' => variable_get('video_cck_vimeo_api_secret', ''),
91 );
92 $form['vimeo']['video_cck_vimeo_thumb_size'] = array(
93 '#type' => 'select',
94 '#title' => t('Vimeo Thumbnail Size'),
95 '#options' => array('96' => '96', '100' => '100', '160' => '160', '200' => '200', '460' => '460'),
96 '#default_value' => variable_get('video_cck_vimeo_thumb_size', '160'),
97 );
98 return $form;
99 }
100
101 /**
102 * hook video_cck_PROVIDER_extract
103 * this is called to extract the video code from a pasted URL or embed code.
104 * @param $embed
105 * an optional string with the pasted URL or embed code
106 * @return
107 * either an array of regex expressions to be tested, or a string with the video code to be used
108 * if the hook tests the code itself, it should return either the string of the video code (if matched), or an empty array.
109 * otherwise, the calling function will handle testing the embed code against each regex string in the returned array.
110 */
111 function video_cck_vimeo_extract($embed = '') {
112 // http://vimeo.com/123456
113 // http://www.vimeo.com/123456
114 return array(
115 '@vimeo\.com/([^\"\&]+)@i',
116 );
117 }
118
119 /**
120 * hook video_cck_PROVIDER_embedded_link($video_code)
121 * returns a link to view the video at the provider's site
122 * @param $video_code
123 * the string containing the video to watch
124 * @return
125 * a string containing the URL to view the video at the original provider's site
126 */
127 function video_cck_vimeo_embedded_link($video_code) {
128 return 'http://www.vimeo.com/'. $video_code;
129 }
130
131 function video_cck_vimeo_convert_color($color = NULL) {
132 if ($color{0} == '#') {
133 return substr($color, 1);
134 }
135 return $color;
136 }
137
138 /**
139 * the embedded flash displaying the Vimeo video
140 */
141 function theme_video_cck_vimeo_flash($embed, $width, $height, $autoplay) {
142 $output = '';
143 if ($embed) {
144 $fullscreen = variable_get('video_cck_vimeo_full_screen', 1);
145 $on_screen_info = variable_get('video_cck_vimeo_on_screen_info', array('portrait', 'title', 'byline'));
146 $show_portrait = $on_screen_info['portrait'] ? 1 : 0;
147 $show_title = $on_screen_info['title'] ? 1 : 0;
148 $show_byline = $on_screen_info['byline'] ? 1 : 0;
149 if (variable_get('video_cck_vimeo_color_override', FALSE)) {
150 $color = video_cck_vimeo_convert_color(variable_get('video_cck_vimeo_color', VIDEO_CCK_VIMEO_COLOR_DEFAULT));
151 }
152 $output = '<object type="application/x-shockwave-flash" width="'. $width .'" height="'. $height .'" data="http://www.vimeo.com/moogaloop.swf?clip_id='. $embed .'&amp;server=www.vimeo.com&amp;fullscreen='. $fullscreen .'&amp;show_title='. $show_title .'&amp;show_byline='. $show_byline .'&amp;show_portrait='. $show_portrait .'&amp;color='. $color .'">';
153 $output .= '<param name="quality" value="best" />';
154 $output .= '<param name="allowfullscreen" value="'. ($fullscreen ? 'true' : 'false') .'" />';
155 $output .= '<param name="scale" value="showAll" />';
156 $output .= '<param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id='. $embed .'&amp;server=www.vimeo.com&amp;fullscreen='. $fullscreen .'&amp;show_title='. $show_title .'&amp;show_byline='. $show_byline .'&amp;show_portrait='. $show_portrait .'&amp;color='. $color .'" /></object>';
157 }
158 return $output;
159 }
160
161 /**
162 * hook video_cck_PROVIDER_video
163 * this actually displays the full/normal-sized video we want, usually on the default page view
164 * @param $embed
165 * the video code for the video to embed
166 * @param $width
167 * the width to display the video
168 * @param $height
169 * the height to display the video
170 * @param $field
171 * the field info from the requesting node
172 * @param $item
173 * the actual content from the field
174 * @return
175 * the html of the embedded video
176 */
177 function video_cck_vimeo_video($embed, $width, $height, $field, $item, $autoplay) {
178 $output = theme('video_cck_vimeo_flash', $embed, $width, $height, $autoplay);
179 return $output;
180 }
181
182 /**
183 * hook video_cck_PROVIDER_video
184 * this actually displays the preview-sized video we want, commonly for the teaser
185 * @param $embed
186 * the video code for the video to embed
187 * @param $width
188 * the width to display the video
189 * @param $height
190 * the height to display the video
191 * @param $field
192 * the field info from the requesting node
193 * @param $item
194 * the actual content from the field
195 * @return
196 * the html of the embedded video
197 */
198 function video_cck_vimeo_preview($embed, $width, $height, $field, $item, $autoplay) {
199 $output = theme('video_cck_vimeo_flash', $embed, $width, $height, $autoplay);
200 return $output;
201 }
202
203
204 /**
205 * hook video_cck_PROVIDER_thumbnail
206 * returns the external url for a thumbnail of a specific video
207 * TODO: make the args: ($embed, $field, $item), with $field/$item provided if we need it, but otherwise simplifying things
208 * @param $field
209 * the field of the requesting node
210 * @param $item
211 * the actual content of the field from the requesting node
212 * @return
213 * a URL pointing to the thumbnail
214 */
215 function video_cck_vimeo_thumbnail($field, $item, $formatter, $node, $width, $height) {
216 $xml = emfield_request_xml('vimeo', 'http://vimeo.com/api/oembed.xml?url=http%3A//vimeo.com/'. $item['value'], array(), TRUE, FALSE, $item['value']);
217 return $xml['OEMBED']['THUMBNAIL_URL'][0];
218 }

  ViewVC Help
Powered by ViewVC 1.1.2