You are here

function hosting_site_form in Hostmaster (Aegir) 6

Implements hook_form().

1 call to hosting_site_form()
hosting_signup_form in modules/hosting/signup/hosting_signup.module
Form definition

File

modules/hosting/site/hosting_site.form.inc, line 184
Site node form.

Code

function hosting_site_form($node) {
  $form['#pre_render'][] = '_hosting_site_form_pre_render';
  $form['#node'] = $node;
  if ($node->nid) {
    $form['info'] = array(
      '#prefix' => '<div class="clear-block" id="hosting-site-edit-info">',
      '#suffix' => '<br /></div>',
      '#weight' => -10,
    );
  }
  _hosting_site_field($form, $node, 'title', array(
    '#type' => 'textfield',
    '#title' => t('Domain name'),
    '#required' => TRUE,
    '#default_value' => strtolower(trim($node->title)),
    '#weight' => -10,
  ));
  $editable = (!$node->client || $node->nid || user_access('administer sites')) && hosting_feature('client');
  _hosting_site_field($form, $node, 'client', array(
    '#type' => 'textfield',
    '#required' => TRUE,
    '#title' => t('Client'),
    '#default_value' => _hosting_client_site_default($node),
    '#description' => t('The client who this site belongs to.'),
    '#autocomplete_path' => 'hosting_client/autocomplete/client',
  ), 'filter_xss', $editable);

  // Install profiles
  $profiles = hosting_get_profiles();
  foreach ($profiles as $id => $name) {

    // Don't allow a site to be provisioned with hostslave or hostmaster profile
    if (in_array($name, array(
      'Hostslave',
      'Hostmaster',
    ))) {
      unset($profiles[$id]);
    }
  }
  reset($profiles);
  _hosting_site_field($form, $node, 'profile', array(
    '#type' => 'radios',
    '#title' => t('Install profile'),
    '#description' => t('The type of site to install.<br />
                           The profile selected here determines the list of supported platforms below.'),
    '#options' => $profiles,
    '#default_value' => $node->profile ? $node->profile : hosting_get_default_profile(key($profiles)),
    '#required' => TRUE,
    '#attributes' => array(
      'class' => "hosting-site-form-profile-options",
    ),
  ), '_hosting_node_link');
  _hosting_site_field($form, $node, 'platform', array(
    '#type' => 'radios',
    '#title' => t('Platform'),
    '#required' => TRUE,
    '#description' => t('The platform you want the site to be hosted on.<br />
                          Not seeing a certain platform? Platforms shown are those that support the profile above.
                          If a different profile is selected, this list may change automatically.'),
    '#options' => _hosting_get_platforms(),
    '#default_value' => $node->platform ? $node->platform : NULL,
  ), '_hosting_node_link');
  _hosting_site_field($form, $node, 'site_language', array(
    '#type' => 'radios',
    '#title' => t('Language'),
    '#description' => t('The language of site being installed.'),
    '#options' => hosting_get_profile_languages(),
    '#required' => TRUE,
    '#default_value' => $node->site_language ? $node->site_language : 'en',
    '#attributes' => array(
      'class' => "hosting-site-form-site-language-options",
    ),
  ), '_hosting_language_name');
  _hosting_site_field($form, $node, 'db_server', array(
    '#type' => 'radios',
    '#title' => t('Database server'),
    '#required' => TRUE,
    '#description' => t('The database server the site will use to host its content.'),
    '#options' => hosting_get_servers('db'),
    '#default_value' => $node->db_server ? $node->db_server : HOSTING_DEFAULT_DB_SERVER,
  ), '_hosting_node_link');
  foreach (array(
    'verified',
    'last_cron',
    'site_status',
  ) as $extra_attribute) {
    $form["{$extra_attribute}"] = array(
      '#type' => 'value',
      '#value' => $node->{$extra_attribute},
    );
  }
  return $form;
}