Render quicktabs.

3 calls to quicktabs_render()
quicktabs_block_view dans ./quicktabs.module
Implements hook_block_view().
theme_quicktabs_style_options dans includes/admin.inc
Theme function for quicktabs style radio options.
_quicktabs_build_content_qtabs dans ./quicktabs.module

Fichier

./quicktabs.module, line 226

Code

function quicktabs_render($quicktabs) {
    // First convert any Views arguments in our tabs to the necessary format
    $quicktabs->tabs = _quicktabs_prepare_views_args($quicktabs->tabs, $quicktabs->ajax);
    $tab_settings = (array) $quicktabs;
    // Check if any tabs need to be hidden because of empty content.
    if ($quicktabs->hide_empty_tabs && !$quicktabs->ajax) {
        // Remove empty tabpages.
        foreach ($quicktabs->tabs as $key => $tab) {
            $contents = quicktabs_render_tab_content($tab, TRUE);
            if (empty($contents)) {
                unset($quicktabs->tabs[$key]);
            }
            else {
                $quicktabs->tabs[$key]['rendered'] = $contents;
            }
        }
        $quicktabs->tabs = array_merge($quicktabs->tabs);
    }
    $active_tab = _quicktabs_get_active_tab($quicktabs);
    if ($tabs = _quicktabs_build_tablinks($quicktabs, $active_tab)) {
        // Create the quicktabs renderable array and add the necessary css and js to it
        $qt_ra = array(
            '#attached' => array(
                'css' => array(
                    array(
                        'data' => drupal_get_path('module', 'quicktabs') . '/css/quicktabs.css',
                    ),
                    array(
                        'data' => quicktabs_get_css($quicktabs->style),
                    ),
                ),
                'js' => array(
                    array(
                        'data' => drupal_get_path('module', 'quicktabs') . '/js/quicktabs.js',
                    ),
                    array(
                        'data' => 'misc/progress.js',
                        'weight' => JS_LIBRARY,
                    ),
                ),
            ),
            'content' => array(
                '#theme' => 'quicktabs',
                '#options' => array(
                    'attributes' => array(
                        'id' => 'quicktabs-' . $quicktabs->machine_name,
                        'class' => 'quicktabs_wrapper quicktabs-style-' . drupal_strtolower($quicktabs->style),
                    ),
                ),
                'tabs' => array(
                    '#theme' => 'quicktabs_tabs',
                    '#options' => array(
                        'active' => $active_tab,
                        'style' => drupal_strtolower($quicktabs->style),
                    ),
                    'tablinks' => $tabs,
                ),
                // The main content area, each quicktab container needs a unique id.
'container' => array(
                    '#prefix' => '<div id="quicktabs_container_' . $quicktabs->machine_name . '" class="quicktabs_main quicktabs-style-' . drupal_strtolower($quicktabs->style) . '">',
                    '#suffix' => '</div>',
                ),
            ),
        );
        if (!isset($javascript['setting'][1]['quicktabs']) || !array_key_exists('qt_' . $quicktabs['machine_name'], $javascript['setting'][1]['quicktabs'])) {
            $qt_ra['#attached']['js'][] = array(
                'data' => array(
                    'quicktabs' => array(
                        'qt_' . $quicktabs->machine_name => $tab_settings,
                    ),
                ),
                'type' => 'setting',
            );
        }
        if ($quicktabs->ajax) {
            $attribs = array(
                'id' => 'quicktabs_tabpage_' . $quicktabs->machine_name . '_' . $active_tab,
                'class' => array(
                    'quicktabs_tabpage',
                ),
            );
            $qt_ra['content']['container']['active'] = array(
                '#prefix' => '<div ' . drupal_attributes($attribs) . '>',
                '#suffix' => '</div>',
                'content' => quicktabs_render_tab_content($quicktabs->tabs[$active_tab]),
            );
        }
        else {
            // Render all tabpgages.
            $qt_ra['content']['container']['divs'] = array();
            foreach ($quicktabs->tabs as $key => $tab) {
                $attribs = array(
                    'id' => 'quicktabs_tabpage_' . $quicktabs->machine_name . '_' . $key,
                    'class' => array(
                        'quicktabs_tabpage',
                        $active_tab == $key ? '' : 'quicktabs-hide',
                    ),
                );
                $qt_ra['content']['container']['divs'][] = array(
                    '#prefix' => '<div ' . drupal_attributes($attribs) . '>',
                    '#suffix' => '</div>',
                    'content' => $tab_content = isset($tab['rendered']) ? $tab['rendered'] : quicktabs_render_tab_content($tab),
                );
            }
        }
        return $qt_ra;
    }
    return array();
}