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

Build the actual tab links, with appropriate href, title and attributes.

Parameters

$active_tab The index of the active tab.:

1 call to QuickQuicktabs::build_tablinks()
QuickQuicktabs::render in plugins/QuickQuicktabs.inc
The only method that renderer plugins must implement.

File

plugins/QuickQuicktabs.inc, line 69

Class

QuickQuicktabs
Renders the content using the original Quicktabs mechanism of previous versions. Includes support for ajax rendered content.

Code

protected function build_tablinks($active_tab) {
    $quickset = $this->quickset;
    $settings = $quickset->getSettings();
    $tabs = array();
    foreach ($quickset->getContents() as $i => $tab) {
        if (!empty($tab)) {
            $tablink = array(
                '#type' => 'link',
                '#title' => $quickset->translateString($tab->getTitle(), 'tab', $i),
                '#href' => $_GET['q'],
                '#options' => $this->construct_link_options($i),
            );
            if ($settings['ajax']) {
                $tab_settings = $tab->getSettings();
                $ajax_keys = $tab->getAjaxKeys();
                $ajax_args = array();
                foreach ($ajax_keys as $key) {
                    $ajax_args[] = $tab_settings[$key];
                }
                $ajax_path = $quickset->getAjaxPath($i, $tab->getType());
                $ajax_href = $ajax_path . '/' . implode('/', $ajax_args);
                $tablink['#ajax'] = array(
                    'progress' => array(
                        'message' => '',
                        'type' => 'throbber',
                    ),
                    'path' => $ajax_href,
                );
            }
            $tabs[$i] = $tablink;
        }
    }
    return $tabs;
}