You are here

function feedapi_node_link in FeedAPI 6

Same name and namespace in other branches
  1. 5 feedapi_node/feedapi_node.module \feedapi_node_link()

Implementation of hook_link().

File

feedapi_node/feedapi_node.module, line 83
Handle how the feed items are represented as a content Handle the processing of the feed items

Code

function feedapi_node_link($type, $node = NULL) {
  $links = array();
  if ($type == 'node') {
    if (isset($node->feed)) {
      if (count($node->feed->processors) > 0 && module_exists('views')) {
        if (in_array('feedapi_node', $node->feed->processors)) {
          $links['view_items'] = array(
            'title' => t('Feed items'),
            'href' => 'feed-item/' . $node->nid,
          );
        }
      }
    }
    if (isset($node->feedapi_node)) {
      $result = db_query(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n WHERE n.nid IN (" . db_placeholders($node->feedapi_node->feed_nids, 'int') . ") ORDER BY title DESC"), $node->feedapi_node->feed_nids);
      $owner_feeds_num = count($node->feedapi_node->feed_nids);
      while ($feed = db_fetch_object($result)) {
        $links['feedapi_feed' . ($owner_feeds_num == 1 ? '' : '_' . $feed->nid)] = array(
          'title' => t('Feed:') . ' ' . $feed->title,
          'href' => 'node/' . $feed->nid,
        );
      }
      if ($node->feedapi_node->url) {
        $links['feedapi_original'] = array(
          'title' => t('Original article'),
          'href' => $node->feedapi_node->url,
        );
      }
    }
  }
  return $links;
}