You are here

function _parser_simplepie_get_parser in FeedAPI 6

Same name and namespace in other branches
  1. 5 parser_simplepie/parser_simplepie.module \_parser_simplepie_get_parser()

Set SimplePie setting

Parameters

$url: The feed's url

$enable_cache: If FALSE, the caching is disabled

$settings:

Return value

SimplePie object

2 calls to _parser_simplepie_get_parser()
parser_simplepie_feedapi_feed in parser_simplepie/parser_simplepie.module
Implementation of hook_feedapi_feed().
_parser_simplepie_feedapi_parse in parser_simplepie/parser_simplepie.module
Parsing the feed

File

parser_simplepie/parser_simplepie.module, line 213
Parse the incoming URL with SimplePie then provide a data structure of the feed

Code

function _parser_simplepie_get_parser($url, $enable_cache = TRUE, $settings = array()) {
  if (!class_exists('SimplePie')) {
    if (module_exists('libraries') && file_exists(libraries_get_path('simplepie') . '/simplepie.inc')) {
      $path = libraries_get_path('simplepie') . '/simplepie.inc';
    }
    else {
      $path = drupal_get_path('module', 'parser_simplepie') . '/simplepie.inc';
    }
    require_once $path;
  }
  $parser = new SimplePie();
  $parser
    ->set_feed_url($url);
  $parser
    ->set_timeout(15);
  if (isset($settings['cache_lifetime'])) {
    $parser
      ->set_cache_duration($settings['cache_lifetime']);
  }
  $parser
    ->set_stupidly_fast(TRUE);
  $parser
    ->encode_instead_of_strip(FALSE);
  $cache_location = _parser_simplepie_sanitize_cache();
  $parser
    ->enable_cache($cache_location !== FALSE ? $enable_cache : FALSE);
  $parser
    ->set_cache_location($cache_location);
  $parser
    ->init();
  return $parser;
}