function video_form in Video 6.2
Same name and namespace in other branches
- 5 video.module \video_form()
- 6 video.module \video_form()
Hook, displays the contents of the node form page for creating and editing nodes.
Parameters
$node: object
Return value
string value of form content
File
- ./
video.module, line 672 - video.module
Code
function video_form($node) {
//We must unserialize the array for display in the forms.
if ($node->serial_data) {
$node->serial_data = unserialize($node->serialized_data);
}
$form = array();
// default node stuff
$type = node_get_types('type', $node);
$form['title'] = array(
'#type' => 'textfield',
'#title' => check_plain($type->title_label),
'#size' => 60,
'#maxlength' => 128,
'#required' => TRUE,
'#default_value' => $node->title,
'#weight' => -20,
);
if ($type->has_body) {
$form['body_filter']['body'] = array(
'#type' => 'textarea',
'#title' => check_plain($type->body_label),
'#required' => $type->min_word_count > 0,
'#rows' => 10,
'#default_value' => $node->body,
);
$form['body_filter']['format'] = filter_form($node->format);
}
// set an hidden field to store video type
$form['vtype'] = array(
'#type' => 'hidden',
'#value' => $node->vtype,
);
// kjh: set an hidden field to store encoded fid
if ($node->serial_data && isset($node->serial_data['video_encoded_fid'])) {
$form['video_encoded_fid'] = array(
'#type' => 'hidden',
'#value' => $node->serial_data['video_encoded_fid'],
);
}
$form['video'] = array(
'#type' => 'fieldset',
'#title' => t('Video Information'),
'#weight' => -19,
);
if (!video_support_autoresolution($node)) {
// this vtype doesn't support autoresolution
$selected_option = _video_get_resolution_selected_option($node);
// let's display the resolution selection
$form['video']['vresolution'] = array(
'#type' => 'select',
'#title' => t('Resolution'),
'#description' => t("Select the approriate resolution (aspect ratio) for your video.<br />If you don't know what to choose then the default value will probably be ok for you."),
'#options' => _video_get_resolution_options(),
'#default_value' => $selected_option,
'#required' => true,
);
// manual resolution form logic
$form['video']['manual_resolution'] = array(
'#type' => 'fieldset',
'#title' => t('Manual resolution'),
);
$is_manually_set = $selected_option == VIDEO_MANUALLY_SET_VIDEO_RESOLUTION_SELECT_ID;
$width = $is_manually_set ? $node->videox : NULL;
$height = $is_manually_set ? $node->videoy : NULL;
$form['video']['manual_resolution']['manual_resolution_width'] = array(
'#type' => 'textfield',
'#title' => t('Width'),
'#size' => 4,
'#maxlength' => 4,
'#default_value' => $width,
'#description' => t('Video width expressed in pixels.'),
);
$form['video']['manual_resolution']['manual_resolution_height'] = array(
'#type' => 'textfield',
'#title' => t('Height'),
'#size' => 4,
'#maxlength' => 4,
'#default_value' => $height,
'#description' => t('Video height expressed in pixels.'),
);
}
else {
// set an hidden field to store video resolution
$form['hvresolution'] = array(
'#type' => 'hidden',
'#value' => $node->videox . 'x' . $node->videoy,
);
}
if (!video_support_autoplaytime($node)) {
// this vtype doesn't support autoplaytime
$form['video']['playtime'] = array(
'#type' => 'fieldset',
'#title' => t('Playtime'),
'#collapsible' => true,
'#collapsed' => $node->playtime_seconds ? false : true,
// display expanded if we have values inserted by the user
'#description' => t('Insert here the duration of the video.<br />Values may be entered in excess of their normal "clock maximum" (the seconds field may be 3600 to represent 1 hour), however each value will be summed for a total of all three.'),
);
$playtime = _video_sec2hms($node->playtime_seconds);
$form['video']['playtime']['playtime_hours'] = array(
'#type' => 'textfield',
'#title' => t('Hours'),
'#size' => 11,
'#maxlength' => 11,
'#default_value' => $playtime['hours'],
);
$form['video']['playtime']['playtime_minutes'] = array(
'#type' => 'textfield',
'#title' => t('Minutes'),
'#size' => 11,
'#maxlength' => 11,
'#default_value' => $playtime['minutes'],
);
$form['video']['playtime']['playtime_seconds'] = array(
'#type' => 'textfield',
'#title' => t('Seconds'),
'#required' => FALSE,
'#size' => 11,
'#maxlength' => 11,
'#default_value' => $playtime['seconds'],
);
}
else {
// set an hidden field to store video length
$form['playtime_seconds'] = array(
'#type' => 'hidden',
'#value' => $node->playtime_seconds,
);
// we need to store file size too
$form['hsize'] = array(
'#type' => 'hidden',
'#value' => $node->size,
);
}
// Get the video-type-specific bits.
$form = module_invoke('video_' . $node->vtype, 'v_form', $node, $form);
return $form;
}