12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?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 id="tripal_project-relationships-box" class="tripal_project-info-box tripal-info-box">
- <div class="tripal_project-info-box-title tripal-info-box-title">Relationships</div>
- <div class="tripal_project-info-box-desc tripal-info-box-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',
- ),
- 'sticky' => FALSE,
- 'caption' => '',
- 'colgroups' => array(),
- 'empty' => '',
- );
-
-
-
- print theme_table($table); ?>
- </div> <?php
- }
|