You are here

function location_node_node_view in Location 7.4

Same name and namespace in other branches
  1. 7.3 location_node.module \location_node_node_view()

Implementation of hook_node_view().

File

./location_node.module, line 74
Associate locations with nodes.

Code

function location_node_node_view($node, $view_mode, $langcode) {

  // @@@TODO 7.x Switch to a pure "fields" approach?
  if (empty($node->locations)) {
    return;
  }

  // @@@TODO 7.x -- TEST THIS!
  if ($view_mode == 'rss') {
    $settings = variable_get('location_settings_node_' . $node->type, array());
    $mode = isset($settings['rss']['mode']) ? $settings['rss']['mode'] : 'simple';
    if ($mode == 'none') {
      return;
    }
    if (is_array($node->locations) && !empty($node->locations)) {
      require_once drupal_get_path('module', 'location') . '/location.georss.inc';
      $node->rss_namespaces += location_rss_namespaces($mode);
      foreach ($node->locations as $location) {
        if ($item = location_rss_item($location, $mode)) {
          $node->rss_elements[] = $item;
        }
      }
    }
  }
  else {

    // @@@TODO 7.x -- location_display_location is idiotic. KILL IT.
    if (variable_get('location_display_location', 1)) {
      $settings = variable_get('location_settings_node_' . $node->type, array());
      if (isset($settings['display']['teaser']) && isset($settings['display']['full'])) {
        if (isset($settings['display'][$view_mode]) && $settings['display'][$view_mode]) {
          $node->content['locations'] = location_display($settings, $node->locations);
        }
      }
    }
  }
}