|
@@ -7,40 +7,48 @@
|
|
*/
|
|
*/
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Implementation of hook_node_info(). This hook provides information to drupal
|
|
|
|
- * about any node types that are being created by this module. If your module
|
|
|
|
- * does not create any node types then this function is not required.
|
|
|
|
|
|
+ * Implementation of hook_node_info().
|
|
|
|
+ *
|
|
|
|
+ * This hook provides information to drupal about any node types that are being
|
|
|
|
+ * created by this module. If your module does not create any node types then
|
|
|
|
+ * this function is not required.
|
|
*
|
|
*
|
|
* @ingroup tripal_example
|
|
* @ingroup tripal_example
|
|
*/
|
|
*/
|
|
function tripal_example_node_info() {
|
|
function tripal_example_node_info() {
|
|
$nodes = array();
|
|
$nodes = array();
|
|
|
|
|
|
- //$nodes['chado_example'] = array(
|
|
|
|
- // 'name' => t('Example'),
|
|
|
|
- // 'base' => 'chado_example',
|
|
|
|
- // 'description' => t('A example from the chado database'),
|
|
|
|
- // 'has_title' => TRUE,
|
|
|
|
- // 'locked' => TRUE
|
|
|
|
- // This section of the node type array specifies how Tripal will sync the node
|
|
|
|
- // types with data in Chado. When Drupal creates a node it has no way of
|
|
|
|
- // coordinating which node belongs to which record in Chado. Therefore,
|
|
|
|
- // Tripal maintains tables in the Drupal schema that maps Drupal nodes
|
|
|
|
- // to recrords in Chado. Syncing is the process of creating Drupal nodes
|
|
|
|
- // and linking them to the appropriate record.
|
|
|
|
- // 'chado_node_api' => array(
|
|
|
|
- // 'base_table' => 'example', // the base table name (e.g. feature, example, contact)
|
|
|
|
- // 'hook_prefix' => 'chado_example',// the node type hook prefix
|
|
|
|
- // 'record_type_title' => array(
|
|
|
|
- // 'singular' => t('Library'), // how to refer to the record
|
|
|
|
- // 'plural' => t('Libraries') // how to refer to the record in plurals
|
|
|
|
- // ),
|
|
|
|
- // 'sync_filters' => array(
|
|
|
|
- // 'type_id' => TRUE, // if the record has a type_id set to TRUE
|
|
|
|
- // 'organism_id' => TRUE // if the record has an organism_id set to TRUE
|
|
|
|
- // ),
|
|
|
|
- // )
|
|
|
|
- //);
|
|
|
|
|
|
+ // EXPLANATION: this array describes all of the node types that are created
|
|
|
|
+ // by this module. For many Tripal modules (e.g. tripal_example, tripal_stock,
|
|
|
|
+ // tripal_library, tripal_pub, etc.) new node types are created. It is
|
|
|
|
+ // customary to name all new node types that interact with data in Chado
|
|
|
|
+ // with a 'chado_' prefix.
|
|
|
|
+
|
|
|
|
+ $nodes['chado_example'] = array(
|
|
|
|
+ 'name' => t('Example'),
|
|
|
|
+ 'base' => 'chado_example',
|
|
|
|
+ 'description' => t('A record from the fake chado example table'),
|
|
|
|
+ 'has_title' => TRUE,
|
|
|
|
+ 'locked' => TRUE,
|
|
|
|
+ // EXPLANATION: This section of the node type array specifies how Tripal will sync the node
|
|
|
|
+ // types with data in Chado. When Drupal creates a node it has no way of
|
|
|
|
+ // coordinating which node belongs to which record in Chado. Therefore,
|
|
|
|
+ // Tripal maintains tables in the Drupal schema that maps Drupal nodes
|
|
|
|
+ // to recrords in Chado. Syncing is the process of creating Drupal nodes
|
|
|
|
+ // and linking them to the appropriate record.
|
|
|
|
+ 'chado_node_api' => array(
|
|
|
|
+ 'base_table' => 'example', // the base table name (e.g. example, example, contact)
|
|
|
|
+ 'hook_prefix' => 'chado_example',// the node type hook prefix
|
|
|
|
+ 'record_type_title' => array(
|
|
|
|
+ 'singular' => t('Example'), // how to refer to the record
|
|
|
|
+ 'plural' => t('Examples') // how to refer to the record in plurals
|
|
|
|
+ ),
|
|
|
|
+ 'sync_filters' => array(
|
|
|
|
+ 'type_id' => TRUE, // if the record has a type_id set to TRUE
|
|
|
|
+ 'organism_id' => TRUE // if the record has an organism_id set to TRUE
|
|
|
|
+ ),
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
|
|
return $nodes;
|
|
return $nodes;
|
|
}
|
|
}
|
|
@@ -65,7 +73,9 @@ function chado_example_node_access($node, $op, $account) {
|
|
if (is_object($node)) {
|
|
if (is_object($node)) {
|
|
$node_type = $node->type;
|
|
$node_type = $node->type;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ // EXPLANATION: in the tripal_example_permissions() function we
|
|
|
|
+ // created the permission types that are used here to check for
|
|
|
|
+ // access permissions to the 'chado_exmaple' node type.
|
|
if($node_type == 'chado_example') {
|
|
if($node_type == 'chado_example') {
|
|
if ($op == 'create') {
|
|
if ($op == 'create') {
|
|
if (!user_access('create chado_example content', $account)) {
|
|
if (!user_access('create chado_example content', $account)) {
|
|
@@ -93,15 +103,27 @@ function chado_example_node_access($node, $op, $account) {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Implementation of hook_form() when a node type of chado_example is defined.
|
|
|
|
- * If a node type is not defined then this function is not needed. The table
|
|
|
|
- * name in chado for this example module is named 'example' so there is a
|
|
|
|
- * corresponding example_id in that table (similar to feature.feature_id,
|
|
|
|
- * contact.contact_id, etc).
|
|
|
|
|
|
+ * Implementation of hook_form()
|
|
|
|
+ *
|
|
|
|
+ * Creates the form for editing or inserting a record
|
|
*
|
|
*
|
|
* @ingroup tripal_example
|
|
* @ingroup tripal_example
|
|
*/
|
|
*/
|
|
function chado_example_form($node, &$form_state) {
|
|
function chado_example_form($node, &$form_state) {
|
|
|
|
+
|
|
|
|
+ // EXPLANATION: This function should construct a form array that is used
|
|
|
|
+ // by Drupal to contruct a form for inserting or editing our new node type.
|
|
|
|
+ // See this page for information about the Form API:
|
|
|
|
+ // https://api.drupal.org/api/drupal/includes!form.inc/group/form_api/7
|
|
|
|
+ //
|
|
|
|
+ // The code below is laid out in the following order
|
|
|
|
+ // 1) Set default values
|
|
|
|
+ // 2) Add form elements used by this node type
|
|
|
|
+ // 3) Use the Tripal API to add form elemetns for properties,
|
|
|
|
+ // dbxref's and relationships
|
|
|
|
+ //
|
|
|
|
+ // For the example code below we assume that the fake 'example' table
|
|
|
|
+ // only has a uniquename, organism_id, type_id and example_id.
|
|
|
|
|
|
$form = array();
|
|
$form = array();
|
|
|
|
|
|
@@ -116,37 +138,72 @@ function chado_example_form($node, &$form_state) {
|
|
// set form field defaults
|
|
// set form field defaults
|
|
|
|
|
|
|
|
|
|
- // if we are editing an existing node then the example is already part of the node
|
|
|
|
|
|
+ // SET FORM DEFAULTS
|
|
|
|
+ //---------------------------------------------
|
|
|
|
+
|
|
|
|
+ // if we are editing an existing node then the 'example' record from Chado
|
|
|
|
+ // is already part of the node, so we set the defaults from that object
|
|
if (property_exists($node, 'example')) {
|
|
if (property_exists($node, 'example')) {
|
|
- // $example = $node->example;
|
|
|
|
- // $example = chado_expand_var($example, 'field', 'example.residues');
|
|
|
|
- // $example_id = $example->example_id;
|
|
|
|
- // $uniquename = $example->uniquename;
|
|
|
|
|
|
+ $example = $node->example;
|
|
|
|
+ $example = chado_expand_var($example, 'field', 'example.residues');
|
|
|
|
+ $example_id = $example->example_id;
|
|
|
|
+ $uniquename = $example->uniquename;
|
|
|
|
|
|
// keep track of the example id
|
|
// keep track of the example id
|
|
- //$form['example_id'] = array(
|
|
|
|
- // '#type' => 'value',
|
|
|
|
- // '#value' => $example_id,
|
|
|
|
- //);
|
|
|
|
|
|
+ $form['example_id'] = array(
|
|
|
|
+ '#type' => 'value',
|
|
|
|
+ '#value' => $example_id,
|
|
|
|
+ );
|
|
}
|
|
}
|
|
// if we are re constructing the form from a failed validation or ajax callback
|
|
// if we are re constructing the form from a failed validation or ajax callback
|
|
// then use the $form_state['values'] values
|
|
// then use the $form_state['values'] values
|
|
if (array_key_exists('values', $form_state)) {
|
|
if (array_key_exists('values', $form_state)) {
|
|
- // $uniquename = $form_state['values']['uniquename'];
|
|
|
|
|
|
+ $uniquename = $form_state['values']['uniquename'];
|
|
|
|
+ $example_type = $form_state['values']['example_type'];
|
|
|
|
|
|
}
|
|
}
|
|
// if we are re building the form from after submission (from ajax call) then
|
|
// if we are re building the form from after submission (from ajax call) then
|
|
// the values are in the $form_state['input'] array
|
|
// the values are in the $form_state['input'] array
|
|
if (array_key_exists('input', $form_state) and !empty($form_state['input'])) {
|
|
if (array_key_exists('input', $form_state) and !empty($form_state['input'])) {
|
|
- // $uniquename = $form_state['input']['uniquename'];
|
|
|
|
-
|
|
|
|
|
|
+ $uniquename = $form_state['input']['uniquename'];
|
|
|
|
+ $example_type = $form_state['input']['example_type'];
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
|
|
- // NOTE: if the table has a 'type_id' column, be sure to use the
|
|
|
|
- // tripal_get_default_cv('example', 'type_id') to get the site's
|
|
|
|
- // default vocabulary.
|
|
|
|
|
|
+ // FORM ELEMENTS
|
|
|
|
+ //---------------------------------------------
|
|
|
|
+ $form['uniquename']= array(
|
|
|
|
+ '#type' => 'textfield',
|
|
|
|
+ '#title' => t('Unique Name'),
|
|
|
|
+ '#required' => TRUE,
|
|
|
|
+ '#default_value' => $uniquename,
|
|
|
|
+ '#description' => t('Enter a unique name for this example. This name must be unique.'),
|
|
|
|
+ '#maxlength' => 255
|
|
|
|
+ );
|
|
|
|
|
|
-
|
|
|
|
|
|
+ // for the type_id we want to use the default vocabulary so that this
|
|
|
|
+ // field can have autocomplete functionality
|
|
|
|
+ $type_cv = tripal_get_default_cv('example', 'type_id');
|
|
|
|
+ $cv_id = $type_cv->cv_id;
|
|
|
|
+ $form['example_type'] = array(
|
|
|
|
+ '#title' => t('Feature Type'),
|
|
|
|
+ '#type' => 'textfield',
|
|
|
|
+ '#description' => t("Choose the example type."),
|
|
|
|
+ '#required' => TRUE,
|
|
|
|
+ '#default_value' => $example_type,
|
|
|
|
+ '#autocomplete_path' => "admin/tripal/chado/tripal_cv/cvterm/auto_name/$cv_id",
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ // add a select box of organisms
|
|
|
|
+ $organisms = tripal_get_organism_select_options();
|
|
|
|
+ $form['organism_id'] = array(
|
|
|
|
+ '#title' => t('Organism'),
|
|
|
|
+ '#type' => t('select'),
|
|
|
|
+ '#description' => t("Choose the organism with which this example is associated"),
|
|
|
|
+ '#required' => TRUE,
|
|
|
|
+ '#default_value' => $organism_id,
|
|
|
|
+ '#options' => $organisms,
|
|
|
|
+ );
|
|
|
|
|
|
// PROPERTIES FORM
|
|
// PROPERTIES FORM
|
|
//---------------------------------------------
|
|
//---------------------------------------------
|
|
@@ -198,6 +255,10 @@ function chado_example_form($node, &$form_state) {
|
|
/**
|
|
/**
|
|
* Implementation of hook_validate
|
|
* Implementation of hook_validate
|
|
*
|
|
*
|
|
|
|
+ * This function validates a form prior to insert or update. If an error
|
|
|
|
+ * is detected, it sets the error using form_set_error() which takes the
|
|
|
|
+ * user back to the form to make corrections.
|
|
|
|
+ *
|
|
* This validation is being used for three activities:
|
|
* This validation is being used for three activities:
|
|
* CASE A: Update a node that exists in both drupal and chado
|
|
* CASE A: Update a node that exists in both drupal and chado
|
|
* CASE B: Synchronizing a node from chado to drupal
|
|
* CASE B: Synchronizing a node from chado to drupal
|
|
@@ -222,20 +283,20 @@ function chado_example_validate($node, $form, &$form_state) {
|
|
}
|
|
}
|
|
|
|
|
|
// be sure to always trim text fields
|
|
// be sure to always trim text fields
|
|
- // $node->uniquename = trim($node->uniquename);
|
|
|
|
|
|
+ $node->uniquename = trim($node->uniquename);
|
|
|
|
|
|
// Validating for an update. If the 'nid' property is present in the node then
|
|
// Validating for an update. If the 'nid' property is present in the node then
|
|
// this is an update and validation can be different for updates
|
|
// this is an update and validation can be different for updates
|
|
if (property_exists($node, 'nid')) {
|
|
if (property_exists($node, 'nid')) {
|
|
|
|
|
|
// if there is a problem with a field then you can set an error on the form
|
|
// if there is a problem with a field then you can set an error on the form
|
|
- // form_set_error('uniquename', t("example update cannot proceed. The example name '$node->uniquename' is not unique for this organism. Please provide a unique name for this example."));
|
|
|
|
|
|
+ form_set_error('uniquename', t("example update cannot proceed. The example name '$node->uniquename' is not unique for this organism. Please provide a unique name for this example."));
|
|
}
|
|
}
|
|
// Validating for an insert
|
|
// Validating for an insert
|
|
else {
|
|
else {
|
|
|
|
|
|
// if there is a problem with a field then you can set an error on the form
|
|
// if there is a problem with a field then you can set an error on the form
|
|
- // form_set_error('uniquename', t("example insert cannot proceed. The example name '$node->uniquename' already exists for this organism. Please provide a unique name for this example."));
|
|
|
|
|
|
+ form_set_error('uniquename', t("example insert cannot proceed. The example name '$node->uniquename' already exists for this organism. Please provide a unique name for this example."));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -256,81 +317,75 @@ function chado_example_validate($node, $form, &$form_state) {
|
|
*/
|
|
*/
|
|
function chado_example_insert($node) {
|
|
function chado_example_insert($node) {
|
|
// be sure to always trim text fields
|
|
// be sure to always trim text fields
|
|
- //$node->uniquename = trim($node->uniquename);
|
|
|
|
|
|
+ $node->uniquename = trim($node->uniquename);
|
|
|
|
|
|
// if there is an example_id in the $node object then this must be a sync so
|
|
// if there is an example_id in the $node object then this must be a sync so
|
|
// we can skip adding the example as it is already there, although
|
|
// we can skip adding the example as it is already there, although
|
|
// we do need to proceed with the rest of the insert
|
|
// we do need to proceed with the rest of the insert
|
|
if (!property_exists($node, 'example_id')) {
|
|
if (!property_exists($node, 'example_id')) {
|
|
|
|
|
|
- // ADD TO CHADO
|
|
|
|
-
|
|
|
|
- // * Example Table *
|
|
|
|
// perform the insert using the tripal_core_chado_insert function();
|
|
// perform the insert using the tripal_core_chado_insert function();
|
|
- //$values = array(
|
|
|
|
- // 'uniquename' => $node->uniquename,
|
|
|
|
- // 'residues' => $residues,
|
|
|
|
- //);
|
|
|
|
- //$example = chado_select_record('example', array('*'), $values);
|
|
|
|
- //if (!$example) {
|
|
|
|
- // drupal_set_message(t('Unable to add example.'), 'warning');
|
|
|
|
- // tripal_report_error('tripal_example', TRIPAL_WARNING, 'Insert example: Unable to create example where values: %values',
|
|
|
|
- // array('%values' => print_r($values, TRUE)));
|
|
|
|
- // return;
|
|
|
|
- //}
|
|
|
|
|
|
+ $values = array(
|
|
|
|
+ 'uniquename' => $node->uniquename,
|
|
|
|
+ 'residues' => $residues,
|
|
|
|
+ );
|
|
|
|
+ $example = chado_select_record('example', array('*'), $values);
|
|
|
|
+ if (!$example) {
|
|
|
|
+ drupal_set_message(t('Unable to add example.'), 'warning');
|
|
|
|
+ tripal_report_error('tripal_example', TRIPAL_WARNING, 'Insert example: Unable to create example where values: %values',
|
|
|
|
+ array('%values' => print_r($values, TRUE)));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
// get the example_id for linking Drupal node with Chado data
|
|
// get the example_id for linking Drupal node with Chado data
|
|
- // $example_id = $example->example_id;
|
|
|
|
|
|
+ $example_id = $example->example_id;
|
|
|
|
|
|
// Only add to other chado tables if the base record was inserted properly
|
|
// Only add to other chado tables if the base record was inserted properly
|
|
if ($example_id > 0) {
|
|
if ($example_id > 0) {
|
|
|
|
|
|
- // * Properties Form *
|
|
|
|
// If you implemented the properties form in chado_example_form then you need to
|
|
// If you implemented the properties form in chado_example_form then you need to
|
|
// handle inserting these properties into your chado prop table.
|
|
// handle inserting these properties into your chado prop table.
|
|
- // $details = array(
|
|
|
|
- // 'property_table' => 'exampleprop', // the name of the prop table
|
|
|
|
- // 'base_table' => 'example', // the name of your chado base table
|
|
|
|
- // 'foreignkey_name' => 'example_id', // the name of the key in your base table
|
|
|
|
- // 'foreignkey_value' => $example_id // the value of the example_id key
|
|
|
|
- // );
|
|
|
|
- // chado_update_node_form_properties($node, $details);
|
|
|
|
-
|
|
|
|
- // * Additional DBxrefs Form *
|
|
|
|
|
|
+ $details = array(
|
|
|
|
+ 'property_table' => 'exampleprop', // the name of the prop table
|
|
|
|
+ 'base_table' => 'example', // the name of your chado base table
|
|
|
|
+ 'foreignkey_name' => 'example_id', // the name of the key in your base table
|
|
|
|
+ 'foreignkey_value' => $example_id // the value of the example_id key
|
|
|
|
+ );
|
|
|
|
+ chado_update_node_form_properties($node, $details);
|
|
|
|
+
|
|
// If you implemented the dbxrefs form in chado_example_form then you need to
|
|
// If you implemented the dbxrefs form in chado_example_form then you need to
|
|
// handle inserting these database references into your chado _dbxref table.
|
|
// handle inserting these database references into your chado _dbxref table.
|
|
- // $details = array(
|
|
|
|
- // 'linking_table' => 'example_dbxref', // the name of your _dbxref table
|
|
|
|
- // 'foreignkey_name' => 'example_id', // the name of the key in your base table
|
|
|
|
- // 'foreignkey_value' => $example_id // the value of the example_id key
|
|
|
|
- // );
|
|
|
|
- // chado_update_node_form_dbxrefs($node, $details);
|
|
|
|
-
|
|
|
|
- // * Relationships Form *
|
|
|
|
|
|
+ $details = array(
|
|
|
|
+ 'linking_table' => 'example_dbxref', // the name of your _dbxref table
|
|
|
|
+ 'foreignkey_name' => 'example_id', // the name of the key in your base table
|
|
|
|
+ 'foreignkey_value' => $example_id // the value of the example_id key
|
|
|
|
+ );
|
|
|
|
+ chado_update_node_form_dbxrefs($node, $details);
|
|
|
|
+
|
|
// If you implemented the relationships form in chado_example_form then you need to
|
|
// If you implemented the relationships form in chado_example_form then you need to
|
|
// handle inserting these relationships into your chado _relationship table.
|
|
// handle inserting these relationships into your chado _relationship table.
|
|
- // $details = array(
|
|
|
|
- // 'relationship_table' => 'example_relationship', // name of the _relationship table
|
|
|
|
- // 'foreignkey_value' => $example_id // value of the example_id key
|
|
|
|
- // );
|
|
|
|
- // chado_update_node_form_relationships($node, $details);
|
|
|
|
|
|
+ $details = array(
|
|
|
|
+ 'relationship_table' => 'example_relationship', // name of the _relationship table
|
|
|
|
+ 'foreignkey_value' => $example_id // value of the example_id key
|
|
|
|
+ );
|
|
|
|
+ chado_update_node_form_relationships($node, $details);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
// the node has an example_id so get it for linking Drupal node with Chado data
|
|
// the node has an example_id so get it for linking Drupal node with Chado data
|
|
- // $example_id = $node->example_id;
|
|
|
|
|
|
+ $example_id = $node->example_id;
|
|
}
|
|
}
|
|
|
|
|
|
// Make sure the entry for this example doesn't already exist in the
|
|
// Make sure the entry for this example doesn't already exist in the
|
|
// chado_example table if it doesn't exist then we want to add it.
|
|
// chado_example table if it doesn't exist then we want to add it.
|
|
// $check_org_id = chado_get_id_from_nid('example', $node->nid);
|
|
// $check_org_id = chado_get_id_from_nid('example', $node->nid);
|
|
- //if (!$check_org_id) {
|
|
|
|
- // $record = new stdClass();
|
|
|
|
- // $record->nid = $node->nid;
|
|
|
|
- // $record->vid = $node->vid;
|
|
|
|
- // $record->example_id = $example_id;
|
|
|
|
- // drupal_write_record('chado_example', $record);
|
|
|
|
- //}
|
|
|
|
|
|
+ if (!$check_org_id) {
|
|
|
|
+ $record = new stdClass();
|
|
|
|
+ $record->nid = $node->nid;
|
|
|
|
+ $record->vid = $node->vid;
|
|
|
|
+ $record->example_id = $example_id;
|
|
|
|
+ drupal_write_record('chado_example', $record);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -345,53 +400,50 @@ function chado_example_insert($node) {
|
|
*/
|
|
*/
|
|
function chado_example_update($node) {
|
|
function chado_example_update($node) {
|
|
// be sure to always trim text fields
|
|
// be sure to always trim text fields
|
|
- // $node->uniquename = trim($node->uniquename);
|
|
|
|
|
|
+ $node->uniquename = trim($node->uniquename);
|
|
|
|
|
|
// use the chado_update_record() function to update the record
|
|
// use the chado_update_record() function to update the record
|
|
- //$match = array(
|
|
|
|
- //'example_id' => $example_id,
|
|
|
|
- //);
|
|
|
|
- //$values = array(
|
|
|
|
- // 'uniquename' => $node->uniquename,
|
|
|
|
- //);
|
|
|
|
- //$options = array('return_record' => TRUE);
|
|
|
|
- //$status = chado_update_record('example', $match, $values, $options);
|
|
|
|
-
|
|
|
|
- //if (!$status) {
|
|
|
|
- // drupal_set_message(t('Unable to update example.'), 'warning');
|
|
|
|
- // tripal_report_error('tripal_example', TRIPAL_WARNING, 'Update example: Unable to update example where values: %values',
|
|
|
|
- // array('%values' => print_r($values, TRUE)));
|
|
|
|
- //}
|
|
|
|
-
|
|
|
|
- // * Properties Form *
|
|
|
|
|
|
+ $match = array(
|
|
|
|
+ 'example_id' => $example_id,
|
|
|
|
+ );
|
|
|
|
+ $values = array(
|
|
|
|
+ 'uniquename' => $node->uniquename,
|
|
|
|
+ );
|
|
|
|
+ $options = array('return_record' => TRUE);
|
|
|
|
+ $status = chado_update_record('example', $match, $values, $options);
|
|
|
|
+
|
|
|
|
+ if (!$status) {
|
|
|
|
+ drupal_set_message(t('Unable to update example.'), 'warning');
|
|
|
|
+ tripal_report_error('tripal_example', TRIPAL_WARNING, 'Update example: Unable to update example where values: %values',
|
|
|
|
+ array('%values' => print_r($values, TRUE)));
|
|
|
|
+ }
|
|
|
|
+
|
|
// If you implemented the properties form in chado_example_form then you need to
|
|
// If you implemented the properties form in chado_example_form then you need to
|
|
// handle updating these properties into your chado prop table.
|
|
// handle updating these properties into your chado prop table.
|
|
- // $details = array(
|
|
|
|
- // 'property_table' => 'exampleprop', // the name of the prop table
|
|
|
|
- // 'base_table' => 'example', // the name of your chado base table
|
|
|
|
- // 'foreignkey_name' => 'example_id', // the name of the key in your base table
|
|
|
|
- // 'foreignkey_value' => $example_id // the value of the example_id key
|
|
|
|
- // );
|
|
|
|
- // chado_update_node_form_properties($node, $details);
|
|
|
|
-
|
|
|
|
- // * Additional DBxrefs Form *
|
|
|
|
|
|
+ $details = array(
|
|
|
|
+ 'property_table' => 'exampleprop', // the name of the prop table
|
|
|
|
+ 'base_table' => 'example', // the name of your chado base table
|
|
|
|
+ 'foreignkey_name' => 'example_id', // the name of the key in your base table
|
|
|
|
+ 'foreignkey_value' => $example_id // the value of the example_id key
|
|
|
|
+ );
|
|
|
|
+ chado_update_node_form_properties($node, $details);
|
|
|
|
+
|
|
// If you implemented the dbxrefs form in chado_example_form then you need to
|
|
// If you implemented the dbxrefs form in chado_example_form then you need to
|
|
// handle updating these database references into your chado _dbxref table.
|
|
// handle updating these database references into your chado _dbxref table.
|
|
- // $details = array(
|
|
|
|
- // 'linking_table' => 'example_dbxref', // the name of your _dbxref table
|
|
|
|
- // 'foreignkey_name' => 'example_id', // the name of the key in your base table
|
|
|
|
- // 'foreignkey_value' => $example_id // the value of the example_id key
|
|
|
|
- // );
|
|
|
|
- // chado_update_node_form_dbxrefs($node, $details);
|
|
|
|
-
|
|
|
|
- // * Relationships Form *
|
|
|
|
|
|
+ $details = array(
|
|
|
|
+ 'linking_table' => 'example_dbxref', // the name of your _dbxref table
|
|
|
|
+ 'foreignkey_name' => 'example_id', // the name of the key in your base table
|
|
|
|
+ 'foreignkey_value' => $example_id // the value of the example_id key
|
|
|
|
+ );
|
|
|
|
+ chado_update_node_form_dbxrefs($node, $details);
|
|
|
|
+
|
|
// If you implemented the relationships form in chado_example_form then you need to
|
|
// If you implemented the relationships form in chado_example_form then you need to
|
|
// handle updating these relationships into your chado _relationship table.
|
|
// handle updating these relationships into your chado _relationship table.
|
|
- // $details = array(
|
|
|
|
- // 'relationship_table' => 'example_relationship', // name of the _relationship table
|
|
|
|
- // 'foreignkey_value' => $example_id // value of the example_id key
|
|
|
|
- // );
|
|
|
|
- // chado_update_node_form_relationships($node, $details);
|
|
|
|
|
|
+ $details = array(
|
|
|
|
+ 'relationship_table' => 'example_relationship', // name of the _relationship table
|
|
|
|
+ 'foreignkey_value' => $example_id // value of the example_id key
|
|
|
|
+ );
|
|
|
|
+ chado_update_node_form_relationships($node, $details);
|
|
|
|
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
@@ -407,7 +459,7 @@ function chado_example_update($node) {
|
|
function chado_example_delete($node) {
|
|
function chado_example_delete($node) {
|
|
|
|
|
|
// get the example id from the node
|
|
// get the example id from the node
|
|
- //$example_id = chado_get_id_from_nid('example', $node->nid);
|
|
|
|
|
|
+ $example_id = chado_get_id_from_nid('example', $node->nid);
|
|
|
|
|
|
// if we don't have a example id for this node then this isn't a node of
|
|
// if we don't have a example id for this node then this isn't a node of
|
|
// type chado_example or the entry in the chado_example table was lost.
|
|
// type chado_example or the entry in the chado_example table was lost.
|
|
@@ -417,13 +469,13 @@ function chado_example_delete($node) {
|
|
|
|
|
|
// remove the entry in the chado_exapmle table linking the deleted
|
|
// remove the entry in the chado_exapmle table linking the deleted
|
|
// Drupal node with the data in chado
|
|
// Drupal node with the data in chado
|
|
- // $sql_del = "DELETE FROM {chado_example} WHERE nid = :nid AND vid = :vid";
|
|
|
|
- // db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
|
|
|
|
|
|
+ $sql_del = "DELETE FROM {chado_example} WHERE nid = :nid AND vid = :vid";
|
|
|
|
+ db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
|
|
|
|
|
|
// Remove data from example tables of chado database. This will
|
|
// Remove data from example tables of chado database. This will
|
|
// cause a cascade delete and remove all data in referencing tables
|
|
// cause a cascade delete and remove all data in referencing tables
|
|
// for this example
|
|
// for this example
|
|
- // chado_query("DELETE FROM {example} WHERE example_id = :example_id", array(':example_id' => $example_id));
|
|
|
|
|
|
+ chado_query("DELETE FROM {example} WHERE example_id = :example_id", array(':example_id' => $example_id));
|
|
|
|
|
|
// inform the user that the data was deleted
|
|
// inform the user that the data was deleted
|
|
drupal_set_message(t("The example and all associated data were removed from Chado"));
|
|
drupal_set_message(t("The example and all associated data were removed from Chado"));
|
|
@@ -433,8 +485,8 @@ function chado_example_delete($node) {
|
|
/**
|
|
/**
|
|
* Implementation of hook_load(). This function is necessary to load
|
|
* Implementation of hook_load(). This function is necessary to load
|
|
* into the $node object the fields of the table form Chado. For example
|
|
* into the $node object the fields of the table form Chado. For example
|
|
- * for the feature table, the chado_feature_load() function adds in
|
|
|
|
- * a feature object which contains all of the fields and sub objects
|
|
|
|
|
|
+ * for the example table, the chado_example_load() function adds in
|
|
|
|
+ * a example object which contains all of the fields and sub objects
|
|
* for data in tables with foreign key relationships.
|
|
* for data in tables with foreign key relationships.
|
|
*
|
|
*
|
|
* This function is not required if the hook_node_info() does not define
|
|
* This function is not required if the hook_node_info() does not define
|
|
@@ -443,22 +495,26 @@ function chado_example_delete($node) {
|
|
* @ingroup tripal_example
|
|
* @ingroup tripal_example
|
|
*/
|
|
*/
|
|
function chado_example_load($nodes) {
|
|
function chado_example_load($nodes) {
|
|
|
|
+
|
|
|
|
+ // EXPLANATION: when displaying or node or accessing the node in a template
|
|
|
|
+ // we need the data from Chado. This fucntion finds the record in Chado that
|
|
|
|
+ // this node belongs to and adds the record.
|
|
|
|
|
|
// there may be multiple nodes that get passed in so we have to iterate through
|
|
// there may be multiple nodes that get passed in so we have to iterate through
|
|
// them all
|
|
// them all
|
|
foreach ($nodes as $nid => $node) {
|
|
foreach ($nodes as $nid => $node) {
|
|
// find the example and add in the details
|
|
// find the example and add in the details
|
|
- //$example_id = chado_get_id_from_nid('example', $nid);
|
|
|
|
|
|
+ $example_id = chado_get_id_from_nid('example', $nid);
|
|
|
|
|
|
// if the nid does not have a matching record then skip this node.
|
|
// if the nid does not have a matching record then skip this node.
|
|
// this can happen with orphaned nodes.
|
|
// this can happen with orphaned nodes.
|
|
- //if (!$example_id) {
|
|
|
|
- // continue;
|
|
|
|
- //}
|
|
|
|
|
|
+ if (!$example_id) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
|
|
// build the example variable by using the chado_generate_var() function
|
|
// build the example variable by using the chado_generate_var() function
|
|
- //$values = array('example_id' => $example_id);
|
|
|
|
- //$example = chado_generate_var('example', $values);
|
|
|
|
|
|
+ $values = array('example_id' => $example_id);
|
|
|
|
+ $example = chado_generate_var('example', $values);
|
|
|
|
|
|
// for fields in the table that are of type 'text' you may want to include those
|
|
// for fields in the table that are of type 'text' you may want to include those
|
|
// by default, the tripal_core_generate_chado_var does not include text fields as
|
|
// by default, the tripal_core_generate_chado_var does not include text fields as
|
|
@@ -468,180 +524,193 @@ function chado_example_load($nodes) {
|
|
// include it here using the chado_expand_var() function. In most
|
|
// include it here using the chado_expand_var() function. In most
|
|
// cases it is probably best to let the end-user decide if text fields should
|
|
// cases it is probably best to let the end-user decide if text fields should
|
|
// be included by using this function in the templates.
|
|
// be included by using this function in the templates.
|
|
- //$example = chado_expand_var($example, 'field', 'example.residues');
|
|
|
|
|
|
+ $example = chado_expand_var($example, 'field', 'example.residues');
|
|
|
|
|
|
// add the new example object to this node.
|
|
// add the new example object to this node.
|
|
- //$nodes[$nid]->example = $example;
|
|
|
|
|
|
+ $nodes[$nid]->example = $example;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Implementation of hook_node_presave(). This node is useful for
|
|
|
|
- * making changes to the node prior to it being saved to the database.
|
|
|
|
- * One useful case for this is to set the title of a node. In some cases
|
|
|
|
- * such as for the organism module, the title will be set depending on
|
|
|
|
- * what genus and species is provided. This hook can allow the title to
|
|
|
|
- * be set using user supplied data before the node is saved. In practice
|
|
|
|
- * any change can be made to any fields in the node object.
|
|
|
|
- *
|
|
|
|
- * This function is not required. You probably won't need it if you
|
|
|
|
- * don't define a custom node type in the hook_node_info() function. But
|
|
|
|
- * it is node type agnostic, so you can use this function to change the
|
|
|
|
- * contents of any node regardless of it's type.
|
|
|
|
|
|
+ * Implementation of hook_node_presave().
|
|
|
|
+ *
|
|
|
|
+ * Performs actions on a node object prior to it being saved
|
|
*
|
|
*
|
|
* @ingroup tripal_example
|
|
* @ingroup tripal_example
|
|
*/
|
|
*/
|
|
function tripal_example_node_presave($node) {
|
|
function tripal_example_node_presave($node) {
|
|
|
|
|
|
- /*
|
|
|
|
|
|
+ // EXPLANATION: This node is useful for
|
|
|
|
+ // making changes to the node prior to it being saved to the database.
|
|
|
|
+ // One useful case for this is to set the title of a node. In some cases
|
|
|
|
+ // such as for the organism module, the title will be set depending on
|
|
|
|
+ // what genus and species is provided. This hook can allow the title to
|
|
|
|
+ // be set using user supplied data before the node is saved. In practice
|
|
|
|
+ // any change can be made to any fields in the node object.
|
|
|
|
+ //
|
|
|
|
+ // This function is not required. You probably won't need it if you
|
|
|
|
+ // don't define a custom node type in the hook_node_info() function. But
|
|
|
|
+ // it is node type agnostic, so you can use this function to change the
|
|
|
|
+ // contents of any node regardless of it's type.
|
|
|
|
+
|
|
// set the node title
|
|
// set the node title
|
|
switch ($node->type) {
|
|
switch ($node->type) {
|
|
case 'chado_example':
|
|
case 'chado_example':
|
|
- // for a form submission the 'examplename' field will be set,
|
|
|
|
|
|
+ // for a form submission the 'uniquename' field will be set,
|
|
// for a sync, we must pull from the example object
|
|
// for a sync, we must pull from the example object
|
|
- if (property_exists($node, 'examplename')) {
|
|
|
|
|
|
+ if (property_exists($node, 'uniquename')) {
|
|
// set the title
|
|
// set the title
|
|
- $node->title = $node->examplename;
|
|
|
|
|
|
+ $node->title = $node->uniquename;
|
|
}
|
|
}
|
|
else if (property_exists($node, 'example')) {
|
|
else if (property_exists($node, 'example')) {
|
|
- $node->title = $node->example->name;
|
|
|
|
|
|
+ $node->title = $node->example->uniquename;
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- */
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Implementation of hook node_insert(). This function is used
|
|
|
|
- * after any a node is inserted into the database. It is different
|
|
|
|
- * from the hook_insert() function above in that it is called after
|
|
|
|
- * any node is saved, regardlesss of it's type. This function is useful
|
|
|
|
- * for making changes to the database after a node is inserted when you
|
|
|
|
- * can't edit the hook_insert() function of a node not defined by this
|
|
|
|
- * module, or to access values of a node when have not yet been saved.
|
|
|
|
- * An example comes from the tripal_feature module where the URL alias
|
|
|
|
- * of a node cannot be set in the hook_insert() function. Therefore
|
|
|
|
- * the tripal_feature module uses this function to set the url path
|
|
|
|
- * of a newly inserted feature node.
|
|
|
|
- *
|
|
|
|
- * This function is not required. You probably won't need it if you
|
|
|
|
- * don't define a custom node type in the hook_node_info() function. But
|
|
|
|
- * it is node type agnostic, so you can use this function to do any
|
|
|
|
- * activity after insert of a node.
|
|
|
|
|
|
+ * Implementation of hook node_insert().
|
|
|
|
+ *
|
|
|
|
+ * Performs actions after any node has been inserted.
|
|
*
|
|
*
|
|
* @ingroup tripal_example
|
|
* @ingroup tripal_example
|
|
*/
|
|
*/
|
|
function tripal_example_node_insert($node) {
|
|
function tripal_example_node_insert($node) {
|
|
-
|
|
|
|
- // set the URL path after inserting. We do it here because we do not know the
|
|
|
|
- // example_id in the presave and cannot do it in the hook_insert()
|
|
|
|
- //switch ($node->type) {
|
|
|
|
- // case 'chado_example':
|
|
|
|
- // if (!$node->example_id) {
|
|
|
|
- // $sql = "SELECT * FROM {chado_example} WHERE nid = :nid";
|
|
|
|
- // $chado_example = db_query($sql, array(':nid' => $node->nid))->fetchObject();
|
|
|
|
- // $node->example_id = $chado_example->example_id;
|
|
|
|
- // }
|
|
|
|
|
|
|
|
- // // on an insert we need to add the feature_id to the node object
|
|
|
|
- // // so that the tripal_example_get_example_url function can set the URL properly
|
|
|
|
- // $node->example_id = chado_get_id_from_nid('example', $node->nid);
|
|
|
|
-
|
|
|
|
- // // remove any previous alias
|
|
|
|
- // db_query("DELETE FROM {url_alias} WHERE source = :source", array(':source' => "node/$node->nid"));
|
|
|
|
-
|
|
|
|
- // // set the URL for this example page
|
|
|
|
- // $url_alias = tripal_example_get_example_url($node);
|
|
|
|
- // $path_alias = array("source" => "node/$node->nid", "alias" => $url_alias);
|
|
|
|
- // path_save($path_alias);
|
|
|
|
- // break;
|
|
|
|
- //}
|
|
|
|
|
|
+ // EXPLANATION: This function is used
|
|
|
|
+ // after any a node is inserted into the database. It is different
|
|
|
|
+ // from the hook_insert() function above in that it is called after
|
|
|
|
+ // any node is saved, regardlesss of it's type. This function is useful
|
|
|
|
+ // for making changes to the database after a node is inserted.
|
|
|
|
+ // An example comes from the tripal_feature module where the URL alias
|
|
|
|
+ // of a node cannot be set in the hook_insert() function. Therefore
|
|
|
|
+ // the tripal_feature module uses this function to set the url path
|
|
|
|
+ // of a newly inserted example node.
|
|
|
|
+ //
|
|
|
|
+ // This function is not required. You probably won't need it if you
|
|
|
|
+ // don't define a custom node type in the hook_node_info() function. But
|
|
|
|
+ // it is node type agnostic, so you can use this function to do any
|
|
|
|
+ // activity after insert of any node.
|
|
|
|
+
|
|
|
|
+ // the Example code below will set the URL path after inserting. We do it
|
|
|
|
+ // here because we do not know the example_id in the presave and cannot do
|
|
|
|
+ // it in the hook_insert()
|
|
|
|
+ switch ($node->type) {
|
|
|
|
+ case 'chado_example':
|
|
|
|
+
|
|
|
|
+ // if we do not have an record ID for this node then get it
|
|
|
|
+ if (!$node->example_id) {
|
|
|
|
+ $node->example_id = chado_get_id_for_node('example', $node);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // set the URL for this example page
|
|
|
|
+ // see the code in the tripal_feature/includes/tripal_feature.chado_node.inc file
|
|
|
|
+ // in the function tripal_feature_node_insert for an example of how that
|
|
|
|
+ // module sets the URL. It uses a configuration file to allow the user
|
|
|
|
+ // to dynmically build a URL schema and then uses that schema to generate
|
|
|
|
+ // a URL string.
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * Implementation of hook node_update(). This function is used
|
|
|
|
- * after any a node is updated in the database. It is different
|
|
|
|
- * from the hook_update() function above in that it is called after
|
|
|
|
- * any node is updated, regardlesss of it's type. This function is useful
|
|
|
|
- * for making changes to the database after a node is updated when you
|
|
|
|
- * can't perform changes in the hook_upate() function of a node not defined by this
|
|
|
|
- * module, or to access values of a node when have not yet been updated.
|
|
|
|
- * An example comes from the tripal_feature module where the URL alias
|
|
|
|
- * of a node cannot be set in the hook_update() function. Therefore
|
|
|
|
- * the tripal_feature module uses this function to reset the url path
|
|
|
|
- * of an updated feature node.
|
|
|
|
- *
|
|
|
|
- * This function is not required. You probably won't need it if you
|
|
|
|
- * don't define a custom node type in the hook_node_info() function. But
|
|
|
|
- * it is node type agnostic, so you can use this function to do any
|
|
|
|
- * activity after insert of a node.
|
|
|
|
|
|
+ * Implementation of hook node_update().
|
|
|
|
+ *
|
|
|
|
+ * Performs actions after any node has been updated.
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
function tripal_example_node_update($node) {
|
|
function tripal_example_node_update($node) {
|
|
|
|
|
|
|
|
+ // EXPLANATION: This function is used
|
|
|
|
+ // after any a node is updated in the database. It is different
|
|
|
|
+ // from the hook_update() function above in that it is called after
|
|
|
|
+ // any node is updated, regardlesss of it's type.
|
|
|
|
+ // An example comes from the tripal_feature module where the URL alias
|
|
|
|
+ // of a node cannot be set in the hook_update() function. Therefore
|
|
|
|
+ // the tripal_feature module uses this function to reset the url path
|
|
|
|
+ // of an updated feature node.
|
|
|
|
+ //
|
|
|
|
+ // This function is not required. You probably won't need it if you
|
|
|
|
+ // don't define a custom node type in the hook_node_info() function. But
|
|
|
|
+ // it is node type agnostic, so you can use this function to do any
|
|
|
|
+ // activity after insert of a node.
|
|
|
|
+
|
|
// add items to other nodes, build index and search results
|
|
// add items to other nodes, build index and search results
|
|
switch ($node->type) {
|
|
switch ($node->type) {
|
|
case 'chado_example':
|
|
case 'chado_example':
|
|
- // remove any previous alias
|
|
|
|
- //db_query("DELETE FROM {url_alias} WHERE source = :source", array(':source' => "node/$node->nid"));
|
|
|
|
-
|
|
|
|
// set the URL for this example page
|
|
// set the URL for this example page
|
|
- //$url_alias = tripal_example_get_example_url($node);
|
|
|
|
- //$path_alias = array("source" => "node/$node->nid", "alias" => $url_alias);
|
|
|
|
- //path_save($path_alias);
|
|
|
|
|
|
+ // see the code in the tripal_feature/includes/tripal_feature.chado_node.inc file
|
|
|
|
+ // in the function tripal_feature_node_insert for an example of how that
|
|
|
|
+ // module sets the URL. It uses a configuration file to allow the user
|
|
|
|
+ // to dynmically build a URL schema and then uses that schema to generate
|
|
|
|
+ // a URL string.
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
- * Implementation of hook_node_view(). This function allows you to
|
|
|
|
- * add custom content to any node page. It is node type agnostic.
|
|
|
|
- * Here we typically use it to add content to our custom node type or
|
|
|
|
- * to other Tripal node types. Typically for Tripal, a content "block"
|
|
|
|
- * (e.g. feature properties, feature dbxref, feature pub) has a corresponding
|
|
|
|
- * template file. Those template files are first defined to Drupal using
|
|
|
|
- * the hook_theme() function defined in the tripal_example.module file. Here
|
|
|
|
- * we can add items to a node's content by calling those templates as needed.
|
|
|
|
|
|
+ * Implementation of hook_node_view().
|
|
*
|
|
*
|
|
* @ingroup tripal_example
|
|
* @ingroup tripal_example
|
|
*/
|
|
*/
|
|
function tripal_example_node_view($node, $view_mode, $langcode) {
|
|
function tripal_example_node_view($node, $view_mode, $langcode) {
|
|
|
|
+
|
|
|
|
+ // EXPLANATION: This function defines the content "blocks" that appear
|
|
|
|
+ // when thhe node is displayed. It is node type agnostic so we can add
|
|
|
|
+ // content to any node type. So, we use this function to add the content
|
|
|
|
+ // from all of our theme templates onto our new node type. We will also
|
|
|
|
+ // use this function to add content to other node types.
|
|
|
|
+
|
|
switch ($node->type) {
|
|
switch ($node->type) {
|
|
case 'chado_example':
|
|
case 'chado_example':
|
|
// there are different ways a node can be viewed. Primarily Tripal
|
|
// there are different ways a node can be viewed. Primarily Tripal
|
|
// supports full page view and teaser view.
|
|
// supports full page view and teaser view.
|
|
if ($view_mode == 'full') {
|
|
if ($view_mode == 'full') {
|
|
- // there is always a base template. This is the template that
|
|
|
|
- // is first shown when the example node type is first displayed
|
|
|
|
- //$node->content['tripal_example_base'] = array(
|
|
|
|
- // '#markup' => theme('tripal_example_base', array('node' => $node)),
|
|
|
|
- // '#tripal_toc_id' => 'base',
|
|
|
|
- // '#tripal_toc_title' => 'Overview',
|
|
|
|
- // '#weight' => -100,
|
|
|
|
- //);
|
|
|
|
- // we can add other templates as well.
|
|
|
|
- //$node->content['tripal_example_properties'] = array(
|
|
|
|
- // '#markup' => theme('tripal_example_properties', array('node' => $node)),
|
|
|
|
- // '#tripal_toc_id' => 'properties',
|
|
|
|
- // '#tripal_toc_title' => 'Properties',
|
|
|
|
- //);
|
|
|
|
- //$node->content['tripal_example_publications'] = array(
|
|
|
|
- // '#markup' => theme('tripal_example_publications', array('node' => $node)),
|
|
|
|
- // '#tripal_toc_id' => 'publications',
|
|
|
|
- // '#tripal_toc_title' => 'Publications',
|
|
|
|
- //);
|
|
|
|
- //$node->content['tripal_example_references'] = array(
|
|
|
|
- // '#markup' => theme('tripal_example_references', array('node' => $node)),
|
|
|
|
- // '#tripal_toc_id' => 'references',
|
|
|
|
- // '#tripal_toc_title' => 'Cross References',
|
|
|
|
- //);
|
|
|
|
|
|
+
|
|
|
|
+ // There is always a base template. This is the template that
|
|
|
|
+ // is first shown when the example node type is first displayed.
|
|
|
|
+ // if you are using the default Tripal node template, then you should
|
|
|
|
+ // also set two additional items in each array: tripal_toc_id and
|
|
|
|
+ // tripal_toc_title. The tripal_tock_id should be a single unqiue
|
|
|
|
+ // world that is used to reference the template. This ID is used for
|
|
|
|
+ // constructing URLs for the content. The tripal_toc_title contains
|
|
|
|
+ // the title that should appear in the table of contents for this
|
|
|
|
+ // content. You should only set the '#weight' element for the
|
|
|
|
+ // base template (or Overview) to ensure that it appears at the top of
|
|
|
|
+ // the list. Otherwise items are sorted alphabetically.
|
|
|
|
+ $node->content['tripal_example_base'] = array(
|
|
|
|
+ '#markup' => theme('tripal_example_base', array('node' => $node)),
|
|
|
|
+ '#tripal_toc_id' => 'base',
|
|
|
|
+ '#tripal_toc_title' => 'Overview',
|
|
|
|
+ '#weight' => -100,
|
|
|
|
+ );
|
|
|
|
+ // we can add other templates as well for properties, publications,
|
|
|
|
+ // dbxrefs, etc...
|
|
|
|
+ $node->content['tripal_example_properties'] = array(
|
|
|
|
+ '#markup' => theme('tripal_example_properties', array('node' => $node)),
|
|
|
|
+ '#tripal_toc_id' => 'properties',
|
|
|
|
+ '#tripal_toc_title' => 'Properties',
|
|
|
|
+ );
|
|
|
|
+ $node->content['tripal_example_references'] = array(
|
|
|
|
+ '#markup' => theme('tripal_feature_references', array('node' => $node)),
|
|
|
|
+ '#tripal_toc_id' => 'references',
|
|
|
|
+ '#tripal_toc_title' => 'Cross References',
|
|
|
|
+ );
|
|
|
|
+ $node->content['tripal_example_relationships'] = array(
|
|
|
|
+ '#markup' => theme('tripal_feature_relationships', array('node' => $node)),
|
|
|
|
+ '#tripal_toc_id' => 'relationships',
|
|
|
|
+ '#tripal_toc_title' => 'Relationships',
|
|
|
|
+ );
|
|
}
|
|
}
|
|
// set the content for the teaser view
|
|
// set the content for the teaser view
|
|
if ($view_mode == 'teaser') {
|
|
if ($view_mode == 'teaser') {
|
|
- //$node->content['tripal_example_teaser'] = array(
|
|
|
|
- // '#value' => theme('tripal_example_teaser', array('node' => $node)),
|
|
|
|
- //);
|
|
|
|
|
|
+ // The teaser is also a required template
|
|
|
|
+ $node->content['tripal_example_teaser'] = array(
|
|
|
|
+ '#value' => theme('tripal_example_teaser', array('node' => $node)),
|
|
|
|
+ );
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
- // you can add custom content to any tripal node type by adding
|
|
|
|
|
|
+ // you can add custom content to any node type by adding
|
|
// content to the node in the same way as above.
|
|
// content to the node in the same way as above.
|
|
case 'chado_organism':
|
|
case 'chado_organism':
|
|
break;
|
|
break;
|