function chado_stock_load
2.x tripal_stock.chado_node.inc | chado_stock_load($nodes) |
3.x tripal_stock.chado_node.inc | chado_stock_load( |
1.x tripal_stock.module | chado_stock_load($node) |
Implements hook_load(): Prepares the chado_stock node
Parameters
$node: The basic node containing all variables common to all nodes
Return value
A stock node containing all the variables from the basic node and all stock specific variables
Related topics
File
- tripal_stock/
tripal_stock.module, line 357 - Implements Tripal Stock Module hooks
Code
function chado_stock_load($node) {
// get the stock details from chado
$stock_id = chado_get_id_for_node('stock', $node);
// build the variable with all the stock details
$values = array('stock_id' => $stock_id);
$stock = tripal_core_generate_chado_var('stock', $values);
// by default, the titles are saved using the unique constraint. We will
// keep it the same, but remove the duplicate name if the unique name and name
// are identical
$title_type = variable_get('chado_stock_title', 'unique_constraint');
if ($title_type == 'unique_constraint') {
if (strcmp($stock->name, $stock->uniquename) == 0) {
$node->title = $stock->name . " (" . $stock->type_id->name . ") " . $stock->organism_id->genus . " " . $stock->organism_id->species;
}
// in previous version of Tripal, the stock title was simply the unique name.
// so, we recreate the title just to be sure all of our stock pages are consistent
else {
$node->title = $stock->name . ", " . $stock->uniquename . " (" . $stock->type_id->name . ") " . $stock->organism_id->genus . " " . $stock->organism_id->species;
}
}
// set the title to be the stock name or uniquename as configured
if ($title_type == 'stock_name') {
$node->title = $stock->name;
}
if ($title_type == 'stock_unique_name') {
$node->title = $stock->uniquename;
}
// add this to the node
$additions = new stdClass();
$additions->stock = $stock;
return $additions;
}