TbHtml::carouselItem PHP Method

carouselItem() public static method

Generates a carousel item.
public static carouselItem ( string $content, string $label, string $caption, array $htmlOptions = [] ) : string
$content string the content.
$label string the item label text.
$caption string the item caption text.
$htmlOptions array additional HTML attributes.
return string the generated item.
    public static function carouselItem($content, $label, $caption, $htmlOptions = array())
    {
        self::addCssClass('item', $htmlOptions);
        $overlayOptions = TbArray::popValue('overlayOptions', $htmlOptions, array());
        self::addCssClass('carousel-caption', $overlayOptions);
        $labelOptions = TbArray::popValue('labelOptions', $htmlOptions, array());
        $captionOptions = TbArray::popValue('captionOptions', $htmlOptions, array());
        $url = TbArray::popValue('url', $htmlOptions, false);
        if ($url !== false) {
            $content = self::link($content, $url);
        }
        $output = self::openTag('div', $htmlOptions);
        $output .= $content;
        if (isset($label) || isset($caption)) {
            $output .= self::openTag('div', $overlayOptions);
            if ($label) {
                $output .= self::tag('h4', $labelOptions, $label);
            }
            if ($caption) {
                $output .= self::tag('p', $captionOptions, $caption);
            }
            $output .= '</div>';
        }
        $output .= '</div>';
        return $output;
    }

Usage Example

Exemplo n.º 1
0
 public function testCarouselItem()
 {
     $I = $this->codeGuy;
     $html = TbHtml::carouselItem('Content text', 'Label text', 'Caption text', array('class' => 'div', 'overlayOptions' => array('class' => 'overlay'), 'labelOptions' => array('class' => 'label'), 'captionOptions' => array('class' => 'caption')));
     $div = $I->createNode($html, 'div.item');
     $I->seeNodeCssClass($div, 'div');
     $I->seeNodeText($div, 'Content text');
     $overlay = $div->filter('div.carousel-caption');
     $I->seeNodeCssClass($overlay, 'overlay');
     $I->seeNodeChildren($overlay, array('h4', 'p'));
     $h4 = $overlay->filter('h4');
     $I->seeNodeCssClass($h4, 'label');
     $caption = $overlay->filter('p');
     $I->seeNodeCssClass($caption, 'caption');
     $I->seeNodeText($caption, 'Caption text');
 }
TbHtml