Same name and namespace in other branches
  1. 8.x-1.x src/Plugin/QuickRender/QuickUiTabs.php \Drupal\quicktabs\Plugin\QuickRender\QuickUiTabs::render()

Overrides QuickRenderer::render

File

plugins/QuickUiTabs.inc, line 19

Class

QuickUiTabs
Renders the content using the jQuery UI Tabs widget.

Code

public function render() {
    $quickset = $this->quickset;
    $active_tab = $quickset->getActiveTab();
    $tabs = $this->build_tablinks($active_tab);
    $qt_name = $quickset->getName();
    $render_array = array(
        '#attached' => $this->add_attached(),
        'content' => array(
            '#theme' => 'qt_ui_tabs',
            '#options' => array(
                'attributes' => array(
                    'id' => 'quicktabs-' . $qt_name,
                    'class' => 'quicktabs-ui-wrapper',
                ),
            ),
            'tabs' => array(
                '#theme' => 'qt_ui_tabs_tabset',
                '#options' => array(
                    'active' => $active_tab,
                ),
                'tablinks' => $tabs,
            ),
            'divs' => array(),
        ),
    );
    foreach ($quickset->getContents() as $key => $tab) {
        if (!empty($tab)) {
            $attribs = array(
                'id' => 'qt-' . $qt_name . '-ui-tabs' . ($key + 1),
            );
            $render_array['content']['divs'][] = array(
                '#prefix' => '<div ' . drupal_attributes($attribs) . '>',
                '#suffix' => '</div>',
                'content' => $tab->render(),
            );
        }
    }
    return $render_array;
}