Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
feeds
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal.org
feeds
Commits
cb7f5c66
Commit
cb7f5c66
authored
9 years ago
by
megachriz
Committed by
MegaChriz
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue #1891404 by MegaChriz, twistor, jenlampton: Add a mapper for Updated date (changed)
parent
a11c4504
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
feeds.module
+5
-0
5 additions, 0 deletions
feeds.module
plugins/FeedsNodeProcessor.inc
+10
-0
10 additions, 0 deletions
plugins/FeedsNodeProcessor.inc
tests/feeds_processor_node.test
+40
-0
40 additions, 0 deletions
tests/feeds_processor_node.test
with
55 additions
and
0 deletions
feeds.module
+
5
−
0
View file @
cb7f5c66
...
@@ -634,6 +634,11 @@ function feeds_node_presave($node) {
...
@@ -634,6 +634,11 @@ function feeds_node_presave($node) {
}
}
$last_title
=
NULL
;
$last_title
=
NULL
;
$last_feeds
=
NULL
;
$last_feeds
=
NULL
;
// Update "changed" value if there was mapped to that.
if
(
isset
(
$node
->
feeds_item
->
node_changed
))
{
$node
->
changed
=
$node
->
feeds_item
->
node_changed
;
}
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
plugins/FeedsNodeProcessor.inc
+
10
−
0
View file @
cb7f5c66
...
@@ -239,6 +239,12 @@ class FeedsNodeProcessor extends FeedsProcessor {
...
@@ -239,6 +239,12 @@ class FeedsNodeProcessor extends FeedsProcessor {
case
'created'
:
case
'created'
:
$target_node
->
created
=
feeds_to_unixtime
(
$value
,
REQUEST_TIME
);
$target_node
->
created
=
feeds_to_unixtime
(
$value
,
REQUEST_TIME
);
break
;
break
;
case
'changed'
:
// The 'changed' value will be set on the node in feeds_node_presave().
// This is because node_save() always overwrites this value (though
// before invoking hook_node_presave()).
$target_node
->
feeds_item
->
node_changed
=
feeds_to_unixtime
(
$value
,
REQUEST_TIME
);
break
;
case
'feeds_source'
:
case
'feeds_source'
:
// Get the class of the feed node importer's fetcher and set the source
// Get the class of the feed node importer's fetcher and set the source
// property. See feeds_node_update() how $node->feeds gets stored.
// property. See feeds_node_update() how $node->feeds gets stored.
...
@@ -305,6 +311,10 @@ class FeedsNodeProcessor extends FeedsProcessor {
...
@@ -305,6 +311,10 @@ class FeedsNodeProcessor extends FeedsProcessor {
'name'
=>
t
(
'Published date'
),
'name'
=>
t
(
'Published date'
),
'description'
=>
t
(
'The UNIX time when a node has been published.'
),
'description'
=>
t
(
'The UNIX time when a node has been published.'
),
);
);
$targets
[
'changed'
]
=
array
(
'name'
=>
t
(
'Updated date'
),
'description'
=>
t
(
'The Unix timestamp when a node has been last updated.'
),
);
$targets
[
'promote'
]
=
array
(
$targets
[
'promote'
]
=
array
(
'name'
=>
t
(
'Promoted to front page'
),
'name'
=>
t
(
'Promoted to front page'
),
'description'
=>
t
(
'Boolean value, whether or not node is promoted to front page. (1 = promoted, 0 = not promoted)'
),
'description'
=>
t
(
'Boolean value, whether or not node is promoted to front page. (1 = promoted, 0 = not promoted)'
),
...
...
This diff is collapsed.
Click to expand it.
tests/feeds_processor_node.test
+
40
−
0
View file @
cb7f5c66
...
@@ -656,6 +656,46 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase {
...
@@ -656,6 +656,46 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase {
$this
->
assertNoText
(
'Updated 2 nodes.'
);
$this
->
assertNoText
(
'Updated 2 nodes.'
);
}
}
/**
* Tests if the target "changed" works as expected.
*/
public
function
testChangedTarget
()
{
// Create and configure importer.
$this
->
createImporterConfiguration
(
'Content CSV'
,
'csv'
);
$this
->
setSettings
(
'csv'
,
NULL
,
array
(
'content_type'
=>
''
,
'import_period'
=>
FEEDS_SCHEDULE_NEVER
));
$this
->
setPlugin
(
'csv'
,
'FeedsFileFetcher'
);
$this
->
setPlugin
(
'csv'
,
'FeedsCSVParser'
);
$this
->
addMappings
(
'csv'
,
array
(
0
=>
array
(
'source'
=>
'title'
,
'target'
=>
'title'
,
),
// Borrow the timestamp value from the "created" column in the csv.
1
=>
array
(
'source'
=>
'created'
,
'target'
=>
'changed'
,
),
));
// Import CSV file.
$this
->
importFile
(
'csv'
,
$this
->
absolutePath
()
.
'/tests/feeds/content.csv'
);
$this
->
assertText
(
'Created 2 nodes'
);
// Assert changed date of nodes.
$expected_values
=
array
(
1
=>
array
(
'changed'
=>
1251936720
,
),
2
=>
array
(
'changed'
=>
1251932360
,
),
);
for
(
$i
=
1
;
$i
<=
2
;
$i
++
)
{
$node
=
node_load
(
$i
);
$this
->
assertEqual
(
$expected_values
[
$i
][
'changed'
],
$node
->
changed
);
}
}
/**
/**
* Tests the FeedsSource::pushImport() method.
* Tests the FeedsSource::pushImport() method.
*/
*/
...
...
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