You are here

function domain_locale_form in Domain Locale 7

A modified version of locale_languages_overview_form to manage domain language settings.

Parameters

string $type:

int $domain_id:

1 string reference to 'domain_locale_form'
domain_locale in ./domain_locale.admin.inc
The domain language page callback router.

File

./domain_locale.admin.inc, line 27
Provides admin functionality for domain specific language settings

Code

function domain_locale_form($form, &$form_state, $domain, $arguments = array()) {
  $form = array();
  drupal_set_title(t('Edit domain languages for !domain', array(
    '!domain' => $domain['subdomain'],
  )));
  $form['domain_id'] = array(
    '#type' => 'value',
    '#value' => $domain['domain_id'],
  );
  $record_edit_url = 'admin/structure/domain/' . ($domain['domain_id'] == 0 ? '' : 'view/' . $domain['domain_id']);
  $link = l($domain['subdomain'], $record_edit_url);
  $form['domain'] = array(
    '#type' => 'markup',
    '#markup' => t('Enabled languages for !link', array(
      '!link' => filter_xss($link),
    )),
  );
  $languages = language_list('language', TRUE);
  $domain_languages = domain_locale_lookup($domain['domain_id']);
  $default_domain_language = domain_conf_variable_get($domain['domain_id'], 'language_default');
  $default_install_language = language_default('language');
  $domain_default = isset($default_domain_language) ? $default_domain_language : $default_install_language;
  $form['domain_language'] = array(
    '#tree' => TRUE,
  );
  foreach ($languages as $langcode => $language) {
    $form['domain_language'][$langcode] = array(
      '#tree' => TRUE,
    );
    $form['domain_language'][$langcode]['title'] = array(
      '#type' => 'value',
      '#value' => filter_xss_admin($language->name),
    );
    $form['domain_language'][$langcode]['langcode'] = array(
      '#type' => 'value',
      '#value' => filter_xss_admin($langcode),
    );
    $form['domain_language'][$langcode]['enabled'] = array(
      '#type' => 'checkbox',
      '#default_value' => isset($domain_languages[$langcode]) && $language->enabled == 1,
    );
    $form['domain_language'][$langcode]['weight'] = array(
      '#type' => 'weight',
      '#default_value' => isset($domain_languages[$langcode]) ? $domain_languages[$langcode]['weight'] : 0,
    );
    $form['domain_language'][$langcode]['site_default'] = array(
      '#type' => 'radio',
      '#return_value' => $langcode,
      '#attributes' => $domain_default == $langcode ? array(
        'checked' => 'checked',
        'name' => 'domain_languages[site_default]',
      ) : array(
        'name' => 'domain_languages[site_default]',
      ),
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save languages'),
  );
  return $form;
}