|
@@ -20,6 +20,7 @@ require_once "includes/fasta_loader.inc";
|
|
|
require_once "includes/gff_loader.inc";
|
|
|
require_once "includes/seq_extract.inc";
|
|
|
require_once "includes/tripal_feature-delete.inc";
|
|
|
+require_once "includes/tripal_feature.form.inc";
|
|
|
|
|
|
/**
|
|
|
*
|
|
@@ -206,7 +207,7 @@ function tripal_feature_menu() {
|
|
|
'type' => MENU_NORMAL_ITEM,
|
|
|
);
|
|
|
$items['admin/tripal/chado/tripal_feature/sync'] = array(
|
|
|
- 'title' => ' Sync',
|
|
|
+ 'title' => 'Sync',
|
|
|
'description' => 'Sync features from Chado with Drupal',
|
|
|
'page callback' => 'drupal_get_form',
|
|
|
'page arguments' => array('tripal_feature_sync_form'),
|
|
@@ -288,12 +289,14 @@ function tripal_feature_menu() {
|
|
|
* @ingroup tripal_feature
|
|
|
*/
|
|
|
function tripal_feature_theme($existing, $type, $theme, $path) {
|
|
|
- return array(
|
|
|
- 'tripal_feature_search_index' => array(
|
|
|
- 'variables' => array('node'),
|
|
|
- ),
|
|
|
- 'tripal_feature_search_results' => array(
|
|
|
- 'variables' => array('node'),
|
|
|
+ $core_path = drupal_get_path('module', 'tripal_core');
|
|
|
+
|
|
|
+ $items = array(
|
|
|
+ 'node__chado_feature' => array(
|
|
|
+ 'template' => 'node--chado-generic',
|
|
|
+ 'render element' => 'node',
|
|
|
+ 'base hook' => 'node',
|
|
|
+ 'path' => "$core_path/theme",
|
|
|
),
|
|
|
'tripal_organism_feature_browser' => array(
|
|
|
'variables' => array('node' => NULL),
|
|
@@ -306,56 +309,64 @@ function tripal_feature_theme($existing, $type, $theme, $path) {
|
|
|
'path' => "$path/theme/tripal_organism",
|
|
|
),
|
|
|
'tripal_feature_base' => array(
|
|
|
- 'variables' => array('node' => NULL),
|
|
|
- 'template' => 'tripal_feature_base',
|
|
|
+ 'variables' => array('node' => NULL),
|
|
|
+ 'template' => 'tripal_feature_base',
|
|
|
+ 'path' => "$path/theme/tripal_feature",
|
|
|
),
|
|
|
'tripal_feature_sequence' => array(
|
|
|
- 'variables' => array('node' => NULL),
|
|
|
- 'template' => 'tripal_feature_sequence',
|
|
|
+ 'variables' => array('node' => NULL),
|
|
|
+ 'template' => 'tripal_feature_sequence',
|
|
|
+ 'path' => "$path/theme/tripal_feature",
|
|
|
),
|
|
|
'tripal_feature_proteins' => array(
|
|
|
- 'variables' => array('node' => NULL),
|
|
|
- 'template' => 'tripal_feature_proteins',
|
|
|
+ 'variables' => array('node' => NULL),
|
|
|
+ 'template' => 'tripal_feature_proteins',
|
|
|
+ 'path' => "$path/theme/tripal_feature",
|
|
|
),
|
|
|
'tripal_feature_synonyms' => array(
|
|
|
- 'variables' => array('node' => NULL),
|
|
|
- 'template' => 'tripal_feature_synonyms',
|
|
|
+ 'variables' => array('node' => NULL),
|
|
|
+ 'template' => 'tripal_feature_synonyms',
|
|
|
+ 'path' => "$path/theme/tripal_feature",
|
|
|
),
|
|
|
'tripal_feature_phenotypes' => array(
|
|
|
- 'variables' => array('node' => NULL),
|
|
|
- 'template' => 'tripal_feature_phenotypes',
|
|
|
+ 'variables' => array('node' => NULL),
|
|
|
+ 'template' => 'tripal_feature_phenotypes',
|
|
|
+ 'path' => "$path/theme/tripal_feature",
|
|
|
),
|
|
|
'tripal_feature_featurepos' => array(
|
|
|
- 'arguments' => array('node' => NULL),
|
|
|
- 'template' => 'tripal_feature_featurepos',
|
|
|
+ 'arguments' => array('node' => NULL),
|
|
|
+ 'template' => 'tripal_feature_featurepos',
|
|
|
+ 'path' => "$path/theme/tripal_feature",
|
|
|
),
|
|
|
'tripal_feature_featureloc_sequences' => array(
|
|
|
- 'variables' => array('node' => NULL),
|
|
|
- 'template' => 'tripal_feature_featureloc_sequences',
|
|
|
+ 'variables' => array('node' => NULL),
|
|
|
+ 'template' => 'tripal_feature_featureloc_sequences',
|
|
|
+ 'path' => "$path/theme/tripal_feature",
|
|
|
),
|
|
|
'tripal_feature_references' => array(
|
|
|
- 'variables' => array('node' => NULL),
|
|
|
- 'template' => 'tripal_feature_references',
|
|
|
+ 'variables' => array('node' => NULL),
|
|
|
+ 'template' => 'tripal_feature_references',
|
|
|
+ 'path' => "$path/theme/tripal_feature",
|
|
|
),
|
|
|
'tripal_feature_properties' => array(
|
|
|
- 'variables' => array('node' => NULL),
|
|
|
- 'template' => 'tripal_feature_properties',
|
|
|
+ 'variables' => array('node' => NULL),
|
|
|
+ 'template' => 'tripal_feature_properties',
|
|
|
+ 'path' => "$path/theme/tripal_feature",
|
|
|
),
|
|
|
'tripal_feature_terms' => array(
|
|
|
- 'variables' => array('node' => NULL),
|
|
|
- 'template' => 'tripal_feature_terms',
|
|
|
+ 'variables' => array('node' => NULL),
|
|
|
+ 'template' => 'tripal_feature_terms',
|
|
|
+ 'path' => "$path/theme/tripal_feature",
|
|
|
),
|
|
|
'tripal_feature_alignments' => array(
|
|
|
- 'variables' => array('node' => NULL),
|
|
|
- 'template' => 'tripal_feature_alignments',
|
|
|
+ 'variables' => array('node' => NULL),
|
|
|
+ 'template' => 'tripal_feature_alignments',
|
|
|
+ 'path' => "$path/theme/tripal_feature",
|
|
|
),
|
|
|
'tripal_feature_relationships' => array(
|
|
|
- 'variables' => array('node' => NULL),
|
|
|
- 'template' => 'tripal_feature_relationships',
|
|
|
- ),
|
|
|
- 'tripal_feature_edit_ALL_properties_form' => array(
|
|
|
- 'arguments' => array('form' => NULL),
|
|
|
- 'function' => 'theme_tripal_feature_edit_ALL_properties_form',
|
|
|
+ 'variables' => array('node' => NULL),
|
|
|
+ 'template' => 'tripal_feature_relationships',
|
|
|
+ 'path' => "$path/theme/tripal_feature",
|
|
|
),
|
|
|
'tripal_feature_help' => array(
|
|
|
'template' => 'tripal_feature_help',
|
|
@@ -368,6 +379,8 @@ function tripal_feature_theme($existing, $type, $theme, $path) {
|
|
|
'arguments' => array('form'),
|
|
|
)
|
|
|
);
|
|
|
+
|
|
|
+ return $items;
|
|
|
}
|
|
|
/**
|
|
|
*
|
|
@@ -665,7 +678,8 @@ function chado_feature_add_synonyms($synonyms, $feature_id) {
|
|
|
// remove any old synonyms
|
|
|
$feature_syn_dsql = "DELETE FROM {feature_synonym} WHERE feature_id = :feature_id";
|
|
|
if (!chado_query($feature_syn_dsql, array(':feature_id' => $feature_id))) {
|
|
|
- $error .= "Could not remove synonyms from feature. ";
|
|
|
+ watchdog('tripal_feature', "Could not remove synonyms from feature. ", array(), WATCHDOG_ERROR);
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
// return if we don't have any synonmys to add
|
|
@@ -676,7 +690,8 @@ function chado_feature_add_synonyms($synonyms, $feature_id) {
|
|
|
foreach ($syn_array as $syn) {
|
|
|
// skip this item if it's empty
|
|
|
if (!$syn) {
|
|
|
- break; }
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
// check to see if we have this accession number already in the database
|
|
|
// if so then don't add it again. it messes up drupal if the insert fails.
|
|
@@ -688,13 +703,14 @@ function chado_feature_add_synonyms($synonyms, $feature_id) {
|
|
|
INSERT INTO {synonym} (name, synonym_sgml, type_id)
|
|
|
VALUES (:name, :synonym_sgml,
|
|
|
(SELECT cvterm_id
|
|
|
- FROM {CVTerm} CVT
|
|
|
- INNER JOIN CV ON CVT.cv_id = CV.cv_id
|
|
|
+ FROM {cvterm} CVT
|
|
|
+ INNER JOIN {cv} ON CVT.cv_id = CV.cv_id
|
|
|
WHERE CV.name = 'feature_property' and CVT.name = 'synonym')
|
|
|
)
|
|
|
";
|
|
|
if (!chado_query($synonym_isql, array(':name' => $syn, ':synonym_sgml' => $syn))) {
|
|
|
- $error .= "Could not add synonym. ";
|
|
|
+ watchdog('tripal_feature', "Could not add synonym. ", array(), WATCHDOG_WARNING);
|
|
|
+ return;
|
|
|
}
|
|
|
// now get the synonym we just added
|
|
|
$synonym_sql = "SELECT synonym_id FROM {synonym} WHERE name = :name";
|
|
@@ -707,13 +723,10 @@ function chado_feature_add_synonyms($synonyms, $feature_id) {
|
|
|
VALUES (:synonym_id, :feature_id, :pub_id)";
|
|
|
$args = array(':synonym_id' => $synonym->synonym_id, ':feature_id' => $feature_id, ':pub_id'=> 1);
|
|
|
if (!chado_query($feature_syn_isql, $args)) {
|
|
|
- $error .= "Could not add synonyms to feature. ";
|
|
|
+ watchdog('tripal_feature', "Could not associate synonym with feature. ", array(), WATCHDOG_WARNING);
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- // return to the drupal database
|
|
|
- return $error;
|
|
|
-
|
|
|
}
|
|
|
/**
|
|
|
*
|
|
@@ -773,265 +786,47 @@ function chado_feature_add_gbaccession($accession, $feature_id) {
|
|
|
return $error;
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- *
|
|
|
- *
|
|
|
- * @ingroup tripal_feature
|
|
|
- */
|
|
|
-function chado_feature_form($node, $param) {
|
|
|
-
|
|
|
- $form = array();
|
|
|
-
|
|
|
- $feature = $node->feature;
|
|
|
-
|
|
|
- // add the residues to the feature object
|
|
|
- $feature = tripal_core_expand_chado_vars($feature, 'field', 'feature.residues');
|
|
|
-
|
|
|
- // if the node has synonyms then use that as the form may be returning
|
|
|
- // from an error. Otherwise try to find synonyms from the database
|
|
|
- $synonyms = $node->synonyms;
|
|
|
- $feature = tripal_core_expand_chado_vars($feature, 'table', 'feature_synonym');
|
|
|
- $feature_synonyms = $feature->feature_synonym;
|
|
|
- if (!$synonyms) {
|
|
|
- if (!is_array($feature_synonyms)) {
|
|
|
- $synonyms = $feature_synonyms->synonym_id->name;
|
|
|
- }
|
|
|
- elseif (is_array($feature_synonyms)) {
|
|
|
- foreach ($feature_synonyms as $index => $synonym) {
|
|
|
- $synonyms .= $synonym->synonym_id->name . "\n";
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $analyses = $node->analyses;
|
|
|
- $references = $node->references;
|
|
|
-
|
|
|
- // We need to pass above variables for preview to show
|
|
|
- $form['feature'] = array(
|
|
|
- '#type' => 'value',
|
|
|
- '#value' => $feature
|
|
|
- );
|
|
|
- // This field is read when previewing a node
|
|
|
- $form['synonyms'] = array(
|
|
|
- '#type' => 'value',
|
|
|
- '#value' => $synonyms
|
|
|
- );
|
|
|
- // This field is read when previewing a node
|
|
|
- $form['analyses'] = array(
|
|
|
- '#type' => 'value',
|
|
|
- '#value' => $analyses
|
|
|
- );
|
|
|
- // This field is read when previewing a node
|
|
|
- $form['references'] = array(
|
|
|
- '#type' => 'value',
|
|
|
- '#value' => $references
|
|
|
- );
|
|
|
-
|
|
|
- // keep track of the feature id if we have one. If we do have one then
|
|
|
- // this would indicate an update as opposed to an insert.
|
|
|
- $form['feature_id'] = array(
|
|
|
- '#type' => 'value',
|
|
|
- '#value' => $feature->feature_id,
|
|
|
- );
|
|
|
-
|
|
|
- /*
|
|
|
- $form['title']= array(
|
|
|
- '#type' => 'textfield',
|
|
|
- '#title' => t('Title'),
|
|
|
- '#required' => TRUE,
|
|
|
- '#default_value' => $node->title,
|
|
|
- '#description' => t('The title must be a unique identifier for this feature. It is recommended to use a combination of uniquename, organism and feature type in the title as this is guranteed to be unique.'),
|
|
|
- '#maxlength' => 255
|
|
|
- );*/
|
|
|
-
|
|
|
- $form['uniquename']= array(
|
|
|
- '#type' => 'textfield',
|
|
|
- '#title' => t('Unique Feature Name'),
|
|
|
- '#required' => TRUE,
|
|
|
- '#default_value' => $feature->uniquename,
|
|
|
- '#description' => t('Enter a unique name for this feature. This name must be unique for the organism and feature type.'),
|
|
|
- '#maxlength' => 255
|
|
|
- );
|
|
|
-
|
|
|
- $form['fname']= array(
|
|
|
- '#type' => 'textfield',
|
|
|
- '#title' => t('Feature Name'),
|
|
|
- '#required' => TRUE,
|
|
|
- '#default_value' => $feature->name,
|
|
|
- '#description' => t('Enter the name used by humans to refer to this feature.'),
|
|
|
- '#maxlength' => 255
|
|
|
- );
|
|
|
-
|
|
|
- // get the sequence ontology CV ID
|
|
|
- $values = array('name' => 'sequence');
|
|
|
- $cv = tripal_core_chado_select('cv', array('cv_id'), $values);
|
|
|
- $cv_id = $cv[0]->cv_id;
|
|
|
-
|
|
|
- $form['feature_type'] = array(
|
|
|
- '#title' => t('Feature Type'),
|
|
|
- '#type' => 'textfield',
|
|
|
- '#description' => t("Choose the feature type."),
|
|
|
- '#required' => TRUE,
|
|
|
- '#default_value' => $feature->type_id->name,
|
|
|
- '#autocomplete_path' => "admin/tripal/tripal_cv/cvterm/auto_name/$cv_id",
|
|
|
- );
|
|
|
-
|
|
|
- // get the list of organisms
|
|
|
- $sql = "SELECT * FROM {Organism} ORDER BY genus, species";
|
|
|
- $org_rset = chado_query($sql);
|
|
|
- $organisms = array();
|
|
|
- $organisms[''] = '';
|
|
|
- while ($organism = $org_rset->fetchObject()) {
|
|
|
- $organisms[$organism->organism_id] = "$organism->genus $organism->species ($organism->common_name)";
|
|
|
- }
|
|
|
- $form['organism_id'] = array(
|
|
|
- '#title' => t('Organism'),
|
|
|
- '#type' => t('select'),
|
|
|
- '#description' => t("Choose the organism with which this feature is associated"),
|
|
|
- '#required' => TRUE,
|
|
|
- '#default_value' => $feature->organism_id->organism_id,
|
|
|
- '#options' => $organisms,
|
|
|
- );
|
|
|
-
|
|
|
- // Get synonyms
|
|
|
- if ($synonyms) {
|
|
|
- if (is_array($synonyms)) {
|
|
|
- foreach ($synonyms as $synonym) {
|
|
|
- $syn_text .= "$synonym->name\n";
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- $syn_text = $synonyms;
|
|
|
- }
|
|
|
- }
|
|
|
- $form['synonyms']= array(
|
|
|
- '#type' => 'textarea',
|
|
|
- '#title' => t('Synonyms'),
|
|
|
- '#required' => FALSE,
|
|
|
- '#default_value' => $syn_text,
|
|
|
- '#description' => t('Enter alternate names (synonmys) for this feature to help in searching and identification. You may enter as many alternate names as needed each on different lines.'),
|
|
|
- );
|
|
|
-
|
|
|
- $form['residues']= array(
|
|
|
- '#type' => 'textarea',
|
|
|
- '#title' => t('Residues'),
|
|
|
- '#required' => FALSE,
|
|
|
- '#default_value' => $feature->residues,
|
|
|
- '#description' => t('Enter the nucelotide sequences for this feature'),
|
|
|
- );
|
|
|
-
|
|
|
- $checked = '';
|
|
|
- if ($feature->is_obsolete == 't') {
|
|
|
- $checked = '1';
|
|
|
- }
|
|
|
- $form['is_obsolete']= array(
|
|
|
- '#type' => 'checkbox',
|
|
|
- '#title' => t('Is Obsolete'),
|
|
|
- '#required' => FALSE,
|
|
|
- '#default_value' => $checked,
|
|
|
- '#description' => t('Check this box if this sequence should be retired and no longer included in further analysis.'),
|
|
|
- );
|
|
|
- return $form;
|
|
|
-}
|
|
|
-/**
|
|
|
- *
|
|
|
- *
|
|
|
- * @ingroup tripal_feature
|
|
|
- */
|
|
|
-function chado_feature_validate($node) {
|
|
|
- $result = 0;
|
|
|
-
|
|
|
- // make sure the feature type is a real sequence ontology term
|
|
|
- $type = tripal_cv_get_cvterm_by_name($node->feature_type, NULL, 'sequence');
|
|
|
- if (!$type) {
|
|
|
- form_set_error('feature_type', t("The feature type is not a valid name from the Sequence Ontology."));
|
|
|
- }
|
|
|
|
|
|
- // if this is an update, we want to make sure that a different feature for
|
|
|
- // the organism doesn't already have this uniquename. We don't want to give
|
|
|
- // two sequences the same uniquename
|
|
|
- if ($node->feature_id) {
|
|
|
- $sql = "
|
|
|
- SELECT *
|
|
|
- FROM {feature} F
|
|
|
- INNER JOIN {cvterm} CVT ON F.type_id = CVT.cvterm_id
|
|
|
- WHERE
|
|
|
- F.uniquename = :uname AND
|
|
|
- F.organism_id = :orgnism_id AND
|
|
|
- CVT.name = :cvtname AND
|
|
|
- NOT f.feature_id = :feature_id
|
|
|
- ";
|
|
|
- $args = array(':uname' => $node->uniquename, ':organism_id' => $node->organism_id,
|
|
|
- ':cvtname' => $node->feature_type, ':feature_id' => $node->feature_id);
|
|
|
- $result = chado_query($sql, $args)->fetchObject();
|
|
|
- if ($result) {
|
|
|
- form_set_error('uniquename', t("Feature update cannot proceed. The feature name '$node->uniquename' is not unique for this organism. Please provide a unique name for this feature."));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // if this is an insert then we just need to make sure this name doesn't
|
|
|
- // already exist for this organism if it does then we need to throw an error
|
|
|
- else {
|
|
|
- $sql = "
|
|
|
- SELECT *
|
|
|
- FROM {feature} F
|
|
|
- INNER JOIN {cvterm} CVT ON F.type_id = CVT.cvterm_id
|
|
|
- WHERE
|
|
|
- F.uniquename = :name AND
|
|
|
- F.organism_id = :organism_id AND
|
|
|
- CVT.name = :cvtname
|
|
|
- ";
|
|
|
- $args = array(':name' => $node->uniquename, ':organism_id' => $node->organism_id, ':cvtname' => $node->feature_type);
|
|
|
- $result = chado_query($sql, $args)->fetchObject();
|
|
|
- if ($result) {
|
|
|
- form_set_error('uniquename', t("Feature insert cannot proceed. The feature name '$node->uniquename' already exists for this organism. Please provide a unique name for this feature."));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // we don't allow a genbank accession number for a contig
|
|
|
- if ($node->feature_type == 'contig' and $node->gbaccession) {
|
|
|
- form_set_error('gbaccession', t("Contigs cannot have a genbank accession number. Please change the feature type or remove the accession number"));
|
|
|
- }
|
|
|
-}
|
|
|
/**
|
|
|
* When a node is requested by the user this function is called to allow us
|
|
|
* to add auxiliary data to the node object.
|
|
|
*
|
|
|
* @ingroup tripal_feature
|
|
|
*/
|
|
|
-function chado_feature_load($node) {
|
|
|
-
|
|
|
- // get the feature details from chado
|
|
|
- $feature_id = chado_get_id_for_node('feature', $node->nid);
|
|
|
-
|
|
|
- $values = array('feature_id' => $feature_id);
|
|
|
- $feature = tripal_core_generate_chado_var('feature', $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_feature_title', 'unique_constraint');
|
|
|
- if ($title_type == 'unique_constraint') {
|
|
|
- if (strcmp($feature->name, $feature->uniquename)==0) {
|
|
|
- $node->title = $feature->name . " (" . $feature->type_id->name . ") " . $feature->organism_id->genus . " " . $feature->organism_id->species ;
|
|
|
+function chado_feature_load($nodes) {
|
|
|
+
|
|
|
+ foreach ($nodes as $nid => $node) {
|
|
|
+ // find the feature and add in the details
|
|
|
+ $feature_id = chado_get_id_for_node('feature', $nid);
|
|
|
+
|
|
|
+ // build the feature variable
|
|
|
+ $values = array('feature_id' => $feature_id);
|
|
|
+ $feature = tripal_core_generate_chado_var('feature', $values);
|
|
|
+ $nodes[$nid]->feature = $feature;
|
|
|
+
|
|
|
+ // 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. This doesn't change the title saved in the database, just what is shown
|
|
|
+ // to the user on the page
|
|
|
+ $title_type = variable_get('chado_feature_title', 'unique_constraint');
|
|
|
+ if ($title_type == 'unique_constraint') {
|
|
|
+ if (strcmp($feature->name, $feature->uniquename)==0) {
|
|
|
+ $node->title = $feature->name . " (" . $feature->type_id->name . ") " . $feature->organism_id->genus . " " . $feature->organism_id->species ;
|
|
|
+ }
|
|
|
+ // in previous version of Tripal, the feature title was simply the unique name.
|
|
|
+ // so, we recreate the title just to be sure all of our feature pages are consistent
|
|
|
+ else {
|
|
|
+ $node->title = $feature->name . ", " . $feature->uniquename . " (" . $feature->type_id->name . ") " . $feature->organism_id->genus . " " . $feature->organism_id->species ;
|
|
|
+ }
|
|
|
}
|
|
|
- // in previous version of Tripal, the feature title was simply the unique name.
|
|
|
- // so, we recreate the title just to be sure all of our feature pages are consistent
|
|
|
- else {
|
|
|
- $node->title = $feature->name . ", " . $feature->uniquename . " (" . $feature->type_id->name . ") " . $feature->organism_id->genus . " " . $feature->organism_id->species ;
|
|
|
+ // set the title to be the feature name or uniquename as configured
|
|
|
+ if ($title_type == 'feature_name') {
|
|
|
+ $node->title = $feature->name;
|
|
|
+ }
|
|
|
+ if ($title_type == 'feature_unique_name') {
|
|
|
+ $node->title = $feature->uniquename;
|
|
|
}
|
|
|
}
|
|
|
- // set the title to be the feature name or uniquename as configured
|
|
|
- if ($title_type == 'feature_name') {
|
|
|
- $node->title = $feature->name;
|
|
|
- }
|
|
|
- if ($title_type == 'feature_unique_name') {
|
|
|
- $node->title = $feature->uniquename;
|
|
|
- }
|
|
|
-
|
|
|
- $additions = new stdClass();
|
|
|
- $additions->feature = $feature;
|
|
|
- return $additions;
|
|
|
}
|
|
|
/**
|
|
|
*
|
|
@@ -1895,11 +1690,12 @@ function tripal_feature_node_insert($node) {
|
|
|
}
|
|
|
|
|
|
// remove any previous alias
|
|
|
- db_query("DELETE FROM {url_alias} WHERE src = :src", array(':src' => "node/$node->nid"));
|
|
|
+ db_query("DELETE FROM {url_alias} WHERE source = :source", array(':source' => "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);
|
|
|
+ $path_alias = array("source" => "node/$node->nid", "alias" => $url_alias);
|
|
|
+ path_save($path_alias);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -1909,6 +1705,25 @@ function tripal_feature_node_insert($node) {
|
|
|
*/
|
|
|
function tripal_feature_node_view($node, $view_mode, $langcode) {
|
|
|
switch ($node->type) {
|
|
|
+ case 'chado_feature':
|
|
|
+ // Show feature browser and counts
|
|
|
+ if ($view_mode == 'full') {
|
|
|
+ $node->content['tripal_feature_base'] = array(
|
|
|
+ '#value' => theme('tripal_feature_base', array('node' => $node)),
|
|
|
+ );
|
|
|
+ $node->content['tripal_feature_seqence'] = array(
|
|
|
+ '#value' => theme('tripal_feature_sequence', array('node' => $node)),
|
|
|
+ );
|
|
|
+ $node->content['tripal_feature_synonyms'] = array(
|
|
|
+ '#value' => theme('tripal_feature_synonyms', array('node' => $node)),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if ($view_mode == 'teaser') {
|
|
|
+ $node->content['tripal_feature_teaser'] = array(
|
|
|
+ '#value' => theme('tripal_feature_teaser', array('node' => $node)),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ break;
|
|
|
case 'chado_organism':
|
|
|
// Show feature browser and counts
|
|
|
if ($view_mode == 'full') {
|
|
@@ -1939,11 +1754,12 @@ function tripal_feature_node_update($node) {
|
|
|
switch ($node->type) {
|
|
|
case 'chado_feature':
|
|
|
// remove any previous alias
|
|
|
- db_query("DELETE FROM {url_alias} WHERE src = :src", array(':src' => "node/$node->nid"));
|
|
|
+ db_query("DELETE FROM {url_alias} WHERE source = :source", array(':source' => "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);
|
|
|
+ $path_alias = array("source" => "node/$node->nid", "alias" => $url_alias);
|
|
|
+ path_save($path_alias);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -2411,10 +2227,11 @@ function tripal_feature_match_features_page($id) {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
- * @param unknown_type $form
|
|
|
- * @param unknown_type $form_state
|
|
|
- * @param unknown_type $form_id
|
|
|
+ * Implementation of hook_form_alter()
|
|
|
+ *
|
|
|
+ * @param $form
|
|
|
+ * @param $form_state
|
|
|
+ * @param $form_id
|
|
|
*/
|
|
|
function tripal_feature_form_alter(&$form, &$form_state, $form_id) {
|
|
|
if ($form_id == "tripal_feature_seq_extract_form") {
|
|
@@ -2423,4 +2240,8 @@ function tripal_feature_form_alter(&$form, &$form_state, $form_id) {
|
|
|
// to the normal form URL
|
|
|
$form['#action'] = url("find/sequences");
|
|
|
}
|
|
|
+ // turn off preview button for insert/updates
|
|
|
+ if ($form_id == "chado_feature_node_form") {
|
|
|
+ $form['actions']['preview']['#access'] = FALSE;
|
|
|
+ }
|
|
|
}
|