function chado_phylotree_load

2.x tripal_phylogeny.chado_node.inc chado_phylotree_load($nodes)
3.x tripal_phylogeny.chado_node.inc chado_phylotree_load($nodes)

Implements hook_load().

When a node is requested by the user this function is called to allow us to add auxiliary data to the node object.

Related topics

File

tripal_phylogeny/includes/tripal_phylogeny.chado_node.inc, line 625
Implements the phylotree node content type

Code

function chado_phylotree_load($nodes) {

  foreach ($nodes as $nid => $node) {

    $phylotree_id = chado_get_id_from_nid('phylotree', $nid);

    // If the nid does not have a matching record then skip this node.
    // this can happen with orphaned nodes.
    if (!$phylotree_id) {
      continue;
    }

    // Build the Chado variable for the phylotree.
    $values = array('phylotree_id' => $phylotree_id);
    $phylotree = chado_generate_var('phylotree', $values);
    $nodes[$nid]->phylotree = $phylotree;

    // Expand the comment field, chado_generate_var() omits it by default
    // because it is a large text field.
    $phylotree = chado_expand_var($phylotree, 'field', 'phylotree.comment');

    // Add non Chado information to the object. These variables are needed
    // for the edit/update forms.
    $phylotree->tripal_variables = new stdClass;
    $variables = tripal_get_node_variables($nid, 'phylotree_name_re');
    $phylotree->tripal_variables->phylotree_name_re = count($variables) > 0 ? $variables[0]->value : '';

    $variables = tripal_get_node_variables($nid, 'phylotree_use_uniquename');
    $phylotree->tripal_variables->phylotree_use_uniquename = count($variables) > 0 ? $variables[0]->value : '';

    $variables = tripal_get_node_variables($nid, 'phylotree_tree_file');
    $phylotree->tripal_variables->phylotree_tree_file = count($variables) > 0 ? $variables[0]->value : '';

    // Set the title for this node.
    $node->title = chado_get_node_title($node);
  }
}