You are here

function kaltura_widget_hendler in Kaltura 7.2

Same name and namespace in other branches
  1. 7.3 plugins/field_kaltura/field_kaltura.module \kaltura_widget_hendler()

Returns the widget according to the given widget type.

1 call to kaltura_widget_hendler()
field_kaltura_field_widget_form in plugins/field_kaltura/field_kaltura.module
Implements hook_field_widget_form().

File

plugins/field_kaltura/field_kaltura.module, line 352
Kaltura as a field primary module file.

Code

function kaltura_widget_hendler($instance, $entry, $mediat, $name, $add_existing, $button_text) {
  drupal_add_js(array(
    'kcw-modal-style' => array(
      'modalSize' => array(
        'type' => 'fixed',
        'width' => 740,
        'height' => 440,
      ),
    ),
  ), 'setting');
  field_kaltura_add_modal_js($name);
  ctools_include('modal');
  ctools_include('ajax');
  ctools_modal_add_js();
  $widget_type = str_replace($instance['widget']['module'] . '_', '', $instance['widget']['type']);
  $cw_vars = drupal_json_encode(array(
    'kshow_id' => 0,
    'partner_data' => '',
    'type' => 'entry',
    'context' => 'field',
    'field_id' => $name,
    'ui_conf' => $instance['uiconf'],
    'wtype' => $instance['widget']['type'],
    'add_existing' => $add_existing,
    'button_text' => rawurlencode($button_text),
  ));
  if ($add_existing == 'both' || $add_existing == 'existing') {
    $action_buttons = ctools_modal_text_button(t($button_text), 'kaltura/nojs/existing/' . $name . '/' . $instance['widget']['type'] . '/' . $cw_vars, t($button_text));
  }
  else {
    $action_buttons = ctools_modal_text_button(t($button_text), 'kaltura/nojs/kcw/' . $cw_vars, t($button_text), 'ctools-modal-kcw-modal-style');
  }
  $widget['entryid'] = array(
    '#title' => t($name),
    '#suffix' => '</div>',
    '#type' => 'hidden',
    '#default_value' => $entry,
    '#pre_render' => array(
      0 => 'field_kaltura_tumb_pre',
    ),
  );
  $widget['mediatype'] = array(
    '#prefix' => '<div id="' . $name . '-media-type">',
    '#suffix' => '</div>',
    '#type' => 'hidden',
    '#default_value' => $mediat,
  );
  if ($entry) {
    drupal_add_js(array(
      'metadata-modal-style' => array(
        'modalSize' => array(
          'type' => 'scale',
          'width' => 0.4,
          'height' => 0.6,
        ),
      ),
    ), 'setting');
    $widget['meta_edit'] = array(
      '#markup' => ctools_modal_text_button('Edit Metadata', 'kaltura/nojs/metadata_editor/' . $entry, 'Edit Metadata', 'ctools-modal-metadata-modal-style'),
    );
  }
  $widget['button'] = array(
    '#type' => 'item',
    '#markup' => $action_buttons,
  );
  return $widget;
}