123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- function tripal_example_preprocess_tripal_example_relationships(&$variables) {
-
-
-
-
-
-
-
-
-
-
- $example = $variables['node']->example;
-
- $options = array(
- 'return_array' => 1,
-
-
-
- 'include_fk' => array(
- 'type_id' => 1,
- 'object_id' => array(
- 'type_id' => 1,
- ),
- 'subject_id' => array(
- 'type_id' => 1,
- ),
- ),
- );
- $example = chado_expand_var($example, 'table', 'example_relationship', $options);
-
- $srelationships = $example->example_relationship->subject_id;
- $orelationships = $example->example_relationship->object_id;
-
- $relationships = array();
- $relationships['object'] = array();
- $relationships['subject'] = array();
-
- if ($orelationships) {
- foreach ($orelationships as $relationship) {
- $rel = new stdClass();
- $rel->record = $relationship;
-
- $rel_type = t(preg_replace('/_/', " ", $relationship->type_id->name));
- $child_type = $relationship->subject_id->type_id->name;
-
- $sql = "SELECT nid FROM {chado_example} WHERE example_id = :example_id";
- $n = db_query($sql, array(':example_id' => $relationship->subject_id->example_id))->fetchObject();
- if ($n) {
- $rel->record->nid = $n->nid;
- }
- if (!array_key_exists($rel_type, $relationships['object'])) {
- $relationships['object'][$rel_type] = array();
- }
- if (!array_key_exists($child_type, $relationships['object'][$rel_type])) {
- $relationships['object'][$rel_type][$child_type] = array();
- }
- $relationships['object'][$rel_type][$child_type][] = $rel;
- }
- }
-
- if ($srelationships) {
- foreach ($srelationships as $relationship) {
- $rel = new stdClass();
- $rel->record = $relationship;
- $rel_type = t(preg_replace('/_/', " ", $relationship->type_id->name));
- $parent_type = $relationship->object_id->type_id->name;
-
- $sql = "SELECT nid FROM {chado_example} WHERE example_id = :example_id";
- $n = db_query($sql, array(':example_id' => $relationship->object_id->example_id))->fetchObject();
- if ($n) {
- $rel->record->nid = $n->nid;
- }
- if (!array_key_exists($rel_type, $relationships['subject'])) {
- $relationships['subject'][$rel_type] = array();
- }
- if (!array_key_exists($parent_type, $relationships['subject'][$rel_type])) {
- $relationships['subject'][$rel_type][$parent_type] = array();
- }
- $relationships['subject'][$rel_type][$parent_type][] = $rel;
- }
- }
- $example->all_relationships = $relationships;
- }
|