You are here

function text_views_argument_handler in Content Construction Kit (CCK) 5

1 string reference to 'text_views_argument_handler'
text_field_settings in ./text.module
Implementation of hook_field_settings().

File

./text.module, line 125
Defines simple text field types.

Code

function text_views_argument_handler($op, &$query, $argtype, $arg = '') {
  $name = explode(':', is_array($argtype) ? $argtype['type'] : $argtype);
  $field_name = trim($name[1]);
  $field = content_fields($field_name);
  $db_info = content_database_info($field);
  $value = $db_info['columns']['value']['column'];
  $table = 'node_data_' . $field['field_name'];
  switch ($op) {
    case 'summary':
      $query
        ->ensure_table($table);
      $query
        ->add_field($value, $table);
      $length = intval($arg);
      $fieldinfo['field'] = $length <= 0 ? "{$table}.{$value}" : "LEFT({$table}.{$value}, {$length})";
      $fieldinfo['fieldname'] = 'letter';
      return $fieldinfo;
    case 'sort':
      break;
    case 'filter':
      $query
        ->ensure_table($table);
      $query
        ->add_field($value, $table);
      $length = intval($argtype['options']);
      $where = $length <= 0 ? "{$table}.{$value} = '%s'" : "LEFT({$table}.{$value}, {$length}) = '%s'";
      $query
        ->add_where($where, $arg);
      break;
    case 'link':
      return l(strtoupper($query->letter), "{$arg}/{$query->letter}");
    case 'title':
      return check_plain(strtoupper($query));
  }
}