function template_preprocess_views_slideshow_thumbnailhover in Views Slideshow 6.2
Same name and namespace in other branches
- 6 contrib/views_slideshow_thumbnailhover/views_slideshow_thumbnailhover.theme.inc \template_preprocess_views_slideshow_thumbnailhover()
Implements template_preprocess_hook_THEMENAME().
File
- contrib/
views_slideshow_thumbnailhover/ views_slideshow_thumbnailhover.theme.inc, line 11 - Theme & preprocess functions for the Views Slideshow: ThumbnailHover module.
Code
function template_preprocess_views_slideshow_thumbnailhover(&$vars) {
$options = $vars['options'];
$view = $vars['view'];
$rows = $vars['rows'];
$vss_id = $view->name . '-' . $view->current_display;
$settings = $options['views_slideshow_thumbnailhover'];
// Cast the strings into int or bool as necessary.
$new_settings = array();
foreach ($settings as $key => $value) {
if (is_string($value)) {
$value = trim($value);
if (is_numeric($value)) {
$value = (int) $value;
}
elseif (strtolower($value) == 'true') {
$value = TRUE;
}
elseif (strtolower($value) == 'false') {
$value = FALSE;
}
}
$new_settings[$key] = $value;
}
$settings = array_merge(array(
'num_divs' => sizeof($vars['rows']),
'teasers_last' => isset($options['thumbnailhover']['teasers_last']) && $options['thumbnailhover']['teasers_last'] ? TRUE : FALSE,
'id_prefix' => '#views_slideshow_thumbnailhover_main_',
'div_prefix' => '#views_slideshow_thumbnailhover_div_',
'vss_id' => $vss_id,
'view_id' => $vss_id,
), $new_settings);
// We need to go through the current js setting values to make sure the one we
// want to add is not already there. If it is already there then append -[num]
// to the id to make it unique.
$slideshow_count = 1;
$current_settings = drupal_add_js();
foreach ($current_settings['setting'] as $current_setting) {
if (isset($current_setting['viewsSlideshowThumbnailHover'])) {
$current_keys = array_keys($current_setting['viewsSlideshowThumbnailHover']);
if (stristr($current_keys[0], '#views_slideshow_thumbnailhover_main_' . $vss_id)) {
$slideshow_count++;
}
}
}
if ($slideshow_count > 1) {
$vss_id .= '-' . $slideshow_count;
$settings['vss_id'] = $vss_id;
}
drupal_add_js(array(
'viewsSlideshowThumbnailHover' => array(
"#views_slideshow_thumbnailhover_main_" . $vss_id => $settings,
),
), 'setting');
// Add the hoverIntent plugin.
if ($settings['pager_event'] == 'hoverIntent') {
if (module_exists('jq')) {
$loaded_plugins = jq_plugins();
if (!empty($loaded_plugins['hoverIntent'])) {
jq_add('hoverIntent');
}
}
if (module_exists('hoverintent')) {
hoverintent_add();
}
}
$teaser = $options['views_slideshow_thumbnailhover']['hover_breakout'] == 'teaser' ? TRUE : FALSE;
$hidden_elements = theme('views_slideshow_thumbnailhover_no_display_section', $view, $rows, $vss_id, $options, $teaser);
$vars['slideshow'] = theme('views_slideshow_main_section', $vss_id, $hidden_elements, 'views_slideshow_thumbnailhover');
$thumbnailhover = $vars['options']['views_slideshow_thumbnailhover'];
// Only show controls when there is more than one result.
$vars['controls_top'] = '';
$vars['controls_bottom'] = '';
if ($settings['num_divs'] > 1) {
if ($thumbnailhover['controls'] == 1) {
$vars['controls_top'] = theme('views_slideshow_thumbnailhover_controls', $vss_id, $view, $options);
}
elseif ($thumbnailhover['controls'] == 2) {
$vars['controls_bottom'] = theme('views_slideshow_thumbnailhover_controls', $vss_id, $view, $options);
}
}
$vars['breakout_top'] = '';
$vars['breakout_bottom'] = '';
if (!$thumbnailhover['teasers_last']) {
$vars['breakout_top'] = theme('views_slideshow_thumbnailhover_breakout_teasers', $view, $rows, $vss_id, $options);
}
else {
$vars['breakout_bottom'] = theme('views_slideshow_thumbnailhover_breakout_teasers', $view, $rows, $vss_id, $options);
}
$vars['image_count_top'] = '';
$vars['image_count_bottom'] = '';
if ($thumbnailhover['image_count'] == 1) {
$vars['image_count_top'] = theme('views_slideshow_thumbnailhover_image_count', $vss_id, $view, $options);
}
elseif ($thumbnailhover['image_count'] == 2) {
$vars['image_count_bottom'] = theme('views_slideshow_thumbnailhover_image_count', $vss_id, $view, $options);
}
}