You are here

function field_kaltura_field in Kaltura 6

Same name and namespace in other branches
  1. 5 plugins/field_kaltura/field_kaltura.module \field_kaltura_field()
  2. 6.2 plugins/field_kaltura/field_kaltura.module \field_kaltura_field()

Implementation of hook_field().

File

plugins/field_kaltura/field_kaltura.module, line 125
kaltura integration module - functions to provide kaltura as CCK field

Code

function field_kaltura_field($op, &$node, $field, &$items, $teaser, $page) {
  switch ($op) {
    case 'validate':
      $allowed_values = content_allowed_values($field);
      if (is_array($items)) {
        foreach ($items as $delta => $item) {
          $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
          if (is_array($item) && isset($item['_error_element'])) {
            unset($item['_error_element']);
          }
          if (!empty($item['value'])) {
            if (count($allowed_values) && !array_key_exists($item['value'], $allowed_values)) {
              form_set_error($error_element, t('%name: illegal value.', array(
                '%name' => t($field['widget']['label']),
              )));
            }
            if (!empty($field['max_length']) && drupal_strlen($item['value']) > $field['max_length']) {
              form_set_error($error_element, t('%name: the value may not be longer than %max characters.', array(
                '%name' => $field['widget']['label'],
                '%max' => $field['max_length'],
              )));
            }
          }
        }
      }
      return $items;
    case 'sanitize':
      foreach ($items as $delta => $item) {
        $items[$delta]['#kaltura_field'] = $field;
      }
      break;
  }
}