function hosting_platform_form in Hostmaster (Aegir) 6
Implementation of hook_form().
File
- modules/
hosting/ platform/ hosting_platform.module, line 176 - 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,
);
if (!$node->nid) {
$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,
);
$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;
}