You are here

function xmlsitemap_node_get_timestamps in XML sitemap 6.2

Same name and namespace in other branches
  1. 7.2 xmlsitemap_node/xmlsitemap_node.module \xmlsitemap_node_get_timestamps()

Fetch all the timestamps for when a node was changed.

Parameters

$node: A node object.

Return value

An array of UNIX timestamp integers.

1 call to xmlsitemap_node_get_timestamps()
xmlsitemap_node_create_link in xmlsitemap_node/xmlsitemap_node.module
Create a sitemap link from a node.

File

xmlsitemap_node/xmlsitemap_node.module, line 177

Code

function xmlsitemap_node_get_timestamps(stdClass $node) {
  static $timestamps = array();
  if (!isset($timestamps[$node->nid])) {
    $query = db_query("SELECT nr.timestamp FROM {node_revisions} nr WHERE nr.nid = %d", $node->nid);
    $timestamps[$node->nid] = xmlsitemap_db_fetch_col($query);
    if (module_exists('comment')) {
      $query = db_query("SELECT c.timestamp FROM {comments} c WHERE c.nid = %d AND c.status = %d", $node->nid, COMMENT_PUBLISHED);
      $comment_timestamps = xmlsitemap_db_fetch_col($query);
      $timestamps[$node->nid] = array_merge($timestamps[$node->nid], $comment_timestamps);
    }
  }
  return $timestamps[$node->nid];
}