class FeedsForenaXMLParser in Forena Reports 7.4
Same name and namespace in other branches
- 7.5 feeds/FeedsForenaXMLParser.inc \FeedsForenaXMLParser
- 7.3 feeds/FeedsForenaXMLParser.inc \FeedsForenaXMLParser
Hierarchy
- class \FeedsForenaXMLParser extends \FeedsParser
Expanded class hierarchy of FeedsForenaXMLParser
1 string reference to 'FeedsForenaXMLParser'
- _forena_feeds_plugins in feeds/
forena_feeds.inc
File
- feeds/
FeedsForenaXMLParser.inc, line 2
View source
class FeedsForenaXMLParser extends FeedsParser {
/**
* Implements FeedsParser::parse().
*/
public function parse(FeedsSource $source, FeedsFetcherResult $fetcher_result) {
$source_config = $source
->getConfigFor($this);
$result = new FeedsParserResult();
// Load and configure parser.
$xpath = @$this->config['xpath'];
$options = @$this->config['options'];
$options = @drupal_parse_info_format($source_config['options']);
$fields = @$options['fields'];
$parser = Frx::Fields($fields);
if (!$fields) {
$fields = array();
}
$format = @(!$options['format']);
$raw = $fetcher_result
->getRaw();
$mappings = feeds_importer($this->id)->processor->config['mappings'];
if ($raw) {
$xml = new SimpleXMLElement($raw);
// Treat * as normal iterator to improve performance.
if ($xpath == '*') {
$nodes = $xml;
}
else {
$nodes = $xml
->xpath($xpath);
}
foreach ($nodes as $node) {
Frx::Data()
->push($node, 'row');
$item = array();
foreach ($mappings as $field) {
$text = $field['source'];
$item[$text] = $parser
->render($text, !$format);
}
$result->items[] = $item;
Frx::Data()
->pop();
}
}
// Create a result object and return it.
return $result;
}
/**
* Define default configuration.
*/
public function configDefaults() {
return array(
'xpath' => '*',
'options' => '',
);
}
/**
* Build configuration form.
*/
public function configForm(&$form_state) {
$form = array();
$form['xpath'] = array(
'#type' => 'textfield',
'#title' => t('Default XPath Expression'),
'#description' => t('Specify an xpath expression that will be used to break up the data into feed items. When in doubt use * '),
'#default_value' => $this->config['xpath'],
);
$form['options'] = array(
'#type' => 'textarea',
'#title' => t('Default Formatting Option '),
'#description' => t('Specify the field configuration options to be used when specifying the data. The format
used is the same as in .info files with falues for the FRX files. (e.g. fields[date_taken][format] = iso_date )'),
'#default_value' => $this->config['options'],
'#rows' => 20,
'#maxlength' => NULL,
'#required' => FALSE,
);
return $form;
}
/**
* {@inherit}
*/
public function getMappingSources() {
return FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FeedsForenaXMLParser:: |
public | function | Define default configuration. | |
FeedsForenaXMLParser:: |
public | function | Build configuration form. | |
FeedsForenaXMLParser:: |
public | function | {@inherit} | |
FeedsForenaXMLParser:: |
public | function | Implements FeedsParser::parse(). |