You are here

function kaltura_existing in Kaltura 7.3

Same name and namespace in other branches
  1. 7.2 kaltura.module \kaltura_existing()

CTools callback: Adds existing media that is already in the drupal db.

Parameters

mixed $js: Is js enabled.

mixed $field_name: The name of the field that will be populated.

mixed $widget: The widget type so we can filter the media type.

mixed $cw_vars:

Return value

string|null

4 string references to 'kaltura_existing'
kaltura_menu in ./kaltura.module
Implements hook_menu().
kaltura_views_post_render in ./kaltura.module
Implements hook_views_post_render().
kaltura_views_pre_render in ./kaltura.module
Implements hook_pre_render().
kaltura_views_views_default_views in plugins/kaltura_views/kaltura_views.views_default.inc
Implements hook_views_default_views().

File

./kaltura.module, line 303
Kaltura integration module - core functions.

Code

function kaltura_existing($js, $field_name, $widget, $cw_vars) {
  if (!$js) {
    return '<div>' . t('We really need javascript for this one') . '</div>';
  }
  if (!module_exists('kaltura_views')) {
    return '<div>' . t('We really need the Views module for this one') . '</div>';
  }
  drupal_add_css(drupal_get_path('module', 'kaltura') . '/style/kaltura_entries.css');
  ctools_include('modal');
  ctools_include('ajax');
  $mtype = kaltura_widget_to_media_type($widget);
  $args[] = $mtype ? $mtype : NULL;
  $widget_vars = drupal_json_decode($cw_vars);
  $out = '';
  if ($widget_vars['add_existing'] == 'both') {
    $out = '<div class="kcw-button">' . ctools_modal_text_button(t('Add New'), 'kaltura/nojs/kcw', t('Add New Media'), 'ctools-modal-kcw-modal-style') . '</div>';
  }
  if (!empty($args[0])) {
    $view = views_get_view('kaltura_existing_one_type');
    $view
      ->set_arguments($args);
  }
  else {
    $view = views_get_view('kaltura_existing');
  }
  $out .= $view
    ->preview('default');
  $b_text = rawurldecode($widget_vars['button_text']);
  ctools_modal_render(t($b_text), $out);
}