function bs_shortcodes_carousel in Bootstrap 3 shortcodes 7
bs_shortcodes_carousel
@since 1.0
File
- ./
bs_shortcodes.module, line 1354
Code
function bs_shortcodes_carousel($attrs, $content = '') {
extract(shortcode_attrs(array(
"interval" => '',
"pause" => '',
"wrap" => '',
"xclass" => '',
"data" => '',
), $attrs));
$div_class = 'carousel slide';
$div_class .= $xclass ? ' ' . $xclass : '';
$inner_class = 'carousel-inner';
$id = 'custom-carousel-' . $GLOBALS['carousel_count'];
$data_props = _bs_shortcodes_parse_data_attributes($data);
// $attrs_map = bs_attribute_map( $content );
// @see bs_shortcodes_tabs
// ~Jur
// Extract the slide titles for use in the carousel widget.
$count = substr_count($content, 'class="item');
$indicators = array();
for ($i = 0; $i < $count; $i++) {
if ($i == 0) {
$active = 'active';
}
else {
$active = '';
}
$indicators[] = sprintf('<li class="%s" data-target="%s" data-slide-to="%s"></li>', $active, check_plain('#' . $id), check_plain($i));
}
if (isset($GLOBALS['carousel_count'])) {
$GLOBALS['carousel_count']++;
}
else {
$GLOBALS['carousel_count'] = 0;
}
return sprintf('<div class="%s" id="%s" data-ride="carousel"%s%s%s%s>%s<div class="%s">%s</div>%s%s</div>', check_plain($div_class), check_plain($id), $interval ? sprintf(' data-interval="%d"', $interval) : '', $pause ? sprintf(' data-pause="%s"', check_plain($pause)) : '', $wrap != '' ? sprintf(' data-wrap="%s"', check_plain($wrap)) : '', $data_props ? ' ' . $data_props : '', $indicators ? '<ol class="carousel-indicators">' . implode($indicators) . '</ol>' : '', check_plain($inner_class), $content, '<a class="left carousel-control" href="' . check_url('#' . $id) . '" data-slide="prev"><i class="glyphicon glyphicon-chevron-left"></i></a>', '<a class="right carousel-control" href="' . check_url('#' . $id) . '" data-slide="next"><i class="glyphicon glyphicon-chevron-right"></i></a>');
}