You are here

function parser_simplepie_feedapi_feed in FeedAPI 5

Same name and namespace in other branches
  1. 6 parser_simplepie/parser_simplepie.module \parser_simplepie_feedapi_feed()

Implementation of hook_feedapi_feed().

File

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

Code

function parser_simplepie_feedapi_feed($op) {
  $args = func_get_args();

  // Validate the URL, if it is not basically valid, why send to simplepie object
  $url_parts = parse_url(is_string($args[1]) ? $args[1] : $args[1]->url);
  $valid_ip_regex = "^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}^";
  $op = gethostbyname($url_parts['host']) !== $url_parts['host'] || preg_match($valid_ip_regex, $url_parts['host']) > 0 ? $op : FALSE;
  switch ($op) {
    case 'type':
      return array(
        "XML feed",
      );
    case 'compatible':

      // Stop gap for simplefeed.inc version <= 1.1
      return "XML feed";
      $url = $args[1]->url;

      // Here we do not allow caching. Otherwise simplepie's cache prevents FeedAPI to process the feed
      $parser = _parser_simplepie_get_parser($url, FALSE);
      if ($parser->error) {
        return FALSE;
      }
      return array_shift(parser_simplepie_feedapi_feed('type'));
    case 'parse':
      $feed = is_object($args[1]) ? $args[1] : FALSE;
      return _parser_simplepie_feedapi_parse($feed);
  }
  return FALSE;
}