src/Common.php
public function carousel(array $images, array $options = array())
    {
        $html = '';
        $id = $this->page->id('carousel');
        $options = array_merge(array(
            'interval' => 5000, // ie. 5 seconds in between frame changes
            'indicators' => true, // set to false if you don't want them
            'controls' => true, // set to false if you don't want them
        ), $options);
        if ($options['indicators']) {
            $indicators = array_keys(array_values($images));
            $html .= '<ol class="carousel-indicators">';
            $html .= '<li data-target="#'.$id.'" data-slide-to="'.array_shift($indicators).'" class="active"></li>';
            foreach ($indicators as $num) {
                $html .= '<li data-target="#'.$id.'" data-slide-to="'.$num.'"></li>';
            }
            $html .= '</ol>';
        }
        $html .= '<div class="carousel-inner" role="listbox">';
        foreach ($images as $key => $value) {
            $class = (isset($class)) ? 'item' : 'item active'; // ie. the first one is active
            $img = (!is_numeric($key)) ? $key : $value;
            $caption = (!is_numeric($key)) ? '<div class="carousel-caption">'.$value.'</div>' : '';
            $html .= '<div class="'.$class.'">'.$img.$caption.'</div>';
        }
        $html .= '</div>';
        if ($options['controls']) {
            if (is_array($options['controls'])) {
                list($left, $right) = $options['controls'];
                if (strpos($left, '<') === false) {
                    $left = $this->icon($left, 'glyphicon', 'span aria-hidden="true"');
                }
                if (strpos($right, '<') === false) {
                    $right = $this->icon($right, 'glyphicon', 'span aria-hidden="true"');
                }
            } else {
                $left = $this->icon('chevron-left', 'glyphicon', 'span aria-hidden="true"');
                $right = $this->icon('chevron-right', 'glyphicon', 'span aria-hidden="true"');
            }
            $html .= $this->page->tag('a', array(
                'class' => 'left carousel-control',
                'href' => '#'.$id,
                'role' => 'button',
                'data-slide' => 'prev',
            ), $left, '<span class="sr-only">Previous</span>');
            $html .= $this->page->tag('a', array(
                'class' => 'right carousel-control',
                'href' => '#'.$id,
                'role' => 'button',
                'data-slide' => 'next',
            ), $right, '<span class="sr-only">Next</span>');
        }

        return $this->page->tag('div', array(
            'id' => $id,
            'class' => 'carousel slide',
            'data-ride' => 'carousel',
            'data-interval' => $options['interval'],
        ), $html);
    }
public function carousel(array $images, array $options = array())
    {
        $html = '';
        $id = $this->page->id('carousel');
        $options = array_merge(array(
            'interval' => 5000, // ie. 5 seconds in between frame changes
            'indicators' => true, // set to false if you don't want them
            'controls' => true, // set to false if you don't want them
        ), $options);
        if ($options['indicators']) {
            $indicators = array_keys(array_values($images));
            $html .= '<ol class="carousel-indicators">';
            $html .= '<li data-target="#'.$id.'" data-slide-to="'.array_shift($indicators).'" class="active"></li>';
            foreach ($indicators as $num) {
                $html .= '<li data-target="#'.$id.'" data-slide-to="'.$num.'"></li>';
            }
            $html .= '</ol>';
        }
        $html .= '<div class="carousel-inner" role="listbox">';
        foreach ($images as $key => $value) {
            $class = (isset($class)) ? 'item' : 'item active'; // ie. the first one is active
            $img = (!is_numeric($key)) ? $key : $value;
            $caption = (!is_numeric($key)) ? '<div class="carousel-caption">'.$value.'</div>' : '';
            $html .= '<div class="'.$class.'">'.$img.$caption.'</div>';
        }
        $html .= '</div>';
        if ($options['controls']) {
            if (is_array($options['controls'])) {
                list($left, $right) = $options['controls'];
                if (strpos($left, '<') === false) {
                    $left = $this->icon($left, 'glyphicon', 'span aria-hidden="true"');
                }
                if (strpos($right, '<') === false) {
                    $right = $this->icon($right, 'glyphicon', 'span aria-hidden="true"');
                }
            } else {
                $left = $this->icon('chevron-left', 'glyphicon', 'span aria-hidden="true"');
                $right = $this->icon('chevron-right', 'glyphicon', 'span aria-hidden="true"');
            }
            $html .= $this->page->tag('a', array(
                'class' => 'left carousel-control',
                'href' => '#'.$id,
                'role' => 'button',
                'data-slide' => 'prev',
            ), $left, '<span class="sr-only">Previous</span>');
            $html .= $this->page->tag('a', array(
                'class' => 'right carousel-control',
                'href' => '#'.$id,
                'role' => 'button',
                'data-slide' => 'next',
            ), $right, '<span class="sr-only">Next</span>');
        }

        return $this->page->tag('div', array(
            'id' => $id,
            'class' => 'carousel slide',
            'data-ride' => 'carousel',
            'data-interval' => $options['interval'],
        ), $html);
    }
public function carousel ( array $ images , array $ options = array ( ) ) { $ html = '' ; $ id = $ this -> page -> id ( 'carousel' ) ; $ options = array_merge ( array ( 'interval' => 5000 , // ie. 5 seconds in between frame changes 'indicators' => true , // set to false if you don't want them 'controls' => true , // set to false if you don't want them ) , $ options ) ; if ( $ options [ 'indicators' ] ) { $ indicators = array_keys ( array_values ( $ images ) ) ; $ html .= '<ol class="carousel-indicators">' ; $ html .= '<li data-target="#' . $ id . '" data-slide-to="' . array_shift ( $ indicators ) . '" class="active"></li>' ; foreach ( $ indicators as $ num ) { $ html .= '<li data-target="#' . $ id . '" data-slide-to="' . $ num . '"></li>' ; } $ html .= '</ol>' ; } $ html .= '<div class="carousel-inner" role="listbox">' ; foreach ( $ images as $ key => $ value ) { $ class = ( isset ( $ class ) ) ? 'item' : 'item active' ; // ie. the first one is active $ img = ( ! is_numeric ( $ key ) ) ? $ key : $ value ; $ caption = ( ! is_numeric ( $ key ) ) ? '<div class="carousel-caption">' . $ value . '</div>' : '' ; $ html .= '<div class="' . $ class . '">' . $ img . $ caption . '</div>' ; } $ html .= '</div>' ; if ( $ options [ 'controls' ] ) { if ( is_array ( $ options [ 'controls' ] ) ) { list ( $ left , $ right ) = $ options [ 'controls' ] ; if ( strpos ( $ left , '<' ) === false ) { $ left = $ this -> icon ( $ left , 'glyphicon' , 'span aria-hidden="true"' ) ; } if ( strpos ( $ right , '<' ) === false ) { $ right = $ this -> icon ( $ right , 'glyphicon' , 'span aria-hidden="true"' ) ; } } else { $ left = $ this -> icon ( 'chevron-left' , 'glyphicon' , 'span aria-hidden="true"' ) ; $ right = $ this -> icon ( 'chevron-right' , 'glyphicon' , 'span aria-hidden="true"' ) ; } $ html .= $ this -> page -> tag ( 'a' , array ( 'class' => 'left carousel-control' , 'href' => '#' . $ id , 'role' => 'button' , 'data-slide' => 'prev' , ) , $ left , '<span class="sr-only">Previous</span>' ) ; $ html .= $ this -> page -> tag ( 'a' , array ( 'class' => 'right carousel-control' , 'href' => '#' . $ id , 'role' => 'button' , 'data-slide' => 'next' , ) , $ right , '<span class="sr-only">Next</span>' ) ; } return $ this -> page -> tag ( 'div' , array ( 'id' => $ id , 'class' => 'carousel slide' , 'data-ride' => 'carousel' , 'data-interval' => $ options [ 'interval' ] , ) , $ html ) ; }
Creates a Bootstrap carousel for cycling through elements. Those elements don't necessarily need to be images, but pretty much they always are.

@param array $images  An ``array($image, ...)`` of images to cycle through, starting with the first (logically). To get fancy and add captions, then make this an ``array($image => $caption, ...)`` of images with captions to cycle through. If you have some images with captions and others without, then you can merge these two concepts no problem. Remember, the **$image** is not just a location, it is the entire ``<img>`` tag src and all.
@param array $options The available options are:

- '**interval**' => The time delay in thousandths of a second between cycles (or frame changes). The default is **5000** ie. 5 seconds.
- '**indicators**' => The little circle things at the bottom that show where you are at. If you don't want them, then set this to **false**. The default is **true** ie. include them.
- '**controls**' => The clickable arrows on the side for scrolling back and forth.  If you don't want them, then set this to **false**. The default is **true** ie. include them. Also by default we use ``array($bp->icon('chevron-left'), $bp->icon('chevron-right'))`` for the left and right arrows. If you would like something else, then you can make this an array of your preferences.

@return string

@example

```php
echo '<div style="width:500px; height:300px; margin:20px auto;">';
echo $bp->carousel(array(
'<img src="http://lorempixel.com/500/300/food/1/" width="500" height="300">',
'<img src="http://lorempixel.com/500/300/food/2/" width="500" height="300">' => '<p>Caption</p>',
'<img src="http://lorempixel.com/500/300/food/3/" width="500" height="300">' => '<h3>Header</h3>',
), array(
'interval' => 3000,
));
echo '</div>';
```
Creates a Bootstrap carousel for cycling through elements . Those elements don t necessarily need to be images but pretty much they always are .