function aggregator_load_feed_items

Loads and optionally filters feed items.

Parameters

$type: The type of filter for the items. Possible values are:

  • sum: No filtering.
  • source: Filter the feed items, limiting the result to items from a single source.
  • category: Filter the feed items by category.

$data: Feed or category data used for filtering. The type and value of $data depends on $type:

  • source: $data is an object with $data->fid identifying the feed used to as filter.
  • category: $data is an array with $data['cid'] being the category id to filter on.

The $data parameter is not used when $type is 'sum'.

Return value

An array of the feed items.

5 calls to aggregator_load_feed_items()
AggregatorController::pageLast in drupal/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php
Displays the most recent items gathered from any feed.
AggregatorController::sources in drupal/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php
Displays all the feeds used by the Aggregator module.
aggregator_page_categories in drupal/core/modules/aggregator/aggregator.pages.inc
Page callback: Displays all the categories used by the Aggregator module.
aggregator_page_category in drupal/core/modules/aggregator/aggregator.pages.inc
Form constructor to list items aggregated in a category.
aggregator_page_source in drupal/core/modules/aggregator/aggregator.pages.inc
Page callback: Displays all the items captured from the particular feed.

File

drupal/core/modules/aggregator/aggregator.pages.inc, line 109
User page callbacks for the Aggregator module.

Code

function aggregator_load_feed_items($type, $data = NULL, $limit = 20) {
  $items = array();
  switch ($type) {
    case 'sum':
      $query = db_select('aggregator_item', 'i');
      $query
        ->join('aggregator_feed', 'f', 'i.fid = f.fid');
      $query
        ->fields('i', array(
        'iid',
      ));
      break;
    case 'source':
      $query = db_select('aggregator_item', 'i');
      $query
        ->fields('i', array(
        'iid',
      ))
        ->condition('i.fid', $data
        ->id());
      break;
    case 'category':
      $query = db_select('aggregator_category_item', 'c');
      $query
        ->leftJoin('aggregator_item', 'i', 'c.iid = i.iid');
      $query
        ->leftJoin('aggregator_feed', 'f', 'i.fid = f.fid');
      $query
        ->fields('i', array(
        'iid',
      ))
        ->condition('cid', $data->cid);
      break;
  }
  $result = $query
    ->extend('Drupal\\Core\\Database\\Query\\PagerSelectExtender')
    ->limit($limit)
    ->orderBy('i.timestamp', 'DESC')
    ->orderBy('i.iid', 'DESC')
    ->execute();
  $items = entity_load_multiple('aggregator_item', $result
    ->fetchCol());
  return $items;
}