Skip navigation
Help

aggregator_feed_items_load

6 aggregator.pages.inc aggregator_feed_items_load($sql)
7 aggregator.pages.inc aggregator_feed_items_load($type, $data = NULL)

Load feed items

Parameters

$type: The filter for the items. Possible values: 'sum', 'source', 'category'

$data: Feed or category data for filtering

Return value

An array of the feed items.

3 calls to aggregator_feed_items_load()

File

drupal/modules/aggregator/aggregator.pages.inc, line 101
User page callbacks for the aggregator module.

Code

function aggregator_feed_items_load($type, $data = NULL) {
  $items = array();
  $range_limit = 20;
  switch ($type) {
    case 'sum':
      $result = db_query_range('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_item} i INNER JOIN {aggregator_feed} f ON i.fid = f.fid ORDER BY i.timestamp DESC, i.iid DESC', 0, $range_limit);
      break;
    case 'source':
      $result = db_query_range('SELECT * FROM {aggregator_item} WHERE fid = :fid ORDER BY timestamp DESC, iid DESC', 0, $range_limit, array(':fid' => $data->fid));
      break;
    case 'category':
      $result = db_query_range('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_category_item} c LEFT JOIN {aggregator_item} i ON c.iid = i.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE cid = :cid ORDER BY timestamp DESC, i.iid DESC', 0, $range_limit, array(':cid' => $data['cid']));
      break;
  }

  foreach ($result as $item) {
    $item->categories = db_query('SELECT c.title, c.cid FROM {aggregator_category_item} ci LEFT JOIN {aggregator_category} c ON ci.cid = c.cid WHERE ci.iid = :iid ORDER BY c.title', array(':iid' => $item->iid))->fetchAll();
    $items[] = $item;
  }

  return $items;
}