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

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

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


Revision 1.2 - (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.1: +8 -8 lines
File MIME type: text/x-php
Corrected all errors registered by Coder module in preperation for D6 port
1 <?php
2 // $Id: imeem.inc,v 1.1 2008/05/11 04:20:59 alexua Exp $
3
4 define('VIDEO_CCK_IMEEM_MAIN_URL', 'http://www.imeem.com/');
5 define('VIDEO_CCK_IMEEM_API_INFO', 'http://www.imeem.com/developers/documentation/');
6 define('VIDEO_CCK_IMEEM_API_APPLICATION_URL', 'http://www.imeem.com/developers/');
7 define('VIDEO_CCK_IMEEM_XML', 'http://www.imeem.com/api/xml/mediaGetInfo?&mediaIds=');
8
9 function video_cck_imeem_info() {
10 $name = t('IMEEM');
11 $features = array(
12 array(t('Autoplay'), t('Yes'), ''),
13 array(t('RSS Attachment'), t('No'), ''),
14 array(t('Show related videos'), t('No'), t('This is embedded in the video itself when enabled; currently not available with other providers. Set the feature above.')),
15 array(t('Thumbnails'), t('Yes'), t('May not currently resize thumbnails. Must have an API key for thumbnails at the moment, although research is underway to determine an alternative to this. Set your API key above.')),
16 );
17 return array(
18 'provider' => 'imeem',
19 'name' => $name,
20 'url' => VIDEO_CCK_IMEEM_MAIN_URL,
21 'settings_description' => t('These settings specifically affect videos displayed from !imeem. You can learn more about its !api here.', array('!imeem' => l($name, VIDEO_CCK_IMEEM_MAIN_URL, array('target' => '_blank')), '!api' => l(t('API'), VIDEO_CCK_IMEEM_API_INFO, array('target' => '_blank')))),
22 'supported_features' => $features,
23 );
24 }
25
26 function video_cck_imeem_settings() {
27 $form['imeem']['api'] = array(
28 '#type' => 'fieldset',
29 '#title' => t('IMEEM API'),
30 '#description' => t('If you wish to be able to display IMEEM thumbnails automatically, you will first need to apply for an API Developer Key from the !imeem. Note that you do not need this key to display IMEEM videos themselves.', array('!imeem' => l('IMEEM Developer Profile page', VIDEO_CCK_IMEEM_API_APPLICATION_URL, array('target' => '_blank')))),
31 '#collapsible' => true,
32 '#collapsed' => true,
33 );
34 $form['imeem']['api']['video_cck_imeem_api_key'] = array(
35 '#type' => 'textfield',
36 '#title' => t('IMEEM API Key'),
37 '#default_value' => variable_get('video_cck_imeem_api_key', ''),
38 '#description' => t('Please enter your IMEEM Developer Key here.'),
39 );
40 $form['imeem']['api']['video_cck_imeem_api_secret'] = array(
41 '#type' => 'textfield',
42 '#title' => t('IMEEM API Secret'),
43 '#default_value' => variable_get('video_cck_imeem_api_secret', ''),
44 '#description' => t('If you have a secret for the IMEEM API, enter it here.'),
45 );
46 return $form;
47 }
48
49 function video_cck_imeem_request($embed, $cacheable = TRUE) {
50 $args = array('docid' => $embed);
51 return module_invoke('emfield', 'request_xml', 'imeem', VIDEO_CCK_IMEEM_XML . $embed .'&version=1.0', $args, $cacheable);
52 }
53
54 function video_cck_imeem_extract($embed = '') {
55 return array(
56 '@http://media\.imeem\.com/[a-z]{1,2}/([^"\?/]+)/@i',
57 );
58 }
59
60 function video_cck_imeem_embedded_link($video_code) {
61 return 'http://www.imeem.com/v/'. $video_code;
62 }
63
64 function theme_video_cck_imeem_flash($embed, $width, $height, $autoplay) {
65 $autoplay = $autoplay ? '/aus=true' : '/aus=false';
66 $colors = 'backColor=666666&primaryColor=cccccc&secondaryColor=333333&linkColor=cccccc';
67
68 $output .= '<object width="'. $width .'" height="'. $height .'">';
69 $output .= '<param name="movie" value="http://media.imeem.com/v/'. $embed . $autoplay .'/pv=2"></param>';
70 $output .= '<param name="allowFullScreen" value="true"></param>';
71 $output .= '<param name="wmode" value="transparent"></param>';
72 $output .= '<param name="FlashVars" value="'. $colors .'"></param>';
73 $output .= '<embed src="http://media.imeem.com/v/'. $embed . $autoplay .'/pv=2" type="application/x-shockwave-flash" width="'. $width .'" height="'. $height .'" allowFullScreen="true" wmode="transparent" FlashVars="'. $colors .'"></embed>';
74 $output .= '</object>';
75 return $output;
76 }
77
78 function video_cck_imeem_thumbnail($field, $item, $formatter, $node, $width, $height) {
79 $xml = video_cck_imeem_request($item['value']);
80 $tmpthm = $xml['ITEM']['ICONURL'][0];
81 $imgmax = $xml['ITEM']['DURATION'][0];
82 $formatnum = str_pad(rand(0, $imgmax) .'.jpg', 9, "0", STR_PAD_LEFT);;
83 $thm = str_replace('00010.jpg', $formatnum, $tmpthm);
84 return $thm;
85 }
86
87 function video_cck_imeem_video($embed, $width, $height, $field, $item, $autoplay) {
88 $output = theme('video_cck_imeem_flash', $embed, $width, $height, $autoplay);
89 return $output;
90 }
91
92 function video_cck_imeem_preview($embed, $width, $height, $field, $item, $autoplay) {
93 $output = theme('video_cck_imeem_flash', $embed, $width, $height, $autoplay);
94 return $output;
95 }

  ViewVC Help
Powered by ViewVC 1.1.2