You are here

function hosting_platform_form in Hosting 6.2

Same name and namespace in other branches
  1. 5 platform/hosting_platform.module \hosting_platform_form()
  2. 7.4 platform/hosting_platform.module \hosting_platform_form()
  3. 7.3 platform/hosting_platform.module \hosting_platform_form()

Implementation of hook_form().

File

platform/hosting_platform.module, line 261
Platform node type definition.

Code

function hosting_platform_form(&$node) {
  $type = node_get_types('type', $node);
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
    '#required' => TRUE,
    '#description' => t('Choose a unique descriptive name for your platform. You very likely want this to be something like "Drupal 6.20".'),
    '#size' => 40,
    '#default_value' => $node->title,
    '#maxlength' => 255,
  );

  // allow edition if the node is in creation, or if wasn't verified correctly
  // *and* we're not using a makefile. The reason while we don't allow editing
  // the path if the makefile was specified is that there's the possibility
  // that the platform path was actually created when the node was saved the
  // first time and we have cruft lying around to cleanup.
  if (!$node->nid || !$node->verified && !$node->makefile) {
    $form['publish_path'] = array(
      '#type' => 'textfield',
      '#title' => t('Publish path'),
      '#required' => TRUE,
      '#description' => t('The absolute path on the filesystem where the sites will be hosted. This needs to be created manually and initialized before your platform works properly. It also needs to be a unique path not already in use by a platform on any server.<br />For example, run the following shell commands:<pre>%commands</pre>Your publish path is the absolute path to the directory that gets created.<br />Alternatively, you can specify a makefile below, and the platform will be created automatically if the path specified here does not exist.<br />You are still required to enter the absolute path above, as it will be treated as the target directory by the makefile.', array(
        '%commands' => "cd /var/aegir/platforms\ndrush dl drupal\n",
      )),
      '#size' => 40,
      '#default_value' => $node->publish_path,
      '#maxlength' => 255,
    );
  }
  else {

    // display it
    $form['info']['publish_path'] = array(
      '#type' => 'item',
      '#title' => t('Publish path'),
      '#value' => $node->publish_path,
    );

    // send it on form submission
    $form['publish_path'] = array(
      '#type' => 'hidden',
      '#value' => $node->publish_path,
    );
  }
  $form['makefile'] = array(
    '#type' => 'textfield',
    '#title' => t('Makefile'),
    '#description' => t('The absolute path on the filesystem or public URL of a makefile that will be used to create the platform in the directory specified above. If the directory already exists, this file will be ignored.'),
    '#size' => 40,
    '#default_value' => $node->makefile,
    '#maxlength' => 255,
  );
  $form['make_working_copy'] = array(
    '#type' => 'radios',
    '#title' => t('Drush make option'),
    '#default_value' => isset($form['#node']->make_working_copy) ? $form['#node']->make_working_copy : FALSE,
    '#options' => array(
      FALSE => t('Normal - Discards SCM files'),
      TRUE => t('Working copy - preserves SCM files'),
    ),
  );
  $form['#after_build'][] = 'hosting_platform_form_platform_after_build';
  $servers = hosting_get_servers('http');
  if (sizeof($servers) > 1) {
    $form['web_server'] = array(
      '#type' => 'radios',
      '#title' => t('Web server'),
      '#description' => t('The web server the sites will be hosted on.'),
      '#options' => $servers,
      '#default_value' => $node->web_server ? $node->web_server : HOSTING_DEFAULT_WEB_SERVER,
    );
  }
  else {
    reset($servers);
    $form['web_server'] = array(
      '#type' => 'hidden',
      '#value' => key($servers),
    );
  }
  foreach (array(
    'verified',
    'platform_status',
  ) as $extra_attribute) {
    $form["{$extra_attribute}"] = array(
      '#type' => 'value',
      '#value' => $node->{$extra_attribute},
    );
  }
  return $form;
}