You are here

public static function FeedImport::loadFeeds in Feed Import 7

Same name and namespace in other branches
  1. 7.2 feed_import.inc.php \FeedImport::loadFeeds()

Feed import load feeds settings

Parameters

bool $enabled: Load only enabled feeds

mixed $id: Load feed by id or name

Return value

array Feeds info

9 calls to FeedImport::loadFeeds()
feed_import_add_new_feed_form_validate in ./feed_import.module
Add new feed form validate
feed_import_cron in ./feed_import.module
Implements hook_cron().
feed_import_edit_feed_form in ./feed_import.module
Edit feed form
feed_import_edit_feed_form_submit in ./feed_import.module
Edit feed form submit
feed_import_edit_filter_form in ./feed_import.module
Edit filter form

... See full list

File

./feed_import.inc.php, line 35
Feed import class for parsing and processing content

Class

FeedImport
@file Feed import class for parsing and processing content

Code

public static function loadFeeds($enabled = FALSE, $id = NULL) {
  static $feeds = NULL;
  static $enabled_feeds = NULL;
  if ($id == NULL) {
    if ($feeds != NULL) {
      return $enabled ? $enabled_feeds : $feeds;
    }
    $feeds = db_select('feed_import_settings', 'f')
      ->fields('f', array(
      'name',
      'url',
      'time',
      'entity_info',
      'xpath',
      'id',
      'enabled',
    ))
      ->orderBy('enabled', 'DESC')
      ->execute()
      ->fetchAllAssoc('name');
    foreach ($feeds as $name => &$feed) {
      $feed = (array) $feed;
      $feed['entity_info'] = unserialize($feed['entity_info']);
      $feed['xpath'] = unserialize($feed['xpath']);
      if ($feed['enabled']) {
        $enabled_feeds[$name] =& $feed;
      }
    }
    return $enabled ? $enabled_feeds : $feeds;
  }
  else {
    $feed = db_select('feed_import_settings', 'f')
      ->fields('f', array(
      'name',
      'url',
      'time',
      'entity_info',
      'xpath',
      'id',
      'enabled',
    ))
      ->condition((int) $id ? 'id' : 'name', $id, '=')
      ->range(0, 1)
      ->execute()
      ->fetchAll();
    if ($feed) {
      $feed = (array) reset($feed);
      $feed['entity_info'] = unserialize($feed['entity_info']);
      $feed['xpath'] = unserialize($feed['xpath']);
      return $feed;
    }
    else {
      return NULL;
    }
  }
}