function flash_form in Flash Node 5
Implementation of hook_form
File
- ./
flash.module, line 230
Code
function flash_form(&$node, &$param) {
// check folders exist and are writable
_flash_check_settings();
// begin form construct
$form['#attributes'] = array(
"enctype" => "multipart/form-data",
);
$form['flash']['#tree'] = TRUE;
// lifted from image.module
if ($node->new_file) {
$form['new_file'] = array(
'#type' => 'value',
'#value' => TRUE,
);
}
if ($node->new_file) {
$form['flash']['_flash'] = array(
'#type' => 'hidden',
'#value' => $node->flash['_flash'],
);
$form['flash']['filemime'] = array(
'#type' => 'hidden',
'#value' => $node->flash['filemime'],
);
$form['flash']['_height'] = array(
'#type' => 'hidden',
'#value' => $node->flash['_height'],
);
$form['flash']['_width'] = array(
'#type' => 'hidden',
'#value' => $node->flash['_width'],
);
}
else {
$form['flash']['_flash'] = array(
'#type' => 'hidden',
'#default_value' => $node->flash['_flash'],
);
$form['flash']['filemime'] = array(
'#type' => 'hidden',
'#default_value' => $node->flash['filemime'],
);
$form['flash']['_height'] = array(
'#type' => 'hidden',
'#default_value' => $node->flash['_height'],
);
$form['flash']['_width'] = array(
'#type' => 'hidden',
'#default_value' => $node->flash['_width'],
);
}
// Title and body fields - this code from node_content_form() in node.module
$type = node_get_types('type', $node);
if ($type->has_title) {
$form['title'] = array(
'#type' => 'textfield',
'#title' => check_plain($type->title_label),
'#required' => TRUE,
'#default_value' => $node->title,
'#weight' => -5,
);
}
if ($type->has_body) {
$form['body_filter']['body'] = array(
'#type' => 'textarea',
'#title' => check_plain($type->body_label),
'#default_value' => $node->body,
'#rows' => 20,
'#required' => $type->min_word_count > 0,
);
$form['body_filter']['format'] = filter_form($node->format);
}
$form['flash']['flashfile'] = array(
'#type' => 'file',
'#title' => t('Flash file'),
'#description' => t('Click "Browse..." to select a Flash file to upload.'),
'#tree' => FALSE,
'#after_build' => array(
'_flash_form_after_build',
),
);
// Put other settings in a collapsible set for a clean input form
$form['flash']['options'] = array(
'#type' => 'fieldset',
'#title' => t('Flash node options'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#tree' => FALSE,
);
$form['flash']['options']['display'] = array(
'#type' => 'radios',
'#title' => t('Display in'),
'#default_value' => $node->flash['display'] ? $node->flash['display'] : 0,
'#options' => array(
0 => t('Teaser and body'),
1 => t('Teaser only'),
2 => t('Body only'),
),
'#parents' => array(
'flash',
'display',
),
);
$form['flash']['options']['width'] = array(
'#type' => 'textfield',
'#title' => t('Width'),
'#default_value' => $node->flash['width'],
'#size' => 5,
'#maxlength' => 5,
'#description' => t('The width of the movie, in pixels. Leave blank to use the file\'s own settings.'),
'#after_build' => array(
'_flash_form_after_build',
),
'#parents' => array(
'flash',
'width',
),
);
$form['flash']['options']['height'] = array(
'#type' => 'textfield',
'#title' => t('Height'),
'#default_value' => $node->flash['height'],
'#size' => 5,
'#maxlength' => 5,
'#description' => t('The height of the movie, in pixels. Leave blank to use the file\'s own settings.'),
'#after_build' => array(
'_flash_form_after_build',
),
'#parents' => array(
'flash',
'height',
),
);
$form['flash']['options']['version'] = array(
'#type' => 'textfield',
'#title' => t('Flash version required'),
'#default_value' => $node->flash['version'] ? $node->flash['version'] : variable_get('flash_version', 6),
'#size' => 5,
'#maxlength' => 5,
'#description' => t('The minimum Flash version required to play this movie. Leave blank to reset to the default.'),
'#after_build' => array(
'_flash_form_after_build',
),
'#parents' => array(
'flash',
'version',
),
);
$form['flash']['options']['build'] = array(
'#type' => 'textfield',
'#title' => t('Flash build required'),
'#default_value' => $node->flash['build'] != '' ? $node->flash['build'] : variable_get('flash_build', 0),
'#size' => 5,
'#maxlength' => 5,
'#description' => t('The minimum Flash build required to play this movie. Leave blank to reset to the default.'),
'#after_build' => array(
'_flash_form_after_build',
),
'#parents' => array(
'flash',
'build',
),
);
return $form;
}