function template_preprocess_field_orbit in ZURB Orbit 7.2
Same name and namespace in other branches
- 8 field_orbit.module \template_preprocess_field_orbit()
- 7 field_orbit.module \template_preprocess_field_orbit()
Implements template_preprocess().
File
- ./
field_orbit.module, line 532 - Implement a orbit formatter for fields.
Code
function template_preprocess_field_orbit(&$variables) {
drupal_add_js(drupal_get_path('module', 'field_orbit') . '/js/froogaloop.min.js', array(
'scope' => 'footer',
'group' => JS_THEME,
'weight' => 3000,
));
drupal_add_js(drupal_get_path('module', 'field_orbit') . '/js/vimeo.js', array(
'scope' => 'footer',
'group' => JS_THEME,
'weight' => 5000,
));
if ($variables['is_front']) {
$variables['theme_hook_suggestions'][] = 'field_orbit__front';
}
else {
$variables['theme_hook_suggestions'][] = 'field_orbit__content';
}
if (isset($variables['entity']->type)) {
$variables['theme_hook_suggestions'][] = 'field_orbit__content__' . $variables['entity']->type;
}
// Generate classes
$variables['classes_array'][] = 'field-orbit-' . $variables['id'];
// Generate slides
$field_orbit_zebra = 'odd';
$variables['slides_max_width'] = 0;
$variables['slides_max_height'] = 0;
if (count($variables['options'])) {
$variables['data_options'] = '';
foreach ($variables['options'] as $key => $value) {
if (drupal_strlen($value)) {
$variables['data_options'] .= $key . ': ' . str_replace("'", '', $value) . '; ';
}
}
if ($variables['options']['bulletThumbs'] && drupal_strlen($variables['options']['orbit_bullet_thumbs'])) {
$variables['options']['orbit_bullets'] = true;
}
}
foreach ($variables['items'] as $num => $item) {
if (isset($item[$variables['options']['orbit_title']]) && !empty($item[$variables['options']['orbit_title']])) {
$variables['items'][$num]['orbit_title'] = check_plain($item[$variables['options']['orbit_title']][LANGUAGE_NONE][0]['value']);
}
if (isset($item[$variables['options']['orbit_caption']]) && !empty($item[$variables['options']['orbit_caption']])) {
$variables['items'][$num]['orbit_caption'] = check_plain($item[$variables['options']['orbit_caption']][LANGUAGE_NONE][0]['value']);
}
if (isset($item[$variables['options']['orbit_link']]) && !empty($item[$variables['options']['orbit_link']])) {
$variables['items'][$num]['orbit_link'] = array(
'url' => check_plain($item[$variables['options']['orbit_link']][LANGUAGE_NONE][0]['url']),
'target' => $item[$variables['options']['orbit_link']][LANGUAGE_NONE][0]['attributes']['target'],
);
if (!$item['slide_link']['external']) {
$variables['items'][$num]['orbit_link']['url'] = '/' . $variables['items'][$num]['orbit_link']['url'];
}
}
if (!empty($item['type']) && $item['type'] == 'video') {
_field_orbit_format_video($num, $field_orbit_zebra, $item, $variables);
}
if (!empty($item['type']) && $item['type'] == 'image') {
_field_orbit_format_image($num, $field_orbit_zebra, $item, $variables);
}
}
}