View source
<?php
define('VIDEO_CCK_VIMEO_MAIN_URL', 'http://www.vimeo.com/');
define('VIDEO_CCK_VIMEO_API_INFO', 'http://vimeo.com/api');
define('VIDEO_CCK_VIMEO_COLOR_DEFAULT', '#01AAEA');
function video_cck_vimeo_info() {
$name = t('Vimeo');
$features = array(
array(
t('Custom player color'),
t('Yes'),
t('You may customize the player\'s skin by choosing your own color.'),
),
array(
t('Thumbnails'),
t('Yes'),
t('You may select the size of thumbnail to request from Vimeo.'),
),
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.'),
),
);
return array(
'provider' => 'vimeo',
'name' => $name,
'url' => VIDEO_CCK_VIMEO_MAIN_URL,
'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',
)),
)),
'supported_features' => $features,
);
}
function video_cck_vimeo_settings() {
$form['vimeo']['color'] = array(
'#type' => 'fieldset',
'#title' => t('Embedded video player color'),
'#description' => t('If allowed, this color, in hexidecimal form (#RRGGBB), will be used to change the skin of the Vimeo player.'),
'#collapsible' => true,
'#collapsed' => true,
);
$form['vimeo']['color']['video_cck_vimeo_color_override'] = array(
'#type' => 'checkbox',
'#title' => t('Override player color'),
'#default_value' => variable_get('video_cck_vimeo_color_override', FALSE),
);
$form['vimeo']['color']['video_cck_vimeo_color'] = array(
'#type' => 'textfield',
'#title' => t('Color'),
'#default_value' => variable_get('video_cck_vimeo_color', VIDEO_CCK_VIMEO_COLOR_DEFAULT),
);
$form['vimeo']['player_options'] = array(
'#type' => 'fieldset',
'#title' => t('Embedded video player options'),
'#collapsible' => true,
'#collapsed' => true,
);
$form['vimeo']['player_options']['video_cck_vimeo_on_screen_info'] = array(
'#type' => 'checkboxes',
'#title' => t('On-screen info'),
'#default_value' => variable_get('video_cck_vimeo_on_screen_info', array(
'portrait',
'title',
'byline',
)),
'#options' => array(
'portrait' => t('Show video author\'s portrait'),
'title' => t('Show video title'),
'byline' => t('Show byline'),
),
'#description' => t('Provide additional video information on the Vimeo player.'),
);
$form['vimeo']['player_options']['video_cck_vimeo_full_screen'] = array(
'#type' => 'checkbox',
'#title' => t('Allow fullscreen'),
'#default_value' => variable_get('video_cck_vimeo_full_screen', 1),
'#description' => t('Allow users to view video using the entire computer screen.'),
);
$form['vimeo']['video_cck_vimeo_api_key'] = array(
'#type' => 'textfield',
'#title' => t('Vimeo API Key'),
'#default_value' => variable_get('video_cck_vimeo_api_key', ''),
);
$form['vimeo']['video_cck_vimeo_api_secret'] = array(
'#type' => 'textfield',
'#title' => t('Vimeo API Shared Secret'),
'#default_value' => variable_get('video_cck_vimeo_api_secret', ''),
);
$form['vimeo']['video_cck_vimeo_thumb_size'] = array(
'#type' => 'select',
'#title' => t('Vimeo Thumbnail Size'),
'#options' => array(
'96' => '96',
'100' => '100',
'160' => '160',
'200' => '200',
'460' => '460',
),
'#default_value' => variable_get('video_cck_vimeo_thumb_size', '160'),
);
return $form;
}
function video_cck_vimeo_extract($embed = '') {
return array(
'@vimeo\\.com/[^\\"\\&\\d]*([^\\"\\&]+)@i',
);
}
function video_cck_vimeo_embedded_link($video_code) {
return 'http://www.vimeo.com/' . $video_code;
}
function video_cck_vimeo_convert_color($color = NULL) {
if ($color[0] == '#') {
return substr($color, 1);
}
return $color;
}
function theme_video_cck_vimeo_flash($embed, $width, $height, $autoplay) {
$output = '';
if ($embed) {
$fullscreen = variable_get('video_cck_vimeo_full_screen', 1);
$on_screen_info = variable_get('video_cck_vimeo_on_screen_info', array(
'portrait',
'title',
'byline',
));
$show_portrait = $on_screen_info['portrait'] ? 1 : 0;
$show_title = $on_screen_info['title'] ? 1 : 0;
$show_byline = $on_screen_info['byline'] ? 1 : 0;
if (variable_get('video_cck_vimeo_color_override', FALSE)) {
$color = video_cck_vimeo_convert_color(variable_get('video_cck_vimeo_color', VIDEO_CCK_VIMEO_COLOR_DEFAULT));
}
$output = '<object type="application/x-shockwave-flash" width="' . $width . '" height="' . $height . '" data="http://www.vimeo.com/moogaloop.swf?clip_id=' . $embed . '&server=www.vimeo.com&fullscreen=' . $fullscreen . '&show_title=' . $show_title . '&show_byline=' . $show_byline . '&show_portrait=' . $show_portrait . '&color=' . $color . '&autoplay=' . $autoplay . '">';
$output .= '<param name="quality" value="best" />';
$output .= '<param name="wmode" value="transparent" />';
$output .= '<param name="allowfullscreen" value="' . ($fullscreen ? 'true' : 'false') . '" />';
$output .= '<param name="scale" value="showAll" />';
$output .= '<param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=' . $embed . '&server=www.vimeo.com&fullscreen=' . $fullscreen . '&show_title=' . $show_title . '&show_byline=' . $show_byline . '&show_portrait=' . $show_portrait . '&color=' . $color . '&autoplay=' . $autoplay . '" /></object>';
}
return $output;
}
function video_cck_vimeo_video($embed, $width, $height, $field, $item, $autoplay) {
$output = theme('video_cck_vimeo_flash', $embed, $width, $height, $autoplay);
return $output;
}
function video_cck_vimeo_preview($embed, $width, $height, $field, $item, $autoplay) {
$output = theme('video_cck_vimeo_flash', $embed, $width, $height, $autoplay);
return $output;
}
function video_cck_vimeo_thumbnail($field, $item, $formatter, $node, $width, $height) {
$xml = emfield_request_xml('vimeo', 'http://vimeo.com/api/oembed.xml?url=http%3A//vimeo.com/' . $item['value'], array(), TRUE, FALSE, $item['value']);
return $xml['OEMBED']['THUMBNAIL_URL'][0];
}