function service_links_get_links in Service links 7.2
Same name and namespace in other branches
- 6.2 service_links.module \service_links_get_links()
Discover all available service links by invoking hook_service_links().
Parameters
$services: If NULL, will retrieve all service link information. If an array is passed, will only obtain information for the given keyed links.
$reset: Resets the Service Links cache.
Return value
An array containing information for all the requested services.
8 calls to service_links_get_links()
- service_links_admin_services in ./
service_links.admin.inc - Menu callback administration settings for services links list.
- service_links_displays_ds_fields_info in plugins/
service_links_displays.module - Implements hook_ds_fields_info().
- 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.
- service_links_service_links_content_type_edit_form in plugins/
content_types/ service_links.inc - The form to add or edit a service_links as content.
File
- ./
service_links.module, line 374 - Adds social network links to the content.
Code
function service_links_get_links($services = NULL, $reset = FALSE) {
$links =& drupal_static(__FUNCTION__, NULL);
if (!isset($links) || $reset) {
// Retrieve the links from the cache.
if (!$reset && ($cache = cache_get('service_links_get_links')) && !empty($cache->data)) {
$links = $cache->data;
}
else {
// Create the repository of links.
$links = array();
foreach (module_implements('service_links') as $module) {
$module_links = module_invoke($module, 'service_links');
foreach ($module_links as $name => $link) {
$link['module'] = $module;
$links[$name] = $link;
}
}
// Allow alteration of the links.
drupal_alter('service_links', $links);
// Save the links in the cache.
cache_set('service_links_get_links', $links);
}
}
// If desired, return only the wanted services.
if (isset($services)) {
// Detect a manual request and populate the array correctly.
if (is_numeric(key($services))) {
$services = array_combine($services, array_fill(0, count($services), 1));
}
// Provide only the services requested.
$services = array_merge($services, array_intersect_key($links, $services));
// Remove the unknown services.
$services = service_links_array_filter($services);
}
return isset($services) ? $services : $links;
}