You are here

function nd_nodeapi in Node displays 6.3

Same name and namespace in other branches
  1. 6 nd.module \nd_nodeapi()
  2. 6.2 nd.module \nd_nodeapi()

Implementation of hook_nodeapi().

File

./nd.module, line 129
Node displays.

Code

function nd_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  switch ($op) {

    // Add has body property.
    case 'load':
      $node->has_body = node_get_types('type', $node->type)->has_body;
      break;

    // Determine build mode.
    case 'view':
      if ($node->build_mode == NODE_BUILD_RSS) {

        // For the RSS build mode, we need to manipulate right now.
        _nd_nodeapi($node);
      }
      elseif ($node->build_mode == NODE_BUILD_PREVIEW) {
        $node->build_mode = $teaser ? 'teaser' : 'full';
        $node->has_body = node_get_types('type', $node->type)->has_body;

        // Prepare taxonomy
        if (isset($node->taxonomy)) {
          foreach ($node->taxonomy as $tid => $term) {
            if (is_int($tid)) {
              $node->taxonomy[$tid] = db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = %d', $tid));
            }
          }
        }
      }
      elseif ($node->build_mode === NODE_BUILD_NORMAL) {
        $build_mode = $teaser ? 'teaser' : 'full';
        $node->build_mode = $build_mode;
      }
      drupal_alter('nd_build', $node);
      break;

    // Alter the node object for viewing.
    case 'alter':

      // We ignore the RSS build mode, which is handled in the view operation.
      if ($node->build_mode == NODE_BUILD_RSS) {
        return;
      }
      _nd_nodeapi($node);
      break;
  }
}