You are here

public function BootstrapQuickTabs::render in Bootstrap Quick Tabs 7

Build render array.

Overrides QuickRenderer::render

File

./BootstrapQuickTabs.inc, line 61
Extends Quicktabs module's core functions.

Class

BootstrapQuickTabs
Renders the content using the Bootstrap Tabs widget.

Code

public function render() {
  $quickset = $this->quickset;
  $settings = $this->quickset
    ->getSettings();
  $options = $settings['options'];
  $active_tab = $quickset
    ->getActiveTab();
  $tabs = $this
    ->buildTabLinks($active_tab);
  $qt_name = $quickset
    ->getName();
  $render_array = array(
    'content' => array(
      '#theme' => 'bootstrap_tabs',
      '#options' => array(
        'attributes' => array(
          'id' => 'quicktabs-' . $qt_name,
          'class' => 'tabbable' . ($options['tabposition'] != 'basic' && $options['tabposition'] != 'stacked' && $options['tabposition'] != 'justified' ? ' tabs-' . $options['tabposition'] : ''),
        ),
      ),
      'tabs' => array(
        '#theme' => 'bootstrap_tabs_tabset',
        '#options' => array(
          'active' => $active_tab,
          'style' => $options['tabstyle'],
          'position' => $options['tabposition'],
          'effects' => $options['tabeffects'],
        ),
        'tablinks' => $tabs,
      ),
      'panes' => array(),
    ),
  );
  $count = 1;
  foreach ($quickset
    ->getContents() as $key => $tab) {
    if (!empty($tab)) {
      $attribs = array(
        'id' => 'quicktabs-' . $qt_name . $count,
      );
      $attribs['class'][] = 'tab-pane';
      if ($key == $active_tab) {
        $attribs['class'][] = 'active';
      }
      if (isset($options['tabeffects']) && in_array('fade', $options['tabeffects'], TRUE)) {
        $attribs['class'][] = 'fade';
        if ($key == $active_tab) {
          $attribs['class'][] = 'in';
        }
      }
      $render_array['content']['panes'][] = array(
        '#prefix' => '<div role="tabpanel" ' . drupal_attributes($attribs) . '>',
        '#suffix' => '</div>',
        'content' => $tab
          ->render(),
      );
      $count++;
    }
  }
  return $render_array;
}