You are here

function hosting_site_form in Hosting 6.2

Same name and namespace in other branches
  1. 5 site/hosting_site.module \hosting_site_form()
  2. 7.4 site/hosting_site.form.inc \hosting_site_form()
  3. 7.3 site/hosting_site.form.inc \hosting_site_form()

Implements hook_form().

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

File

site/hosting_site.form.inc, line 202
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');
  $add_client_text = '';
  if (user_access('administer clients') || user_access('create client')) {
    $add_client_text = t(' Click !here to add a new client.', array(
      '!here' => l('here', 'node/add/client', array(
        'attributes' => array(
          'target' => '_blank',
        ),
      )),
    ));
  }
  _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 to whom this site belongs.') . $add_client_text,
    '#autocomplete_path' => 'hosting_client/autocomplete/client',
  ), 'filter_xss', $editable);

  // Install profiles
  $profiles = hosting_get_profiles();
  foreach ($profiles as $id => $name) {
    $profile = hosting_package_instance_load(array(
      'p.nid' => $id,
    ));
    $profiles[$id] = theme('hosting_site_profile', $profile, TRUE);

    // Don't allow a site to be provisioned with hostslave or hostmaster profile
    if (in_array($name, array(
      'Hostslave',
      'Hostmaster',
    ))) {
      unset($profiles[$id]);
    }
  }
  natcasesort($profiles);
  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;
}