function socialmedia_token_info in Social media 7
@file Token processing for social media
File
- ./
socialmedia.tokens.inc, line 8 - Token processing for social media
Code
function socialmedia_token_info() {
$type = array(
'name' => t('Social media'),
'description' => t('Tokens related to social media sites.'),
);
$tokens = array(
'socialmedia' => array(),
'site' => array(),
'user' => array(),
'current-page' => array(),
);
$profiles = socialmedia_platform_definitions();
foreach ($profiles as $platform => $data) {
if (is_array($data['tokens'])) {
foreach ($data['tokens'] as $ttype => $tdata) {
if ($ttype == 'multi') {
foreach ($tdata as $key => $ttdata) {
$tokens['socialmedia']['sm-' . $key] = $ttdata;
$tokens['site']['sm-' . $key] = $ttdata;
$tokens['user']['sm-' . $key] = $ttdata;
}
}
else {
foreach ($tdata as $key => $ttdata) {
$tokens[$ttype]['sm-' . $key] = $ttdata;
}
}
}
}
}
/*
// Core tokens for nodes.
$socialmedia['twitter_profile_url'] = array(
'name' => t("Twitter profile url"),
'description' => t("URL to twitter profile."),
);
*/
$platforms = socialmedia_icon_platforms();
foreach ($platforms as $platform => $name) {
$tokens['socialmedia']['sm-' . $platform . '_icon-path:?'] = array(
'name' => t('@platform icon path', array(
'@platform' => $name,
)),
'description' => t("The path to the @platform icon", array(
'@platform' => $name,
)),
);
}
$defaults = array(
'width' => t('Default width'),
'height' => t('Default height'),
'color_body_background' => t('Default body background color'),
'color_body_background' => t('Default body background color'),
'color_body_text' => t('Default body text color'),
'color_body_linktext' => t('Default body linktext color'),
'color_header_background' => t('Default header background color'),
'color_header_text' => t('Default header text color'),
'color_border' => t('Default border color'),
'link_target_profile' => t('Default target attribute for profile links'),
'link_target_sharing' => t('Default target attribute for sharing links'),
'link_rel_profile' => t('Default rel attribute for profile links'),
'link_rel_sharing' => t('Default rel attribute for sharing links'),
'link_class_profile' => t('Default class attribute for profile links'),
'link_class_sharing' => t('Default class attribute for sharing links'),
);
foreach ($defaults as $key => $value) {
$tokens['socialmedia']['sm-default-' . $key] = array(
'name' => $value,
'description' => $value . ' ' . t('values set in social media config.'),
);
}
$tokens['current-page']['title-plain'] = array(
'name' => t('The plain title of the current page.'),
'description' => t('The title of the current page stripped of HTML'),
);
$info = array(
'types' => array(
'socialmedia' => $type,
),
'tokens' => array(
'socialmedia' => $tokens['socialmedia'],
//'usersite' => $tokens['usersite'],
'site' => $tokens['site'],
'user' => $tokens['user'],
'current-page' => $tokens['current-page'],
),
);
return $info;
}