You are here

function royalsliderfield_preprocess_royalsliderfield in RoyalSlider Integration 7

Implements hook_preprocess_HOOK().

Preprocess theme variables for the RoyalSlider wrapper.

File

contrib/royalsliderfield/royalsliderfield.module, line 325
RoyalSlider Field module.

Code

function royalsliderfield_preprocess_royalsliderfield(&$variables) {
  $optionset = royalslider_optionset_load($variables['optionset']);
  $id = drupal_html_id($variables['royalslider_id']);
  $variables['attributes_array']['class'][] = 'royalSlider';
  $variables['attributes_array']['id'] = $id;

  // Setup skin & fallback to default.
  $skin = !empty($variables['skin']) ? $variables['skin'] : $optionset->skin;
  $skins = royalslider_skins();
  $skin_class = isset($skins[$skin]['class']) ? $skins[$skin]['class'] : $skins['default']['class'];
  $variables['attributes_array']['class'][] = $skin_class;
  $slides_processed = array();
  foreach ($variables['slides'] as $slide) {
    $slides_processed[] = array(
      '#theme' => 'royalsliderfield_slide',
      '#royalslider_id' => $id,
      '#optionset' => $optionset,
      '#slide' => $slide,
    );
  }
  $variables['slides_processed'] = $slides_processed;

  // Add RoyalSlider library and skin.
  if (!empty($slides_processed)) {
    royalslider_add($id, $optionset, $skin);
    drupal_add_js(drupal_get_path('module', 'royalsliderfield') . '/royalsliderfield.js', array(
      'type' => 'file',
      'scope' => 'footer',
    ));
    return;
  }
}