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

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

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


Revision 1.4 - (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.3: +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: zzz_custom_url.inc,v 1.3 2008/05/11 03:56:54 alexua Exp $
3
4 function _video_cck_zzz_custom_url_default_types() {
5 return array('wmv', 'wma', 'swf', 'flv', 'mov', 'rm');
6 }
7
8 function video_cck_zzz_custom_url_info() {
9 $name = t('Custom URL');
10 $features = array(
11 array(t('Thumbnails'), t('No'), ''),
12 array(t('Autoplay'), t('Yes'), ''),
13 array(t('RSS attachment'), t('No'), ''),
14 );
15 return array(
16 'provider' => 'zzz_custom_url',
17 'name' => $name,
18 'url' => '',
19 'settings_description' => t('These settings specifically affect videos displayed from custom URL\'s. When a field uses a URL it determines to be a link directly to a video file, it will embed that file into the content.'),
20 'supported_features' => $features,
21 'weight' => 9,
22 );
23 }
24
25 function video_cck_zzz_custom_url_settings() {
26 $options = array(
27 'wmv' => t('Windows Media (wmv)'),
28 'wma' => t('Windows Media (wma)'),
29 'swf' => t('Flash (swf)'),
30 'flv' => t('Flash Video (flv)'),
31 'mov' => t('Quicktime (mov)'),
32 'rm' => t('Real Media (rm)'),
33 );
34 $form = array();
35 $form['video_cck_zzz_custom_url_supported_types'] = array(
36 '#type' => 'checkboxes',
37 '#title' => t('Supported Types'),
38 '#options' => $options,
39 '#default_value' => variable_get('video_cck_zzz_custom_url_supported_types', _video_cck_zzz_custom_url_default_types()),
40 '#description' => t('Select the video types you wish to support. When a custom url with that type is entered into an embedded video field, it will be parsed and displayed appropriately. If a type is not supported, then it will be ignored.'),
41 );
42 return $form;
43 }
44
45 function _video_cck_zzz_custom_url_implode_types() {
46 return implode('|', variable_get('video_cck_zzz_custom_url_supported_types', _video_cck_zzz_custom_url_default_types()));
47 }
48
49 function video_cck_zzz_custom_url_extract($embed = '') {
50 $types = _video_cck_zzz_custom_url_implode_types();
51 if (preg_match('@\ .('. $types .')@i', $embed, $matches)) {
52 return $embed;
53 }
54 return false;
55 }
56
57 function video_cck_zzz_custom_url_data($field, $item) {
58 $data = array();
59 // adding the version control
60 $data['video_cck_zzz_custom_url_data_version'] = 1;
61
62 // attempt to get info from headers
63 $response = emfield_request_header('zzz_custom_url', $item['embed']);
64
65 if ($response->code == 200) {
66 $data['url'] = $item['embed'];
67 $data['size'] = $response->headers['Content-Length'];
68 $data['mime'] = $response->headers['Content-Type'];
69 }
70 // @todo replace ['type'] with converted mime info if available
71 $types = _video_cck_zzz_custom_url_implode_types();
72 $regex = '@\.('. $types .')@i';
73 if (preg_match($regex, $item['embed'], $matches)) {
74 $data['type'] = $matches[1];
75 }
76 return $data;
77 }
78
79 /**
80 * hook emfield_PROVIDER_rss
81 */
82 function video_cck_zzz_custom_url_rss($item, $teaser = NULL) {
83 if ($item['value']) {
84 if ($item['data']['video_cck_zzz_custom_url_data_version'] >= 1) {
85 $data = $item['data'];
86 }
87 else {
88 $data = video_cck_zzz_custom_url_data(NULL, $item);
89 }
90
91 $file = array();
92 if ($data['size'] > 0) {
93 $file['filepath'] = $data['url'];
94 $file['filesize'] = $data['size'];
95 $file['filemime'] = $data['mime'];
96 }
97
98 return $file;
99 }
100 }
101
102
103 function video_cck_zzz_custom_url_embedded_link($video_code) {
104 return $video_code;
105 }
106
107 function theme_video_cck_zzz_custom_url_embedded_video($type, $url, $width, $height, $autoplay = false, $field = NULL, $item = NULL) {
108 if ($url) {
109 switch ($type) {
110 case 'wmv':
111 case 'wma':
112 $autostart = $autoplay ? '1' : '0';
113 return '<embed src="'. $url .'" width="'. $width .'" height="'. $height .'" autostart="'. $autostart .'" showcontrols="1" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/windows/windowsmedia/download/"> </embed>';
114 case 'mov':
115 $autostart = $autoplay ? 'true' : 'false';
116 return '<embed src="'. $url .'" width="'. $width .'" height="'. $height .'" autoplay="'. $autostart .'" controller="true" type="video/quicktime" scale="tofit" pluginspage="http://www.apple.com/quicktime/download/"> </embed>';
117 case 'rm':
118 $autostart = $autoplay ? 'true' : 'false';
119 return '<embed type="audio/x-pn-realaudio-plugin" src="'. $url .'" width="'. $width .'" height="'. $height .'" autostart="'. $autostart .'" controls="imagewindow" nojava="true" console="c1183760810807" pluginspage="http://www.real.com/"></embed><br><embed type="audio/x-pn-realaudio-plugin" src="'. $url .'" width="'. $width .'" height="26" autostart="'. $autostart .'" nojava="true" controls="ControlPanel" console="c1183760810807"> </embed>';
120 case 'swf':
121 return '<embed src="'. $url .'" width="'. $width .'" height="'. $height .'" quality="high" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
122 case 'flv':
123 $autostart = $autoplay ? 'true' : 'false';
124 return '<embed src="http://freevideocoding.com/flvplayer.swf?file='. $url .'&autoStart='. $autostart .'" width="'. $width .'" height="'. $height .'" quality="high" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
125 }
126 }
127 }
128
129 function video_cck_zzz_custom_url_thumbnail($field, $item, $formatter, $node, $width, $height) {
130 return '';
131 }
132
133 function video_cck_zzz_custom_url_video($code, $width, $height, $field, $item, $autoplay) {
134 $type = $item['data']['type'];
135 $output = theme('video_cck_zzz_custom_url_embedded_video', $type, $code, $width, $height, $autoplay, $field, $item);
136 return $output;
137 }
138
139 function video_cck_zzz_custom_url_preview($code, $width, $height, $field, $item, $autoplay) {
140 $type = $item['data']['type'];
141 $output = theme('video_cck_zzz_custom_url_embedded_video', $type, $code, $width, $height, $autoplay, $field, $item);
142 return $output;
143 }

  ViewVC Help
Powered by ViewVC 1.1.2