function tripal_feature_nodeapi
1.x tripal_feature.module | tripal_feature_nodeapi(&$node, $op, $teaser, $page) |
Display feature information for associated organisms. This function also provides contents for indexing
Related topics
File
- tripal_feature/
tripal_feature.module, line 1842 - @todo Add file header description
Code
function tripal_feature_nodeapi(&$node, $op, $teaser, $page) {
switch ($op) {
// set the title to ensure it is always unique
case 'presave':
switch ($node->type) {
case 'chado_feature':
$values = array('organism_id' => $node->organism_id);
$organism = tripal_core_chado_select('organism', array('genus', 'species'), $values);
$node->title = $node->fname . ', ' . $node->uniquename . ' (' . $node->feature_type . ') ' . $organism[0]->genus . ' ' . $organism[0]->species;
break;
}
break;
// set the URL path after inserting. We do it here because we do not
// know the feature_id in the presave
case 'insert':
switch ($node->type) {
case 'chado_feature':
if (!$node->feature_id) {
$sql = "SELECT * FROM {chado_feature} WHERE nid = %d";
$chado_feature = db_fetch_object(db_query($sql, $node->nid));
$node->feature_id = $chado_feature->feature_id;
}
// remove any previous alias
db_query("DELETE FROM {url_alias} WHERE src = '%s'", "node/$node->nid");
// set the URL for this feature page
$url_alias = tripal_feature_get_feature_url($node);
path_set_alias("node/$node->nid", $url_alias);
break;
}
break;
// set the URL path after inserting. We do it here because we do not
// know the feature_id in the presave
case 'update':
switch ($node->type) {
case 'chado_feature':
// remove any previous alias
db_query("DELETE FROM {url_alias} WHERE src = '%s'", "node/$node->nid");
// set the URL for this feature page
$url_alias = tripal_feature_get_feature_url($node);
path_set_alias("node/$node->nid", $url_alias);
break;
}
break;
// add items to other nodes, build index and search results
case 'view':
switch ($node->type) {
case 'chado_organism':
// Show feature browser
$types_to_show = array('chado_organism', 'chado_library');
if (in_array($node->type, $types_to_show, TRUE)) {
$node->content['tripal_organism_feature_counts'] = array(
'#value' => theme('tripal_organism_feature_counts', $node),
);
$node->content['tripal_organism_feature_browser'] = array(
'#value' => theme('tripal_organism_feature_browser', $node),
);
}
break;
}
break;
}
}