Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
browserclass
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
browserclass
Commits
68a7b272
Commit
68a7b272
authored
13 years ago
by
Daniel Kalmar
Browse files
Options
Downloads
Plain Diff
Merge branch 'token'
parents
f8bea45c
a46661d5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
browserclass.tokens.inc
+139
-0
139 additions, 0 deletions
browserclass.tokens.inc
with
139 additions
and
0 deletions
browserclass.tokens.inc
0 → 100644
+
139
−
0
View file @
68a7b272
<?php
/**
* @file
* Builds placeholder replacement tokens for browser-related data.
*/
/**
* Implementation of hook_token_info()
*
* @param type $info
*/
function
browserclass_token_info
()
{
$browserclass
=
array
();
$types
[
'browserclass'
]
=
array
(
'name'
=>
t
(
'Browser classes'
),
'description'
=>
t
(
'Token for browser class.'
),
);
//Tokens for browser classes token type.
$browserclass
[
'browser-classes'
]
=
array
(
'name'
=>
t
(
'Browser classes'
),
'description'
=>
t
(
'The current user\'s browser classes.'
),
);
$browserclass
[
'browser'
]
=
array
(
'name'
=>
t
(
'Browser'
),
'description'
=>
t
(
'Type of the browser.'
),
);
$browserclass
[
'platform'
]
=
array
(
'name'
=>
t
(
'Platform'
),
'description'
=>
t
(
'Type of the platform.'
),
);
$browserclass
[
'device'
]
=
array
(
'name'
=>
t
(
'Device'
),
'description'
=>
t
(
'Device info.'
),
);
$browserclass
[
'hook-classes'
]
=
array
(
'name'
=>
t
(
'Extra classes'
),
'description'
=>
t
(
'Extra hook classes.'
),
);
//User tokens.
$user
[
'browserclass'
]
=
array
(
'name'
=>
t
(
'Browser classes'
),
'description'
=>
t
(
'The current user\'s browser classes.'
),
'type'
=>
'browserclass'
,
);
//Site information tokens.
$site
[
'browserclass'
]
=
array
(
'name'
=>
t
(
'Browser classes'
),
'description'
=>
t
(
'The current user\'s browser classes.'
),
'type'
=>
'browserclass'
,
);
return
array
(
'types'
=>
$types
,
'tokens'
=>
array
(
'browserclass'
=>
$browserclass
,
'user'
=>
$user
,
'site'
=>
$site
,
),
);
}
/**
* Implementation of hook_tokens()
*
* @param type $type
* @param type $tokens
* @param type $data
* @param type $options
* @return type
*/
function
browserclass_tokens
(
$type
,
$tokens
,
$data
,
$options
)
{
$replacements
=
array
();
//Browser class tokens.
if
(
$type
==
'browserclass'
)
{
foreach
(
$tokens
as
$name
=>
$original
)
{
switch
(
$name
)
{
case
'browser-classes'
:
$browser_classes
=
implode
(
' '
,
browserclass_get_classes
());
$replacements
[
$original
]
=
check_plain
(
$browser_classes
);
break
;
case
'browser'
:
$browser
=
implode
(
' '
,
browserclass_get_classes
(
BROWSERCLASS_BROWSER
));
$replacements
[
$original
]
=
check_plain
(
$browser
);
break
;
case
'platform'
:
$platform
=
implode
(
' '
,
browserclass_get_classes
(
BROWSERCLASS_PLATFORM
));
$replacements
[
$original
]
=
check_plain
(
$platform
);
break
;
case
'device'
:
$device
=
implode
(
' '
,
browserclass_get_classes
(
BROWSERCLASS_MOBILE
));
$replacements
[
$original
]
=
check_plain
(
$device
);
break
;
case
'hook-classes'
:
$hook_classes
=
implode
(
' '
,
browserclass_get_classes
(
BROWSERCLASS_OTHER_CLASSES
));
$replacements
[
$original
]
=
check_plain
(
$hook_classes
);
break
;
}
}
}
//User tokens.
if
(
$type
==
'user'
)
{
foreach
(
$tokens
as
$name
=>
$original
)
{
switch
(
$name
)
{
case
'browserclass'
:
$browser_classes
=
implode
(
' '
,
browserclass_get_classes
());
$replacements
[
$original
]
=
check_plain
(
$browser_classes
);
break
;
}
}
// Chained token relationships.
if
(
$browserclass_tokens
=
token_find_with_prefix
(
$tokens
,
'browserclass'
))
{
$replacements
+=
token_generate
(
'browserclass'
,
$browserclass_tokens
,
array
(),
$options
);
}
}
//Site information tokens.
if
(
$type
==
'site'
)
{
foreach
(
$tokens
as
$name
=>
$original
)
{
switch
(
$name
)
{
case
'browserclass'
:
$browser_classes
=
implode
(
' '
,
browserclass_get_classes
());
$replacements
[
$original
]
=
check_plain
(
$browser_classes
);
break
;
}
}
// Chained token relationships.
if
(
$browserclass_tokens
=
token_find_with_prefix
(
$tokens
,
'browserclass'
))
{
$replacements
+=
token_generate
(
'browserclass'
,
$browserclass_tokens
,
array
(),
$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