You are here

function _emfield_handler_arg_provider in Embedded Media Field 6

Same name and namespace in other branches
  1. 5 emfield.module \_emfield_handler_arg_provider()
  2. 6.3 deprecated/emfield-deprecated.inc \_emfield_handler_arg_provider()
  3. 6.2 emfield.module \_emfield_handler_arg_provider()

Handle the provider argument. This is called from a wrapper that includes the module.

4 calls to _emfield_handler_arg_provider()
emaudio_handler_arg_provider in contrib/emaudio/emaudio.module
emimage_handler_arg_provider in contrib/emimage/emimage.module
emvideo_handler_arg_provider in contrib/emvideo/emvideo.module
emwave_handler_arg_provider in contrib/emwave/emwave.module

File

./emfield.module, line 681
Embedded Media Field is a CCK-based framework for 3rd party media files.

Code

function _emfield_handler_arg_provider($op, &$query, $argtype, $arg = '', $module = '') {
  if ($op == 'filter') {
    $field_name = drupal_substr($argtype['type'], 10);
  }
  else {
    $field_name = drupal_substr($argtype, 10);
  }
  $field = content_fields($field_name);
  $db_info = content_database_info($field);

  // TODO: This hook no longer exists in D6.
  $main_column = $db_info['columns']['provider'];

  // The table name used here is the Views alias for the table, not the actual
  // table name.
  $table = 'node_data_' . $field['field_name'];
  switch ($op) {
    case 'summary':
      $query
        ->ensure_table($table);
      $query
        ->add_field($main_column['column'], $table);
      $query
        ->add_groupby($table . '.' . $main_column['column']);
      return array(
        'field' => $table . '.' . $main_column['column'],
      );
    case 'sort':
      $query
        ->ensure_table($table);
      $query
        ->add_orderby($table, $main_column['column'], $argtype);
      break;
    case 'filter':
      $query
        ->ensure_table($table);
      $where = db_escape_string($arg);
      $query
        ->add_where($table . '.' . $main_column['column'] . " = '%s'", $where);
      break;
    case 'link':
      $provider = emfield_system_list($module, $query->{$main_column}['column']);
      $info = emfield_include_invoke($module, $provider[$query]->name, 'info');
      $title = $info['name'];
      return l($title, $arg . '/' . $query->{$main_column}['column']);
    case 'title':
      $provider = emfield_system_list($module, $query);
      $info = emfield_include_invoke($module, $provider[$query]->name, 'info');
      $title = $info['name'];
      return $title ? $title : check_plain($query);
  }
}