function ctools_context_language_settings_form

Settings form.

1 string reference to 'ctools_context_language_settings_form'
language.inc in plugins/contexts/language.inc
Ctools context type plugin to hold the current language context.

File

plugins/contexts/language.inc, line 129

Code

function ctools_context_language_settings_form($form, &$form_state) {
    $conf = ctools_context_language_conf_defaults($form_state['conf']);
    $form['enable_cache_argument'] = array(
        '#title' => t('Add language to cache id'),
        '#description' => t('If enabled the langcode will be part of context aware caches.'),
        '#type' => 'checkbox',
        '#default_value' => $conf['enable_cache_argument'],
    );
    // Prepare language type options.
    $language_type_options = drupal_map_assoc(language_types());
    $language_type_options['preset'] = t('Custom');
    $form['language_type'] = array(
        '#title' => t('The language type to use'),
        '#type' => 'radios',
        '#required' => TRUE,
        '#options' => $language_type_options,
        '#default_value' => $conf['language_type'],
    );
    ctools_include('language');
    $language_options = ctools_language_list();
    $form['preset_langcode'] = array(
        '#title' => t('Language'),
        '#type' => 'select',
        '#options' => $language_options,
        '#default_value' => $conf['preset_langcode'],
        '#states' => array(
            'visible' => array(
                ':input[name="language_type"]' => array(
                    'value' => 'preset',
                ),
            ),
        ),
    );
    if (!empty($conf['preset_langcode']) && !isset($language_options[$conf['preset_langcode']])) {
        drupal_set_message(t('The currently selected language %langcode is no longer available.', array(
            '%langcode' => $conf['preset_langcode'],
        )), 'error', FALSE);
    }
    return $form;
}