Same name in other branches
  1. 7.x-3.x plugins/QuickQuicktabs.inc \QuickQuicktabs::construct_link_options()

Helper function to construct link options for tab links.

1 call to QuickQuicktabs::construct_link_options()
QuickQuicktabs::build_tablinks dans src/Plugin/QuickRender/QuickQuicktabs.php
Build the actual tab links, with appropriate href, title and attributes.

Fichier

src/Plugin/QuickRender/QuickQuicktabs.php, line 167

Classe

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

Namespace

Drupal\quicktabs\Plugin\QuickRender

Code

protected function construct_link_options($tabkey) {
    $qt_name = $this->quickset
        ->getName();
    $settings = $this->quickset
        ->getSettings();
    $contents = $this->quickset
        ->getContents();
    $tab_type = $contents[$tabkey]->getType();
    $tab_unique_keys = $contents[$tabkey]->getUniqueKeys();
    $tab_settings = $contents[$tabkey]->getSettings();
    $id = 'quicktabs-tab-' . implode('-', array(
        $qt_name,
        $tabkey,
    ));
    $classes = array(
        'quicktabs-tab',
        'quicktabs-tab-' . $tab_type,
    );
    // Generate unique class for the quicktab.
    $key_contents = array();
    foreach ($tab_unique_keys as $key) {
        if (isset($tab_settings[$key])) {
            $key_content = $tab_settings[$key];
            $key_content = str_replace(array(
                '_',
                ' ',
            ), '-', $key_content);
            $key_content = preg_replace('/[^A-Za-z0-9\\-]/', '', $key_content);
            $key_contents[] = $key_content;
        }
    }
    $suffix = implode('-', $key_contents);
    // Encode class suffixes longer than 50 as hash using md5.
    if (strlen($suffix) > 50) {
        $suffix = md5($suffix);
    }
    if (strlen($suffix) > 0) {
        $classes[] = 'quicktabs-tab-' . $tab_type . '-' . $suffix;
    }
    // Need to construct the correct querystring for the tab links.
    $query = UrlHelper::filterQueryParameters(NULL, array(
        "qt-{$qt_name}",
        'q',
        'page',
    ));
    $query["qt-{$qt_name}"] = $tabkey;
    $link_options = array(
        'attributes' => array(
            'id' => $id,
            'class' => $classes,
        ),
        'query' => $query,
        'fragment' => 'qt-' . $qt_name,
        'html' => isset($settings['html']) ? $settings['html'] : FALSE,
    );
    return $link_options;
}