tripal_featuremap.chado_node.inc 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. <?php
  2. /**
  3. * @file
  4. * Hooks implementing the feature map node content type
  5. */
  6. /**
  7. * Implements hook_node_info().
  8. *
  9. * Provide information to drupal about the node types that we're creating
  10. * in this module
  11. *
  12. * @ingroup tripal_legacy_featuremap
  13. */
  14. function tripal_featuremap_node_info() {
  15. $nodes = [];
  16. $nodes['chado_featuremap'] = [
  17. 'name' => t('Feature Map (Tripal v2 legacy)'),
  18. 'base' => 'chado_featuremap',
  19. 'description' => t('A map of features from the chado database (e.g. genetic map)'),
  20. 'has_title' => TRUE,
  21. 'locked' => TRUE,
  22. 'chado_node_api' => [
  23. 'base_table' => 'featuremap',
  24. 'hook_prefix' => 'chado_featuremap',
  25. 'record_type_title' => [
  26. 'singular' => t('Feature Map'),
  27. 'plural' => t('Feature Maps'),
  28. ],
  29. 'sync_filters' => [
  30. 'type_id' => FALSE,
  31. 'organism_id' => FALSE,
  32. ],
  33. ],
  34. ];
  35. return $nodes;
  36. }
  37. /**
  38. * When editing or creating a new node of type 'chado_featuremap' we need
  39. * a form. This function creates the form that will be used for this.
  40. *
  41. * @ingroup tripal_legacy_featuremap
  42. */
  43. function chado_featuremap_form($node, &$form_state) {
  44. $form = [];
  45. // Default values can come in the following ways:
  46. //
  47. // 1) as elements of the $node object. This occurs when editing an existing library
  48. // 2) in the $form_state['values'] array which occurs on a failed validation or
  49. // ajax callbacks from non submit form elements
  50. // 3) in the $form_state['input'[ array which occurs on ajax callbacks from submit
  51. // form elements and the form is being rebuilt
  52. //
  53. // set form field defaults
  54. $featuremap_id = NULL;
  55. $fmapname = '';
  56. $description = '';
  57. $unittype_id = '';
  58. // if we are editing an existing node then the featuremap is already part of the node
  59. if (property_exists($node, 'featuremap')) {
  60. $featuremap = $node->featuremap;
  61. $featuremap = chado_expand_var($featuremap, 'field', 'featuremap.description');
  62. $featuremap_id = $featuremap->featuremap_id;
  63. // get form defaults
  64. $fmapname = $featuremap->name;
  65. $description = $featuremap->description;
  66. $unittype_id = $featuremap->unittype_id->cvterm_id;
  67. // set the featuremap_id in the form
  68. $form['featuremap_id'] = [
  69. '#type' => 'hidden',
  70. '#value' => $featuremap_id,
  71. ];
  72. }
  73. // if we are re constructing the form from a failed validation or ajax callback
  74. // then use the $form_state['values'] values
  75. if (array_key_exists('values', $form_state)) {
  76. $fmapname = $form_state['values']['fmapname'];
  77. $description = $form_state['values']['description'];
  78. $unittype_id = $form_state['values']['unittype_id'];
  79. }
  80. // if we are re building the form from after submission (from ajax call) then
  81. // the values are in the $form_state['input'] array
  82. if (array_key_exists('input', $form_state) and !empty($form_state['input'])) {
  83. $fmapname = $form_state['input']['fmapname'];
  84. $description = $form_state['input']['description'];
  85. $unittype_id = $form_state['input']['unittype_id'];
  86. }
  87. $form['fmapname'] = [
  88. '#type' => 'textfield',
  89. '#title' => t('Map Name'),
  90. '#description' => t('Please enter a name for this map'),
  91. '#required' => TRUE,
  92. '#default_value' => $fmapname,
  93. '#maxlength' => 255,
  94. ];
  95. $form['description'] = [
  96. '#type' => 'text_format',
  97. '#title' => t('Map Description'),
  98. '#description' => t('A description of the map.'),
  99. '#required' => TRUE,
  100. '#default_value' => $description,
  101. ];
  102. // get the list of unit types
  103. $units = tripal_get_cvterm_default_select_options('featuremap', 'unittype_id', 'map unit types');
  104. $form['unittype_id'] = [
  105. '#title' => t('Map Units'),
  106. '#type' => t('select'),
  107. '#description' => t("Chose the units for this map"),
  108. '#required' => TRUE,
  109. '#default_value' => $unittype_id,
  110. '#options' => $units,
  111. ];
  112. // Properties Form
  113. // ----------------------------------
  114. $prop_cv = tripal_get_default_cv('featuremap_property', 'type_id');
  115. $cv_id = $prop_cv ? $prop_cv->cv_id : NULL;
  116. $instructions = t('To add additional properties to the drop down. ' . l("Add terms to the featuremap_property vocabulary", "admin/tripal/vocab/cvterm/add") . ".");
  117. $details = [
  118. 'property_table' => 'featuremapprop',
  119. 'chado_id' => $featuremap_id,
  120. 'cv_id' => $cv_id,
  121. 'fieldset_name' => 'Additional Details',
  122. 'additional_instructions' => $instructions,
  123. ];
  124. // TODO: remove the 'Map Dbxref' from the list as that should now be handled
  125. // by the dbxref interface below
  126. chado_add_node_form_properties($form, $form_state, $details);
  127. // ADDITIONAL DBXREFS FORM
  128. //---------------------------------------------
  129. $details = [
  130. 'linking_table' => 'featuremap_dbxref',
  131. // the name of the _dbxref table
  132. 'base_foreign_key' => 'featuremap_id',
  133. // the name of the key in your base chado table
  134. 'base_key_value' => $featuremap_id
  135. // the value of featuremap_id for this record
  136. ];
  137. // Adds the form elements to your current form
  138. chado_add_node_form_dbxrefs($form, $form_state, $details);
  139. return $form;
  140. }
  141. /**
  142. * Validates submission of form when adding or updating a map node
  143. *
  144. * @ingroup tripal_legacy_featuremap
  145. */
  146. function chado_featuremap_validate($node, $form, &$form_state) {
  147. // We only want to validate when the node is saved.
  148. // Since this validate can be called on AJAX and Deletion of the node
  149. // we need to make this check to ensure queries are not executed
  150. // without the proper values.
  151. if (property_exists($node, "op") and $node->op != 'Save') {
  152. return;
  153. }
  154. // we are syncing if we do not have a node ID but we do have a featuremap_id. We don't
  155. // need to validate during syncing so just skip it.
  156. if (!property_exists($node, 'nid') and property_exists($node, 'featuremap_id') and $node->featuremap_id != 0) {
  157. return;
  158. }
  159. if ($node->unittype_id == 0) {
  160. form_set_error('unittype_id', 'Please provide a unit type for this map.');
  161. }
  162. // trim white space from text fields
  163. $node->fmapname = property_exists($node, 'fmapname') ? trim($node->fmapname) : '';
  164. $featuremap = 0;
  165. // check to make sure the unique name on the map is unique
  166. // before we try to insert into chado. If this is an update then we will
  167. // have a featuremap_id, therefore we want to look for another map with this
  168. // name but with a different featuremap_id. If this is an insert, just look
  169. // for a case where the name already exists.
  170. if (property_exists($node, 'featuremap_id')) {
  171. $sql = "
  172. SELECT * FROM {featuremap}
  173. WHERE name = :name AND NOT featuremap_id = :featuremap_id
  174. ";
  175. $featuremap = chado_query($sql, [
  176. ':name' => $node->fmapname,
  177. ':featuremap_id' => $node->featuremap_id,
  178. ])->fetchObject();
  179. }
  180. else {
  181. $sql = "SELECT * FROM {featuremap} WHERE name = :name";
  182. $featuremap = chado_query($sql, [':name' => $node->fmapname])->fetchObject();
  183. }
  184. if ($featuremap) {
  185. form_set_error('fmapname', t('The unique map name already exists. Please choose another'));
  186. }
  187. }
  188. /**
  189. * Implement hook_node_access().
  190. *
  191. * This hook allows node modules to limit access to the node types they define.
  192. *
  193. * @param $node
  194. * The node on which the operation is to be performed, or, if it does not yet
  195. * exist, the type of node to be created
  196. *
  197. * @param $op
  198. * The operation to be performed
  199. *
  200. * @param $account
  201. * A user object representing the user for whom the operation is to be
  202. * performed
  203. *
  204. * @return
  205. * If the permission for the specified operation is not set then return FALSE.
  206. * If the permission is set then return NULL as this allows other modules to
  207. * disable access. The only exception is when the $op == 'create'. We will
  208. * always return TRUE if the permission is set.
  209. *
  210. * @ingroup tripal_legacy_featuremap
  211. */
  212. function tripal_featuremap_node_access($node, $op, $account) {
  213. $node_type = $node;
  214. if (is_object($node)) {
  215. $node_type = $node->type;
  216. }
  217. if ($node_type == 'chado_featuremap') {
  218. if ($op == 'create') {
  219. if (!user_access('create chado_featuremap content', $account)) {
  220. return NODE_ACCESS_DENY;
  221. }
  222. return NODE_ACCESS_ALLOW;
  223. }
  224. if ($op == 'update') {
  225. if (!user_access('edit chado_featuremap content', $account)) {
  226. return NODE_ACCESS_DENY;
  227. }
  228. }
  229. if ($op == 'delete') {
  230. if (!user_access('delete chado_featuremap content', $account)) {
  231. return NODE_ACCESS_DENY;
  232. }
  233. }
  234. if ($op == 'view') {
  235. if (!user_access('access chado_featuremap content', $account)) {
  236. return NODE_ACCESS_DENY;
  237. }
  238. }
  239. return NODE_ACCESS_IGNORE;
  240. }
  241. }
  242. /**
  243. * Implements hook_insert().
  244. *
  245. * When a new chado_featuremap node is created we also need to add information
  246. * to our chado_featuremap table. This function is called on insert of a new
  247. * node of type 'chado_featuremap' and inserts the necessary information.
  248. *
  249. * @ingroup tripal_legacy_featuremap
  250. */
  251. function chado_featuremap_insert($node) {
  252. $featuremap_id = '';
  253. // if there is an featuremap_id in the $node object then this must be a sync so
  254. // we can skip adding the featuremap as it is already there, although
  255. // we do need to proceed with insertion into the chado/drupal linking table.
  256. if (!property_exists($node, 'featuremap_id')) {
  257. $node->fmapname = trim($node->fmapname);
  258. $node->description = trim($node->description['value']);
  259. $values = [
  260. 'name' => $node->fmapname,
  261. 'description' => $node->description,
  262. 'unittype_id' => $node->unittype_id,
  263. ];
  264. $featuremap = chado_insert_record('featuremap', $values);
  265. if (!$featuremap) {
  266. drupal_set_message(t('Unable to add featuremap.', 'warning'));
  267. tripal_report_error('tripal_featuremap', TRIPAL_WARNING, 'Unable to create feature map where values: %values',
  268. ['%values' => print_r($values, TRUE)]);
  269. return;
  270. }
  271. $featuremap_id = $featuremap['featuremap_id'];
  272. // now add in the properties
  273. $properties = chado_retrieve_node_form_properties($node);
  274. // We need to deal with the 'Map Dbxref' property specially
  275. $cvterm = chado_select_record(
  276. 'cvterm',
  277. ['cvterm_id'],
  278. ['name' => 'Map Dbxref', 'cv_id' => ['name' => 'featuremap_property']]
  279. );
  280. $map_dbxref_cvterm_id = $cvterm[0]->cvterm_id;
  281. if (isset($properties[$map_dbxref_cvterm_id])) {
  282. foreach ($properties[$map_dbxref_cvterm_id] as $rank => $value) {
  283. $featuremap_dbxref = tripal_featuremap_add_featuremap_dbxref($featuremap_id, $value);
  284. if (!$featuremap_dbxref) {
  285. drupal_set_message("Error cannot add featuremap cross reference: $value", "error");
  286. tripal_report_error('t_featuremap', TRIPAL_ERROR, "Error cannot add featuremap cross reference: %ref",
  287. ['%ref' => $value]);
  288. }
  289. }
  290. unset($properties[$map_dbxref_cvterm_id]);
  291. }
  292. $details = [
  293. 'property_table' => 'featuremapprop',
  294. 'base_table' => 'featuremap',
  295. 'foreignkey_name' => 'featuremap_id',
  296. 'foreignkey_value' => $featuremap_id,
  297. ];
  298. chado_update_node_form_properties($node, $details, $properties);
  299. // * Additional DBxrefs Form *
  300. $details = [
  301. 'linking_table' => 'featuremap_dbxref',
  302. // the name of your _dbxref table
  303. 'foreignkey_name' => 'featuremap_id',
  304. // the name of the key in your base table
  305. 'foreignkey_value' => $featuremap_id
  306. // the value of the featuremap_id key
  307. ];
  308. chado_update_node_form_dbxrefs($node, $details);
  309. }
  310. else {
  311. $featuremap_id = $node->featuremap_id;
  312. }
  313. // Make sure the entry for this featuremap doesn't already exist in the
  314. // chado_featuremap table if it doesn't exist then we want to add it.
  315. $check_org_id = chado_get_id_from_nid('featuremap', $node->nid);
  316. if (!$check_org_id) {
  317. $record = new stdClass();
  318. $record->nid = $node->nid;
  319. $record->vid = $node->vid;
  320. $record->featuremap_id = $featuremap_id;
  321. drupal_write_record('chado_featuremap', $record);
  322. }
  323. }
  324. /**
  325. * Implements hook_update(). Update nodes
  326. *
  327. * @ingroup tripal_legacy_featuremap
  328. */
  329. function chado_featuremap_update($node) {
  330. $node->fmapname = trim($node->fmapname);
  331. $node->description = trim($node->description['value']);
  332. $featuremap_id = chado_get_id_from_nid('featuremap', $node->nid);
  333. // update the map record
  334. $match = [
  335. 'featuremap_id' => $featuremap_id,
  336. ];
  337. $values = [
  338. 'name' => $node->fmapname,
  339. 'description' => $node->description,
  340. 'unittype_id' => $node->unittype_id,
  341. ];
  342. $status = chado_update_record('featuremap', $match, $values);
  343. if (!$status) {
  344. drupal_set_message("Error updating map", "error");
  345. tripal_report_error('t_featuremap', TRIPAL_ERROR, "Error updating map", []);
  346. return;
  347. }
  348. // Update the properties
  349. $properties = chado_retrieve_node_form_properties($node);
  350. // We need to deal with the 'Map Dbxref' property specially
  351. $cvterm = chado_select_record(
  352. 'cvterm',
  353. ['cvterm_id'],
  354. ['name' => 'Map Dbxref', 'cv_id' => ['name' => 'featuremap_property']]
  355. );
  356. $map_dbxref_cvterm_id = $cvterm[0]->cvterm_id;
  357. if (isset($properties[$map_dbxref_cvterm_id])) {
  358. foreach ($properties[$map_dbxref_cvterm_id] as $rank => $value) {
  359. $featuremap_dbxref = tripal_featuremap_add_featuremap_dbxref($featuremap_id, $value);
  360. if (!$featuremap_dbxref) {
  361. drupal_set_message("Error cannot add featuremap cross reference: $value", "error");
  362. tripal_report_error('t_featuremap', TRIPAL_ERROR, "Error cannot add featuremap cross reference: %ref",
  363. ['%ref' => $value]);
  364. }
  365. }
  366. unset($properties[$map_dbxref_cvterm_id]);
  367. }
  368. $details = [
  369. 'property_table' => 'featuremapprop',
  370. 'base_table' => 'featuremap',
  371. 'foreignkey_name' => 'featuremap_id',
  372. 'foreignkey_value' => $featuremap_id,
  373. ];
  374. chado_update_node_form_properties($node, $details, $properties);
  375. // * Additional DBxrefs Form *
  376. $details = [
  377. 'linking_table' => 'featuremap_dbxref',
  378. // the name of your _dbxref table
  379. 'foreignkey_name' => 'featuremap_id',
  380. // the name of the key in your base table
  381. 'foreignkey_value' => $featuremap_id
  382. // the value of the featuremap_id key
  383. ];
  384. chado_update_node_form_dbxrefs($node, $details);
  385. }
  386. /**
  387. * Implements hook_load().
  388. *
  389. * When a node is requested by the user this function is called to allow us
  390. * to add auxiliary data to the node object.
  391. *
  392. * @ingroup tripal_legacy_featuremap
  393. */
  394. function chado_featuremap_load($nodes) {
  395. foreach ($nodes as $nid => $node) {
  396. // get the feature details from chado
  397. $featuremap_id = chado_get_id_from_nid('featuremap', $node->nid);
  398. // if the nid does not have a matching record then skip this node.
  399. // this can happen with orphaned nodes.
  400. if (!$featuremap_id) {
  401. continue;
  402. }
  403. $values = ['featuremap_id' => $featuremap_id];
  404. $featuremap = chado_generate_var('featuremap', $values);
  405. // expand the description field as it is needed by the form
  406. $featuremap = chado_expand_var($featuremap, 'field', 'featuremap.description');
  407. $nodes[$nid]->featuremap = $featuremap;
  408. // Now get the title
  409. $node->title = chado_get_node_title($node);
  410. }
  411. }
  412. /**
  413. * Implements hook_delete().
  414. *
  415. * Delete data from drupal and chado databases when a node is deleted
  416. *
  417. * @ingroup tripal_legacy_featuremap
  418. */
  419. function chado_featuremap_delete(&$node) {
  420. $featuremap_id = chado_get_id_from_nid('featuremap', $node->nid);
  421. // if we don't have a map id for this node then this isn't a node of
  422. // type chado_featuremap or the entry in the chado_featuremap table was lost.
  423. if (!$featuremap_id) {
  424. return;
  425. }
  426. // Remove data from {chado_featuremap}, {node} and {node_revisions} tables of
  427. // drupal database
  428. $sql_del = "DELETE FROM {chado_featuremap} WHERE nid = :nid AND vid = :vid";
  429. db_query($sql_del, [':nid' => $node->nid, ':vid' => $node->vid]);
  430. $sql_del = "DELETE FROM {node_revision} WHERE nid = :nid AND vid = :vid";
  431. db_query($sql_del, [':nid' => $node->nid, ':vid' => $node->vid]);
  432. $sql_del = "DELETE FROM {node} WHERE nid = :nid AND vid = :vid";
  433. db_query($sql_del, [':nid' => $node->nid, ':vid' => $node->vid]);
  434. // Remove data from map and mapprop tables of chado database as well
  435. chado_query("DELETE FROM {featuremapprop} WHERE featuremap_id = :featuremap_id", [':featuremap_id' => $featuremap_id]);
  436. chado_query("DELETE FROM {featuremap_dbxref} WHERE featuremap_id = :featuremap_id", [':featuremap_id' => $featuremap_id]);
  437. chado_query("DELETE FROM {featuremap} WHERE featuremap_id = :featuremap_id", [':featuremap_id' => $featuremap_id]);
  438. }
  439. /**
  440. * Implements hook_node_presave(). Acts on all content types.
  441. *
  442. * @ingroup tripal_legacy_featuremap
  443. */
  444. function tripal_featuremap_node_presave($node) {
  445. switch ($node->type) {
  446. // This step is for setting the title for the Drupal node. This title
  447. // is permanent and thus is created to be unique. Title changes provided
  448. // by tokens are generated on the fly dynamically, but the node title
  449. // seen in the content listing needs to be set here. Do not call
  450. // the chado_get_node_title() function here to set the title as the node
  451. // object isn't properly filled out and the function will fail.
  452. case 'chado_featuremap':
  453. // for a form submission the 'fmapname' field will be set,
  454. // for a sync, we must pull from the featuremap object
  455. if (property_exists($node, 'fmapname')) {
  456. // set the title
  457. $node->title = $node->fmapname;
  458. }
  459. else {
  460. if (property_exists($node, 'featuremap')) {
  461. $node->title = $node->featuremap->name;
  462. }
  463. }
  464. break;
  465. }
  466. }
  467. /**
  468. * Implements hook_node_view(). Acts on all content types.
  469. *
  470. * @ingroup tripal_feature
  471. */
  472. function tripal_featuremap_node_view($node, $view_mode, $langcode) {
  473. switch ($node->type) {
  474. case 'chado_featuremap':
  475. // Show feature browser and counts
  476. if ($view_mode == 'full') {
  477. $node->content['tripal_featuremap_base'] = [
  478. '#theme' => 'tripal_featuremap_base',
  479. '#node' => $node,
  480. '#tripal_toc_id' => 'base',
  481. '#tripal_toc_title' => 'Overview',
  482. '#weight' => -100,
  483. ];
  484. $node->content['tripal_featuremap_featurepos'] = [
  485. '#theme' => 'tripal_featuremap_featurepos',
  486. '#node' => $node,
  487. '#tripal_toc_id' => 'featurepos',
  488. '#tripal_toc_title' => 'Map Features',
  489. ];
  490. $node->content['tripal_featuremap_properties'] = [
  491. '#theme' => 'tripal_featuremap_properties',
  492. '#node' => $node,
  493. '#tripal_toc_id' => 'properties',
  494. '#tripal_toc_title' => 'Properties',
  495. ];
  496. $node->content['tripal_featuremap_publication'] = [
  497. '#theme' => 'tripal_featuremap_publication',
  498. '#node' => $node,
  499. '#tripal_toc_id' => 'publications',
  500. '#tripal_toc_title' => 'Publications',
  501. ];
  502. $node->content['tripal_featuremap_references'] = [
  503. '#theme' => 'tripal_featuremap_references',
  504. '#node' => $node,
  505. '#tripal_toc_id' => 'references',
  506. '#tripal_toc_title' => 'Cross References',
  507. ];
  508. }
  509. if ($view_mode == 'teaser') {
  510. $node->content['tripal_featuremap_teaser'] = [
  511. '#theme' => 'tripal_featuremap_teaser',
  512. '#node' => $node,
  513. ];
  514. }
  515. break;
  516. case 'chado_feature':
  517. if ($view_mode == 'full') {
  518. $node->content['tripal_feature_featurepos'] = [
  519. '#theme' => 'tripal_feature_featurepos',
  520. '#node' => $node,
  521. '#tripal_toc_id' => 'featurepos',
  522. '#tripal_toc_title' => 'Maps',
  523. ];
  524. }
  525. break;
  526. }
  527. }
  528. /**
  529. * Implements hook_node_insert().
  530. * Acts on all content types.
  531. *
  532. * @ingroup tripal_legacy_featuremap
  533. */
  534. function tripal_featuremap_node_insert($node) {
  535. switch ($node->type) {
  536. case 'chado_featuremap':
  537. // get the feature details from chado
  538. $featuremap_id = chado_get_id_from_nid('featuremap', $node->nid);
  539. $values = ['featuremap_id' => $featuremap_id];
  540. $featuremap = chado_generate_var('featuremap', $values);
  541. $node->featuremap = $featuremap;
  542. // Now get the title
  543. $node->title = chado_get_node_title($node);
  544. // Now use the API to set the path.
  545. chado_set_node_url($node);
  546. break;
  547. }
  548. }
  549. /**
  550. * Implements hook_node_update().
  551. * Acts on all content types.
  552. *
  553. * @ingroup tripal_legacy_featuremap
  554. */
  555. function tripal_featuremap_node_update($node) {
  556. switch ($node->type) {
  557. case 'chado_featuremap':
  558. // Now get the title
  559. $node->title = chado_get_node_title($node);
  560. // Now use the API to set the path.
  561. chado_set_node_url($node);
  562. break;
  563. }
  564. }
  565. /**
  566. * Implements [content_type]_chado_node_default_title_format().
  567. *
  568. * Defines a default title format for the Chado Node API to set the titles on
  569. * Chado featuremap nodes based on chado fields.
  570. */
  571. function chado_featuremap_chado_node_default_title_format() {
  572. return '[featuremap.name]';
  573. }
  574. /**
  575. * Implements hook_chado_node_default_url_format().
  576. *
  577. * Designates a default URL format for featuremap nodes.
  578. */
  579. function chado_featuremap_chado_node_default_url_format() {
  580. return '/featuremap/[featuremap.featuremap_id]';
  581. }