function tvi_taxonomy_admin_form in Taxonomy Views Integrator 7
Same name and namespace in other branches
- 6 includes/tvi.admin.inc \tvi_taxonomy_admin_form()
The main TVI administration form.
This is added to both vocabulary and term edit forms.
Parameters
array $form: The form array being built.
object $settings: The TVI settings to build the form.
3 calls to tvi_taxonomy_admin_form()
- tvi_settings_form in includes/
tvi.admin.inc - Create the main settings form.
- tvi_term_form in includes/
tvi.admin.inc - Adds TVI administration form to the term edit page.
- tvi_vocab_form in includes/
tvi.admin.inc - Adds TVI administration form to the vocabulary edit page.
File
- includes/
tvi.admin.inc, line 79 - Administration functions for the tvi module.
Code
function tvi_taxonomy_admin_form(&$form, $settings) {
// Add validate and submit handlers.
$form['#validate'][] = 'tvi_validate_handler';
$form['#submit'][] = 'tvi_submit_handler';
// Add JS & CSS.
$form['#attached']['js'][] = drupal_get_path('module', 'tvi') . '/tvi.js';
$form['#attached']['css'][] = drupal_get_path('module', 'tvi') . '/tvi.css';
// Form container.
$form['tvi'] = array(
'#type' => 'fieldset',
'#title' => t('View usage'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#tree' => TRUE,
);
// Javascript warning message.
$js_msg = t('This form is best used with Javascript enabled. Please enable your Javascript, then refresh this page.');
$js_msg = '<p class="javascript-warning">' . $js_msg . '</p>';
$form['tvi']['javascript_message'] = array(
'#type' => 'markup',
'#value' => check_plain($js_msg),
);
$form['tvi']['is_default'] = array(
'#type' => 'value',
'#value' => $settings->is_default && $settings->type != TVI_TYPE_ALL,
);
$form['tvi']['type'] = array(
'#type' => 'value',
'#value' => $settings->type,
);
$form['tvi']['xid'] = array(
'#type' => 'value',
'#value' => $settings->xid,
);
// Status toggle switch.
$form['tvi']['status'] = array(
'#id' => 'tvi-status-check',
'#type' => 'checkbox',
'#title' => t('Use view override.'),
'#default_value' => $settings->status,
'#description' => t('Unchecking this field will disable the use of the view when displaying this taxonomy page.'),
);
if ($settings->type == TVI_TYPE_TERM) {
// Inheritance switch.
$form['tvi']['inherit'] = array(
'#id' => 'tvi-inherit-check',
'#type' => 'checkbox',
'#title' => t('Child terms will use this settings.'),
'#default_value' => $settings->inherit,
'#description' => t('Checking this field will allow to define a view used by the current term and its children recursively while these children does not have their own settings.'),
'#states' => array(
'disabled' => array(
'#tvi-status-check' => array(
'checked' => FALSE,
),
),
'visible' => array(
'#tvi-status-check' => array(
'checked' => TRUE,
),
),
),
);
}
// View selector.
$form['tvi']['view_name'] = array(
'#id' => 'tvi-view-selector',
'#type' => 'select',
'#title' => t('Using the view'),
'#default_value' => $settings->view_name ? $settings->view_name : NULL,
'#options' => tvi_get_views(),
'#description' => t('The view that you wish to use for this display'),
'#states' => array(
'disabled' => array(
'#tvi-status-check' => array(
'checked' => FALSE,
),
),
'visible' => array(
'#tvi-status-check' => array(
'checked' => TRUE,
),
),
),
);
// Display selector.
$form['tvi']['display'] = array(
'#id' => 'tvi-display-selector',
'#type' => 'select',
'#title' => t('View display'),
'#default_value' => $settings->view_name ? $settings->view_name . ':' . $settings->display : NULL,
// Assume no Javascript.
'#options' => tvi_get_view_displays(),
'#states' => array(
'disabled' => array(
'#tvi-status-check' => array(
'checked' => FALSE,
),
),
'visible' => array(
'#tvi-status-check' => array(
'checked' => TRUE,
),
),
),
);
// Pass arguments.
$form['tvi']['pass_arguments'] = array(
'#id' => 'tvi-pass-arguments',
'#type' => 'checkbox',
'#title' => t('Pass all arguments to views.'),
'#description' => t("Enable this checkbox, and your view's display will receive all arguments going after <em>/taxonomy/term/</em> in the path. If disabled, your view's display will only receive <em>tid</em>, and <em>tid_depth</em>."),
'#default_value' => isset($settings->pass_arguments) ? $settings->pass_arguments : 0,
'#states' => array(
'disabled' => array(
'#tvi-status-check' => array(
'checked' => FALSE,
),
),
'visible' => array(
'#tvi-status-check' => array(
'checked' => TRUE,
),
),
),
);
if ($settings->type == TVI_TYPE_TERM) {
$form['tvi']['display']['#description'] = t('The view display you select from the option above will be used to render this taxonomy term.');
}
elseif ($settings->type == TVI_TYPE_VOCAB) {
$form['tvi']['display']['#description'] = t('The view display you select from the option above will be used to render all the taxonomy terms of this vocabulary except if their settings are overriden.');
}
else {
$form['tvi']['display']['#description'] = t('The view display you select from the option above will be used to render all the taxonomy terms in all the defined vocabularies except if their vocabularies settings or their terms settings are overriden.');
}
}