function theme_tripal_library_node_libraries
1.x tripal_library.module | theme_tripal_library_node_libraries($node) |
This function shows library information on an organism/feature node
Related topics
File
- tripal_library/
tripal_library.module, line 329
Code
function theme_tripal_library_node_libraries($node) {
$content = "";
// Show library information in a expandable box for a organism page.
// Make sure we have $node->organism_id. In the case of creating a new
// organism, the organism_id is not created until we save. This will cause
// an error when users preview the creation without a $node->organism_id
if ($node->type == 'chado_organism' && $node->organism_id) {
$box_status = variable_get("tripal_library-box-libraries", "menu_off");
if (strcmp($box_status, "menu_off") == 0) {
return get_tripal_library_organism_libraries($node->nid);
}
}
// Provide library names to show in a feature page.
// Make sure we have $node->feature->feature_id or there will be an error
// when a feature is previewed at its creation
elseif ($node->type == 'chado_feature' && $node->feature->feature_id) {
$organism_id = $node->feature->organism_id;
$sql = "SELECT * FROM {library} L " .
" INNER JOIN Library_feature LF ON L.library_id = LF.library_id " .
"WHERE LF.feature_id = " . $node->feature->feature_id;
$libraries = array();
$results = chado_query($sql);
while ($library = db_fetch_object($results)) {
$libraries[] = $library;
}
if (count($libraries) > 0) {
$lib_additions = array();
foreach ($libraries as $library) {
$sql = "SELECT nid FROM {chado_library} WHERE library_id = %d";
$lib_nid = db_result(db_query($sql, $library->library_id));
if ($lib_nid) {
$lib_url = url("node/$lib_nid");
}
$lib_additions[$lib_url] = $library->name;
}
$node->lib_additions = $lib_additions;
}
}
return $content;
}