You are here

function service_links_nodeapi in Service links 6.2

Same name and namespace in other branches
  1. 5 service_links.module \service_links_nodeapi()
  2. 6 service_links.module \service_links_nodeapi()

Implementation of hook_nodeapi().

File

./service_links.module, line 105
Adds social network links to the content.

Code

function service_links_nodeapi(&$node, $op, $teaser, $page) {
  switch ($op) {
    case 'view':
      if (arg(2) != 'edit' && service_links_show($node) && user_access('access service links')) {
        if ($node->build_mode == NODE_BUILD_RSS) {
          $node->service_links = service_links_render($node, FALSE);
          $node->service_links_rendered = theme('service_links_block_format', $node->service_links, SERVICE_LINKS_STYLE_IMAGE);
        }
        else {
          $node->service_links = service_links_render($node, TRUE);
          $node->service_links_rendered = theme('service_links_node_format', $node->service_links, variable_get('service_links_label_in_node', t('Bookmark/Search this post with')));
        }
        switch (variable_get('service_links_in_node', SERVICE_LINKS_DISABLED)) {
          case SERVICE_LINKS_IN_TEASER:
            if ($teaser) {
              $node->content['service_links'] = array(
                '#value' => $node->service_links_rendered,
                '#weight' => variable_get('service_links_weight_in_node', 10),
              );
            }
            break;
          case SERVICE_LINKS_IN_FULL:
            if ($page) {
              $node->content['service_links'] = array(
                '#value' => $node->service_links_rendered,
                '#weight' => variable_get('service_links_weight_in_node', 10),
              );
            }
            break;
          case SERVICE_LINKS_IN_BOTH:
            if ($teaser) {
              $node->content['service_links'] = array(
                '#value' => $node->service_links_rendered,
                '#weight' => variable_get('service_links_weight_in_node', 10),
              );
            }
            elseif ($page) {
              $node->content['service_links'] = array(
                '#value' => $node->service_links_rendered,
                '#weight' => variable_get('service_links_weight_in_node', 10),
              );
            }
            break;
        }
      }
      break;
  }
}