function ctools_context_term_settings_form

1 string reference to 'ctools_context_term_settings_form'
term.inc in plugins/contexts/term.inc
Plugin to provide a term context.

File

plugins/contexts/term.inc, line 61

Code

function ctools_context_term_settings_form($form, &$form_state) {
    $conf = $form_state['conf'];
    $form['vid'] = array(
        '#title' => t('Vocabulary'),
        '#type' => 'select',
        '#options' => array(),
        '#description' => t('Select the vocabulary for this form.'),
        '#id' => 'ctools-select-vid',
        '#default_value' => $conf['vid'],
    );
    $description = '';
    if (!empty($conf['tid'])) {
        $info = db_query('SELECT * FROM {taxonomy_term_data} WHERE tid = :tid', array(
            ':tid' => $conf['tid'],
        ))->fetchObject();
        if ($info) {
            $description = ' ' . t('Currently set to @term. Enter another term if you wish to change the term.', array(
                '@term' => $info->name,
            ));
        }
    }
    ctools_include('dependent');
    $options = array();
    $form['taxonomy']['#tree'] = TRUE;
    foreach (taxonomy_get_vocabularies() as $vid => $vocabulary) {
        $options[$vid] = $vocabulary->name;
        $form['taxonomy'][$vocabulary->vid] = array(
            '#type' => 'textfield',
            '#description' => t('Select a term from @vocabulary.', array(
                '@vocabulary' => $vocabulary->name,
            )) . $description,
            '#autocomplete_path' => 'taxonomy/autocomplete/' . $vocabulary->vid,
            '#dependency' => array(
                'ctools-select-vid' => array(
                    $vocabulary->vid,
                ),
            ),
        );
    }
    $form['vid']['#options'] = $options;
    $form['tid'] = array(
        '#type' => 'value',
        '#value' => $conf['tid'],
    );
    $form['set_identifier'] = array(
        '#type' => 'checkbox',
        '#default_value' => FALSE,
        '#title' => t('Reset identifier to term title'),
        '#description' => t('If checked, the identifier will be reset to the term name of the selected term.'),
    );
    return $form;
}