class FeedsSitemapParser in Feeds 7.2
Same name and namespace in other branches
- 6 plugins/FeedsSitemapParser.inc \FeedsSitemapParser
- 7 plugins/FeedsSitemapParser.inc \FeedsSitemapParser
A parser for the Sitemap specification http://www.sitemaps.org/protocol.php.
Hierarchy
- class \FeedsConfigurable
- class \FeedsPlugin implements FeedsSourceInterface
- class \FeedsParser
- class \FeedsSitemapParser
- class \FeedsParser
- class \FeedsPlugin implements FeedsSourceInterface
Expanded class hierarchy of FeedsSitemapParser
2 string references to 'FeedsSitemapParser'
- FeedsSitemapParserTestCase::test in tests/
feeds_parser_sitemap.test - Run tests.
- _feeds_feeds_plugins in ./
feeds.plugins.inc - Break out for feeds_feed_plugins().
File
- plugins/
FeedsSitemapParser.inc, line 11 - Contains FeedsSitemapParser and related classes.
View source
class FeedsSitemapParser extends FeedsParser {
/**
* Implements FeedsParser::parse().
*/
public function parse(FeedsSource $source, FeedsFetcherResult $fetcher_result) {
// Set time zone to GMT for parsing dates with strtotime().
$tz = date_default_timezone_get();
date_default_timezone_set('GMT');
// Yes, using a DOM parser is a bit inefficient, but will do for now.
$xml = new SimpleXMLElement($fetcher_result
->getRaw());
$result = new FeedsParserResult();
foreach ($xml->url as $url) {
$item = array(
'url' => (string) $url->loc,
);
if ($url->lastmod) {
$item['lastmod'] = strtotime($url->lastmod);
}
if ($url->changefreq) {
$item['changefreq'] = (string) $url->changefreq;
}
if ($url->priority) {
$item['priority'] = (string) $url->priority;
}
$result->items[] = $item;
}
date_default_timezone_set($tz);
return $result;
}
/**
* Implements FeedsParser::getMappingSources().
*/
public function getMappingSources() {
return array(
'url' => array(
'name' => t('Item URL (link)'),
'description' => t('URL of the feed item.'),
),
'lastmod' => array(
'name' => t('Last modification date'),
'description' => t('Last modified date as UNIX time GMT of the feed item.'),
),
'changefreq' => array(
'name' => t('Change frequency'),
'description' => t('How frequently the page is likely to change.'),
),
'priority' => array(
'name' => t('Priority'),
'description' => t('The priority of this URL relative to other URLs on the site.'),
),
) + parent::getMappingSources();
}
}
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:: |
|
FeedsParser:: |
public | function | Returns if the parsed result can have a title. | 3 |
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:: |
|
FeedsSitemapParser:: |
public | function |
Implements FeedsParser::getMappingSources(). Overrides FeedsParser:: |
|
FeedsSitemapParser:: |
public | function |
Implements FeedsParser::parse(). Overrides FeedsParser:: |