|
@@ -4,34 +4,34 @@ $library = $variables['node']->library;
|
|
|
|
|
|
$options = array('return_array' => 1);
|
|
$options = array('return_array' => 1);
|
|
$library = tripal_core_expand_chado_vars($library, 'table', 'library_cvterm', $options);
|
|
$library = tripal_core_expand_chado_vars($library, 'table', 'library_cvterm', $options);
|
|
-$terms = $library->library_cvterm;
|
|
|
|
|
|
+$terms = (isset($library->library_cvterm)) ? $library->library_cvterm : array();
|
|
|
|
|
|
// order the terms by CV
|
|
// order the terms by CV
|
|
$s_terms = array();
|
|
$s_terms = array();
|
|
foreach ($terms as $term) {
|
|
foreach ($terms as $term) {
|
|
- $s_terms[$term->cvterm_id->cv_id->name][] = $term;
|
|
|
|
|
|
+ $s_terms[$term->cvterm_id->cv_id->name][] = $term;
|
|
}
|
|
}
|
|
|
|
|
|
if (count($s_terms) > 0) { ?>
|
|
if (count($s_terms) > 0) { ?>
|
|
<div id="tripal_library-terms-box" class="tripal_library-info-box tripal-info-box">
|
|
<div id="tripal_library-terms-box" class="tripal_library-info-box tripal-info-box">
|
|
<div class="tripal_library-info-box-title tripal-info-box-title">Annotated Terms</div>
|
|
<div class="tripal_library-info-box-title tripal-info-box-title">Annotated Terms</div>
|
|
<div class="tripal_library-info-box-desc tripal-info-box-desc">The following terms have been associated with this <?php print $node->library->type_id->name ?>:</div> <?php
|
|
<div class="tripal_library-info-box-desc tripal-info-box-desc">The following terms have been associated with this <?php print $node->library->type_id->name ?>:</div> <?php
|
|
-
|
|
|
|
|
|
+
|
|
// iterate through each term
|
|
// iterate through each term
|
|
$i = 0;
|
|
$i = 0;
|
|
- foreach ($s_terms as $cv => $terms) {
|
|
|
|
|
|
+ foreach ($s_terms as $cv => $terms) {
|
|
// the $headers array is an array of fields to use as the colum headers.
|
|
// the $headers array is an array of fields to use as the colum headers.
|
|
// additional documentation can be found here
|
|
// additional documentation can be found here
|
|
// https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
|
|
// https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
|
|
$headers = array('Term', 'Definition');
|
|
$headers = array('Term', 'Definition');
|
|
-
|
|
|
|
|
|
+
|
|
// the $rows array contains an array of rows where each row is an array
|
|
// 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
|
|
// of values for each column of the table in that row. Additional documentation
|
|
// can be found here:
|
|
// can be found here:
|
|
// https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
|
|
// https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
|
|
$rows = array();
|
|
$rows = array();
|
|
-
|
|
|
|
- foreach ($terms as $term) {
|
|
|
|
|
|
+
|
|
|
|
+ foreach ($terms as $term) {
|
|
|
|
|
|
$accession = $term->cvterm_id->dbxref_id->accession;
|
|
$accession = $term->cvterm_id->dbxref_id->accession;
|
|
if (is_numeric($term->cvterm_id->dbxref_id->accession)) {
|
|
if (is_numeric($term->cvterm_id->dbxref_id->accession)) {
|
|
@@ -39,13 +39,13 @@ if (count($s_terms) > 0) { ?>
|
|
}
|
|
}
|
|
if ($term->cvterm_id->dbxref_id->db_id->urlprefix) {
|
|
if ($term->cvterm_id->dbxref_id->db_id->urlprefix) {
|
|
$accession = l($accession, $term->cvterm_id->dbxref_id->db_id->urlprefix . $accession, array('attributes' => array("target" => '_blank')));
|
|
$accession = l($accession, $term->cvterm_id->dbxref_id->db_id->urlprefix . $accession, array('attributes' => array("target" => '_blank')));
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
$rows[] = array(
|
|
$rows[] = array(
|
|
$accession,
|
|
$accession,
|
|
$term->cvterm_id->name
|
|
$term->cvterm_id->name
|
|
);
|
|
);
|
|
- }
|
|
|
|
|
|
+ }
|
|
// the $table array contains the headers and rows array as well as other
|
|
// the $table array contains the headers and rows array as well as other
|
|
// options for controlling the display of the table. Additional
|
|
// options for controlling the display of the table. Additional
|
|
// documentation can be found here:
|
|
// documentation can be found here:
|
|
@@ -61,7 +61,7 @@ if (count($s_terms) > 0) { ?>
|
|
'colgroups' => array(),
|
|
'colgroups' => array(),
|
|
'empty' => '',
|
|
'empty' => '',
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+
|
|
// once we have our table array structure defined, we call Drupal's theme_table()
|
|
// once we have our table array structure defined, we call Drupal's theme_table()
|
|
// function to generate the table.
|
|
// function to generate the table.
|
|
print theme_table($table);
|
|
print theme_table($table);
|