Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
domain-3264896
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Issue forks
domain-3264896
Commits
ed3701d3
Commit
ed3701d3
authored
13 years ago
by
Dave Reid
Committed by
Ken Rickard
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Feature
#1300596
. Provide additional domain tokens.
parent
33fe84be
No related branches found
Branches containing commit
Tags
7.x-3.0-rc3
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
domain.tokens.inc
+38
-5
38 additions, 5 deletions
domain.tokens.inc
with
38 additions
and
5 deletions
domain.tokens.inc
+
38
−
5
View file @
ed3701d3
...
...
@@ -47,11 +47,21 @@ function domain_token_info() {
'name'
=>
t
(
'Domain URL'
),
'description'
=>
t
(
'The domain\'s URL, lower-cased and with only alphanumeric characters.'
),
);
$info
[
'tokens'
][
'domain'
][
'hostname'
]
=
array
(
'name'
=>
t
(
'Domain hostname'
),
'description'
=>
t
(
'The domain hostname.'
),
);
$info
[
'tokens'
][
'domain'
][
'subdomain'
]
=
array
(
'name'
=>
t
(
'Subdomain'
),
'description'
=>
t
(
'The subdomain, lower-cased and with only alphanumeric characters. Only works with *.example.com formats'
),
);
$info
[
'tokens'
][
'node'
][
'domain'
]
=
array
(
'name'
=>
t
(
'Domain information'
),
'description'
=>
t
(
'The domain associated with this content.'
),
'type'
=>
'domain'
,
);
return
$info
;
}
...
...
@@ -61,7 +71,7 @@ function domain_token_info() {
function
domain_tokens
(
$type
,
$tokens
,
array
$data
=
array
(),
array
$options
=
array
())
{
$sanitize
=
!
empty
(
$options
[
'sanitize'
]);
$replacements
=
array
();
// Base token handling.
if
(
$type
==
'domain'
&&
!
empty
(
$data
[
'domain'
]))
{
$domain
=
$data
[
'domain'
];
...
...
@@ -97,16 +107,39 @@ function domain_tokens($type, $tokens, array $data = array(), array $options = a
$subdomain
=
domain_url_encode
(
$subdomain
);
$replacements
[
$original
]
=
$sanitize
?
check_plain
(
$subdomain
)
:
$subdomain
;
break
;
case
'hostname'
:
$subdomain
=
$domain
[
'subdomain'
];
$replacements
[
$original
]
=
$sanitize
?
check_plain
(
$subdomain
)
:
$subdomain
;
break
;
}
}
}
if
(
$type
==
'current-domain'
)
{
// Node tokens.
if
(
$type
==
'node'
&&
!
empty
(
$data
[
'node'
]))
{
$domain
=
domain_get_node_match
(
$data
[
'node'
]
->
nid
);
$node
=
$data
[
'node'
];
// Check for valid domain data.
$domain
=
domain_get_node_match
(
$node
->
nid
);
if
(
$domain
==
-
1
)
{
return
;
}
// Loop through the tokens to not waste cycles.
foreach
(
$tokens
as
$name
=>
$original
)
{
if
(
$name
==
'domain'
)
{
$replacements
[
$original
]
=
$sanitize
?
check_plain
(
$domain
[
'subdomain'
])
:
$domain
[
'subdomain'
];
}
}
if
(
$domain_tokens
=
token_find_with_prefix
(
$tokens
,
'domain'
))
{
$replacements
+=
token_generate
(
'domain'
,
$domain_tokens
,
array
(
'domain'
=>
$domain
),
$options
);
}
}
// Current domain tokens.
elseif
(
$type
==
'current-domain'
)
{
$current_domain
=
domain_get_domain
();
$replacements
+=
token_generate
(
'domain'
,
$tokens
,
array
(
'domain'
=>
$current_domain
),
$options
);
}
if
(
$type
==
'default-domain'
)
{
// Default domain tokens.
else
if
(
$type
==
'default-domain'
)
{
$default_domain
=
domain_default
(
FALSE
);
$replacements
+=
token_generate
(
'domain'
,
$tokens
,
array
(
'domain'
=>
$default_domain
),
$options
);
}
...
...
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