1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- $project = $variables['node']->project;
- $all_relationships = $project->all_relationships;
- $object_rels = $all_relationships['object'];
- $subject_rels = $all_relationships['subject'];
- if (count($object_rels) > 0 or count($subject_rels) > 0) { ?>
- <div class="tripal_project-data-block-desc tripal-data-block-desc">This project is related to the following other projects:</div> <?php
- // the $headers array is an array of fields to use as the colum headers.
- // additional documentation can be found here
- // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
- $headers = array('Relationship');
-
- // the $rows array contains an array of rows where each row is an array
- // of values for each column of the table in that row. Additional documentation
- // can be found here:
- // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
- $rows = array();
-
- // first add in the subject relationships.
- foreach ($subject_rels as $rel_type => $objects){
- foreach ($objects as $object){
-
- $object_name = $object->record->object_project_id->name;
- if (property_exists($object->record, 'nid')) {
- $object_name = l($object_name, "node/" . $object->record->nid, array('attributes' => array('target' => "_blank")));
- }
- $rows[] = array(
- "$project->name is a \"$rel_type\" of $object_name",
- );
- }
- }
-
-
- foreach ($object_rels as $rel_type => $subjects){
- foreach ($subjects as $subject){
-
- $subject_name = $subject->record->subject_project_id->name;
- if (property_exists($subject->record, 'nid')) {
- $subject_name = l($subject_name, "node/" . $subject->record->nid, array('attributes' => array('target' => "_blank")));
- }
- $rows[] = array(
- "$subject_name is a \"$rel_type\" of $project->name",
- );
- }
- }
-
-
-
-
- $table = array(
- 'header' => $headers,
- 'rows' => $rows,
- 'attributes' => array(
- 'id' => 'tripal_project-table-relationship-subject',
- 'class' => 'tripal-data-table'
- ),
- 'sticky' => FALSE,
- 'caption' => '',
- 'colgroups' => array(),
- 'empty' => '',
- );
-
-
-
- print theme_table($table);
- }
|