You are here

kaltura_comments.module in Kaltura 6

File

plugins/kaltura_comments/kaltura_comments.module
View source
<?php

/*
 * @file
 * Should add functionality to add kaltura items inline within body (as filter)
 *
 */
function kaltura_comments_comment(&$a1, $op) {
  switch ($op) {
    case 'view':
      $comment = kaltura_replace_tags($a1->comment, $comment = TRUE);
      $a1->comment = $comment;
      break;
  }
}

/*
 * Implementation of hook_form_alter().
 */
function kaltura_comments_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'comment_form') {
    $cw_vars = kaltura_format_cw_vars(array(
      'kshow_id' => -2,
      'partner_data' => 'entry_as_comment@yes',
      'type' => '',
      'context' => 'comment',
      'field_id' => 'edit-comment',
    ));
    $form['video_comment'] = array(
      '#type' => 'item',
      '#value' => '<input type="button" value="' . t('Video Comment') . '" onclick="kalturaInitModalBox(\'' . url('kaltura/contribution_wizard/' . $cw_vars) . '\');" />',
      '#title' => t('Add Video Comment'),
    );
  }
}

/*
 * Implementation of hook_menu().
 */
function kaltura_comments_menu() {
  $items = array();
  $items['admin/settings/kaltura/kaltura_comments_settings'] = array(
    'title' => 'Kaltura Video Comments Settings',
    'description' => 'Administer the Kaltura video comments module.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'kaltura_vc_settings_form',
    ),
    'access arguments' => array(
      'administer kaltura',
    ),
    'type' => MENU_NORMAL_ITEM,
    'weight' => -6,
  );
  return $items;
}

/*
 * kaltura video comments module settings form
 */
function kaltura_vc_settings_form() {
  $form['kaltura_comment_display'] = array(
    '#type' => 'fieldset',
    '#title' => t('Display settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#weight' => -1,
  );
  $players = kaltura_choose_player(0, 'comment', 'mix');
  $saved_player = variable_get('kaltura_comment_entry_widget', KalturaSettings_DEFAULT_COMMENT_PLAYER_UICONF);
  $form['kaltura_comment_display']['kaltura_comment_entry_widget'] = $players['default_widget'];
  $form['kaltura_comment_display']['kaltura_comment_entry_widget']['#default_value'] = $saved_player;
  $form['kaltura_comment_display']['clear_block_item'] = array(
    '#type' => 'item',
    '#value' => '<div class="clear-block"></div>',
  );
  $form['kaltura_comment_display']['kaltura_comment_width'] = array(
    '#type' => 'textfield',
    '#size' => 5,
    '#title' => t('Width (in pixels)'),
    '#default_value' => variable_get('kaltura_comment_width', '250'),
  );
  $form['kaltura_comment_display']['kaltura_comment_height'] = array(
    '#type' => 'textfield',
    '#size' => 5,
    '#title' => t('Height (in pixels)'),
    '#default_value' => variable_get('kaltura_comment_height', '244'),
  );
  return system_settings_form($form);
}