function node_kaltura_mix_form in Kaltura 5
Same name and namespace in other branches
- 6.2 plugins/node_kaltura_mix/node_kaltura_mix.module \node_kaltura_mix_form()
- 6 plugins/node_kaltura_mix/node_kaltura_mix.module \node_kaltura_mix_form()
Implementation of hook_form().
Determine how the "add node" form, of mix node, will look like
We actually use a 2 steps form, the one for collecting basic data (needed in kaltura's API) about the mix the second step is to call the contibution wizard to add media to the mix.
The mix is being created b an API call to kaltura.
File
- plugins/
node_kaltura_mix/ node_kaltura_mix.module, line 167
Code
function node_kaltura_mix_form(&$node, $form_state) {
global $user;
$type = node_get_types('type', $node);
// if nid exists, it means we are in edit node mode
if ($node->nid) {
$form['title'] = array(
'#type' => 'textfield',
'#title' => check_plain($type->title_label),
'#required' => TRUE,
'#default_value' => $node->title,
'#weight' => -5,
);
$form['body_filter']['body'] = array(
'#type' => 'textarea',
'#title' => check_plain($type->body_label),
'#default_value' => $node->body,
'#rows' => 20,
'#required' => FALSE,
);
$action_buttons = '<input type="button" value="Edit Mix" onclick=" kalturaInitModalBox(\'' . url('kaltura/simple_editor/') . '\' + \'' . $node->kaltura_entryId . '\' + \'/entry/empty_partner_data/no_refresh\', { width: 890, height: 546 });" />';
$form['edit_mix'] = array(
'#type' => 'item',
'#value' => $action_buttons,
);
$form['kaltura_tags'] = array(
'#type' => 'hidden',
'#title' => 'Kaltura Tags',
'#required' => FALSE,
'#default_value' => $node->kaltura_tags,
'#weight' => -4,
);
$form['kaltura_admin_tags'] = array(
'#type' => 'hidden',
'#title' => 'Kaltura Admin Tags',
'#required' => FALSE,
'#default_value' => $node->kaltura_admin_tags,
'#weight' => -3,
);
$form['kaltura_entryId'] = array(
'#type' => 'hidden',
'#default_value' => $node->kaltura_entryId,
);
$form['media_preview'] = array(
'#type' => 'item',
'#title' => t('Media'),
'#value' => kaltura_replace_tags(theme('node_kaltura_mix_entryId', $node, 0)),
);
$form['kstatus'] = array(
'#type' => 'hidden',
'#default_value' => $node->kstatus,
);
$form['kaltura_total_rank'] = array(
'#type' => 'hidden',
'#default_value' => $node->kaltura_total_rank,
);
$form['kaltura_rank'] = array(
'#type' => 'hidden',
'#default_value' => $node->kaltura_rank,
);
$form['kaltura_votes'] = array(
'#type' => 'hidden',
'#default_value' => $node->kaltura_votes,
);
$form['kaltura_plays'] = array(
'#type' => 'hidden',
'#default_value' => $node->kaltura_plays,
);
$form['kaltura_views'] = array(
'#type' => 'hidden',
'#default_value' => $node->kaltura_views,
);
$form['kaltura_media_date'] = array(
'#type' => 'hidden',
'#default_value' => $node->kaltura_media_date,
);
$form['kaltura_download_url'] = array(
'#type' => 'hidden',
'#default_value' => $node->kaltura_download_url,
);
$form['kaltura_height'] = array(
'#type' => 'hidden',
'#default_value' => $node->kaltura_height,
);
$form['kaltura_width'] = array(
'#type' => 'hidden',
'#default_value' => $node->kaltura_width,
);
$form['kaltura_source_link'] = array(
'#type' => 'hidden',
'#default_value' => $node->kaltura_source_link,
);
$form['kaltura_source_id'] = array(
'#type' => 'hidden',
'#default_value' => $node->kaltura_source_id,
);
$form['kaltura_source'] = array(
'#type' => 'hidden',
'#default_value' => $node->kaltura_source,
);
$form['kaltura_partner_data'] = array(
'#type' => 'hidden',
'#default_value' => $node->kaltura_partner_data,
);
$form['kaltura_thumbnail_url'] = array(
'#type' => 'hidden',
'#default_value' => $node->kaltura_thumbnail_url,
);
$form['kaltura_duration'] = array(
'#type' => 'hidden',
'#default_value' => $node->kaltura_duration,
);
$form['kaltura_media_type'] = array(
'#type' => 'hidden',
'#default_value' => $node->kaltura_media_type,
);
}
else {
$form['kaltura_tags'] = array(
'#type' => 'hidden',
'#title' => 'Kaltura Tags',
'#required' => FALSE,
'#default_value' => $node->kaltura_tags ? $node->kaltura_tags : $_REQUEST['kaltura_tags'],
);
$form['kaltura_admin_tags'] = array(
'#type' => 'hidden',
'#title' => 'Kaltura Admin Tags',
'#required' => FALSE,
'#default_value' => $node->kaltura_admin_tags ? $node->kaltura_admin_tags : $_REQUEST['kaltura_admin_tags'],
);
$form['title'] = array(
'#type' => 'textfield',
'#title' => check_plain($type->title_label),
'#required' => TRUE,
'#default_value' => $node->title ? $node->title : $_REQUEST['title'],
'#weight' => -5,
);
// if form state have a continue attribute, it means we are on the second step of the form
// so we create the mix using kaltura API client, and then we start the contribution wizard to add media
if ($_REQUEST['title'] && $_REQUEST['op'] == 'Continue') {
$partner_data = "user_id@" . $user->uid;
$kaltura_client = KalturaHelpers::getKalturaClient();
$session_user = KalturaHelpers::getSessionUser();
if (WORK_WITH_KSHOW) {
$result = kaltura_add_kshow($session_user, $kaltura_client, $partner_data);
$partner_data .= "|kshow_exist@yes";
$show_entry_id = $result['result']['kshow']['id'];
$cw_vars = kaltura_format_cw_vars(array(
'kshow_id' => $show_entry_id,
'partner_data' => $partner_data,
));
$prefix = "<div class=\"add_video_to_node\"><script>jQuery(document).ready(function(){ kalturaInitModalBox('" . url("kaltura/contribution_wizard/" . $cw_vars) . "'); });</script>";
kaltura_create_node_from_kshow($result['result']);
}
else {
$result = kaltura_add_roughcut($session_user, $kaltura_client, $partner_data);
$partner_data .= "|kshow_exist@yes";
$show_entry_id = $result['result']['entry']['id'];
$cw_vars = kaltura_format_cw_vars(array(
'kshow_id' => $show_entry_id,
'partner_data' => $partner_data,
'type' => 'entry',
));
$prefix = "<div class=\"add_video_to_node\"><script>jQuery(document).ready(function(){ kalturaInitModalBox('" . url("kaltura/contribution_wizard/" . $cw_vars) . "'); });</script>";
kaltura_create_node_from_roughcut($result['result']);
}
$form["add_kaltura"] = array(
"#prefix" => $prefix,
"#type" => "item",
"#value" => "",
"#suffix" => "</div>",
);
}
}
return $form;
}