You are here

function kaltura_list_entries in Kaltura 5

Same name and namespace in other branches
  1. 6.2 kaltura.module \kaltura_list_entries()
  2. 6 kaltura.module \kaltura_list_entries()
  3. 7.3 kaltura.module \kaltura_list_entries()
  4. 7.2 kaltura.module \kaltura_list_entries()
1 string reference to 'kaltura_list_entries'
kaltura_menu in ./kaltura.module

File

./kaltura.module, line 288

Code

function kaltura_list_entries() {
  global $pager_page_array, $pager_total;
  $args = func_get_args();
  if ($args[0] == 'allow-insert' && $args[1]) {
    drupal_add_css(drupal_get_path('module', 'kaltura') . '/style/kaltura.css', 'all');
    $allow_insert = TRUE;
    $field_name = $args[1];
  }
  $media_types = new KalturaSettings();
  $title = 'Kaltura Content';
  $filter_media = '';
  if ($_GET['filter']) {
    $filter_media = 'AND knode.kaltura_media_type = ' . db_escape_string($_GET['filter']);
    $title .= ' (filter by - ' . $media_types->media_types_map[$_GET['filter']] . ')';
  }
  drupal_set_title($title);
  $node_count = db_fetch_object(db_query(db_rewrite_sql('SELECT COUNT(node.nid) c FROM {node} node LEFT JOIN {node_kaltura} knode on node.nid = knode.nid WHERE type like \'kaltura%\' AND status > 0 ' . $filter_media, 'node', 'nid')));
  $pager_total[0] = ceil($node_count->c / 20);
  if ($_GET['page']) {
    $start = 20 * (int) $_GET['page'];
    $pager_page_array[0] = $_GET['page'];
  }
  else {
    $start = 0;
  }
  $get_all = 'SELECT node.nid,node.title,node.type,knode.kaltura_entryId,knode.kaltura_thumbnail_url FROM {node} node ' . 'LEFT JOIN {node_kaltura} knode on node.nid = knode.nid WHERE (type = \'kaltura_entry\' OR type = \'kaltura_mix\') ' . $filter_media . ' AND status > 0 ORDER BY nid DESC LIMIT ' . $start . ', 20';
  $result = db_query(db_rewrite_sql($get_all, 'node', 'nid'));
  while ($node_nid = db_fetch_object($result)) {
    $nodes[$node_nid->nid] = $node_nid;
  }
  $html = theme("list_of_entries", $nodes, $allow_insert, $field_name);
  $pager = '';
  if (ceil($node_count->c / 20) > 1) {
    $pager = theme('pager', NULL, 20, 0, array(), ceil($node_count->c / 20));
  }
  if ($allow_insert && $field_name) {
    $html = '<div id="media-upload-header">
	<ul id="sidemenu">
	<li id="tab-kaltura"><a href="' . $_GET['cwurl'] . '">Add Interactive Video</a></li>
	<li id="tab-kaltura_browse"><a class="current" href="' . url('kaltura/entries/allow-insert/' . $field_id) . '">Browse Interactive Videos</a></li>
        <li><a href="#" onclick="window.top.kalturaCloseModalBox();return false;">Close</a></li>
        </ul>
    </div><div class="ktitle"><h3>' . $title . '</h3></div>' . $html;
    $js = '$(document).ready(function() { ' . PHP_EOL . 'window.top.document.getElementById("kaltura_modal_iframe").className += " remove_overflow"; ';
    $js .= PHP_EOL . 'window.top.document.getElementById("kaltura_modal_iframe").scrolling = "";';
    $js .= PHP_EOL . 'window.top.document.getElementById("modalbox").style.height = "500px";';
    $js .= PHP_EOL . 'window.top.document.getElementById("kaltura_modal_iframe").height = "500";';
    $js .= PHP_EOL . 'window.top.document.getElementById("modalbox").className += " white_bg"; });';
    echo theme('kaltura_modal', array(
      'flashEmbed' => $html . '<div class="kaltura_pager">' . $pager . '</div>',
      'javascript' => $js,
    ));
    exit;
  }
  return $html . $pager;
}