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
51600e96
Commit
51600e96
authored
13 years ago
by
Dave Reid
Browse files
Options
Downloads
Patches
Plain Diff
Issue #1032640: Added basic token integration.
parent
da8d974a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
feeds.tokens.inc
+52
-0
52 additions, 0 deletions
feeds.tokens.inc
with
52 additions
and
0 deletions
feeds.tokens.inc
0 → 100644
+
52
−
0
View file @
51600e96
<?php
/**
* @file
* Builds placeholder replacement tokens for feed-related data.
*/
/**
* Implements hook_token_info().
*/
function
feeds_token_info
()
{
// @todo This token could be for any entity type.
$info
[
'tokens'
][
'node'
][
'feed-source'
]
=
array
(
'name'
=>
t
(
'Feed source'
),
'description'
=>
t
(
'The node the feed item was sourced from.'
),
'type'
=>
'node'
,
);
return
$info
;
}
/**
* Implements hook_tokens().
*/
function
feeds_tokens
(
$type
,
$tokens
,
array
$data
,
array
$options
)
{
$replacements
=
array
();
$sanitize
=
!
empty
(
$options
[
'sanitize'
]);
if
(
$type
==
'node'
&&
!
empty
(
$data
[
'node'
]))
{
$node
=
$data
[
'node'
];
foreach
(
$tokens
as
$name
=>
$original
)
{
switch
(
$name
)
{
case
'feed-source'
:
if
(
!
empty
(
$node
->
feed_nid
)
&&
$feed_source
=
node_load
(
$node
->
feed_nid
))
{
$replacements
[
$original
]
=
$sanitize
?
check_plain
(
$feed_source
->
title
)
:
$feed_source
->
title
;
}
break
;
}
}
// Chained node token relationships.
if
(
$feed_source_tokens
=
token_find_with_prefix
(
$tokens
,
'feed-source'
))
{
if
(
!
empty
(
$node
->
feed_nid
)
&&
$feed_source
=
node_load
(
$node
->
feed_nid
))
{
$replacements
+=
token_generate
(
'node'
,
$feed_source_tokens
,
array
(
'node'
=>
$feed_source
),
$options
);
}
}
}
return
$replacements
;
}
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