-
Notifications
You must be signed in to change notification settings - Fork 0
/
videocarousel.module
executable file
·171 lines (143 loc) · 4.79 KB
/
videocarousel.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
/**
* @file
* Embedded Video Field provider for distant FLV url.
*/
function videocarousel_emfield_providers($module, $provider = NULL) {
if ($module == 'emvideo') {
return drupal_system_listing(".inc", drupal_get_path('module', 'videocarousel') ."/providers", 'name', 0);
}
}
/**
* Implementation of hook_views_api().
*/
function videocarousel_views_api() {
return array(
'api' => 2,
'path' => drupal_get_path('module', 'videocarousel'),
//'path' => drupal_get_path('module', 'videocarousel') . '/includes',
);
}
/**
* Themes the Views Carousel View.
*/
function theme_videocarousel_view($view, $options = array(), $rows = array()) {
// Remove the skin and skin path from the options.
$skin = $options['skin'];
$path = ($skin == 'custom') ? $options['skin_path'] : NULL;
unset($options['skin'], $options['skin_path']);
// Remove any empty options and convert any numbers to float values.
foreach ($options as $key => $value) {
if (is_numeric($value)) {
$options[$key] = (float)$value;
}
if (empty($value)) {
unset($options[$key]);
}
}
// Use jCarousel to create the carousel.
return theme('videocarousel', $rows, $options, $skin, $path, 'videocarousel-'. $view->name .'-'. $view->current_display, $view);
}
/**
* Implementation of hook_theme().
*/
function videocarousel_theme($existing, $type, $theme, $path) {
return array(
'videocarousel' => array(
'arguments' => array(
'items' => array(),
'options' => array(),
'skin' => 'tango',
'skin_path' => NULL,
'id' => 'videocarousel',
'view' => array(),
),
'template' => 'videocarousel',
),
);
}
/**
* Process variables for videocarousel.tpl.php.
*
*/
function template_preprocess_videocarousel(&$vars) {
drupal_add_js(drupal_get_path('module', 'videocarousel') .'/videocarousel.js');
drupal_add_css(drupal_get_path('module', 'videocarousel') .'/videocarousel.css');
$options = $vars['options'];
$skin = $vars['skin'];
$skin_path = $vars['skin_path'];
$id = $vars['id'];
// add the caroussel
$name = form_clean_id($id);
jcarousel_add('#'. $name, $options, $skin, $skin_path);
$vars['name'] = $name;
// begin our loop
$i = 0;
$jq_container = null;
$jq_listing = null;
$jq_body = null;
$tab = array();
$title = array();
$body = array();
$video_type = array();
foreach ($vars['view']->style_plugin->rendered_fields as $view_item) {
$i++;
if ($view_item['field_emvideo_embed'] == "" && $view_item['field_local_video_fid'] != "" && $view_item['field_illustration_fid'] != "") {
// here we have a local video file
$video_type[$i] = "local";
$filename = array();
$filename = explode("/",$view_item['field_illustration_fid']);
$filename = array_pop($filename);
$video_type[$i] = $filename;
$tab[$i] = swf($view_item['field_local_video_fid'], array('flashvars' => array('image' => $filename)));
$title[$i] = $view_item['title'];
$body[$i] = $view_item['body'];
}
else {
$video_type[$i] = "embed";
$tab[$i] = $view_item['field_emvideo_embed'];
$title[$i] = $view_item['title'];
$body[$i] = $view_item['body'];
}
}
$i=0;
foreach ($vars['items'] as $item) {
$i++;
if ($i == 1) {
$display = "display: block;";
}
else {
$display = "display: none;";
}
if ($video_type[$i] != "embed") {
$item = "<img src=".imagecache_create_url("videocarousel_item", $video_type[$i])." />";
}
$jq_container .= '<div style="'.$display.'" id="videocarousel-item-'.$i.'-main" class="videocarousel-video-container">'. $tab[$i] .'</div>';
$jq_listing .= '<li id="videocarousel-item-'.$i.'" class="videocarousel-item">'. $item .'</li>';
$jq_body .= '<h2 id="videocarousel-item-'.$i.'-title" style="'.$display.'" class="videocarousel-item-title">'. $title[$i] .'</h2><div id="videocarousel-item-'.$i.'-body" style="'.$display.'" class="videocarousel-item-body">'. $body[$i] .'</div>';
}
$vars['jq_container'] = $jq_container;
$vars['jq_listing'] = $jq_listing;
$vars['jq_body'] = $jq_body;
}
/**
* Implementation of hook_imagecache_default_presets().
*/
function videocarousel_imagecache_default_presets() {
$presets = array();
$presets['videocarousel_item'] = array (
'presetname' => 'videocarousel_item',
'actions' => array (
0 => array (
'weight' => '0',
'module' => 'imagecache',
'action' => 'imagecache_scale_and_crop',
'data' => array (
'width' => '120',
'height' => '90',
),
),
),
);
return $presets;
}