class FeedsSyndicationParser in Feeds 7.2
Same name and namespace in other branches
- 6 plugins/FeedsSyndicationParser.inc \FeedsSyndicationParser
- 7 plugins/FeedsSyndicationParser.inc \FeedsSyndicationParser
Class definition for Common Syndication Parser.
Parses RSS and Atom feeds.
Hierarchy
- class \FeedsConfigurable
- class \FeedsPlugin implements FeedsSourceInterface
- class \FeedsParser
- class \FeedsSyndicationParser
- class \FeedsParser
- class \FeedsPlugin implements FeedsSourceInterface
Expanded class hierarchy of FeedsSyndicationParser
6 string references to 'FeedsSyndicationParser'
- FeedsImporter::configDefaults in includes/
FeedsImporter.inc - Return defaults for feed configuration.
- FeedsMapperFieldTestCase::testCardinalityValidation in tests/
feeds_mapper_field.test - Tests cardinality validation.
- FeedsSyndicationParserTestCase::test in tests/
feeds_parser_syndication.test - Run tests.
- FeedsWebTestCase::createImporterConfiguration in tests/
feeds.test - Create an importer configuration.
- feeds_news_feeds_importer_default in feeds_news/
feeds_news.feeds_importer_default.inc - Implements hook_feeds_importer_default().
File
- plugins/
FeedsSyndicationParser.inc, line 13 - Contains FeedsSyndicationParser and related classes.
View source
class FeedsSyndicationParser extends FeedsParser {
/**
* Implements FeedsParser::parse().
*/
public function parse(FeedsSource $source, FeedsFetcherResult $fetcher_result) {
feeds_include_library('common_syndication_parser.inc', 'common_syndication_parser');
$feed = common_syndication_parser_parse($fetcher_result
->getRaw());
$result = new FeedsParserResult();
// Return an empty result object when feed is false.
if (!$feed) {
return $result;
}
$result->title = $feed['title'];
$result->description = $feed['description'];
$result->link = $feed['link'];
if (is_array($feed['items'])) {
foreach ($feed['items'] as $item) {
if (isset($item['geolocations'])) {
foreach ($item['geolocations'] as $k => $v) {
$item['geolocations'][$k] = new FeedsGeoTermElement($v);
}
}
$result->items[] = $item;
}
}
return $result;
}
/**
* Return mapping sources.
*
* At a future point, we could expose data type information here,
* storage systems like Data module could use this information to store
* parsed data automatically in fields with a correct field type.
*/
public function getMappingSources() {
return array(
'title' => array(
'name' => t('Title'),
'description' => t('Title of the feed item.'),
),
'description' => array(
'name' => t('Description'),
'description' => t('Description of the feed item.'),
),
'author_name' => array(
'name' => t('Author name'),
'description' => t('Name of the feed item\'s author.'),
),
'timestamp' => array(
'name' => t('Published date'),
'description' => t('Published date as UNIX time GMT of the feed item.'),
),
'url' => array(
'name' => t('Item URL (link)'),
'description' => t('URL of the feed item.'),
),
'guid' => array(
'name' => t('Item GUID'),
'description' => t('Global Unique Identifier of the feed item.'),
),
'tags' => array(
'name' => t('Categories'),
'description' => t('An array of categories that have been assigned to the feed item.'),
),
'geolocations' => array(
'name' => t('Geo Locations'),
'description' => t('An array of geographic locations with a name and a position.'),
),
'source:url' => array(
'name' => t('Source: URL'),
'description' => t('The URL of the RSS channel that the item came from.'),
),
'source:title' => array(
'name' => t('Source: Title'),
'description' => t('The title of the RSS channel that the item came from.'),
),
) + parent::getMappingSources();
}
/**
* Overrides FeedsParser::providesSourceTitle().
*
* This parser supports retrieving a title from the source.
*/
public function providesSourceTitle() {
return TRUE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FeedsConfigurable:: |
protected | property | Holds the actual configuration information. | |
FeedsConfigurable:: |
protected | property | CTools export enabled status of this object. | |
FeedsConfigurable:: |
protected | property | CTools export type of this object. | |
FeedsConfigurable:: |
protected | property | An unique identifier for the configuration. | |
FeedsConfigurable:: |
public | function | Similar to setConfig but adds to existing configuration. | |
FeedsConfigurable:: |
public | function | Returns configuration form for this object. | 6 |
FeedsConfigurable:: |
public | function | Submission handler for configForm(). | 2 |
FeedsConfigurable:: |
public | function | Validation handler for configForm(). | 3 |
FeedsConfigurable:: |
public | function | Copy a configuration. | 1 |
FeedsConfigurable:: |
public | function | Determine whether this object is persistent. | 1 |
FeedsConfigurable:: |
public | function | Determines whether this object is persistent and enabled. | 1 |
FeedsConfigurable:: |
public | function | Implements getConfig(). | 1 |
FeedsConfigurable:: |
public | function | Returns whether or not the configurable has a config form. | |
FeedsConfigurable:: |
public | function | Determine whether this object is enabled. | |
FeedsConfigurable:: |
public | function | Set configuration. | |
FeedsConfigurable:: |
public | function | Validates the configuration. | 2 |
FeedsConfigurable:: |
public | function | Overrides magic method __get(). | |
FeedsConfigurable:: |
public | function | Override magic method __isset(). This is needed due to overriding __get(). | |
FeedsParser:: |
public | function | Clear all caches for results for given source. | |
FeedsParser:: |
public | function | Get list of mapped sources. | 1 |
FeedsParser:: |
public | function | Get an element identified by $element_key of the given item. The element key corresponds to the values in the array returned by FeedsParser::getMappingSources(). | 1 |
FeedsParser:: |
public | function |
Implements FeedsPlugin::pluginType(). Overrides FeedsPlugin:: |
|
FeedsPlugin:: |
protected | property | The plugin definition. | |
FeedsPlugin:: |
public static | function | Get all available plugins. | |
FeedsPlugin:: |
public static | function | Gets all available plugins of a particular type. | |
FeedsPlugin:: |
public static | function | Determines whether given plugin is derived from given base plugin. | |
FeedsPlugin:: |
public | function |
Overrides FeedsConfigurable::configDefaults(). Overrides FeedsConfigurable:: |
4 |
FeedsPlugin:: |
public | function |
Implements FeedsConfigurable::dependencies(). Overrides FeedsConfigurable:: |
1 |
FeedsPlugin:: |
public | function |
Returns TRUE if $this->sourceForm() returns a form. Overrides FeedsSourceInterface:: |
|
FeedsPlugin:: |
public static | function |
Instantiates a FeedsPlugin object. Overrides FeedsConfigurable:: |
|
FeedsPlugin:: |
public static | function | Loads on-behalf implementations from mappers/ directory. | |
FeedsPlugin:: |
public | function | Returns the plugin definition. | |
FeedsPlugin:: |
public | function |
Save changes to the configuration of this object.
Delegate saving to parent (= Feed) which will collect
information from this object by way of getConfig() and store it. Overrides FeedsConfigurable:: |
1 |
FeedsPlugin:: |
protected | function | Sets the plugin definition. | |
FeedsPlugin:: |
public | function |
Implements FeedsSourceInterface::sourceDefaults(). Overrides FeedsSourceInterface:: |
1 |
FeedsPlugin:: |
public | function |
A source is being deleted. Overrides FeedsSourceInterface:: |
2 |
FeedsPlugin:: |
public | function |
Callback methods, exposes source form. Overrides FeedsSourceInterface:: |
3 |
FeedsPlugin:: |
public | function |
Validation handler for sourceForm. Overrides FeedsSourceInterface:: |
2 |
FeedsPlugin:: |
public | function |
A source is being saved. Overrides FeedsSourceInterface:: |
2 |
FeedsPlugin:: |
public static | function | Determines the type of a plugin. | |
FeedsPlugin:: |
protected | function |
Constructs a FeedsPlugin object. Overrides FeedsConfigurable:: |
|
FeedsSyndicationParser:: |
public | function |
Return mapping sources. Overrides FeedsParser:: |
|
FeedsSyndicationParser:: |
public | function |
Implements FeedsParser::parse(). Overrides FeedsParser:: |
|
FeedsSyndicationParser:: |
public | function |
Overrides FeedsParser::providesSourceTitle(). Overrides FeedsParser:: |