function quicktabs_form in Quick Tabs 5
Same name and namespace in other branches
- 6.3 includes/admin.inc \quicktabs_form()
- 6 quicktabs.module \quicktabs_form()
- 6.2 includes/admin.inc \quicktabs_form()
- 7.3 quicktabs.admin.inc \quicktabs_form()
- 7.2 includes/admin.inc \quicktabs_form()
2 string references to 'quicktabs_form'
File
- ./
quicktabs.module, line 133
Code
function quicktabs_form($form_values = NULL) {
if (stristr($_POST['op'], 'remove_')) {
$tab_to_remove = intval(substr($_POST['op'], 7));
}
$changed = FALSE;
$form = array(
'#cache' => TRUE,
);
$form['title'] = array(
'#title' => t('Block Title'),
'#type' => 'textfield',
'#description' => t('The title of the whole block'),
'#default_value' => isset($form_values['title']) ? $form_values['title'] : '',
'#weight' => -5,
);
$formtype = $form_values['formtype'] ? $form_values['formtype'] : 'new';
$form['formtype'] = array(
'#type' => 'hidden',
'#value' => $formtype,
);
if ($formtype == 'edit') {
$form['qtid'] = array(
'#type' => 'hidden',
'#value' => $form_values['qtid'],
);
}
if (isset($form_values)) {
$tabcontent = $form_values['tabs'];
if (isset($tab_to_remove) && $tab_to_remove <= count($tabcontent)) {
unset($tabcontent[$tab_to_remove]);
$tabcontent = array_values($tabcontent);
unset($_POST);
unset($tab_to_remove);
$changed = TRUE;
}
}
if (isset($_POST['num_tabs'])) {
if ($_POST['op'] == 'More tabs' && isset($_POST['new_tabs'])) {
$qt_count = $_POST['num_tabs'] + $_POST['new_tabs'];
unset($_POST['new_tabs']);
}
elseif (isset($tab_to_remove)) {
$qt_count = $_POST['num_tabs'] - 1;
}
else {
$qt_count = $_POST['num_tabs'];
}
}
else {
$qt_count = max(2, empty($tabcontent) ? 2 : count($tabcontent));
}
$form['num_tabs'] = array(
'#type' => 'hidden',
'#value' => $qt_count,
);
// Add a wrapper for the tabs and Add More Tabs button.
$form['qt_wrapper'] = array(
'#tree' => FALSE,
'#weight' => -4,
'#prefix' => '<div class="clear-block" id="quicktabs-tabs-wrapper">',
'#suffix' => '</div>',
);
$form['qt_wrapper']['tabs'] = array(
'#prefix' => '<div id="quicktabs-tabs">',
'#suffix' => '</div>',
'#theme' => 'qt_tabs',
);
//dprint_r($tabcontent);
//die();
// Add the current tabs to the form.
for ($delta = 0; $delta < $qt_count; $delta++) {
$weight = isset($tabcontent[$delta]['weight']) ? $tabcontent[$delta]['weight'] : $delta - 10;
$title = isset($tabcontent[$delta]['title']) ? $tabcontent[$delta]['title'] : '';
$type = isset($tabcontent[$delta]['type']) ? $tabcontent[$delta]['type'] : 'block';
$bid = isset($tabcontent[$delta]['bvid']) ? $tabcontent[$delta]['bvid'] : NULL;
$vid = isset($tabcontent[$delta]['bvid']) ? $tabcontent[$delta]['bvid'] : NULL;
$args = isset($tabcontent[$delta]['args']) ? $tabcontent[$delta]['args'] : NULL;
$limit = isset($tabcontent[$delta]['limit']) ? $tabcontent[$delta]['limit'] : NULL;
$build = isset($tabcontent[$delta]['build']) ? $tabcontent[$delta]['build'] : variable_get('quicktabs_viewbuild', 'embed');
$form['qt_wrapper']['tabs'][$delta] = _quicktabs_form($delta, $weight, $title, $type, $bid, $vid, $args, $limit, $build, $changed);
}
$form['qt_wrapper']['new_tabs'] = array(
'#type' => 'select',
'#title' => 'Create more tabs',
'#options' => array(
'0' => 0,
'1' => 1,
'2' => 2,
'3' => 3,
'4' => 4,
'5' => 5,
'6' => 6,
'7' => 7,
'8' => 8,
'9' => 9,
'10' => 10,
),
'#default_value' => 0,
);
$form['qt_wrapper']['tabs_more'] = array(
'#type' => 'button',
'#value' => t('More tabs'),
'#description' => t("Click here to add more tabs."),
'#id' => 'tabs_add_more_button',
'#weight' => 1,
);
if ($changed) {
$form['please_save'] = array(
'#value' => '<div class="qt_warning">Changes will not be saved until you click submit. You can only remove one pre-existing tab from a QT block before re-saving.</div>',
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}