You are here

function _weight_get_weight in Weight 7.2

Get the weight of a node.

3 calls to _weight_get_weight()
weight_node_load in ./weight.module
Implements hook_node_load().
weight_weight_property_get in ./weight.module
Entity API getter callback for the 'weight' property.
_weight_set_weight in ./weight.module
Set the weight of a node.

File

./weight.module, line 683

Code

function _weight_get_weight($node) {
  if (is_numeric($node)) {
    $nid = $node;
  }
  elseif (module_exists('translation') && $node->nid != $node->tnid) {
    $settings = _weight_get_settings($node->type);
    if (empty($settings)) {
      return FALSE;
    }
    if ($settings['sync_translations'] && $node->tnid != 0) {
      $nid = $node->tnid;
    }
    else {
      $nid = $node->nid;
    }
  }
  else {
    $nid = $node->nid;
  }
  $weight = db_query("SELECT weight FROM {weight_weights} WHERE entity_id=:id AND entity_type=:type", array(
    ':id' => $nid,
    ':type' => 'node',
  ))
    ->fetchField();
  return $weight;
}