Same name in other branches
  1. 7.x-3.x quicktabs.admin.inc \_quicktabs_form()
  2. 8.x-1.x quicktabs.admin.inc \_quicktabs_form()
1 call to _quicktabs_form()
quicktabs_form dans includes/admin.inc
Build the quicktab creation and edit form.

Fichier

includes/admin.inc, line 318

Code

function _quicktabs_form(array $tab) {
    $form['#tree'] = TRUE;
    $delta = $tab['delta'];
    $form['weight'] = array(
        '#type' => 'weight',
        '#default_value' => isset($tab['weight']) ? $tab['weight'] : $delta - 100,
        '#delta' => 100,
    );
    $form['title'] = array(
        '#type' => 'textfield',
        '#size' => '10',
        '#default_value' => isset($tab['title']) ? $tab['title'] : '',
    );
    if (module_exists('block')) {
        $tabtypes['block'] = t('Block');
        $form['block']['bid'] = array(
            '#type' => 'select',
            '#options' => quicktabs_get_blocks(),
            '#default_value' => isset($tab['bid']) ? $tab['bid'] : '',
            '#title' => t('Select a block'),
        );
        $form['block']['hide_title'] = array(
            '#type' => 'checkbox',
            '#title' => t('Hide the title of this block'),
            '#default_value' => isset($tab['hide_title']) ? $tab['hide_title'] : 1,
        );
    }
    if (module_exists('views')) {
        $views = quicktabs_get_views();
        $views_keys = array_keys($views);
        $tabtypes['view'] = t('View!translate_as_list_of_content', array(
            '!translate_as_list_of_content' => '',
        ));
        $selected_view = isset($tab['vid']) ? $tab['vid'] : (isset($views_keys[0]) ? $views_keys[0] : '');
        $form['view']['vid'] = array(
            '#type' => 'select',
            '#options' => $views,
            '#default_value' => $selected_view,
            '#title' => t('Select a view'),
            '#ajax' => array(
                'callback' => 'quicktabs_ajax_callback',
                'wrapper' => 'quicktab-tabs',
                'method' => 'replace',
                'effect' => 'fade',
            ),
        );
        $form['view']['display'] = array(
            '#type' => 'select',
            '#title' => 'display',
            '#options' => _quicktabs_get_views_displays($selected_view),
            '#default_value' => isset($tab['display']) ? $tab['display'] : '',
        );
        $form['view']['args'] = array(
            '#type' => 'textfield',
            '#title' => 'arguments',
            '#size' => '40',
            '#required' => FALSE,
            '#default_value' => isset($tab['args']) ? $tab['args'] : '',
            '#description' => t('Additional arguments to send to the view as if they were part of the URL in the form of arg1/arg2/arg3. You may use %0, %1, ..., %N to grab arguments from the URL.'),
        );
    }
    $tabtypes['node'] = t('Node');
    $form['node']['nid'] = array(
        '#type' => 'textfield',
        '#title' => t('Node'),
        '#description' => t('The node ID of the node.'),
        '#maxlength' => 10,
        '#size' => 20,
        '#default_value' => isset($tab['nid']) ? $tab['nid'] : '',
    );
    $form['node']['teaser'] = array(
        '#type' => 'checkbox',
        '#title' => t('Teaser view'),
        '#default_value' => isset($tab['teaser']) ? $tab['teaser'] : 0,
    );
    $form['node']['hide_title'] = array(
        '#type' => 'checkbox',
        '#title' => t('Hide the title of this node'),
        '#default_value' => isset($tab['hide_title']) ? $tab['hide_title'] : 1,
    );
    $tabtypes['qtabs'] = t('QTab');
    $form['qtabs']['machine_name'] = array(
        '#type' => 'textfield',
        '#title' => t('Quicktab'),
        '#description' => t('The quicktab machine name.') . ' ' . t('Different styles may not work when putting an ajax quicktab inside ajax quicktab.'),
        '#maxlength' => 10,
        '#size' => 20,
        '#default_value' => isset($tab['machine_name']) ? $tab['machine_name'] : '',
    );
    $form['type'] = array(
        '#type' => 'radios',
        '#options' => $tabtypes,
        '#default_value' => isset($tab['type']) ? $tab['type'] : key($tabtypes),
    );
    $form['remove'] = array(
        '#type' => 'submit',
        '#prefix' => '<div>',
        '#suffix' => '<label for="edit-remove">' . t('Delete') . '</label></div>',
        '#value' => 'remove_' . $delta,
        '#attributes' => array(
            'class' => array(
                'delete-tab',
            ),
            'title' => t('Click here to delete this tab.'),
        ),
        '#submit' => array(
            'qt_remove_tab_submit',
        ),
        '#ajax' => array(
            'callback' => 'quicktabs_ajax_callback',
            'wrapper' => 'quicktab-tabs',
            'method' => 'replace',
            'effect' => 'fade',
        ),
        '#limit_validation_errors' => array(),
    );
    return $form;
}