You are here

function views_handler_arg_nid in Views (for Drupal 7) 5

1 string reference to 'views_handler_arg_nid'
node_views_arguments in modules/views_node.inc

File

modules/views_node.inc, line 658

Code

function views_handler_arg_nid($op, &$query, $argtype, $arg = '') {
  switch ($op) {
    case 'summary':
      $query
        ->add_field("title");
      $fieldinfo['field'] = 'node.nid';
      return $fieldinfo;
    case 'sort':

      // do nothing here.
      break;
    case 'filter':
      $args = _views_break_phrase($arg);
      if ($args[0] == 'and') {
        $operator = $argtype['options'] ? '!=' : '=';
        foreach ($args[1] as $arg) {
          $query
            ->add_where("node.nid {$operator} %d", $arg);
        }
      }
      else {
        $query
          ->add_where("node.nid IN (%s)", implode(',', $args[1]));
      }
      break;
    case 'link':
      return l($query->title, "{$arg}/{$query->nid}");
    case 'title':
      list($type, $info) = _views_break_phrase($query);
      if (!$info) {
        return t('Untitled');
      }
      $nids = implode(',', $info);

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