function sharerich_node_view in Sharerich 7.2
Same name and namespace in other branches
- 7.3 sharerich.module \sharerich_node_view()
- 7 sharerich.module \sharerich_node_view()
Implements hook_node_view().
File
- ./
sharerich.module, line 395
Code
function sharerich_node_view($node, $view_mode, $langcode) {
$extra = sharerich_field_extra_fields(0, $node->type);
// Check that we're supporting the node type being viewed.
if (empty($extra)) {
return;
}
// Get current configuration for the node type.
$config = field_bundle_settings('node', $node->type);
// Fall back to default view mode if custom settings are disabled.
$view_mode_compat = isset($config['view_modes'][$view_mode]) && $config['view_modes'][$view_mode]['custom_settings'] ? $view_mode : 'default';
foreach ($extra['node'][$node->type]['display'] as $sharerich_name => $default_instance) {
// Check if the specified button set is configured for that type.
if (!isset($config['extra_fields']['display'][$sharerich_name][$view_mode_compat]) || isset($config['extra_fields']['display'][$sharerich_name][$view_mode_compat]) && empty($config['extra_fields']['display'][$sharerich_name][$view_mode_compat]['settings']['sharerich_sets'])) {
continue;
}
$machinename = $config['extra_fields']['display'][$sharerich_name][$view_mode_compat]['settings']['sharerich_sets'];
// Only add the set if it is visible and the button set can be loaded.
$visible = $config['extra_fields']['display'][$sharerich_name][$view_mode_compat]['visible'];
if ($visible && ($sharerich_set = sharerich_set_load($machinename))) {
if ($buttons = sharerich_get_buttons($sharerich_set, $node, $machinename)) {
$node->content[$sharerich_name] = $buttons;
$node->content[$sharerich_name]['attributes_array'] = array(
'class' => array(
drupal_html_class($sharerich_name),
),
);
}
}
}
}