You are here

function views_handler_arg_nodehierarchy_antecedent in Node Hierarchy 5

Handle the antecedent argument.

1 string reference to 'views_handler_arg_nodehierarchy_antecedent'
nodehierarchy_views_arguments in nodehierarchy_views/nodehierarchy_views.module
Implementation of hook_views_arguments().

File

nodehierarchy_views/nodehierarchy_views.module, line 302
Views.module integration for nodehierarchy.module.

Code

function views_handler_arg_nodehierarchy_antecedent($op, &$query, $argtype, $arg = '') {
  switch ($op) {
    case 'summary':
      $query
        ->add_field('nid');
      $query
        ->add_field("title");
      $fieldinfo['field'] = 'nodehierarchy.parent';
      return $fieldinfo;
    case 'sort':
      $query
        ->add_orderby('nodehierarchy', 'order_by', $argtype);
      break;
    case 'filter':
      $query
        ->ensure_table("nodehierarchy");
      $descendants = _nodehierarchy_views_get_descendant_parents($arg);
      $descendant_list = implode(",", $descendants);
      $query
        ->add_where("nodehierarchy.parent IN ( {$descendant_list} )");
      break;
    case 'link':
      return l($query->title, "{$arg}/{$query->nid}");
    case 'title':
      $node = db_fetch_object(db_query("SELECT title FROM {node} WHERE nid=%d", $query));
      return $node->title;
  }
}