You are here

function views_handler_arg_feed_nid in FeedAPI 5

Pass in a URL argument to find all feed items for a specific feed node id.

1 string reference to 'views_handler_arg_feed_nid'
feedapi_node_views_views_arguments in feedapi_node_views/feedapi_node_views.module
Implementation of hook_views_arguments().

File

feedapi_node_views/feedapi_node_views.module, line 147

Code

function views_handler_arg_feed_nid($op, &$query, $a1, $a2 = '') {
  switch ($op) {
    case 'summary':
      $query
        ->ensure_table('feedapi_node_item');
      $query
        ->add_field('feed_nid', 'feedapi_node_item');
      $query
        ->add_field('title', 'node');
      $query
        ->add_where('feedapi.nid IS NOT NULL');
      $fieldinfo['field'] = 'node.nid';
      return $fieldinfo;
    case 'sort':
      $query
        ->add_orderby('feedapi_node_item', 'timestamp', $a1);
      break;
    case 'filter':
      $join = array();
      $join['left']['table'] = 'node';
      $join['left']['field'] = 'nid';
      $join['right']['table'] = 'feedapi_node_item_feed';
      $join['right']['field'] = 'feed_item_nid';
      $query
        ->add_table('feedapi_node_item_feed', TRUE, 1, $join);
      $query
        ->add_field('feed_item_nid', 'feedapi_node_item_feed');
      $query
        ->add_where('feedapi_node_item_feed.feed_nid = %d', $a2);
      break;
    case 'link':
      $query->num_nodes .= format_plural($query->num_nodes, ' item', ' items');
      return l($query->title, "{$a2}/{$query->fpnid}");
    case 'title':
      if ($query) {
        $title = db_result(db_query('SELECT title FROM {node} WHERE nid = %d', $query));
        return check_plain($title);
      }
  }
}