1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* The theme system, which controls the output of views slideshow.
|
6 |
|
|
*
|
7 |
|
|
* This just adds a wrapper div to the slideshow.
|
8 |
|
|
*/
|
9 |
|
|
|
10 |
|
|
function _views_slideshow_preprocess_views_slideshow(&$vars) {
|
11 |
|
|
$options = $vars['options'];
|
12 |
|
|
$vars['skin'] = 'default';
|
13 |
|
|
$vars['slideshow'] = '';
|
14 |
|
|
$main_frame_module = $options['slideshow_type'];
|
15 |
|
|
|
16 |
|
|
if (empty($main_frame_module)) {
|
17 |
|
|
// Get all slideshow types.
|
18 |
|
|
$slideshows = module_invoke_all('views_slideshow_slideshow_info');
|
19 |
|
|
|
20 |
|
|
if ($slideshows) {
|
21 |
|
|
foreach ($slideshows as $slideshow_id => $slideshow_info) {
|
22 |
|
|
$main_frame_module = $slideshow_id;
|
23 |
|
|
break;
|
24 |
|
|
}
|
25 |
|
|
}
|
26 |
|
|
}
|
27 |
|
|
|
28 |
|
|
// Make sure the main slideshow settings are defined before building the
|
29 |
|
|
// slideshow.
|
30 |
|
|
if (empty($main_frame_module)) {
|
31 |
|
|
drupal_set_message(t('No main frame module is enabled for views slideshow.'), 'error');
|
32 |
|
|
}
|
33 |
|
|
elseif (empty($options[$main_frame_module])) {
|
34 |
|
|
drupal_set_message(t('The options for !module does not exists.', array('!module' => $main_frame_module)), 'error');
|
35 |
|
|
}
|
36 |
|
|
elseif (!empty($vars['rows'])) {
|
37 |
|
|
$settings = $options[$main_frame_module];
|
38 |
|
|
$view = $vars['view'];
|
39 |
|
|
$rows = $vars['rows'];
|
40 |
|
|
$num_divs = count($rows);
|
41 |
|
|
$vss_id = $view->name . '-' . $view->current_display;
|
42 |
|
|
|
43 |
|
|
// Give each slideshow a unique id if there are more than one on the page.
|
44 |
|
|
static $instances = array();
|
45 |
|
|
if (isset($instances[$vss_id])) {
|
46 |
|
|
$instances[$vss_id]++;
|
47 |
|
|
$vss_id .= "_" . $instances[$vss_id];
|
48 |
|
|
}
|
49 |
|
|
else {
|
50 |
|
|
$instances[$vss_id] = 1;
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
// Building our default methods.
|
54 |
|
|
$methods = array(
|
55 |
|
|
'goToSlide' => array(),
|
56 |
|
|
'nextSlide' => array(),
|
57 |
|
|
'pause' => array(),
|
58 |
|
|
'play' => array(),
|
59 |
|
|
'previousSlide' => array(),
|
60 |
|
|
'transitionBegin' => array(),
|
61 |
|
|
'transitionEnd' => array(),
|
62 |
|
|
);
|
63 |
|
|
|
64 |
|
|
// Pull all widget info and slideshow info and merge them together.
|
65 |
|
|
$widgets = module_invoke_all('views_slideshow_widget_info');
|
66 |
|
|
$slideshows = module_invoke_all('views_slideshow_slideshow_info');
|
67 |
|
|
$addons = array_merge($widgets, $slideshows);
|
68 |
|
|
|
69 |
|
|
// Loop through all the addons and call their methods if needed.
|
70 |
|
|
foreach ($addons as $addon_id => $addon_info) {
|
71 |
|
|
foreach ($addon_info['accepts'] as $imp_key => $imp_value) {
|
72 |
|
|
if (is_array($imp_value)) {
|
73 |
|
|
$methods[$imp_key][] = views_slideshow_format_addons_name($addon_id);
|
74 |
|
|
}
|
75 |
|
|
else {
|
76 |
|
|
$methods[$imp_value][] = views_slideshow_format_addons_name($addon_id);
|
77 |
|
|
}
|
78 |
|
|
}
|
79 |
|
|
}
|
80 |
|
|
|
81 |
|
|
$js_settings = array(
|
82 |
|
|
'viewsSlideshow' => array(
|
83 |
|
|
$vss_id => array(
|
84 |
|
|
'methods' => $methods,
|
85 |
|
|
'paused' => 0,
|
86 |
|
|
)
|
87 |
|
|
)
|
88 |
|
|
);
|
89 |
|
|
drupal_add_library('views_slideshow', 'views_slideshow');
|
90 |
|
|
drupal_add_js($js_settings, 'setting');
|
91 |
|
|
|
92 |
|
|
/**
|
93 |
|
|
* Process Skins
|
94 |
|
|
*/
|
95 |
|
|
$skin_info = array();
|
96 |
|
|
if (isset($options['skin_info'])) {
|
97 |
|
|
$skin_info = $options['skin_info'];
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
// Make sure $skin_info has all the values.
|
101 |
|
|
$skin_info += array(
|
102 |
|
|
'class' => 'default',
|
103 |
|
|
'name' => t('Untitled skin'),
|
104 |
|
|
'module' => 'views_slideshow',
|
105 |
|
|
'path' => '',
|
106 |
|
|
'stylesheets' => array(),
|
107 |
|
|
);
|
108 |
|
|
|
109 |
|
|
$vars['skin'] = $skin_info['class'];
|
110 |
|
|
|
111 |
|
|
// Enqueue any stylesheets set for the skin on this view are added.
|
112 |
|
|
$skin_path = drupal_get_path('module', $skin_info['module']);
|
113 |
|
|
if ($skin_info['path']) {
|
114 |
|
|
$skin_path .= '/' . $skin_info['path'];
|
115 |
|
|
}
|
116 |
|
|
|
117 |
|
|
// Add stylesheet.
|
118 |
|
|
if (!empty($skin_info['stylesheets'])) {
|
119 |
|
|
foreach ($skin_info['stylesheets'] as $stylesheet) {
|
120 |
|
|
drupal_add_css($skin_path . '/' . $stylesheet);
|
121 |
|
|
}
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
/**
|
125 |
|
|
* Process Widgets
|
126 |
|
|
*/
|
127 |
|
|
|
128 |
|
|
// Build weights
|
129 |
|
|
for ($i = 1; $i <= count($widgets); $i++) {
|
130 |
|
|
$weight['top'][$i] = '';
|
131 |
|
|
$weight['bottom'][$i] = '';
|
132 |
|
|
}
|
133 |
|
|
|
134 |
|
|
foreach ($widgets as $widget_id => $widget_name) {
|
135 |
|
|
// Put our widgets in the right location.
|
136 |
|
|
if ($options['widgets']['top'][$widget_id]['enable']) {
|
137 |
|
|
$widget_weight = ($options['widgets']['top'][$widget_id]['weight'] > count($widgets)) ? count($widgets) : $options['widgets']['top'][$widget_id]['weight'];
|
138 |
|
|
$weight['top'][$widget_weight][] = $widget_id;
|
139 |
|
|
}
|
140 |
|
|
|
141 |
|
|
if ($options['widgets']['bottom'][$widget_id]['enable']) {
|
142 |
|
|
$widget_weight = ($options['widgets']['bottom'][$widget_id]['weight'] > count($widgets)) ? count($widgets) : $options['widgets']['bottom'][$widget_id]['weight'];
|
143 |
|
|
$weight['bottom'][$widget_weight][] = $widget_id;
|
144 |
|
|
}
|
145 |
|
|
}
|
146 |
|
|
|
147 |
|
|
// Build our widgets
|
148 |
|
|
foreach ($weight as $location => $order) {
|
149 |
|
|
$vars[$location . '_widget_rendered'] = '';
|
150 |
|
|
foreach ($order as $order_num => $widgets) {
|
151 |
|
|
if (is_array($widgets)) {
|
152 |
|
|
foreach ($widgets as $widget_id) {
|
153 |
|
|
$vars[$widget_id . '_' . $location] = theme(views_theme_functions($widget_id . '_widget_render', $view, $view->display[$view->current_display]), array('vss_id' => $vss_id, 'view' => $view, 'settings' => $options['widgets'][$location][$widget_id], 'location' => $location, 'rows' => $rows));
|
154 |
|
|
$vars[$location . '_widget_rendered'] .= $vars[$widget_id . '_' . $location];
|
155 |
|
|
}
|
156 |
|
|
}
|
157 |
|
|
}
|
158 |
|
|
}
|
159 |
|
|
|
160 |
|
|
/**
|
161 |
|
|
* Process Slideshow
|
162 |
|
|
*/
|
163 |
|
|
$slides = theme(views_theme_functions($main_frame_module . '_main_frame', $view, $view->display[$view->current_display]), array('vss_id' => $vss_id, 'view' => $view, 'settings' => $settings, 'rows' => $rows));
|
164 |
|
|
$vars['slideshow'] = theme(views_theme_functions('views_slideshow_main_section', $view, $view->display[$view->current_display]), array('vss_id' => $vss_id, 'slides' => $slides, 'plugin' => $main_frame_module));
|
165 |
|
|
}
|
166 |
|
|
}
|
167 |
|
|
|
168 |
|
|
/**
|
169 |
|
|
* The current element of the slideshow.
|
170 |
|
|
*
|
171 |
|
|
* @ingroup themeable
|
172 |
|
|
*/
|
173 |
|
|
function theme_views_slideshow_main_section($vars) {
|
174 |
|
|
return '<div id="' . $vars['plugin'] . '_main_' . $vars['vss_id'] . '" class="' . $vars['plugin'] . '_main views_slideshow_main">' . $vars['slides'] . '</div>';
|
175 |
|
|
}
|
176 |
|
|
|
177 |
|
|
/**
|
178 |
|
|
* Views Slideshow: pager.
|
179 |
|
|
*
|
180 |
|
|
* @ingroup themeable
|
181 |
|
|
*/
|
182 |
|
|
function theme_views_slideshow_pager_widget_render($vars) {
|
183 |
|
|
// Add javascript settings for the pager type.
|
184 |
|
|
$js_vars = array(
|
185 |
|
|
'viewsSlideshowPager' => array(
|
186 |
|
|
$vars['vss_id'] => array(
|
187 |
|
|
$vars['location'] => array(
|
188 |
|
|
'type' => views_slideshow_format_addons_name($vars['settings']['type'])
|
189 |
|
|
),
|
190 |
|
|
),
|
191 |
|
|
),
|
192 |
|
|
);
|
193 |
|
|
|
194 |
|
|
drupal_add_library('views_slideshow', 'views_slideshow');
|
195 |
|
|
drupal_add_js($js_vars, 'setting');
|
196 |
|
|
|
197 |
|
|
// Create some attributes
|
198 |
|
|
$attributes['class'] = 'widget_pager widget_pager_' . $vars['location'];
|
199 |
|
|
$attributes['id'] = 'widget_pager_' . $vars['location'] . '_' . $vars['vss_id'];
|
200 |
|
|
return theme(views_theme_functions($vars['settings']['type'], $vars['view'], $vars['view']->display[$vars['view']->current_display]), array('vss_id' => $vars['vss_id'], 'view' => $vars['view'], 'settings' => $vars['settings'], 'location' => $vars['location'], 'attributes' => $attributes));
|
201 |
|
|
}
|
202 |
|
|
|
203 |
|
|
/**
|
204 |
|
|
* Theme pager fields
|
205 |
|
|
*/
|
206 |
|
|
function _views_slideshow_preprocess_views_slideshow_pager_fields(&$vars) {
|
207 |
|
|
// Build our javascript settings.
|
208 |
|
|
$js_vars = array(
|
209 |
|
|
'viewsSlideshowPagerFields' => array(
|
210 |
|
|
$vars['vss_id'] => array(
|
211 |
|
|
$vars['location'] => array(
|
212 |
|
|
'activatePauseOnHover' => $vars['settings']['views_slideshow_pager_fields_hover'],
|
213 |
|
|
),
|
214 |
|
|
),
|
215 |
|
|
),
|
216 |
|
|
);
|
217 |
|
|
|
218 |
|
|
// Add the settings to the page.
|
219 |
|
|
drupal_add_library('views_slideshow', 'views_slideshow');
|
220 |
|
|
drupal_add_js($js_vars, 'setting');
|
221 |
|
|
|
222 |
|
|
// Add hover intent library
|
223 |
|
|
if ($vars['settings']['views_slideshow_pager_fields_hover']) {
|
224 |
|
|
if (module_exists('libraries')) {
|
225 |
|
|
// Load jQuery hoverIntent
|
226 |
|
|
$hoverIntent_path = libraries_get_path('jquery.hoverIntent');
|
227 |
|
|
if (!empty($hoverIntent_path) && file_exists($hoverIntent_path . '/jquery.hoverIntent.js')) {
|
228 |
|
|
drupal_add_js($hoverIntent_path . '/jquery.hoverIntent.js');
|
229 |
|
|
}
|
230 |
|
|
}
|
231 |
|
|
}
|
232 |
|
|
|
233 |
|
|
$vars['classes_array'][] = $vars['attributes']['class'];
|
234 |
|
|
$vars['widget_id'] = $vars['attributes']['id'];
|
235 |
|
|
// Add our class to the wrapper.
|
236 |
|
|
$vars['classes_array'][] = 'views_slideshow_pager_field';
|
237 |
|
|
|
238 |
|
|
// Render all the fields unless there is only 1 slide and the user specified
|
239 |
|
|
// to hide them when there is only one slide.
|
240 |
|
|
$vars['rendered_field_items'] = '';
|
241 |
|
|
if (empty($vars['settings']['hide_on_single_slide']) || count($vars['view']->result) > $vars['view']->style_options['views_slideshow_cycle']['items_per_slide']) {
|
242 |
|
|
foreach ($vars['view']->result as $count => $node) {
|
243 |
|
|
$rendered_fields = '';
|
244 |
|
|
foreach ($vars['settings']['views_slideshow_pager_fields_fields'] as $field => $use) {
|
245 |
|
|
if ($use !== 0 && is_object($vars['view']->field[$field])) {
|
246 |
|
|
$rendered_fields .= theme(views_theme_functions('views_slideshow_pager_field_field', $vars['view'], $vars['view']->display[$vars['view']->current_display]), array('view' => $vars['view'], 'field' => $field, 'count' => $count));
|
247 |
|
|
}
|
248 |
|
|
}
|
249 |
|
|
$vars['rendered_field_items'] .= theme(views_theme_functions('views_slideshow_pager_field_item', $vars['view'], $vars['view']->display[$vars['view']->current_display]), array('vss_id' => $vars['vss_id'], 'item' => $rendered_fields, 'count' => $count, 'location' => $vars['location'], 'length' => count($vars['view']->result)));
|
250 |
|
|
}
|
251 |
|
|
}
|
252 |
|
|
}
|
253 |
|
|
|
254 |
|
|
/**
|
255 |
|
|
* Views Slideshow: pager item.
|
256 |
|
|
*
|
257 |
|
|
* @ingroup themeable
|
258 |
|
|
*/
|
259 |
|
|
function _views_slideshow_preprocess_views_slideshow_pager_field_item(&$vars) {
|
260 |
|
|
$vars['classes_array'][] = 'views_slideshow_pager_field_item';
|
261 |
|
|
$vars['classes_array'][] = ($vars['count'] % 2) ? 'views-row-even' : 'views-row-odd';
|
262 |
|
|
if ($vars['count'] == 0) {
|
263 |
|
|
$vars['classes_array'][] = 'views-row-first';
|
264 |
|
|
}
|
265 |
|
|
elseif ($vars['count'] == $vars['length'] - 1) {
|
266 |
|
|
$vars['classes_array'][] = 'views-row-last';
|
267 |
|
|
}
|
268 |
|
|
}
|
269 |
|
|
|
270 |
|
|
/**
|
271 |
|
|
* Views Slideshow: Controls.
|
272 |
|
|
*
|
273 |
|
|
* @inggroup themeable
|
274 |
|
|
*/
|
275 |
|
|
function theme_views_slideshow_controls_widget_render($vars) {
|
276 |
|
|
// Add javascript settings for the controls type.
|
277 |
|
|
$js_vars = array(
|
278 |
|
|
'viewsSlideshowControls' => array(
|
279 |
|
|
$vars['vss_id'] => array(
|
280 |
|
|
$vars['location'] => array(
|
281 |
|
|
'type' => views_slideshow_format_addons_name($vars['settings']['type'])
|
282 |
|
|
),
|
283 |
|
|
),
|
284 |
|
|
),
|
285 |
|
|
);
|
286 |
|
|
|
287 |
|
|
drupal_add_library('views_slideshow', 'views_slideshow');
|
288 |
|
|
drupal_add_js($js_vars, 'setting');
|
289 |
|
|
|
290 |
|
|
$output = '';
|
291 |
|
|
if (empty($vars['settings']['hide_on_single_slide']) || count($vars['rows']) > $vars['view']->style_options['views_slideshow_cycle']['items_per_slide']) {
|
292 |
|
|
$output = theme(views_theme_functions($vars['settings']['type'], $vars['view'], $vars['view']->display[$vars['view']->current_display]), array('vss_id' => $vars['vss_id'], 'view' => $vars['view'], 'settings' => $vars['settings'], 'location' => $vars['location'], 'rows' => $vars['rows']));
|
293 |
|
|
}
|
294 |
|
|
|
295 |
|
|
return $output;
|
296 |
|
|
}
|
297 |
|
|
|
298 |
|
|
/**
|
299 |
|
|
* The slideshow controls.
|
300 |
|
|
*
|
301 |
|
|
* @ingroup themeable
|
302 |
|
|
*/
|
303 |
|
|
function _views_slideshow_preprocess_views_slideshow_controls_text(&$vars) {
|
304 |
|
|
$module_path = drupal_get_path('module', 'views_slideshow');
|
305 |
|
|
drupal_add_css($module_path . '/views_slideshow_controls_text.css', array('type' => 'file'));
|
306 |
|
|
|
307 |
|
|
$vars['classes_array'][] = 'views_slideshow_controls_text';
|
308 |
|
|
|
309 |
|
|
$vars['rendered_control_previous'] = theme(views_theme_functions('views_slideshow_controls_text_previous', $vars['view'], $vars['view']->display[$vars['view']->current_display]), array('vss_id' => $vars['vss_id'], 'view' => $vars['view'], 'settings' => $vars['settings']));
|
310 |
|
|
|
311 |
|
|
$vars['rendered_control_pause'] = theme(views_theme_functions('views_slideshow_controls_text_pause', $vars['view'], $vars['view']->display[$vars['view']->current_display]), array('vss_id' => $vars['vss_id'], 'view' => $vars['view'], 'settings' => $vars['settings']));
|
312 |
|
|
|
313 |
|
|
$vars['rendered_control_next'] = theme(views_theme_functions('views_slideshow_controls_text_next', $vars['view'], $vars['view']->display[$vars['view']->current_display]), array('vss_id' => $vars['vss_id'], 'view' => $vars['view'], 'settings' => $vars['settings']));
|
314 |
|
|
}
|
315 |
|
|
|
316 |
|
|
/**
|
317 |
|
|
* Views Slideshow: "previous" control.
|
318 |
|
|
*
|
319 |
|
|
* @ingroup themeable
|
320 |
|
|
*/
|
321 |
|
|
function _views_slideshow_preprocess_views_slideshow_controls_text_previous(&$vars) {
|
322 |
|
|
$vars['classes_array'][] = 'views_slideshow_controls_text_previous';
|
323 |
|
|
}
|
324 |
|
|
|
325 |
|
|
/**
|
326 |
|
|
* Views Slideshow: "pause" control.
|
327 |
|
|
*
|
328 |
|
|
* @ingroup themeable
|
329 |
|
|
*/
|
330 |
|
|
function _views_slideshow_preprocess_views_slideshow_controls_text_pause(&$vars) {
|
331 |
|
|
$vars['classes_array'][] = 'views_slideshow_controls_text_pause views-slideshow-controls-text-status-play';
|
332 |
|
|
$vars['start_text'] = t('Pause');
|
333 |
|
|
}
|
334 |
|
|
|
335 |
|
|
/**
|
336 |
|
|
* Views Slideshow: "next" control.
|
337 |
|
|
*
|
338 |
|
|
* @ingroup themeable
|
339 |
|
|
*/
|
340 |
|
|
function _views_slideshow_preprocess_views_slideshow_controls_text_next(&$vars) {
|
341 |
|
|
$vars['classes_array'][] = 'views_slideshow_controls_text_next';
|
342 |
|
|
}
|
343 |
|
|
|
344 |
|
|
/**
|
345 |
|
|
* Views Slideshow: Slide Counter.
|
346 |
|
|
*
|
347 |
|
|
* @inggroup themeable
|
348 |
|
|
*/
|
349 |
|
|
function theme_views_slideshow_slide_counter_widget_render($vars) {
|
350 |
|
|
return theme(views_theme_functions('views_slideshow_slide_counter', $vars['view'], $vars['view']->display[$vars['view']->current_display]), array('vss_id' => $vars['vss_id'], 'view' => $vars['view'], 'settings' => $vars['settings'], 'location' => $vars['location'], 'rows' => $vars['rows']));
|
351 |
|
|
}
|
352 |
|
|
|
353 |
|
|
/**
|
354 |
|
|
* Views Slideshow: slide counter.
|
355 |
|
|
*/
|
356 |
|
|
function _views_slideshow_preprocess_views_slideshow_slide_counter(&$vars) {
|
357 |
|
|
$vars['classes_array'][] = 'views_slideshow_slide_counter';
|
358 |
|
|
} |