aggregator_aggregator_parse

  1. drupal
    1. drupal7
Versionen
drupal7 aggregator_aggregator_parse($feed)

Implementation of hook_aggregator_parse().

Code

modules/aggregator/aggregator.parser.inc, line 22

<?php
function aggregator_aggregator_parse($feed) {
  global $channel, $image;

  // Filter the input data.
  if (aggregator_parse_feed($feed->source_string, $feed)) {
    $modified = empty($feed->http_headers['Last-Modified']) ? 0 : strtotime($feed->http_headers['Last-Modified']);

    // Prepare the channel data.
    foreach ($channel as $key => $value) {
      $channel[$key] = trim($value);
    }

    // Prepare the image data (if any).
    foreach ($image as $key => $value) {
      $image[$key] = trim($value);
    }

    if (!empty($image['link']) && !empty($image['url']) && !empty($image['title'])) {
      $image = l(theme('image', $image['url'], $image['title']), $image['link'], array('html' => TRUE));
    }
    else {
      $image = '';
    }

    $etag = empty($feed->http_headers['ETag']) ? '' : $feed->http_headers['ETag'];
    // Update the feed data.
    db_merge('aggregator_feed')
      ->key(array('fid' => $feed->fid))
      ->fields(array(
        'url' => $feed->url,
        'checked' => REQUEST_TIME,
        'link' => !empty($channel['link']) ? $channel['link'] : '',
        'description' => !empty($channel['description']) ? $channel['description'] : '',
        'image' => $image,
        'hash' => md5($feed->source_string),
        'etag' => $etag,
        'modified' => $modified,
      ))
      ->execute();

    // Clear the cache.
    cache_clear_all();

    if (isset($feed->redirected)) {
      watchdog('aggregator', 'Updated URL for feed %title to %url.', array('%title' => $feed->title, '%url' => $feed->url));
    }

    watchdog('aggregator', 'There is new syndicated content from %site.', array('%site' => $feed->title));
    drupal_set_message(t('There is new syndicated content from %site.', array('%site' => $feed->title)));

  }
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen