You are here

function views_handler_arg_taxid in Views (for Drupal 7) 5

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

File

modules/views_taxonomy.inc, line 308

Code

function views_handler_arg_taxid($op, &$query, $argtype, $arg = '') {
  switch ($op) {
    case 'summary':
      $query
        ->ensure_table('term_data', true);
      $query
        ->add_field('name', 'term_data');
      $query
        ->add_field('weight', 'term_data');
      $query
        ->add_field('tid', 'term_data');
      $fieldinfo['field'] = "term_data.name";
      return $fieldinfo;
    case 'sort':
      $query
        ->add_orderby('term_data', 'weight', $argtype);
      $query
        ->add_orderby('term_data', 'name', $argtype);
      break;
    case 'filter':
      if ($arg == 0) {

        // untagged only!
        $query
          ->ensure_table("term_node");
        $query
          ->add_where("term_node.tid IS NULL");
      }
      else {
        $values = _views_break_phrase($arg);
        _views_add_taxonomy(strtoupper($values[0]), $values[1], $argtype['options'], $query);
      }
      break;
    case 'link':
      $name = $query->name ? $query->name : t('Uncategorized');
      return l($name, "{$arg}/" . intval($query->tid));
    case 'title':
      if (!$query) {
        return t('Uncategorized');
      }
      list($type, $info) = _views_break_phrase($query);
      if (!$info) {
        return t('Uncategorized');
      }
      $tids = implode(',', $info);

      // only does numbers so safe
      $result = db_query("SELECT name FROM {term_data} WHERE tid IN (%s)", $tids);
      while ($term = db_fetch_object($result)) {
        $title .= ($title ? $type == 'or' ? ' + ' : ', ' : '') . check_plain($term->name);
      }
      return $title;
  }
}