Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
feeds_xpathparser
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
feeds_xpathparser
Commits
c8c99e9b
Commit
c8c99e9b
authored
14 years ago
by
Chris Leppanen
Browse files
Options
Downloads
Patches
Plain Diff
Fixed an error message. Suppress XPath warnings.
parent
2050672c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
FeedsXPathParser.inc
+6
-23
6 additions, 23 deletions
FeedsXPathParser.inc
feeds_xpathparser.module
+2
-12
2 additions, 12 deletions
feeds_xpathparser.module
with
8 additions
and
35 deletions
FeedsXPathParser.inc
+
6
−
23
View file @
c8c99e9b
...
...
@@ -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.
*
*
S
olution is to keep track in the form how many have been added.
*
The s
olution 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
();
...
...
This diff is collapsed.
Click to expand it.
feeds_xpathparser.module
+
2
−
12
View file @
c8c99e9b
...
...
@@ -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'
=>
'Feeds
XPath
Parser
Base'
,
// 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'
=>
'Feeds
XPath
Parser
Base'
,
// A plugin needs to derive either directly or indirectly from FeedsFetcher, FeedsParser or FeedsProcessor.
'parent'
=>
'FeedsParser
'
,
'class'
=>
'FeedsXPathParserXML'
,
'file'
=>
'FeedsXPathParser.inc'
,
'path'
=>
$path
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment