You are here

function views_atom_guid in Views Atom 7

Same name and namespace in other branches
  1. 6 views_atom.module \views_atom_guid()

Generate a GUID for Atom feeds.

Parameters

$entity_type: The type of entity for which to generate a URI, such as "node" or "user".

$entity_id: The ID of the entity.

$options: An array of options, currently only use_existing_from_feed supported.

Return value

A unique string that identifies the specified entity.

2 calls to views_atom_guid()
template_preprocess_views_atom_fields_item in ./views_atom.theme.inc
Preprocess for theme('views_atom_fields_item').
template_preprocess_views_view_views_atom_delete in ./views_atom.theme.inc

File

./views_atom.module, line 108

Code

function views_atom_guid($entity_type, $entity_id, $options = array()) {

  // This is currently set to the absolute system path until a better UUID
  // system can be implemented
  $guid = url("{$entity_type}/{$entity_id}", array(
    'absolute' => TRUE,
    'alias' => TRUE,
    'purl' => array(
      'disabled' => TRUE,
    ),
    'language' => '',
  ));

  // See if there already exists a guid for this node if configured to.
  if (!empty($options['use_existing_from_feed']) && $entity_type == 'node' && module_exists('feeds')) {
    $temp_guid = db_query("SELECT guid FROM {feeds_node_item} WHERE nid = :nid", array(
      ':nid' => $entity_id,
    ))
      ->fetchField();
    if ($temp_guid) {
      $guid = $temp_guid;
    }
  }
  return $guid;
}