function template_process_flexslider in Flex Slider 7.2
Prepares variables for flexslider templates.
See also
File
- theme/
flexslider.theme.inc, line 57 - Theming functions for the flexslider module.
Code
function template_process_flexslider(&$variables) {
// Reference configuration variables
$optionset =& $variables['settings']['optionset'];
$settings =& $variables['settings'];
$items =& $variables['items'];
// Set the default container type
if (empty($settings['type'])) {
$settings['type'] = 'ul';
}
// Load the selected optionset
if (!empty($optionset)) {
$optionset = flexslider_optionset_load($optionset);
}
// Check if an optionset was loaded
if (empty($optionset)) {
// Fall back to 'default' option set
$optionset = flexslider_optionset_load('default');
watchdog('flexslider', 'Fallback to default optionset.', array(), WATCHDOG_WARNING);
}
// Configure attributes for containing elements
$attributes = array();
// Merge with defined attributes
if (isset($settings['attributes']) and is_array($settings['attributes'])) {
$attributes += $settings['attributes'];
}
// Set the ID for each flexslider instance if none is provided
if (empty($attributes['id'])) {
$flexslider_id =& drupal_static('flexslider_id', 0);
$attributes['id'] = 'flexslider-' . ++$flexslider_id;
}
// Add the namespace to any classes
// @todo figure out what this is supposed to do
if (!empty($attributes['class']) && !empty($optionset->options['namespace'])) {
foreach ($attributes['class'] as $key => $value) {
$attributes['class'][$key] = $optionset->options['namespace'] . $value;
}
}
// Add the flexslider class to be namespaced
$attributes['class'][] = 'flexslider';
// Add the optionset name as a class to the container.
$attributes['class'][] = 'optionset-' . drupal_html_class($optionset->name);
// Add the image style name as a class to the container.
if (!empty($settings['image_style'])) {
$attributes['class'][] = 'imagestyle-' . drupal_html_class($settings['image_style']);
}
// Add the attributes to the settings array.
$settings['attributes'] = $attributes;
// Finally, add the configuration to the page
flexslider_add($variables['settings']['attributes']['id'], $variables['settings']['optionset']);
}