Browse Source

A few fixes to the stock node template and sub-templates

laceysanderson 14 năm trước cách đây
mục cha
commit
70d3f53169

+ 10 - 4
theme_tripal/node-chado_stock.tpl.php

@@ -18,15 +18,20 @@
 //       specific fields such as stock_name, uniquename, stock_type, synonyms,
 //       properties, db_references, object_relationships, subject_relationships,
 //       organism, etc.
-//   NOTE: For a full listing of fields available in the node object add
-//       <pre><?php print_r($node); ?></pre> to this template or install
-//       the Drupal Devel module which provides an extra tab at the top of
-//       the node page labelled Devel
+//   NOTE: For a full listing of fields available in the node object the
+//       print_r $node line below or install the Drupal Devel module which 
+//       provides an extra tab at the top of the node page labelled Devel
+?>
+
+<?php
+ //uncomment this line to see a full listing of the fields avail. to $node
+ //print '<pre>'.print_r($node,TRUE).'</pre>';
 ?>
 
 <!-- Base Theme -->
 <?php include('tripal_stock/tripal_stock_base.tpl.php'); ?>
 
+<?php if (!$teaser) { ?>
 <!-- Database References -->
 <?php include('tripal_stock/tripal_stock_references.tpl.php'); ?>
 
@@ -41,3 +46,4 @@
 
 <!-- Subject Relationships -->
 <?php include('tripal_stock/tripal_stock_relationships_as_subject.tpl.php'); ?>
+<?php } ?>

+ 81 - 0
theme_tripal/tripal_stock/tripal_stock_base.tpl.php

@@ -0,0 +1,81 @@
+<?php
+// Copyright 2010 University of Saskatchewan (Lacey-Anne Sanderson)
+//
+// Purpose: Provide layout and content for the basic stock details. This
+//   includes all fields in the chado stock table supplemented with extra
+//   details for each foreign key to provide human-readable output
+//
+// Note: This template controls the layout/content for the default stock node
+//   template (node-chado_stock.tpl.php) and the Stock Details Block
+//
+// Variables Available:
+//   - $node: a standard object which contains all the fields associated with
+//       nodes including nid, type, title, taxonomy. It also includes stock
+//       specific fields such as stock_name, uniquename, stock_type, synonyms,
+//       properties, db_references, object_relationships, subject_relationships,
+//       organism, etc.
+//   NOTE: For a full listing of fields available in the node object the
+//       print_r $node line below or install the Drupal Devel module which 
+//       provides an extra tab at the top of the node page labelled Devel
+?>
+
+<?php
+ //uncomment this line to see a full listing of the fields avail. to $node
+ //print '<pre>'.print_r($node,TRUE).'</pre>';
+?>
+
+<?php $organism = $node->organism; ?>
+
+<div id="tripal_stock-base-box" class="tripal_stock-info-box tripal-info-box">
+  <div class="tripal_stock-info-box-title tripal-info-box-title">Stock Details</div>
+  <div class="tripal_stock-info-box-desc tripal-info-box-desc"></div>
+
+   <?php if($node->is_obsolete == 't'){ ?>
+      <div class="tripal_stock-obsolete">This stock is obsolete and no longer used in analysis, but is here for reference</div>
+   <?php }?>
+   <table class="tripal_stock-table tripal-table tripal-table-vert">
+      <tr class="tripal_stock-table-odd-row tripal-table-even-row">
+        <th>Name</th>
+        <td><?php print $node->stock_name; ?></td>
+      </tr>
+      <tr class="tripal_stock-table-odd-row tripal-table-odd-row">
+        <th nowrap>Unique Name</th>
+        <td><?php print $node->uniquename; ?></td>
+      </tr>
+      <tr class="tripal_stock-table-odd-row tripal-table-even-row">
+        <th>Internal ID</th>
+        <?php if (!empty($node->main_db_reference->dbxref_id)) { ?>
+        	<?php 
+        		if ($node->main_db_reference->db_urlprefix) {
+        			$accession = l($node->main_db_reference->accession, $node->main_db_reference->db_urlprefix.$node->main_db_reference->accession);
+        		} else {
+        			$accession = $node->main_db_reference->accession;
+        		}
+        		if ($node->main_db_reference->db_url) {
+        			$accession .= ' ('.l($node->main_db_reference->db_name, $node->main_db_reference->db_url).')';
+        		} else {
+        			$accession .= ' ('.$node->main_db_reference->db_name.')';
+        		}
+        	?>
+        	<td><?php print $accession; ?></td>
+        <?php } else { ?>
+        	<td></td>
+        <?php } ?>
+      </tr>
+      <tr class="tripal_stock-table-odd-row tripal-table-odd-row">
+        <th>Type</th>
+        <td><?php print $node->stock_type; ?></td>
+      </tr>
+      <tr class="tripal_stock-table-odd-row tripal-table-even-row">
+        <th>Organism</th>
+        <td>
+          <?php if ($organism->nid) { ?>
+      	   <a href="<?php print url("node/$organism->nid") ?>"><?php print $organism->genus ." " . $organism->species ." (" .$organism->common_name ." )"?></a>
+      	 <?php 
+          } else { 
+            print $organism->genus ." " . $organism->species ." (" .$organism->common_name ." )";
+          } ?>
+        </td>
+     	</tr>           	                                
+   </table>
+</div>

+ 49 - 0
theme_tripal/tripal_stock/tripal_stock_properties.tpl.php

@@ -0,0 +1,49 @@
+<?php
+// Copyright 2010 University of Saskatchewan (Lacey-Anne Sanderson)
+//
+// Purpose: Provide layout and content for stock properties. This includes all
+//   fields in the stockprop table with the stock_id of the current stock
+//   supplemented with extra details for the type to provide human-readable
+//   output
+//
+// Note: This template controls the layout/content for the default stock node
+//   template (node-chado_stock.tpl.php) and the Stock Properties Block
+//
+// Variables Available:
+//   - $node: a standard object which contains all the fields associated with
+//       nodes including nid, type, title, taxonomy. It also includes stock
+//       specific fields such as stock_name, uniquename, stock_type, synonyms,
+//       properties, db_references, object_relationships, subject_relationships,
+//       organism, etc.
+//   - $node->properties: an array of stock property objects where each object
+//       the following fields: stockprop_id, type_id, type, value, rank
+//       and includes synonyms
+//   NOTE: For a full listing of fields available in the node object the
+//       print_r $node line below or install the Drupal Devel module which 
+//       provides an extra tab at the top of the node page labelled Devel
+?>
+
+<?php
+ //uncomment this line to see a full listing of the fields avail. to $node
+ //print '<pre>'.print_r($node,TRUE).'</pre>';
+?>
+
+<div id="tripal_stock-properties-box" class="tripal_stock-info-box tripal-info-box">
+  <div class="tripal_stock-info-box-title tripal-info-box-title">Properties</div>
+  <div class="tripal_stock-info-box-desc tripal-info-box-desc">Properties for the stock '<?php print $node->stock_name ?>' include:</div>
+	<?php if(count($node->properties) > 0){ ?>
+  <table class="tripal_stock-table tripal-table tripal-table-horz">
+  <tr><th>Type</th><th>Value</th></tr>
+	<?php	// iterate through each property
+		$i = 0;
+		foreach ($node->properties as $result){
+		  $class = 'tripal_stock-table-odd-row tripal-table-odd-row';
+      if($i % 2 == 0 ){
+         $class = 'tripal_stock-table-odd-row tripal-table-even-row';
+      }
+			print '<tr class="'.$class.'"><td>'.$result->type.'</td><td>'.$result->value.'</td></tr>';
+			$i++;
+		} ?>
+		</table>
+	<?php } ?>
+</div>

+ 66 - 0
theme_tripal/tripal_stock/tripal_stock_references.tpl.php

@@ -0,0 +1,66 @@
+<?php
+// Copyright 2010 University of Saskatchewan (Lacey-Anne Sanderson)
+//
+// Purpose: Provides the layout and content for stock external database 
+//   references (this doesn't include the main database reference from the
+//   stock table). This includes all fields from the dbxref and db chado tables
+//   where each dbxref is associated with the current stock through the
+//   stock_dbxref table
+//
+// Note: This template controls the layout/content for the default stock node
+//   template (node-chado_stock.tpl.php) and the Stock Database References Block
+//
+// Variables Available:
+//   - $node: a standard object which contains all the fields associated with
+//       nodes including nid, type, title, taxonomy. It also includes stock
+//       specific fields such as stock_name, uniquename, stock_type, synonyms,
+//       properties, db_references, object_relationships, subject_relationships,
+//       organism, etc.
+//   - $node->db_references: an array of stock database reference objects 
+//       where each object has the following fields: dbxref_id, accession,
+//       version, description, db_id, db_name, db_description, db_url, 
+//       db_urlprefix 
+//   NOTE: For a full listing of fields available in the node object the
+//       print_r $node line below or install the Drupal Devel module which 
+//       provides an extra tab at the top of the node page labelled Devel
+?>
+
+<?php
+ //uncomment this line to see a full listing of the fields avail. to $node
+ //print '<pre>'.print_r($node,TRUE).'</pre>';
+?>
+
+<div id="tripal_stock-references-box" class="tripal_stock-info-box tripal-info-box">
+  <div class="tripal_stock-info-box-title tripal-info-box-title">References</div>
+  <div class="tripal_stock-info-box-desc tripal-info-box-desc">The stock '<?php print $node->stock_name ?>' is also available at these locations</div>
+  <?php if(count($node->db_references) > 0){ ?>
+  <table class="tripal_stock-table tripal-table tripal-table-horz">
+    <tr>
+      <th>Dababase</th>
+      <th>Accession</th>
+    </tr>
+    <?php
+    $i = 0; 
+    foreach ($node->db_references as $result){ 
+      $class = 'tripal_stock-table-odd-row tripal-table-odd-row';
+      if($i % 2 == 0 ){
+         $class = 'tripal_stock-table-odd-row tripal-table-even-row';
+      }
+      ?>
+      <tr class="<?php print $class ?>">
+        <td><?php print $result->db_name?></td>
+        <td><?php 
+           if($result->db_urlprefix){ 
+           	 print l($result->accession, $result->db_urlprefix.$result->accession);
+           } else { 
+             print $result->accession; 
+           } 
+           ?>
+        </td>
+      </tr>
+      <?php
+      $i++;  
+    } ?>
+  </table>
+  <?php } ?>
+</div>

+ 64 - 0
theme_tripal/tripal_stock/tripal_stock_relationships_as_object.tpl.php

@@ -0,0 +1,64 @@
+<?php
+// Copyright 2010 University of Saskatchewan (Lacey-Anne Sanderson)
+//
+// Purpose: Provides layout and content for Stock Relationships where
+//   the current stock is the Subject of the relationships. This includes all 
+//   fields in the stock_relationship table.
+//
+// Note: This template controls the layout/content for the default stock node
+//   template (node-chado_stock.tpl.php) and the Stock Object Relationships Block
+//
+// Variables Available:
+//   - $node: a standard object which contains all the fields associated with
+//       nodes including nid, type, title, taxonomy. It also includes stock
+//       specific fields such as stock_name, uniquename, stock_type, synonyms,
+//       properties, db_references, object_relationships, subject_relationships,
+//       organism, etc.
+//   - $node->object_relationships: an array of stock relaionship objects 
+//       where each object has the following fields: stock_relationship_id,
+//       subject_id (current stock_id), type_id, type, value, rank, object
+//   - $node->object_relationships->object: a stock object describing the
+//       object stock with the fields: stock_id, stock_name, uniquename, 
+//       description, stock_type_id, organism(object), man_db_reference(object),
+//       nid (if sync'd with Drupal)
+//   NOTE: For a full listing of fields available in the node object the
+//       print_r $node line below or install the Drupal Devel module which 
+//       provides an extra tab at the top of the node page labelled Devel
+?>
+
+<?php
+ //uncomment this line to see a full listing of the fields avail. to $node
+ //print '<pre>'.print_r($node,TRUE).'</pre>';
+?>
+
+<div id="tripal_stock-object_relationships-box" class="tripal_stock-info-box tripal-info-box">
+  <div class="tripal_stock-info-box-title tripal-info-box-title">Object Relationships</div>
+  <div class="tripal_stock-info-box-desc tripal-info-box-desc">The stock '<?php print $node->stock_name ?>' is the subject in the following relationships:</div>
+  <?php if(count($node->object_relationships) > 0){ ?>
+  <table class="tripal_stock-table tripal-table tripal-table-horz">
+    <tr>
+      <th>Current Stock (Subject)</th>
+      <th>Type</th>
+      <th>Object</th>
+    </tr>
+    <?php
+    $i = 0; 
+    foreach ($node->object_relationships as $result){   
+      $class = 'tripal_stock-table-odd-row tripal-table-odd-row';
+      if($i % 2 == 0 ){
+         $class = 'tripal_stock-table-odd-row tripal-table-even-row';
+      } ?>
+      <tr class="<?php print $class ?>">
+				<td><?php print $node->stock_name; ?></td>
+				<td><?php print $result->type; ?></td>
+				<?php $object = $result->object;
+					if ($object->nid) {?>
+					<td><?php print l($object->stock_name.' ('.$object->uniquename.')', 'node/'.$object->nid); ?></td>
+				<?php } else { ?>
+					<td><?php print $object->stock_name.' ('.$object->uniquename.')'; ?></td>
+				<?php } ?>
+      </tr>
+    <?php } //end of foreach?>
+  </table>
+  <?php } //end of if there are object relationships ?>
+</div>

+ 64 - 0
theme_tripal/tripal_stock/tripal_stock_relationships_as_subject.tpl.php

@@ -0,0 +1,64 @@
+<?php
+// Copyright 2010 University of Saskatchewan (Lacey-Anne Sanderson)
+//
+// Purpose: Provides layout and content for Stock Relationships where
+//   the current stock is the Object of the relationships. This includes all 
+//   fields in the stock_relationship table.
+//
+// Note: This template controls the layout/content for the default stock node
+//   template (node-chado_stock.tpl.php) and the Stock Subject Relationships Block
+//
+// Variables Available:
+//   - $node: a standard object which contains all the fields associated with
+//       nodes including nid, type, title, taxonomy. It also includes stock
+//       specific fields such as stock_name, uniquename, stock_type, synonyms,
+//       properties, db_references, object_relationships, subject_relationships,
+//       organism, etc.
+//   - $node->subject_relationships: an array of stock relaionship objects 
+//       where each object has the following fields: stock_relationship_id,
+//       subject, type_id, type, value, rank, object_id (current stock_id)
+//   - $node->subject_relationships->subject: a stock object describing the
+//       subject stock with the fields: stock_id, stock_name, uniquename, 
+//       description, stock_type_id, organism(object), man_db_reference(object),
+//       nid (if sync'd with Drupal)
+//   NOTE: For a full listing of fields available in the node object the
+//       print_r $node line below or install the Drupal Devel module which 
+//       provides an extra tab at the top of the node page labelled Devel
+?>
+
+<?php
+ //uncomment this line to see a full listing of the fields avail. to $node
+ //print '<pre>'.print_r($node,TRUE).'</pre>';
+?>
+
+<div id="tripal_stock-subject_relationships-box" class="tripal_stock-info-box tripal-info-box">
+  <div class="tripal_stock-info-box-title tripal-info-box-title">Subject Relationships</div>
+  <div class="tripal_stock-info-box-desc tripal-info-box-desc">The stock '<?php print $node->stock_name ?>' is the object in the following relationships:</div>
+  <?php if(count($node->subject_relationships) > 0){ ?>
+  <table class="tripal_stock-table tripal-table tripal-table-horz">
+    <tr>
+      <th>Subject</th>
+      <th>Type</th>
+      <th>Current Stock (Object)</th>
+    </tr>
+    <?php
+    $i = 0; 
+    foreach ($node->subject_relationships as $result){   
+      $class = 'tripal_stock-table-odd-row tripal-table-odd-row';
+      if($i % 2 == 0 ){
+         $class = 'tripal_stock-table-odd-row tripal-table-even-row';
+      } ?>
+      <tr class="<?php print $class ?>">
+				<?php $subject = $result->subject;
+					if ($subject->nid) {?>
+					<td><?php print l($subject->stock_name.' ('.$subject->uniquename.')', 'node/'.$subject->nid); ?></td>
+				<?php } else { ?>
+					<td><?php print $subject->stock_name.' ('.$subject->uniquename.')'; ?></td>
+				<?php } ?>
+				<td><?php print $result->type; ?></td>
+				<td><?php print $node->stock_name; ?></td>
+      </tr>
+    <?php } //end of foreach?>
+  </table>
+  <?php } //end of if there are subject relationships ?>
+</div>

+ 41 - 0
theme_tripal/tripal_stock/tripal_stock_synonyms.tpl.php

@@ -0,0 +1,41 @@
+<?php
+// Copyright 2010 University of Saskatchewan (Lacey-Anne Sanderson)
+//
+// Purpose: Provides layout and content for Synonyms of the Current Stock.
+//   Stock synonyms are stored in the stockprop table with a type corresponding
+//   to the cvterm synonym.
+//
+// Note: This template controls the layout/content for the default stock node
+//   template (node-chado_stock.tpl.php) and the Stock Synonyms Block
+//
+// Variables Available:
+//   - $node: a standard object which contains all the fields associated with
+//       nodes including nid, type, title, taxonomy. It also includes stock
+//       specific fields such as stock_name, uniquename, stock_type, synonyms,
+//       properties, db_references, object_relationships, subject_relationships,
+//       organism, etc.
+//   - $node->synonyms: an array of stock property objects where each object
+//       has type=synonyms and the following fields: stockprop_id, type_id,
+//       type, value, rank
+//   NOTE: For a full listing of fields available in the node object the
+//       print_r $node line below or install the Drupal Devel module which 
+//       provides an extra tab at the top of the node page labelled Devel
+?>
+
+<?php
+ //uncomment this line to see a full listing of the fields avail. to $node
+ //print '<pre>'.print_r($node,TRUE).'</pre>';
+?>
+
+<div id="tripal_stock-synonyms-box" class="tripal_stock-info-box tripal-info-box">
+  <div class="tripal_stock-info-box-title tripal-info-box-title">Synonyms</div>
+  <div class="tripal_stock-info-box-desc tripal-info-box-desc">Synonyms for the stock '<?php print $node->stock_name ?>' include:</div>
+	<?php if(count($node->synonyms) > 0){
+		print '<ul>';
+			// iterate through each synonym
+			foreach ($node->synonyms as $result){
+				print '<li>'.$result->value.'</li>';
+			}
+		print '</ul>';
+	} ?>
+</div>