You are here

function domain_alias_form in Domain Access 6.2

Same name and namespace in other branches
  1. 7.3 domain_alias/domain_alias.admin.inc \domain_alias_form()
  2. 7.2 domain_alias/domain_alias.admin.inc \domain_alias_form()

FAPI for editing domain aliases

Parameters

$form_state: The current form state, passed by FormsAPI.

$domain: An array containing the record from the {domain} table.

$arguments: An array of additional hidden key/value pairs to pass to the form. Used by child modules to control behaviors.

1 string reference to 'domain_alias_form'
domain_alias in domain_alias/domain_alias.admin.inc
Edit aliases

File

domain_alias/domain_alias.admin.inc, line 34
Administration functions for the domain_alias module.

Code

function domain_alias_form($form_state, $domain, $arguments = array()) {
  $form = array();
  drupal_set_title(t('Edit domain aliases: %domain', array(
    '%domain' => $domain['subdomain'],
  )));
  $form['domain_id'] = array(
    '#type' => 'value',
    '#value' => $domain['domain_id'],
  );
  $record_edit_url = 'admin/build/domain/' . ($domain['domain_id'] == 0 ? '' : 'edit/' . $domain['domain_id']);
  $form['domain_help'] = array(
    '#type' => 'markup',
    '#value' => domain_alias_help_text(),
  );
  $form['domain'] = array(
    '#type' => 'markup',
    '#value' => t('Registered aliases for <a href="!url"%title</a>', array(
      '!url' => url($record_edit_url),
      '%title' => $domain['subdomain'],
    )),
  );
  $form['domain_alias'] = array(
    '#tree' => TRUE,
  );

  // List all existing aliases
  if (isset($domain['aliases']) && is_array($domain['aliases'])) {
    foreach ($domain['aliases'] as $alias_id => $alias) {
      $form['domain_alias'][$alias_id] = array(
        '#tree' => TRUE,
      );
      $form['domain_alias'][$alias_id]['alias_id'] = array(
        '#type' => 'value',
        '#value' => $alias_id,
      );
      $form['domain_alias'][$alias_id]['redirect'] = array(
        '#type' => 'checkbox',
        '#default_value' => $alias['redirect'],
      );
      $form['domain_alias'][$alias_id]['pattern'] = array(
        '#type' => 'textfield',
        '#default_value' => $alias['pattern'],
        '#maxlength' => 255,
        '#width' => 40,
      );
      $form['domain_alias'][$alias_id]['delete'] = array(
        '#type' => 'checkbox',
        '#default_value' => FALSE,
      );
    }
  }
  $form['domain_new'] = array(
    '#type' => 'markup',
    '#value' => t('Add new aliases'),
  );
  $form['domain_new_help'] = array(
    '#type' => 'markup',
    '#value' => t('To create a new alias, enter the matching pattern. Check the <em>redirect</em> box if you would like requests made to the alias to redirect to the registered domain.
      <em>You may enter up to five (5) aliases at a time.</em>'),
  );
  $form['domain_alias_new'] = array(
    '#tree' => TRUE,
  );
  for ($i = 0; $i < 5; $i++) {
    $form['domain_alias_new'][$i]['redirect'] = array(
      '#type' => 'checkbox',
      '#default_value' => FALSE,
    );
    $form['domain_alias_new'][$i]['pattern'] = array(
      '#type' => 'textfield',
      '#default_value' => NULL,
      '#maxlength' => 255,
      '#width' => 40,
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save aliases'),
  );
  return $form;
}