Skip to content
Snippets Groups Projects
Commit c8c99e9b authored by Chris Leppanen's avatar Chris Leppanen
Browse files

Fixed an error message. Suppress XPath warnings.

parent 2050672c
No related branches found
No related tags found
No related merge requests found
......@@ -73,10 +73,8 @@ class FeedsXPathParserBase extends FeedsParser {
}
}
// Perfom xpath query.
$results = $xml->xpath($query);
$results = @$xml->xpath($query);
// SimpleXMLElement::xpath doesn't throw warnings or raise exceptions on
// errors, it simply returns FALSE.
if ($results === FALSE) {
throw new Exception(t('There was an error with the XPath query: <em>%query</em>', array('%query' => $query)));
}
......@@ -90,7 +88,7 @@ class FeedsXPathParserBase extends FeedsParser {
* A SimpleXMLElement from the context array.
* @param $query
* An XPath query.
* @ $source
* @param $source
* The name of the source for this query.
* @return array
* An array containing the results of the query.
......@@ -100,10 +98,10 @@ class FeedsXPathParserBase extends FeedsParser {
return;
}
$results = $this->namespacedXPathQuery($item, $query);
unset($xml);
unset($item);
/**
* Iterate through the results of the xpath query. If this source is
* configured to return raw xml make it so.
* configured to return raw xml, make it so.
*/
foreach ($results as &$result) {
if (in_array($source, $this->rawXML)) {
......@@ -116,10 +114,7 @@ class FeedsXPathParserBase extends FeedsParser {
/**
* If their is one result, return it directly. If there is more than one,
* return the array. If there are no results return an empty string.
*
* @TODO: Determine if an empty string is appropriate. Add in some kind of check
* that makes the title only return one result (maybe).
* return the array.
*/
$count = count($results);
if ($count == 1) {
......@@ -176,9 +171,6 @@ class FeedsXPathParserBase extends FeedsParser {
);
$form['sources']['help']['#value'] = '<div class="help">' . theme('item_list', $items) . '</div>';
}
else {
$form['sources']['help']['#value'] = '<div class="help">It is <strong>strongly</strong> recommended that you select at least one unique target.</div>';
}
foreach ($mappings as $source => $target) {
$form['sources'][$source] = array(
......@@ -286,15 +278,6 @@ class FeedsXPathParserHTML extends FeedsXPathParserBase {
unset($dom);
$batch->setItems($this->query($xml));
}
/**
* Source form.
*/
public function sourceForm($source_config) {
$form = parent::sourceForm($source_config);
return $form;
}
}
class FeedsXPathParserXML extends FeedsXPathParserBase {
......@@ -327,7 +310,7 @@ class FeedsXPathParserXML extends FeedsXPathParserBase {
* but we have no idea how many to create with getMappingSources() because we
* don't know how many targets there are going to be.
*
* Solution is to keep track in the form how many have been added.
* The solution is to keep track in the form how many have been added.
*/
function feeds_xpathparser_form_feeds_ui_mapping_form_alter($form, &$form_state) {
$newest_xpath_mapping = array();
......
......@@ -8,21 +8,11 @@ function feeds_xpathparser_feeds_plugins() {
$path = drupal_get_path('module', 'feeds_xpathparser');
$info = array();
$info['FeedsXPathParserBase'] = array(
'hidden' => TRUE,
'handler' => array(
'parent' => 'FeedsParser', // A plugin needs to derive either directly or indirectly from FeedsFetcher, FeedsParser or FeedsProcessor.
'class' => 'FeedsXPathParserBase',
'file' => 'FeedsXPathParser.inc',
'path' => $path,
),
);
$info['FeedsXPathParserHTML'] = array(
'name' => t('XPath HTML parser'),
'description' => t('Parse HTML using XPath.'),
'handler' => array(
'parent' => 'FeedsXPathParserBase', // A plugin needs to derive either directly or indirectly from FeedsFetcher, FeedsParser or FeedsProcessor.
'parent' => 'FeedsParser',
'class' => 'FeedsXPathParserHTML',
'file' => 'FeedsXPathParser.inc',
'path' => $path,
......@@ -33,7 +23,7 @@ function feeds_xpathparser_feeds_plugins() {
'name' => t('XPath XML parser'),
'description' => t('Parse XML using XPath.'),
'handler' => array(
'parent' => 'FeedsXPathParserBase', // A plugin needs to derive either directly or indirectly from FeedsFetcher, FeedsParser or FeedsProcessor.
'parent' => 'FeedsParser',
'class' => 'FeedsXPathParserXML',
'file' => 'FeedsXPathParser.inc',
'path' => $path,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment