You are here

function views_handler_arg_taxletter in Views (for Drupal 7) 5

1 string reference to 'views_handler_arg_taxletter'
taxonomy_views_arguments in modules/views_taxonomy.inc

File

modules/views_taxonomy.inc, line 378

Code

function views_handler_arg_taxletter($op, &$query, $argtype, $arg = '') {
  static $field = NULL;
  switch ($op) {
    case 'summary':
      $query
        ->add_table('term_data', true);
      $len = intval($arg);
      $field = $fieldinfo['field'] = $len <= 0 ? "term_data.name" : "LEFT(term_data.name, {$len})";
      $fieldinfo['fieldname'] = 'letter';
      $query
        ->add_field('tid', 'term_data');
      $query
        ->add_where('term_data.name IS NOT NULL');
      return $fieldinfo;
      break;
    case 'sort':
      $query
        ->add_orderby('', $field, $argtype, 'letter');
      break;
    case 'filter':
      $len = intval($argtype['options']);
      $query
        ->add_table('term_data', true);
      if ($len <= 0) {
        $query
          ->add_where("term_data.name = '%s'", $arg);
      }
      else {
        $query
          ->add_where("LEFT(term_data.name, {$len}) = '%s'", $arg);
      }
      break;
    case 'link':
      return l($query->letter, "{$arg}/{$query->letter}");
    case 'title':
      return check_plain($query);
  }
}