function _service_links_render in Service links 7.2
Same name and namespace in other branches
- 6.2 service_links.module \_service_links_render()
The common render function used privately.
3 calls to _service_links_render()
- panel_service_links_render in plugins/
content_types/ service_links.inc - Helper function to render the output of the pane.
- service_links_render in ./
service_links.module - Function that render all the selected services.
- service_links_render_some in ./
service_links.module - This function render only the services requested by their id.
File
- ./
service_links.module, line 573 - Adds social network links to the content.
Code
function _service_links_render($service_id, $service, $settings, $nodelink, $node = NULL) {
if (isset($service['preset'])) {
if (function_exists($function = $service['preset'])) {
$function($service, $settings, $node);
}
}
// On Drupal 7 this tag should be filled before the split otherwise will be lost.
$service['link'] = str_replace('<front-page>', $settings['subst']['front-page'], $service['link']);
if (strpos($service['link'], '=') === FALSE) {
$service['url'] = array(
$service['link'],
);
}
else {
$service['url'] = preg_split('/\\?/', $service['link']);
}
if (count($service['url']) > 1) {
$service['url'][1] = service_links_get_query($service['url'][1]);
$service['url'][1] = str_replace($settings['tag'], $settings['subst'], $service['url'][1]);
}
else {
$service['url'][0] = str_replace($settings['tag'], $settings['subst'], $service['url'][0]);
}
$service['attributes']['title'] = t($service['description']);
$class = str_replace(array(
'][',
'_',
' ',
), '-', 'service_links-' . $service_id);
$service['attributes']['class'] = isset($service['attributes']['class']) ? array_merge($service['attributes']['class'], array(
$class,
)) : array(
$class,
);
$service['attributes'] += $settings['attributes'];
$service['icon'] = isset($service['icon']) ? $service['icon'] : "{$service_id}.png";
$service_id = str_replace('_', '-', 'service_links_' . $service_id);
// Check if a predefined style should be imposed.
if (empty($service['style'])) {
$service['style'] = $settings['style'];
}
// Add the related JavaScript and CSS.
if (isset($service['javascript'])) {
_service_links_add_js($service['javascript']);
}
if (isset($service['css'])) {
drupal_add_css(service_links_expand_path($service['css'], 'css'));
}
// Invoke callback function.
if (isset($service['callback'])) {
if (function_exists($function = $service['callback'])) {
$function($service, $settings['subst']);
}
}
// Create the HTML.
$link = theme('service_links_build_link', array(
'text' => t($service['name']),
'url' => $service['url'],
'image' => $service['icon'],
'nodelink' => $nodelink,
'style' => $service['style'],
'attributes' => $service['attributes'],
));
return array(
$service_id => $link,
);
}