You are here

function google_plusone_nodeapi in Google Plus One Button | Google+ Badge 6

Implements hook_nodeapi().

File

./google_plusone.module, line 57

Code

function google_plusone_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  $node_types = variable_get('google_plusone_node_types', array());
  if ($op === 'view' && !empty($node_types[$node->type]) && user_access('view google plusone') && $node->build_mode === NODE_BUILD_NORMAL) {
    $locations = variable_get('google_plusone_node_location', array(
      'full',
    ));
    $view_mode = $a3 ? 'teaser' : 'full';
    if (!empty($locations[$view_mode]) && empty($locations['link'])) {
      $default = array(
        'annotation' => 'bubble',
        'width' => '250',
        'size' => '',
        // standard
        'css' => 'margin: 0 1em 1em 1em;float:right',
        'syntax' => 'HTML5',
        'alias' => 'aliased',
      );
      $button_settings = array_merge($default, variable_get('google_plusone_button_settings', array()));
      $button_settings['node'] = $node;
      $node->content['google_plusone'] = array(
        '#weight' => variable_get('google_plusone_weight', -5),
        '#value' => theme('google_plusone_button', $button_settings),
      );
    }
  }
}