You are here

function addtoany_node_view in AddToAny Share Buttons 5.0

Same name and namespace in other branches
  1. 7.4 addtoany.module \addtoany_node_view()
  2. 7 addtoany.module \addtoany_node_view()
  3. 7.3 addtoany.module \addtoany_node_view()

Implementation of hook_node_view().

File

./addtoany.module, line 27
Stand alone module file to handle AddToAny button integration

Code

function addtoany_node_view($node, $view_mode) {
  $links = array();
  $types = variable_get('addtoany_nodetypes', array());
  $teaser = $view_mode == 'teaser' ? TRUE : FALSE;
  $show = !empty($types[$node->type]) && ($teaser && variable_get('addtoany_display_in_teasers', '1') != 0 || !$teaser && variable_get('addtoany_display_in_nodelink', '1') != 0);
  if ($show && user_access('view addtoany')) {
    $links['addtoany'] = array(
      'title' => _addtoany_create_button($node, $teaser),
      'html' => TRUE,
    );
    $node->content['links']['addtoany'] = array(
      '#theme' => 'links',
      '#links' => $links,
      '#attributes' => array(
        'class' => array(
          'links',
          'inline',
        ),
      ),
    );
  }
  $show = !empty($types[$node->type]) && variable_get('addtoany_display_in_nodecont', '0');
  $weight = variable_get('addtoany_display_weight', 40);
  if ($show && user_access('view addtoany')) {
    $node->content['addtoany'] = array(
      '#value' => _addtoany_create_button($node, FALSE),
      '#weight' => $weight,
    );
  }
}